-
Notifications
You must be signed in to change notification settings - Fork 15
Reading switch like devices using hexapush
If you want to use Pushbuttons or other switch-like devices on the hexabus, you can simply use the hexapush app:
Simply hook up your devices between GND and one of the pins PA0 to PA7 on the Hexabusdevice. If the connection between this two pins is open, the "button" is pushed, elsewhere it is released.
In hexabus/firmware/contiki-2.x/platform/Hexabus-Socket/apps/hexapush/hexapush.h only comment the #define HEXAPUSH_Bx PAx
corresponding to the pins you used.
Set HEXAPUSH_ENABLE in firmware/contiki-2.x/platform/Hexabus-Socket/hexabus_config.h to 1.
Then configure HEXAPUSH_CLICK_ENABLE, HEXAPUSH_PRESS_RELEASE_ENABLE and HEXAPUSH_PRESS_DELAY to your liking:
-
If only HEXAPUSH_CLICK_ENABLE is set to 1, the pushed button will be broadcast once with EID 25 as soon as its pushed. It will be broadcast again only if it is released and pushed again.
-
If only HEXAPUSH_PRESS_RELEASE_ENABLE is set to 1, all pushed buttons are broadcast with EID 24 when one button is pushed or released.
-
If both HEXAPUSH_CLICK_ENABLE and HEXAPUSH_PRESS_RELEASE_ENABLE are set to 1, the pushed button will be broadcast as EID 25 if it is released before the press delay runs out, otherwise the buttons will behave like only HEXAPUSH_PRESS_RELEASE_ENABLE was set to 1. The press delay can be configured via HEXAPUSH_PRESS_DELAY. The value set here is multiplied by 50 milliseconds.
-
If both HEXAPUSH_CLICK_ENABLE and HEXAPUSH_PRESS_RELEASE_ENABLE are set to 0, nothing will happen.
Both EID 24 and 25 are 8Bit values with the bits corresponding to the pushed buttons set to 1.
Examples:
-
Button on PA3 is clicked: Value EID 25 = 00001000 Binary = 8 Decimal
-
Buttons PA0 and PA2 are pressed: Value EID 24 = 0000101 Binary = 5 Decimal
-
"Is Button on PA1 pressed?": Value EID 24 'AND' 00000010 '!=' 0 ?
For usage on the reciver side, refer to State Machines.