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/03/01 22:06] – Fixed NOTOC _kimozaic_tips_and_tricks [2020/03/01 22:12] – Minor addition to Knob Double-Tap _ki
Line 224: Line 224:
  
  
-If a knob is only used to toggle between two states like a switch, the code for double-tap detection would look like:+If a knob is only used to toggle between two states like a switch (like the variable //isOn// in the example), the code for double-tap detection would look like:
 <code> <code>
 +@OnKnobChange
 +  _knob = LastKnob
 +  _val  = GetKnobValue _knob
 +  
 +  if _knob = TOGGLE_KNOB
 +    if _val = 64
 +      isOn = not isOn
 +      SetKnobValue TOGGLE_KNOB,48 + 32*isOn
 +    else
 +      isOn = _val > 64  
 +    endif
 +    
 +    if isOn
 +      LabelKnob TOGGLE_KNOB,  {ON}
 +    else
 +      LabelKnob TOGGLE_KNOB,  {OFF}
 +    endif
 +  endif
 +@End
 +
 @OnLoad @OnLoad
   ShowLayout 2   ShowLayout 2
Line 246: Line 266:
   else   else
     LabelKnob TOGGLE_KNOB,  {OFF}     LabelKnob TOGGLE_KNOB,  {OFF}
-  endif 
-@End 
- 
-@OnKnobChange 
-  _knob = LastKnob 
-  _val  = GetKnobValue _knob 
-   
-  if _knob = TOGGLE_KNOB 
-    if _val = 64 
-      isOn = not isOn 
-      SetKnobValue TOGGLE_KNOB,48 + 32*isOn 
-    else 
-      isOn = _val > 64   
-    endif 
-     
-    if isOn 
-      LabelKnob TOGGLE_KNOB,  {ON} 
-    else 
-      LabelKnob TOGGLE_KNOB,  {OFF} 
-    endif 
   endif   endif
 @End @End
  • mozaic_tips_and_tricks.txt
  • Last modified: 2024/04/23 19:07
  • by _ki