Atm_AccelStepper.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. #include "Atm_AccelStepper.h"
  2. /* Add optional parameters for the state machine to begin()
  3. * Add extra initialization code
  4. */
  5. Atm_AccelStepper& Atm_AccelStepper::begin(int step_pin, int dir_pin) {
  6. // clang-format off
  7. const static state_t state_table[] PROGMEM = {
  8. /* ON_ENTER ON_LOOP ON_EXIT EVT_DISABLE EVT_ENABLE EVT_ENABLED_TIMEOUT EVT_MOVE EVT_STOP EVT_EMERGENCY_STOP EVT_ON_LIMIT_LOW EVT_ON_LIMIT_HIGH EVT_ON_TARGET EVT_HOMING_LOW EVT_HOMING_HIGH ELSE */
  9. /* DISABLE */ ENT_DISABLED, -1, -1, -1, ENABLED, -1, RUNNING, -1, -1, -1, -1, -1, HOMING_LOW, HOMING_HIGH, -1,
  10. /* ENABLED */ ENT_ENABLED, -1, -1, DISABLE, -1, DISABLE, RUNNING, STOP, STOP, LIMIT_LOW, LIMIT_HIGH, -1, HOMING_LOW, HOMING_HIGH, -1,
  11. /* RUNNING */ ENT_RUNNING, LP_RUNNING, -1, DISABLE, -1, -1, RUNNING, STOP, STOP, LIMIT_LOW, LIMIT_HIGH, ENABLED, -1, -1, -1,
  12. /* STOP */ ENT_STOP, LP_STOP, -1, DISABLE, -1, -1, RUNNING, -1, -1, -1, -1, ENABLED, -1, -1, -1,
  13. /* HOMING_LOW */ ENT_HOMING_LOW, LP_HOMING_LOW, EXT_HOMING_LOW, DISABLE, -1, -1, -1, STOP, STOP, LIMIT_LOW, LIMIT_HIGH, -1, -1, -1, -1,
  14. /* HOMING_HIGH */ ENT_HOMING_HIGH, LP_HOMING_HIGH, EXT_HOMING_HIGH, DISABLE, -1, -1, -1, STOP, STOP, LIMIT_LOW, LIMIT_HIGH, -1, -1, -1, -1,
  15. /* LIMIT_LOW */ ENT_LIMIT_LOW, -1, -1, -1, -1, -1, RUNNING, STOP, STOP, LIMIT_LOW, -1, -1, -1, -1, -1,
  16. /* LIMIT_HIGH */ ENT_LIMIT_HIGH, -1, -1, -1, -1, -1, RUNNING, STOP, STOP, -1, LIMIT_HIGH, -1, -1, -1, -1
  17. };
  18. // clang-format on
  19. Machine::begin( state_table, ELSE );
  20. stepper = new AccelStepper(1, step_pin, dir_pin);
  21. stepper->setMaxSpeed(max_speed);
  22. stepper->setAcceleration(acceleration);
  23. idle_timer.set(ATM_TIMER_OFF);
  24. position_timer.set(POSITION_SEND_TIMER);
  25. return *this;
  26. }
  27. /* Add C++ code for each internally handled event (input)
  28. * The code must return 1 to trigger the event
  29. */
  30. int Atm_AccelStepper::event( int id ) {
  31. //updateLimitSwitch();
  32. switch ( id ) {
  33. case EVT_DISABLE:
  34. return 0;
  35. case EVT_ENABLE:
  36. return 0;
  37. case EVT_ENABLED_TIMEOUT:
  38. return 0;
  39. case EVT_MOVE:
  40. return 0;
  41. case EVT_STOP:
  42. return 0;
  43. case EVT_EMERGENCY_STOP:
  44. return 0;
  45. case EVT_ON_LIMIT_LOW:
  46. switch(_limitLow_Mode) {
  47. case 0:
  48. //
  49. Serial.println("no limit");
  50. return 0;
  51. case 1: //digital INPUT
  52. // Serial.println("digital");
  53. limitLow_State = digitalRead(_limitLow_Pin);
  54. limitLow_State = _limitLow_Reversed ? !limitLow_State : limitLow_State;
  55. return limitLow_State;
  56. case 2:
  57. int analogTemp = analogRead(_limitLow_Pin);
  58. limitLow_State = (_limitLow_Thresholds[0] < analogTemp) && (analogTemp < _limitLow_Thresholds[1]);
  59. limitLow_State = _limitLow_Reversed ? !limitLow_State : limitLow_State;
  60. return limitLow_State;
  61. }
  62. case EVT_ON_LIMIT_HIGH:
  63. switch(_limitHigh_Mode) {
  64. case 0:
  65. return 0;
  66. case 1: //digital INPUT
  67. limitHigh_State = digitalRead(_limitHigh_Pin);
  68. limitHigh_State = _limitHigh_Reversed ? !limitHigh_State : limitHigh_State;
  69. return limitHigh_State;
  70. case 2:
  71. //Serial.println("analog");
  72. int analogTemp = analogRead(_limitHigh_Pin);
  73. limitHigh_State = (_limitHigh_Thresholds[0] < analogTemp) && (analogTemp < _limitHigh_Thresholds[1]);
  74. limitHigh_State = _limitHigh_Reversed ? !limitHigh_State : limitHigh_State;
  75. return limitHigh_State;
  76. }
  77. case EVT_ON_TARGET:
  78. return runMode ? 0 : _currentStep == _targetStep;
  79. case EVT_HOMING_LOW:
  80. return 0;
  81. case EVT_HOMING_HIGH:
  82. return 0;
  83. }
  84. return 0;
  85. }
  86. /* Add C++ code for each action
  87. * This generates the 'output' for the state machine
  88. *
  89. * Available connectors:
  90. * push( connectors, ON_CHANGEPOSITION, 0, <v>, <up> );
  91. * push( connectors, ON_CHANGESTATE, 0, <v>, <up> );
  92. * push( connectors, ON_ONLIMITHIGH, 0, <v>, <up> );
  93. * push( connectors, ON_ONLIMITLOW, 0, <v>, <up> );
  94. * push( connectors, ON_ONTARGET, 0, <v>, <up> );
  95. * push( connectors, ON_STOP, 0, <v>, <up> );
  96. */
  97. void Atm_AccelStepper::action( int id ) {
  98. switch ( id ) {
  99. case ENT_DISABLED:
  100. push(connectors, ON_CHANGESTATE, 0, state(), 0);
  101. enabled = _enableReversed ? HIGH : LOW;
  102. digitalWrite(_enablePin, enabled);
  103. return;
  104. case ENT_ENABLED:
  105. _isHoming = 0 ;
  106. if(last_trigger == EVT_ON_TARGET){push( connectors, ON_ONTARGET, 0, _currentStep, 0 );};
  107. push(connectors, ON_CHANGESTATE, 0, state(), 0);
  108. push(connectors, ON_CHANGEPOSITION, 0, _currentStep, stepper->speed());
  109. enabled = _enableReversed ? LOW : HIGH ;
  110. digitalWrite(_enablePin, enabled);
  111. return;
  112. case ENT_RUNNING:
  113. push(connectors, ON_CHANGESTATE, 0, state(), 0);
  114. push(connectors, ON_CHANGEPOSITION, 0, _currentStep, stepper->speed());
  115. _isHoming = 0;
  116. stepper->setMaxSpeed(max_speed);
  117. stepper->setAcceleration(acceleration);
  118. //push(connectors, ON_CHANGEPOSITION, 0, _currentStep, stepper->speed());
  119. position_timer.setFromNow(this, POSITION_SEND_TIMER);
  120. return;
  121. case LP_RUNNING:
  122. stepper_update();
  123. Serial.println(stepper->speed());
  124. if(stepper->speed() == 0) {trigger(EVT_ON_TARGET);}
  125. return;
  126. case ENT_STOP:
  127. push(connectors, ON_CHANGESTATE, 0, state(), 0);
  128. push(connectors, ON_CHANGEPOSITION, 0, _currentStep, stepper->speed());
  129. if (last_trigger == EVT_STOP) {
  130. runMode = 0 ;
  131. stepper->stop();
  132. _targetStep = stepper->targetPosition();
  133. push( connectors, ON_STOP, 0, 0, 0 );
  134. }
  135. if (last_trigger == EVT_EMERGENCY_STOP) {
  136. _currentStep = stepper->currentPosition();
  137. _targetStep = _currentStep ;
  138. stepper->moveTo(_targetStep);
  139. stepper->setSpeed(0);
  140. push( connectors, ON_STOP, 0, 1, 0 );
  141. }
  142. stepper_update();
  143. return;
  144. case LP_STOP:
  145. stepper_update();
  146. _currentStep = stepper->currentPosition();
  147. if(stepper->speed() == 0.) {Serial.println(stepper->speed());trigger(EVT_ON_TARGET);}
  148. return;
  149. case ENT_HOMING_LOW:
  150. push(connectors, ON_CHANGEPOSITION, 0, _currentStep, stepper->speed());
  151. push(connectors, ON_CHANGESTATE, 0, state(), 0);
  152. runMode = 1;
  153. _isHoming = 1 ;
  154. stepper->setSpeed(-1*homing_speed);
  155. return;
  156. case LP_HOMING_LOW:
  157. stepper_update();
  158. return;
  159. case EXT_HOMING_LOW:
  160. if(last_trigger == EVT_ON_LIMIT_LOW) {
  161. stepper->setCurrentPosition(0);
  162. _currentStep = 0;
  163. Serial.println("homing low done");
  164. }
  165. else{Serial.println("homing low failed");}
  166. _targetStep = _currentStep;
  167. return;
  168. case ENT_HOMING_HIGH:
  169. push(connectors, ON_CHANGESTATE, 0, state(), 0);
  170. push(connectors, ON_CHANGEPOSITION, 0, _currentStep, stepper->speed());
  171. runMode = 1;
  172. _isHoming = 2 ;
  173. stepper->setSpeed(homing_speed);
  174. return;
  175. case LP_HOMING_HIGH:
  176. stepper_update();
  177. return;
  178. case EXT_HOMING_HIGH:
  179. if(last_trigger == EVT_ON_LIMIT_HIGH) {
  180. _maxStep = stepper->currentPosition();
  181. _currentStep = _maxStep;
  182. Serial.println("homing high done");
  183. }
  184. else{Serial.println("homing high failed");}
  185. _targetStep = _currentStep;
  186. return;
  187. case ENT_LIMIT_LOW:
  188. push( connectors, ON_ONLIMITLOW, 0, 0, 0 );
  189. push(connectors, ON_CHANGEPOSITION, 0, _currentStep, stepper->speed());
  190. //stop motor if going down, allow going up
  191. if(_limitLow_Hard && (stepper->speed()<0) ) {trigger(EVT_EMERGENCY_STOP);}
  192. else{ stepper_update(); _isHoming ? trigger(EVT_ENABLE):trigger(EVT_MOVE);}
  193. // switch(_isHoming) {
  194. // case 0 :
  195. // trigger(EVT_MOVE);
  196. // break;
  197. // case 1 :
  198. // trigger(EVT_HOMING_LOW);
  199. // break;
  200. // case 2 :
  201. // trigger(EVT_HOMING_HIGH);
  202. // break;
  203. // }
  204. // }
  205. return;
  206. case ENT_LIMIT_HIGH:
  207. push( connectors, ON_ONLIMITHIGH, 0, 1, 0 );
  208. push(connectors, ON_CHANGEPOSITION, 0, _currentStep, stepper->speed());
  209. if(_limitHigh_Hard && (stepper->speed()>0)) {trigger(EVT_EMERGENCY_STOP);}
  210. else{ stepper_update(); _isHoming ? trigger(EVT_ENABLE):trigger(EVT_MOVE);}
  211. // stepper_update();
  212. // switch(_isHoming) {
  213. // case 0 :
  214. // trigger(EVT_MOVE);
  215. // break;
  216. // case 1 :
  217. // trigger(EVT_HOMING_HIGH);
  218. // break;
  219. // case 2 :
  220. // trigger(EVT_HOMING_HIGH);
  221. // break;
  222. // }
  223. // }
  224. return;
  225. }
  226. }
  227. /* Optionally override the default trigger() method
  228. * Control how your machine processes triggers
  229. */
  230. Atm_AccelStepper& Atm_AccelStepper::trigger( int event ) {
  231. Machine::trigger( event );
  232. return *this;
  233. }
  234. /* Optionally override the default state() method
  235. * Control what the machine returns when another process requests its state
  236. */
  237. int Atm_AccelStepper::state( void ) {
  238. return Machine::state();
  239. }
  240. /* Nothing customizable below this line
  241. ************************************************************************************************
  242. */
  243. /* Still I'll customize a little just here
  244. */
  245. void Atm_AccelStepper::stepper_update(void) {
  246. switch (runMode) {
  247. case 0: //positional modae
  248. stepper->run();
  249. break;
  250. case 1: // speed mode
  251. stepper->runSpeed();
  252. break;
  253. }
  254. long int tempStep = stepper->currentPosition();
  255. if (tempStep != _currentStep){
  256. _currentStep = tempStep;
  257. if (position_timer.expired(this)){
  258. push(connectors, ON_CHANGEPOSITION, 0, _currentStep, stepper->speed());
  259. position_timer.setFromNow(this, POSITION_SEND_TIMER);
  260. }
  261. }
  262. }
  263. Atm_AccelStepper& Atm_AccelStepper::setMaxSpeed( long int maxSpeed){
  264. max_speed = maxSpeed ;
  265. stepper->setMaxSpeed(max_speed);
  266. return *this ;
  267. }
  268. Atm_AccelStepper& Atm_AccelStepper::setHomingSpeed(long int homingSpeed){
  269. homing_speed = homingSpeed ;
  270. return *this ;
  271. }
  272. Atm_AccelStepper& Atm_AccelStepper::setAcceleration(long int acc){
  273. acceleration = acc ;
  274. stepper->setAcceleration(max_speed);
  275. return *this ;
  276. }
  277. Atm_AccelStepper& Atm_AccelStepper::position_refresh(long int refresh_ms){
  278. POSITION_SEND_TIMER = refresh_ms ;
  279. return *this ;
  280. }
  281. Atm_AccelStepper& Atm_AccelStepper::move( long int stepRel, long int maxSpeed,
  282. long int acc) {
  283. _targetStep = _currentStep + stepRel;
  284. runMode = 0;
  285. _isHoming = 0;
  286. //Serial.println(_targetStep);
  287. max_speed = maxSpeed;
  288. acceleration = acc;
  289. stepper->moveTo(_targetStep);
  290. enable();
  291. trigger( EVT_MOVE );
  292. return *this;
  293. }
  294. Atm_AccelStepper& Atm_AccelStepper::moveTo( long int stepAbs, long int maxSpeed,
  295. long int acc) {
  296. _targetStep = stepAbs;
  297. _isHoming = 0 ;
  298. runMode = 0;
  299. max_speed = maxSpeed;
  300. acceleration = acc;
  301. stepper->moveTo(_targetStep);
  302. enable();
  303. trigger( EVT_MOVE );
  304. return *this;
  305. }
  306. Atm_AccelStepper& Atm_AccelStepper::rotate( long int speed) {
  307. runMode = 1;
  308. _isHoming = 0 ;
  309. stepper->setSpeed( speed);
  310. enable();
  311. trigger( EVT_MOVE );
  312. return *this;
  313. }
  314. Atm_AccelStepper& Atm_AccelStepper::homing( bool direction, long int speed ){
  315. enable();
  316. homing_speed = speed ;
  317. direction == 1 ? _isHoming = 2 : _isHoming = 1;
  318. direction == 1 ? this->trigger(EVT_HOMING_HIGH) : this->trigger(EVT_HOMING_LOW);
  319. return *this;
  320. }
  321. // Atm_AccelStepper& Atm_AccelStepper::rotationReversed(bool reversed){
  322. // _rotationReversed = reversed ? -1 : 1 ;
  323. // }
  324. Atm_AccelStepper& Atm_AccelStepper::setEnablePin( int enablePin ){
  325. _enablePin = enablePin ;
  326. pinMode(_enablePin, OUTPUT);
  327. return *this;
  328. }
  329. Atm_AccelStepper& Atm_AccelStepper::pinReversed( bool directionInvert,
  330. bool stepInvert, bool enableInvert){
  331. stepper->setPinsInverted(directionInvert, stepInvert, enableInvert);
  332. return *this;
  333. }
  334. Atm_AccelStepper& Atm_AccelStepper::limitLow_set(int mode, int pin, int reversed){
  335. _limitLow_Mode = mode ;
  336. _limitLow_Pin = pin ;
  337. _limitLow_Reversed = reversed ;
  338. if (_limitLow_Mode==1) {pinMode(_limitLow_Pin, INPUT_PULLUP);}
  339. if (_limitLow_Mode==2) {pinMode(_limitLow_Pin, INPUT);}
  340. return *this;
  341. }
  342. Atm_AccelStepper& Atm_AccelStepper::limitLow_isHard(bool hardlimit){
  343. _limitLow_Hard = hardlimit;
  344. return *this;
  345. }
  346. Atm_AccelStepper& Atm_AccelStepper::limitLow_setThresholds (int threshold_low, int threshold_high){
  347. _limitLow_Thresholds[0] = threshold_low ;
  348. _limitLow_Thresholds[1] = threshold_high ;
  349. return *this;
  350. }
  351. Atm_AccelStepper& Atm_AccelStepper::limitHigh_set(int mode, int pin, int reversed){
  352. _limitHigh_Mode = mode ;
  353. _limitHigh_Pin = pin ;
  354. _limitHigh_Reversed = reversed ;
  355. if (_limitHigh_Mode==1) {pinMode(_limitHigh_Pin, INPUT_PULLUP);}
  356. if (_limitHigh_Mode==2) {pinMode(_limitHigh_Pin, INPUT);}
  357. return *this;
  358. }
  359. Atm_AccelStepper& Atm_AccelStepper::limitHigh_isHard(bool hardlimit){
  360. _limitHigh_Hard = hardlimit;
  361. return *this;
  362. }
  363. Atm_AccelStepper& Atm_AccelStepper::limitHigh_setThresholds (int threshold_low, int threshold_high){
  364. _limitHigh_Thresholds[0] = threshold_low ;
  365. _limitHigh_Thresholds[1] = threshold_high ;
  366. return *this;
  367. }
  368. /* Public event methods
  369. *
  370. */
  371. Atm_AccelStepper& Atm_AccelStepper::disable() {
  372. trigger( EVT_DISABLE );
  373. return *this;
  374. }
  375. Atm_AccelStepper& Atm_AccelStepper::enable() {
  376. trigger( EVT_ENABLE );
  377. return *this;
  378. }
  379. // Atm_AccelStepper& Atm_AccelStepper::move() {
  380. // trigger( EVT_MOVE );
  381. // return *this;
  382. // }
  383. Atm_AccelStepper& Atm_AccelStepper::stop() {
  384. trigger( EVT_STOP );
  385. return *this;
  386. }
  387. Atm_AccelStepper& Atm_AccelStepper::emergency_stop() {
  388. trigger( EVT_EMERGENCY_STOP );
  389. return *this;
  390. }
  391. Atm_AccelStepper& Atm_AccelStepper::on_limit_low() {
  392. trigger( EVT_ON_LIMIT_LOW );
  393. return *this;
  394. }
  395. Atm_AccelStepper& Atm_AccelStepper::on_limit_high() {
  396. trigger( EVT_ON_LIMIT_HIGH );
  397. return *this;
  398. }
  399. Atm_AccelStepper& Atm_AccelStepper::on_target() {
  400. trigger( EVT_ON_TARGET );
  401. return *this;
  402. }
  403. /*
  404. * onChangeposition() push connector variants ( slots 1, autostore 0, broadcast 0 )
  405. */
  406. Atm_AccelStepper& Atm_AccelStepper::onChangeposition( Machine& machine, int event ) {
  407. onPush( connectors, ON_CHANGEPOSITION, 0, 1, 1, machine, event );
  408. return *this;
  409. }
  410. Atm_AccelStepper& Atm_AccelStepper::onChangeposition( atm_cb_push_t callback, int idx ) {
  411. onPush( connectors, ON_CHANGEPOSITION, 0, 1, 1, callback, idx );
  412. return *this;
  413. }
  414. /*
  415. * onChangestate() push connector variants ( slots 1, autostore 0, broadcast 0 )
  416. */
  417. Atm_AccelStepper& Atm_AccelStepper::onChangestate( Machine& machine, int event ) {
  418. onPush( connectors, ON_CHANGESTATE, 0, 1, 1, machine, event );
  419. return *this;
  420. }
  421. Atm_AccelStepper& Atm_AccelStepper::onChangestate( atm_cb_push_t callback, int idx ) {
  422. onPush( connectors, ON_CHANGESTATE, 0, 1, 1, callback, idx );
  423. return *this;
  424. }
  425. /*
  426. * onOnlimithigh() push connector variants ( slots 1, autostore 0, broadcast 0 )
  427. */
  428. Atm_AccelStepper& Atm_AccelStepper::onOnlimithigh( Machine& machine, int event ) {
  429. onPush( connectors, ON_ONLIMITHIGH, 0, 1, 1, machine, event );
  430. return *this;
  431. }
  432. Atm_AccelStepper& Atm_AccelStepper::onOnlimithigh( atm_cb_push_t callback, int idx ) {
  433. onPush( connectors, ON_ONLIMITHIGH, 0, 1, 1, callback, idx );
  434. return *this;
  435. }
  436. /*
  437. * onOnlimitlow() push connector variants ( slots 1, autostore 0, broadcast 0 )
  438. */
  439. Atm_AccelStepper& Atm_AccelStepper::onOnlimitlow( Machine& machine, int event ) {
  440. onPush( connectors, ON_ONLIMITLOW, 0, 1, 1, machine, event );
  441. return *this;
  442. }
  443. Atm_AccelStepper& Atm_AccelStepper::onOnlimitlow( atm_cb_push_t callback, int idx ) {
  444. onPush( connectors, ON_ONLIMITLOW, 0, 1, 1, callback, idx );
  445. return *this;
  446. }
  447. /*
  448. * onOntarget() push connector variants ( slots 1, autostore 0, broadcast 0 )
  449. */
  450. Atm_AccelStepper& Atm_AccelStepper::onOntarget( Machine& machine, int event ) {
  451. onPush( connectors, ON_ONTARGET, 0, 1, 1, machine, event );
  452. return *this;
  453. }
  454. Atm_AccelStepper& Atm_AccelStepper::onOntarget( atm_cb_push_t callback, int idx ) {
  455. onPush( connectors, ON_ONTARGET, 0, 1, 1, callback, idx );
  456. return *this;
  457. }
  458. /*
  459. * onStop() push connector variants ( slots 1, autostore 0, broadcast 0 )
  460. */
  461. Atm_AccelStepper& Atm_AccelStepper::onStop( Machine& machine, int event ) {
  462. onPush( connectors, ON_STOP, 0, 1, 1, machine, event );
  463. return *this;
  464. }
  465. Atm_AccelStepper& Atm_AccelStepper::onStop( atm_cb_push_t callback, int idx ) {
  466. onPush( connectors, ON_STOP, 0, 1, 1, callback, idx );
  467. return *this;
  468. }
  469. Atm_AccelStepper& Atm_AccelStepper::onOnhominglow( Machine& machine, int event ) {
  470. onPush( connectors, ON_ONTARGET, 0, 1, 1, machine, event );
  471. return *this;
  472. }
  473. Atm_AccelStepper& Atm_AccelStepper::onOnhominglow( atm_cb_push_t callback, int idx ) {
  474. onPush( connectors, ON_ONTARGET, 0, 1, 1, callback, idx );
  475. return *this;
  476. }
  477. Atm_AccelStepper& Atm_AccelStepper::onOnhominghigh( Machine& machine, int event ) {
  478. onPush( connectors, ON_ONTARGET, 0, 1, 1, machine, event );
  479. return *this;
  480. }
  481. Atm_AccelStepper& Atm_AccelStepper::onOnhominghigh( atm_cb_push_t callback, int idx ) {
  482. onPush( connectors, ON_ONTARGET, 0, 1, 1, callback, idx );
  483. return *this;
  484. }
  485. /* State trace method
  486. * Sets the symbol table and the default logging method for serial monitoring
  487. */
  488. Atm_AccelStepper& Atm_AccelStepper::trace( Stream & stream ) {
  489. Machine::setTrace( &stream, atm_serial_debug::trace,
  490. "ACCELSTEPPER\0EVT_DISABLE\0EVT_ENABLE\0EVT_ENABLED_TIMEOUT\0EVT_MOVE\0EVT_STOP\0EVT_EMERGENCY_STOP\0EVT_ON_LIMIT_LOW\0EVT_ON_LIMIT_HIGH\0EVT_ON_TARGET\0EVT_HOMING_LOW\0EVT_HOMING_HIGH\0ELSE\0DISABLED\0ENABLED\0RUNNING\0STOP\0HOMING_LOW\0HOMING_HIGH\0LIMIT_LOW\0LIMIT_HIGH" );
  491. return *this;
  492. }