Atm_TeensyStep.h 2.2 KB

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