[First time post]
I want to make an interactive installation, which interrrupts the current state, saves it, and then returns when the interactive session ends. For example, e.g. using a PIR sensor or a gesture sensor wired to a DIY WIFI module. Both the main board and the sensors are ESP-M2 based.
I can see two issues:
- How to save the current state, and be able to restore it later. This seems like a general feature.
- How to realize the interactive mode.
I couldn’t see (1) anywhere, so Im considering the following approaches to implement a State_Stack usermod
A. Use JSON api to set a flag that gets processed in loop() to control push/pop.
B. Use a custom server.on handler
and for (2), the same two approaches seem applicable.
Feedback anyone?
[WLED noobie here, but experienced coder; I’ve got WLED to compile with config changes for my custom board]
PIR sensor usermod does that.
As far as I can tell the PIR Sensor usermod can performs WLED state mods based on it’s sensing state, but it doesn’t save/restore the current state.
** edit ** the code seems to be doing something with switching and saving playlists and presets (in preset 255), so I’ll look at that part again. I was also considering using a preset, but I was worried that it would be written to the filestore which is apparently slow and causing hiccups.
You’ll benefit with the device with PSRAM. 8266 will still save state to temporary file.
Thanks. I spent a little time today on presets.cpp and I can see that now.
I think I’ve settled on trying this approach: a usermod which is a state machine that takes events from remote sensors via json API, and has actions including manipulating the WLED state. The state machine definitions will be coded as json files, and managed like others.
** Update ** Development is underway on the statemachine, the skeleton built and integrated. The sensor side will be at least the PAJ7620, but I’m looking into a video-based gesture engine for >= 1m range. Once a demo is ready, I’ll open a project topic.
I’m not sure why the presets are being leveraged for temporary state save/restore, but in any case I think I can deal with that when the time comes. [On PSRAM: I have a couple of dozen ESP-M2 and custom boards designed around them, so I think I’ll stick with them for a while.]