No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

statemachine.cpp 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include <Arduino.h>
  2. #include "config.h"
  3. #include "config_pins.h"
  4. #include "common.h"
  5. #include "lcd.h"
  6. #include "steppers.h"
  7. #include "statemachine.h"
  8. enum states {
  9. sm_init,
  10. sm_ask_homing,
  11. sm_do_homing,
  12. sm_menu
  13. };
  14. static states state = sm_init;
  15. static void switch_state(states s) {
  16. state = s;
  17. if (state == sm_ask_homing) {
  18. lcd.clear();
  19. lcd.print(F(" Homing Required!"));
  20. lcd.setCursor(0, 2);
  21. lcd.print(F(" Click to home XYZE"));
  22. } else if (state == sm_do_homing) {
  23. } else if (state == sm_menu) {
  24. }
  25. }
  26. void statemachine_run(int click, int encoder, int kill) {
  27. if (state == sm_init) {
  28. if (click) {
  29. switch_state(sm_ask_homing);
  30. }
  31. } else if (state == sm_ask_homing) {
  32. if (click) {
  33. switch_state(sm_do_homing);
  34. }
  35. } else if (state == sm_do_homing) {
  36. } else if (state == sm_menu) {
  37. }
  38. }
  39. void statemachine_motors_done(void) {
  40. if (state == sm_do_homing) {
  41. if (steppers_homed()) {
  42. async_beep(100, 2000);
  43. switch_state(sm_menu);
  44. }
  45. }
  46. }