Closed gtom closed 7 years ago
First you need to be clear about what you want to achieve. If you just want to switch the individual leds on and off without a time element involved (like with blinking or fading) then it's questionable that you need a state machine at all.
It might be nice to have an Automaton-like interface to the leds, but you could achieve that even with a dummy state table. The machine would basically be sleeping all the time.
const static state_t state_table[] PROGMEM = {
/* ON_ENTER ON_LOOP ON_EXIT ELSE */
/* IDLE */ -1, ATM_SLEEP, -1, IDLE,
};
You could then create an interface like this:
mcp1.begin( 1 );
mcp1.trigger( EVT_LED1_ON );
mcp1.trigger( EVT_LED2_ON );
mcp1.trigger( EVT_LED2_ON );
mcp1.on( 1 );
mcp1.off( 1 );
By just implementing your own trigger(), on() and off() methods.
Rgdz, Tinkerspy
Thanks, I will think about it. When I need some timing within this, I think I will try to setup a new machine. gTom
I would like to use an led-machine (only EVT_ON and EVT_OFF needed) with 16 pins controlled through mcp23017. I'm using Adafruit-MCP23017 library:
I'm thinking about building an own machine derived from led-machine to handle different way of initializing and writing to pins. But before I start: is there a better way to achieve this? gTom