main.cpp 543 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "Arduino.h"
  2. #include "states/state_impl/state_impl.h"
  3. StateLock state_lock;
  4. StateTarget state_target;
  5. IState *states[_STATES_COUNT] = {
  6. &state_lock,
  7. &state_target
  8. };
  9. StateID curr_state_id = LOCK;
  10. StateID next_state_id = LOCK;
  11. void setup()
  12. {
  13. M5.begin();
  14. Serial.begin(115200);
  15. states[curr_state_id]->setup();
  16. }
  17. void loop()
  18. {
  19. next_state_id = states[curr_state_id]->loop();
  20. if (next_state_id != curr_state_id)
  21. {
  22. curr_state_id = next_state_id;
  23. states[curr_state_id]->setup();
  24. }
  25. M5.update();
  26. }