mozaic_tips_and_tricks

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revisionBoth sides next revision
mozaic_tips_and_tricks [2020/08/13 07:54] – Added Long & Short Pad and Shift deteciotn by wim _kimozaic_tips_and_tricks [2020/11/17 02:08] – Added Output Fixed Point Values in Labels _ki
Line 9: Line 9:
   * [[#Store two positive Values into a single Variable]]   * [[#Store two positive Values into a single Variable]]
   * [[#Store three unsigned Bytes into a single Variable]]   * [[#Store three unsigned Bytes into a single Variable]]
 +  * [[#Output Fixed Point Values in Labels]]
   * [[#Some Best Practice Tips]]   * [[#Some Best Practice Tips]]
   * [[#Detect Long or Short Pad Taps]]   * [[#Detect Long or Short Pad Taps]]
Line 119: Line 120:
 </code> </code>
  
 +
 +\\ 
 +===== Output Fixed Point Values in Labels =====
 +<html><p align = "right"><small><i>From -ki</i></small></p></html>
 +When outputting floating point values into labels (knobs, pads, titles) Moazic generates either a 4 digit fraction string 
 +like 42.5000 (if a remainder present) or an integer value without fraction.
 +
 +
 +To always output a positive float with two digits (even when integer), one needs to split the input value and output the computed integer parts individually:
 +<code>
 +  n = Round value * 100
 +  f = Div n, 100
 +  d = n-f*100
 +  r1 = Div d, 10
 +  r2 = d % 10
 +  LabelKnob 0, {B:},f,{.},r1,r2
 +</code>
 +
 +To always output a negative and positive float with a single digit, the split needs to work on the absolute value
 +and a conditional statement is used to output both variants:
 +<code>
 +  n = Round Abs(value * 10)
 +  f = Div n, 10
 +  r = (n-f*10) % 10
 +  if number>=0
 +    LabelKnob 1, {N: +},f,{.},r
 +  else
 +    LabelKnob 1, {N: +},f,{.},r
 +  endif
 +</code>
  
 \\  \\ 
  • mozaic_tips_and_tricks.txt
  • Last modified: 2024/04/23 19:07
  • by _ki