Atm_stepper.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #pragma once
  2. #include <Automaton.h>
  3. // #include <TeensyStep.h>
  4. #include "AccelStepper.h"
  5. class Atm_stepper: public Machine {
  6. public:
  7. enum { IDLE, READY, RUNNING, STOPPING }; // STATES
  8. enum { EVT_IDLE_TIMER, EVT_ON_TARGET, EVT_GOTO, ELSE }; // EVENTS
  9. Atm_stepper( void ) : Machine() {};
  10. Atm_stepper& begin( int setpPin, int dirPin ) ;
  11. Atm_stepper& trace( Stream & stream );
  12. Atm_stepper& trigger( int event );
  13. int state( void );
  14. Atm_stepper& onOnchange( Machine& machine, int event = 0 );
  15. Atm_stepper& onOnchange( atm_cb_push_t callback, int idx = 0 );
  16. Atm_stepper& gotoStep( long int targetStep );
  17. private:
  18. AccelStepper _motor;
  19. // Stepper *_motor; // STEP pin: 2, DIR pin: 3
  20. // StepControl _controller;
  21. enum { ENT_IDLE, ENT_READY, ENT_RUNNING, LP_RUNNING, ENT_STOPPING, EXT_STOPPING }; // ACTIONS
  22. enum { ON_ONCHANGE, CONN_MAX }; // CONNECTORS
  23. atm_connector connectors[CONN_MAX];
  24. int event( int id );
  25. void action( int id );
  26. };
  27. /*
  28. Automaton::ATML::begin - Automaton Markup Language
  29. <?xml version="1.0" encoding="UTF-8"?>
  30. <machines>
  31. <machine name="Atm_stepper">
  32. <states>
  33. <IDLE index="0" on_enter="ENT_IDLE">
  34. <EVT_GOTO>RUNNING</EVT_GOTO>
  35. </IDLE>
  36. <READY index="1" on_enter="ENT_READY">
  37. <EVT_IDLE_TIMER>IDLE</EVT_IDLE_TIMER>
  38. <EVT_GOTO>RUNNING</EVT_GOTO>
  39. </READY>
  40. <RUNNING index="2" on_enter="ENT_RUNNING" on_loop="LP_RUNNING">
  41. <EVT_ON_TARGET>STOPPING</EVT_ON_TARGET>
  42. <EVT_GOTO>RUNNING</EVT_GOTO>
  43. </RUNNING>
  44. <STOPPING index="3" on_enter="ENT_STOPPING" on_exit="EXT_STOPPING">
  45. <EVT_ON_TARGET>READY</EVT_ON_TARGET>
  46. </STOPPING>
  47. </states>
  48. <events>
  49. <EVT_IDLE_TIMER index="0" access="PRIVATE"/>
  50. <EVT_ON_TARGET index="1" access="PRIVATE"/>
  51. <EVT_GOTO index="2" access="PUBLIC"/>
  52. </events>
  53. <connectors>
  54. <ONCHANGE autostore="0" broadcast="0" dir="PUSH" slots="1"/>
  55. </connectors>
  56. <methods>
  57. </methods>
  58. </machine>
  59. </machines>
  60. Automaton::ATML::end
  61. */