Toggle Button w/toggle2nist not Toggling

More
7 years 8 months ago #125923 by thadwald
I want a physical on/off button on my control panel. The behavior I am getting is push-on, release-off. Can someone tell me what I am doing wrong?

Code:
# ################################################## # matrix keypad # ################################################## loadrt matrix_kb config=8x8 loadrt debounce cfg=17,6 loadrt toggle2nist count=1 addf matrix_kb.0 servo-thread addf debounce.0 servo-thread addf debounce.1 servo-thread addf toggle2nist.0 servo-thread net keypad hm2_7i96.0.7i73.0.0.keycode => matrix_kb.0.keycode setp debounce.0.delay 10 setp debounce.1.delay 5 net key23todebounce matrix_kb.0.key.r5c0 => debounce.0.16.in net enablebutton debounce.0.16.out => toggle2nist.0.in net is-enabled halui.machine.is-on => toggle2nist.0.is-on net enableon halui.machine.on <= toggle2nist.0.on net enableoff halui.machine.off <= toggle2nist.0.off

I have checked the signals using the HAL scope and it appears to be sending a single pulse. I can get it to "catch" in the toggled state by hitting the button quickly, but it will usually quite reliably turn on for the duration of the button press, then turn off as soon as I release it.

Please Log in to join the conversation.

More
7 years 8 months ago #125928 by Todd Zuercher
You need to use the toggle2nist component with an ordinary toggle component like this
Code:
# ################################################## # matrix keypad # ################################################## loadrt matrix_kb config=8x8 loadrt debounce cfg=17,6 loadrt toggle2nist count=1 loadrt toggle count=1 addf matrix_kb.0 servo-thread addf debounce.0 servo-thread addf debounce.1 servo-thread addf toggle2nist.0 servo-thread addf toggle.0 servo-thread net keypad hm2_7i96.0.7i73.0.0.keycode => matrix_kb.0.keycode setp debounce.0.delay 10 setp debounce.1.delay 5 net key23todebounce matrix_kb.0.key.r5c0 => debounce.0.16.in net enablebutton debounce.0.16.out => toggle.0.in net toggle-on <= toggle.0.out => toggle2nist.0.in net is-enabled halui.machine.is-on => toggle2nist.0.is-on net enableon halui.machine.on <= toggle2nist.0.on net enableoff halui.machine.off <= toggle2nist.0.off

It does seem rather confusing but basically what it does is invert the result of the 1st regular toggle if the "is-on" is true.

Please Log in to join the conversation.

More
7 years 8 months ago #125929 by thadwald

Please Log in to join the conversation.

Time to create page: 0.228 seconds
Powered by Kunena Forum