dOperator Posted February 13, 2014 Report Share Posted February 13, 2014 Hi, dusted off my unfinished midibox_ng ... so i got all encoders, LEDs and buttons working, but i can't figure out how to use buttons connected to a ainser64 module as toggle buttons. (I wanted to use analog pots for the encoders at first, but decided for digi encoders later, so thats why all my buttons ended up on the ainser64 module.) My first try was something like: EVENT_BUTTON id=1041 range=0:80 button_mode=toggle fwd_id=LED:144 EVENT_AINSER id=41 ain_sensor_mode=NoteOnOff if_equal=80 fwd_id=BUTTON:1041 which does toggle the button on, but doesn't turn it off again. Tried a couple of other ideas too (conditional events, depending on the buttons state) .. but no matter what i do i don't get it to toggle on and off. Is it possible? Just missing something obvious (just starting to get into the config options)? Thanks a lot :) Quote Link to comment Share on other sites More sharing options...
Marxon Posted February 13, 2014 Report Share Posted February 13, 2014 (edited) Hi dOperator! Just an idea, because right now i can not test it myself: try "if_equal_stop_on_match" instead "if_equal" Best regards Marxon Edited February 13, 2014 by Marxon Quote Link to comment Share on other sites More sharing options...
dOperator Posted February 14, 2014 Author Report Share Posted February 14, 2014 Hey, adding _stop_on_match doesn't change anything, it toggles on at first press, but doesn't toggle off on the next press. (the "note_off" events are already filtered out with 'if_equal' condition, and it only sends one 'note_on' when the button is pressed.) Quote Link to comment Share on other sites More sharing options...
Marxon Posted February 14, 2014 Report Share Posted February 14, 2014 (edited) Hmm, sorry.... Whats about using a ngr script? ngc EVENT_AINSER id= 41 type=meta meta=RunSection:2 range=0:127 ngr if ^section == 2 if (hw_id)AINSER:41 > 100 set Button:1041 80 else set Button:1041 0 endif endif Best regards Marxon Edited February 14, 2014 by Marxon 1 Quote Link to comment Share on other sites More sharing options...
dOperator Posted February 15, 2014 Author Report Share Posted February 15, 2014 YAY! EVENT_AINSER id= 41 type=meta ain_sensor_mode=NoteOnOff if_equal=80 meta=RunSection:2 and if ^section == 2 if Button:1041 > 0 set Button:1041 0 else set Button:1041 80 endif endif Thanks Marxon! Quote Link to comment Share on other sites More sharing options...
TK. Posted February 18, 2014 Report Share Posted February 18, 2014 I added a "threshold" function to the wish list, so that this function could be configured without such a hack Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
dOperator Posted February 21, 2014 Author Report Share Posted February 21, 2014 Thx TK! In case somebody is in the same situation, i figured sth like: EVENT_AINSER id= 41 range=0:1 type=meta ain_mode=Snap if_unequal=0 meta=RunSection:1 EVENT_BUTTON id=1041 button_mode=Toggle type=CC chn=1 cc=1 range=0:127 fwd_id=LED:144 and if ^section == 1 if Button:1041 > 0 set Button:1041 0 else set Button:1041 127 endif endif works way better than the code above (didn't allways trigger correctly, double trigger etc.) Quote Link to comment Share on other sites More sharing options...
TK. Posted March 6, 2014 Report Share Posted March 6, 2014 Could you please try following version: http://www.ucapps.de/mios32/midibox_ng_v1_030_pre2.zip It supports the new "ain_mode=Switch", which should work much better: o added ain_mode=Switch for AIN and AINSER events. Can be used if buttons are connected to analog inputs. The event will send the min value if a 30% threshold is reached, and the max value if a 70% threshold is reached. Schematic: Ground |----o Button o-----> analog input + 10k Pull-Up resistor to 3.3V (AIN) resp. 5V (AINSER) No .NGR hack required anymore :) I tested this with: EVENT_AINSER id= 1 type=CC ain_mode=Switch chn= 1 cc= 16 range= 0:127 offset= 0 ports=1000100000001000 lcd_pos=1:1:1 label="^std_aser" Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
dOperator Posted March 7, 2014 Author Report Share Posted March 7, 2014 Hey, First, thanks, that was fast! :smile: Just tried it, but it doesn't work for me. I guess that's because i wired the buttons differently. My Buttons are Vd ----o Button o---- analog input .. and i added a 220 ohm resistor from pin #3 to #8 on the ainser64 4051's, to get rid of random messages. No idea what i am doing there, really, just tried things until it worked :o Will that setup potentially damage my hardware? I'm considering to rewire the buttons, but it's some work, and it is actually working pretty nice with the hack for now. When i set the range very low, something like 0:4 it does work like a standard 'press' button, but it doesn't toggle on/off .. with higher settings it doesn't trigger at all, or triggers once, but not again. EVENT_AINSER id= 41 type=CC ain_mode=Switch chn=1 cc=16 range=0:3 offset=0 fwd_id=LED:144 lcd_pos=1:1:1 label="^std_aser" [6010.478] MBNG_AINSER_NotifyChange(41, 2578) [6010.480] [EVENT] id=AINSER:41 hw_id=AINSER:41 bank=0 fwd_id=LED:144 type=CC value=0 label=^std_aser [6010.480] MBNG_DOUT_NotifyReceivedValue(144, 3) [6010.581] MBNG_AINSER_NotifyChange(41, 0) [6010.581] [EVENT] id=AINSER:41 hw_id=AINSER:41 bank=0 fwd_id=LED:144 type=CC value=3 label=^std_aser [6010.581] MBNG_DOUT_NotifyReceivedValue(144, 0) Quote Link to comment Share on other sites More sharing options...
TK. Posted March 7, 2014 Report Share Posted March 7, 2014 Ok, I see! In the hysteresis function I haven't considered that somebody could use the new switch mode with a reduced range. This should be fixed now: http://www.ucapps.de/mios32/midibox_ng_v1_030_pre3.zip But you have to change your hardware as well. (don't worry, no risk for damage!) One side of the button should be connected to ground, the other to the analog input. And the Pull-Up resistor is mandatory, otherwise the input will float when the button is not closed, and this will result into random MIDI events. The other unused inputs can be connected to ground directly, no need for 220 Ohm resistors. Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.