tinkerspy / Automaton

Reactive State Machine Framework for Arduino
https://github.com/tinkerspy/Automaton/wiki
MIT License
369 stars 63 forks source link

Atm_opendrain welcome? #53

Open dvv opened 6 years ago

dvv commented 6 years ago

I have a (set of) active-low relay which I control both via a controller pin and an external switch.

That controller pin carries two tasks:

So I'd like to have let's-name-it Atm_opendrain which is Atm_led without PWM parts and overridden on/off and Atm_digital/Atm_button with custom state reader.

How would you suggest to realise this?

TIA

tinkerspy commented 6 years ago

Perhaps you could use a combination of an Atm_bit object (to control the relay) with an Atm_digital object to read the state. From the Atm_digital's onChange() handler you can set the Atm_bit object's state. The Atm_bit's state method then should both reflect and control the relay's state. You can of course write a custom class to control and read the relay. I've used a latching relay in the past which I wrote a custom state machine for (pre-Automaton).

Rgdz, Tinkerspy

dvv commented 6 years ago

Thank you. I would like to merge Atm_button's debouncing and Atm_led blinking (in sense of limited on state duration mostly). Am not afraid to write custom class, but am way far from making own state machine.

euphi commented 5 years ago

It's almost one year, but if you are still intested have a look at my PR https://github.com/tinkerspy/Automaton/pull/50/ . It allows to use C++ inheritance to have on functions for setting the output. So you can just derive Atm_opendrain and overwrite the switchOn() and switchOff functions.

tinkerspy commented 5 years ago

Hi Euphi,

Sorry, I've been busy with other projects. It looks very useful. I'll merge it into the master branch. Could I ask you to update the Atm_led and Atm_button documentation?

Tinkerspy