Using a matrix keyboard with TcMenu is straightforward, we use the IoAbstraction Keyboard Manager component to handle the keyboard, along with a custom listener for tcMenu that feeds the menu manager with appropriate events upon key presses. This library allows you to connect your keyboard either using Arduino pin, or any supported IoAbstraction such as the I2C PCF8574 or MCP23017. Setting up the menu sketch for a Matrix Keyboard Step 1 is to wire up your keyboard in accordance with the above linked keyboard manager page, I recommend at this point testing it through the packaged IoAbstraction example.
TcMenu has considerable out of the box remote connectivity on Arduino. Supporting Ethernet2 library, UipEthernet library, ESP8266 WiFi, ESP32 WiFi and Serial (including Bluetooth Serial). It is recommended that this guide is read in conjunction with the embedded library reference docs. A typical remote menu application designed using the library will be able to accept connections from any source that can communicate using TagVal protocol. On the Arduino side, there will be an object instance named remoteServer provided by the plugin.
IoAbstraction has full support for interrupts on most devices, meaning we can connect a Rotary Encoder to an Arduino using a standard PCF8574 IO expander chip. In order to do this we need the PCF8574 /INT line to be connected to an Arduino pin that supports interrupts (such as pins 2 or 3). Further, you can also have switches handle push button input without polling, by initialising for interrupt, especially useful with IO exapnders.
Worked example: Building a timer For this example we will create a menu that has two top level menu items; a counter which counts down from the selected value, and a Boolean switch that turns on or off the countdown. It will also have a submenu with one menu item to control the notification method. So lets draw this out conceptually below menu root +- countdown, integer values 0 to 1000 seconds +- enabled, boolean YES, NO.
You can connect up a device using just about any arrangement of pins or expander, at the end of the day any device supported by IoAbstraction, including MultiIo (pins and IoExpander mix) can be used here. Examples showing these use cases MCP23017 LiquidCrystal example Shift register 74HC595 LiquidCrystal Back to the main page
Matrix keyboards are arranged such that the keys are in a matrix of rows and columns. This means that instead of needing a spare input for each key, one INPUT for each column and one OUTPUT for each row is all that’s needed. In order to use the keyboard, we create a class of type MatrixKeyboardManager and configure it with an IoAbstractionRef, a KeyboardLayout that describes the keyboard attached (there are some standard ones already defined) and a listener that will be informed of changes.
Have you ever wanted to treat button presses in Arduino similar to other languages, where you get an event callback when the switch is pressed? Look no further, the IO abstraction library can do that with very little fuss. In fact it can also do the same for rotary encoders as well, treating them similar to how scroll bars work in desktop applications. To start we need to get the IoAbstraction library and open the buttonRotartyEncoder example.
In this tutorial for IoAbstraction’s taskManager I explain the differences between traditional loop based programming; which is very common on the Arduino platform and event based programming based on taskManager. Although event based programming looks slightly more complicated at first, as the sketch and surrounding code gets more complex, eventing will scale to that much easier. Eventing task frameworks make ongoing maintenance much easier. Example: Two LEDs blink at different rates.
Recently, I have made a fork of Arduino LiquidCrystal (HD44780 display driver library) that allows the library to work with the IO abstraction library, meaning you can configure a display to use Arduino pins, an i2c 8574 IO expander or shift registers by simply changing one line of code in your sketch. There are two additional examples provided with this version that show how to use the fork with both a shift register and an 8574 i2c IO expander.
Here we demonstrate the IO Abstraction library on an Arduino with a PCF8574 i2c 8-bit IO expander chip. We use the device in order to receive input from a switch and light an LED. It’s about the most basic example possible that has both input and output. To use this example, first download the IoAbstraction library. Devices such as the PCF8574 provide an easy way to expand both input and output capabilities using a single chip, and because it’s on i2c, needs only two pins from the Arduino (SDA and SCL).