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 revision
Previous revision
Next revisionBoth sides next revision
mozaic_tips_and_tricks [2020/07/30 19:01] – [Mozaic: Scripting Tips & Tricks] Added link to ‚Dynamic Letters for Labeling‚ section _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 SHIFT Button Taps]]
   * [[#Multi-Line Pad Labels]]   * [[#Multi-Line Pad Labels]]
   * [[#Dynamic Letters for Labeling]]   * [[#Dynamic Letters for Labeling]]
Line 117: 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>
  
 \\  \\ 
Line 145: Line 178:
 </code> </code>
  
 +
 +\\ 
 +===== Detect Long or Short Pad Taps =====
 +<html><p align = "right"><small><i>From wim</i></small></p></html>
 +
 +<code>
 +@OnLoad
 +  FillArray downStart,0,16
 +  pressTime = 250
 +@End
 +
 +@OnPadDown
 +  downStart[LastPad] = SystemTime
 +@End
 +
 +@OnPadUp
 +  pad = LastPad
 +  if SystemTime - downStart[pad] < pressTime
 +    Log {Short tap pad }, pad
 +  else
 +    Log {Long tap pad }, pad
 +  endif
 +@End
 +</code>
 +
 +\\ 
 +
 +===== Detect Long or Short SHIFT Button Taps =====
 +<html><p align = "right"><small><i>From wim</i></small></p></html>
 +
 +<code>
 +@OnLoad
 +  shiftStart = 0
 +  pressTime  = 250
 +@End
 +
 +@OnShiftDown
 +  shiftStart = SystemTime
 +@End
 +
 +@OnShiftUp
 +  if SystemTime - shiftStart < pressTime
 +    Log {Short tap SHIFT}
 +  else
 +    Log {Long  tap SHIFT}
 +  endif
 +@End
 +</code>
  
 \\  \\ 
Line 181: Line 262:
 </code> </code>
  
 +\\ 
 ===== Use the SHIFT Button to toggle to HELP View ===== ===== Use the SHIFT Button to toggle to HELP View =====
 <html><p align = "right"><small><i>From -ki</i></small></p></html> <html><p align = "right"><small><i>From -ki</i></small></p></html>
  • mozaic_tips_and_tricks.txt
  • Last modified: 2024/04/23 19:07
  • by _ki