Differences

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

Link to this comparison view

Both sides previous revision Previous revision
mozaic_tips_and_tricks [2020/03/01 22:06]
_ki Fixed NOTOC
mozaic_tips_and_tricks [2020/03/01 22:12] (current)
_ki Minor addition to Knob Double-Tap
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: 2020/03/01 22:12
  • by _ki