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).
LiquidCrystalIO is now also compatible with mbed boards. It supports regular mbed pins, I2C backpacks based on PCF8574 and MCP23017 based connections. You can adapt any of the Arduino examples for mbed very easily, as the API is 99% the same. Examples showing these use cases Hello Mbed I2C PCF8574 example Back to the main page
If like me you use both 8 bit AVR and 32 bit boards, you’ve probably already noticed that there’s no EEPROM support on some 32 bit boards. I think that’s quite unfortunate as EEPROM storage is very useful for many applications. Relying on memory backup like many systems today do, is nowhere near as reliable (a flat battery loses everything). Further, I’ve even seen discussions where people suggest using an area of program Flash as an EEPROM, I don’t personally like it as flash write cycles are generally an order of magnitude lower than EEPROM, but it’s now supported via the EEPROM class wrapper.
Many embedded applications need to present status and allow users to manage settings. TcMenu provides first class support for both presenting status and managing configuration/settings using menu items. It is possible to use with and without a local user interface. All menu item types can be accessed remotely, and we have a remote API, UI solutions, and connectors to commercial IoT endpoints for that. Menu item arrangement and storage Each menu item is part of a tree, if you are unfamiliar with trees, there’s a little terminology worth learning.
Task Manager supports the concept of Spin Locks to protect sensitive asynchronous operations from becoming interleaved. For example, to protect sensitive blocks of code. Be very aware that this does not include a memory barrier. A spin lock loops waiting for the lock to become available, you can either spin for a period of time, or until the lock is acquired. While waiting for the lock in the spin, TASKS DO NOT RUN, and you must never call yieldForMicros while holding a lock.
Along with TaskManagerIO that tries to keep a consistent user level API regardless of the platform, IoAbstraction also has only very small differences across platforms. We support nearly all official (and many unofficial) Arduino devices, most ESP devices and many mbed boards too. Known working devices Processor Platform Tested? Analog Digital Example developer boards AVR Arduino Fully ADC,PWM Pin, Int Uno, AT32x, MEGA 2560, MightyCore SAMD Arduino Fully ADC,PWM,DAC Pin, Int MKR, Nano IoT and Zero nrf52840 Arduino Fully ADC,PWM,DAC Pin, Int Nano 33 BLE devices ESP8266 Arduino Fully ADC,PWM Pin, Int Huzzah, Node MCU ESP32 Arduino Fully ADC,PWM,DAC Pin, Int Wifi32, Huzzah 32 STM32F* mbed Fully ADC,PWM,DAC Pin, Int Discovery, Nucleo etc STM32 Arduino User Report Not tested Pin, Int Blue pill Key:
In summary, task manager supports a wide range of hardware, including nearly every official Arduino board, most ESP boards, many mbed version 5 and 6 boards with or without an RTOS. We mainly test mbed with STM32 and nrf52 hardware. What boards does TaskManagerIO support? Processor Platform Tested? Locking Example developer boards AVR Arduino Fully Atomic Uno, AT32x, MEGA 2560, MightyCore SAMD Arduino Fully Atomic MKR, Nano IoT and Zero nrf52840 Arduino Fully CAS Nano 33 BLE devices ESP8266 Arduino Fully Atomic Huzzah, Node MCU ESP32 Arduino Fully CAS Wifi32, Huzzah 32 STM32F* mbed Fully CAS Discovery, Nucleo etc STM32 Arduino User Report Atomic Blue pill For mbed we support both RTOS and BareMetal versions 5 and 6, and we test on several STM32 boards.