A playground/example of event based programming on the DSTIKE ESP8266 Watch V2
Eventually is a library for adding event listeners to a chain, the chain is periodically iterated and each event is evaluated for any trigger event(s), if a listener is triggered the relevant action is called.
A custom listener is defined for listening for the ESPs wifi adapter status.
Note that Eventually's loop iteration macro isn't used, this is because the ESP's watchdog needs a slight delay to keep it happy (fed).
I am currently using a fork of eventually, this is while PR7 and PR12 are open.
A PlatformIO ini is supplied you can build, upload and monitor from the project root with the following command.
$ pio run -t upload && pio device monitor -f esp8266_exception_decoderor specify the device port:
$ pio run -t upload --upload-port /dev/ttyUSB0 -v && pio device monitor -p /dev/ttyUSB0 -f esp8266_exception_decoderThe currently enabled listeners can be found here:
- Three button (pullup) listeners for up, down, and push (select) on the DSTIKE's slide button.
Each button will display text on the screen and a display timeout timer will run for ten seconds. - A timer listener.
Each trigger of this one second timer will increment an int and display it in the bottom left corner. - A WiFi status listener
This listener with trigger every time the Wifi's status changes and will display an icon in the top right of the screen.
Solid for connected, blinking with an!for anything else.
If the ssid is not availableWL_NO_SSID_AVAIL, a timer for ten seconds will start the connection process again.
Serial is started and contains loads of runtime stuff.
To setup wifi, create src/wifi.h and paste in the following:
#define WIFI_SSID "your-ssid"
#define WIFI_PASS "9e87b4b63fd7cfb770718150e1b94faf0dac7f1245526c7209746c55aaee1daf"
// or #define WIFI_PASS "your-plain-password"Please fork and PR any new event based examples or fixes, all are welcome, i'll be updating this when i need to play around with other events on the DSTIKE.
Raise issues if you find problems or have any questions.