Badge WX: Buttons and Touchpad

The Badge WX has two 3-way rocker buttons (left, right, press) and two passive touchpad buttons on the back labeled A and B. These are easily used as user-programmable inputs for many purposes, including: selecting a mode (like enabling receiving of data over infrared), navigating a menu system, or activating different outputs for lights or sound.

All input states for the Badge WX’s rocker buttons and touchpads are “active high” and return a decimal value of one when pressed. By switching to code view in BlocklyProp you will notice that choosing the Badge WX board type included badgewxtools.h library. This library simplifies the use of all Badge WX hardware. For example, the A and B touchpads are designed as capacitive inputs with resistors and capacitors. The combination of the touchpad sensitivity block and the C code in the underlying badgewxtools.h library returns a simple one-bit state for the programmer.

This program loads into the Propeller’s main processor. If you include time-blocking commands (i.e., pauses, sound, writing to display) in your main loop you could miss the rocker button and touchpad transitions. This is solved by putting the button reading into a function, and putting that function into a new processor block. Keep the OLED routines in the main loop.    

BlocklyProp Program (opens in new window):


BlocklyProp Program

Buttons and Touchpad BlocklyProp code for the Badge WX.