bricofoy / yasm Goto Github PK
View Code? Open in Web Editor NEWYet Another State Machine library - a function pointer based state machine library for arduino
License: GNU General Public License v3.0
Yet Another State Machine library - a function pointer based state machine library for arduino
License: GNU General Public License v3.0
Hello
I Love YASM. I use it in several projects.
In one project (https://github.com/Loic74650/HenHouse), I use a low power ADAFRUIT FEATHER 32U4 AVR board which deep sleeps most of the time and regularly wakes up then uses a YASM object to move a door. It compiles and works fine.
Now I wish to port that project to a more powerful SAMD21 board (ADAFRUIT FEATHER M0) but now the same code does not compile and gives me the following error message:
HenHouseLowPower.ino: In function 'void setup()':
HenHouseLowPower:535:22: error: passing 'volatile YASM' as 'this' argument discards qualifiers [-fpermissive]
535 | Door.next(Door_wait);
Before I send you a bare bone piece of code to replicate, do you see anything obvious I should check?
Thank you
Hi,
I'm using YASM for a OLED menu system and would like to add a screen saver. To do this I envisage a method for returning to the previous state. I have not been able to figure out how to do this with the lib. Perhaps there's a clever way to do this that I have missed. If not, is it possible to add such functionality?.
Here's how I envisage the use in my screen saver functionality:
In all states that draw to the OLED display I would use the bool elapsed(timeout)
to trigger a jump to next(state_screen_saver)
in situations of inactivity after the timeout. The elapsed(timeout)
would be reset by external events via a call to the same state next(state_display, true)
. So the screen saver would only be called after the elapsed time and absence of external events (such as buttons, rotary input etc).
Inside the state_screen_saver
a bool periodic(period)
would periodically redraw the screen witch a character or glyph with random x, y positions. An external event (such as buttons, rotary input etc) would trigger a return to next(previous_state)
with the bool isFirstRun
could be optionally be set to true (which would reset the elapsed(timeout)
) .
I assume such functionality could be useful in other ways as well when there is a need to return to previous state without having to specify the state. Storing a pointer to the previous state could of course be done outside the lib but it would be handy function in my view.
Thanks again for a very useful lib.
bug if a state calls itself with machine.next(current_state,true);
and also if the machine is stopped then resume from outside : the _isFirstRun flag (is present) and the _runCount counter are cleared and incremented wrongly.
see https://forum.arduino.cc/index.php?topic=442441.msg4330263#msg4330263
may be time counter needs to be stored when calling stop() ans then resumed with the stored value on resume() (when we stay in the same state) so we keep accurate execution time record. Now we just keep "time in state" record, no matter if is is running or paused
Hi,
I'm using your lib to implement a menu displayed on an OLED. Works great and makes the task very easy. I'm now wondering if it's possible to change the resume()
function so that it could optionally resume the state with setting the isFirstRun
to true? Something like StateMachine.resume(true)
.
My menu is only refreshed when user change a rotary encoder.
However the application also stop the StateMachine periodically, to do other tasks (displaying other parameters on the OLED) and then resume the last state.
When the program returns to the state it was stopped in it skips refreshing the OLED because I use the isFirstRun
flag to refresh the OLED. I could refresh every time the state is run through but it would be unnecessary workload and a waste of processor cycles. I could also check which state
was stopped and do next(state, true)
but it can be in any of some 15 states and it would be tedious to check for all with a switch statement.
Any tip or hint on how I could do this would be extremely helpful.
link error in1.0.1 because of the btn.cpp modification, should keep BTN* BTN::_this (without static) instead of removing it completely
Sorry, I am quite a novice, but are using YASM and very enthousiastic about it. But there is one thing that I don's get right. It is while using 'bool isInState(void (*state)())'.
There is no example for this method in the repository.
Say my machine is called myMachine and one of the states in that machine is called myState. How would I use the method (written out, please) to check that I am in that state?
Thank you so much! Have a very nice day, Theo
in your blink examples you use the built in LED and usually have a line such as
#define LedPin 13 //pin 13 because most arduino boards provide a led here
This is un-necessary as most Arduino boards have a pin connected to an on-board LED in series with a resistor and the IDE constant LED_BUILTIN is the number of the pin to which the on-board LED is connected (Most boards have this LED connected to digital pin 13).
Would suggest you use LED_BUILTIN instead of 13 (or remove your #define and use LED_BUILTIN directly in the code but that's less flexible)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.