|
@@ -34,7 +34,7 @@ Atm_AccelStepper& Atm_AccelStepper::begin(int step_pin, int dir_pin) {
|
|
|
|
|
|
int Atm_AccelStepper::event( int id ) {
|
|
int Atm_AccelStepper::event( int id ) {
|
|
//updateLimitSwitch();
|
|
//updateLimitSwitch();
|
|
- bool changed ;
|
|
|
|
|
|
+ bool changed = 0 ;
|
|
switch ( id ) {
|
|
switch ( id ) {
|
|
case EVT_DISABLE:
|
|
case EVT_DISABLE:
|
|
return 0;
|
|
return 0;
|
|
@@ -50,15 +50,15 @@ int Atm_AccelStepper::event( int id ) {
|
|
return 0;
|
|
return 0;
|
|
case EVT_ON_LIMIT_LOW:
|
|
case EVT_ON_LIMIT_LOW:
|
|
// previous_state = limitLow_State;
|
|
// previous_state = limitLow_State;
|
|
|
|
+
|
|
switch(_limitLow_Mode) {
|
|
switch(_limitLow_Mode) {
|
|
|
|
+
|
|
case 0:
|
|
case 0:
|
|
- changed = limitLow_State != limitLow_State_prev ? 1 : 0 ;
|
|
|
|
break;
|
|
break;
|
|
case 1: //digital INPUT
|
|
case 1: //digital INPUT
|
|
// Serial.println("digital");
|
|
// Serial.println("digital");
|
|
limitLow_State = digitalRead(_limitLow_Pin);
|
|
limitLow_State = digitalRead(_limitLow_Pin);
|
|
limitLow_State = _limitLow_Reversed ? !limitLow_State : limitLow_State;
|
|
limitLow_State = _limitLow_Reversed ? !limitLow_State : limitLow_State;
|
|
- changed = limitLow_State != limitLow_State_prev ? 1 : 0 ;
|
|
|
|
break;
|
|
break;
|
|
case 2:
|
|
case 2:
|
|
int analogTemp = analogRead(_limitLow_Pin);
|
|
int analogTemp = analogRead(_limitLow_Pin);
|
|
@@ -70,22 +70,21 @@ int Atm_AccelStepper::event( int id ) {
|
|
limitLow_State = (_limitLow_Thresholds[0] < analogTemp) && (analogTemp < _limitLow_Thresholds[1]);
|
|
limitLow_State = (_limitLow_Thresholds[0] < analogTemp) && (analogTemp < _limitLow_Thresholds[1]);
|
|
limitLow_State = _limitLow_Reversed ? !limitLow_State : limitLow_State;
|
|
limitLow_State = _limitLow_Reversed ? !limitLow_State : limitLow_State;
|
|
}
|
|
}
|
|
- changed = limitLow_State != limitLow_State_prev ? 1 : 0 ;
|
|
|
|
break;
|
|
break;
|
|
- }
|
|
|
|
- limitLow_State_prev = limitLow_State ;
|
|
|
|
- return changed ;
|
|
|
|
|
|
+ }
|
|
|
|
+ changed = limitLow_State != limitLow_State_prev ? 1 : 0 ;
|
|
|
|
+ limitLow_State_prev = limitLow_State ;
|
|
|
|
+ return changed ;
|
|
|
|
+
|
|
|
|
|
|
case EVT_ON_LIMIT_HIGH:
|
|
case EVT_ON_LIMIT_HIGH:
|
|
// previous_state = limitHigh_State;
|
|
// previous_state = limitHigh_State;
|
|
switch(_limitHigh_Mode) {
|
|
switch(_limitHigh_Mode) {
|
|
case 0:
|
|
case 0:
|
|
- changed = limitHigh_State != limitHigh_State_prev ? 1 : 0;
|
|
|
|
break;
|
|
break;
|
|
case 1: //digital INPUT
|
|
case 1: //digital INPUT
|
|
limitHigh_State = digitalRead(_limitHigh_Pin);
|
|
limitHigh_State = digitalRead(_limitHigh_Pin);
|
|
limitHigh_State = _limitHigh_Reversed ? !limitHigh_State : limitHigh_State;
|
|
limitHigh_State = _limitHigh_Reversed ? !limitHigh_State : limitHigh_State;
|
|
- changed = limitHigh_State != limitHigh_State_prev ? 1 : 0;
|
|
|
|
break;
|
|
break;
|
|
case 2:
|
|
case 2:
|
|
//Serial.println("analog");
|
|
//Serial.println("analog");
|
|
@@ -98,11 +97,11 @@ int Atm_AccelStepper::event( int id ) {
|
|
limitHigh_State = (_limitHigh_Thresholds[0] < analogTemp) && (analogTemp < _limitHigh_Thresholds[1]);
|
|
limitHigh_State = (_limitHigh_Thresholds[0] < analogTemp) && (analogTemp < _limitHigh_Thresholds[1]);
|
|
limitHigh_State = _limitHigh_Reversed ? !limitHigh_State : limitHigh_State;
|
|
limitHigh_State = _limitHigh_Reversed ? !limitHigh_State : limitHigh_State;
|
|
}
|
|
}
|
|
- changed = limitHigh_State != limitHigh_State_prev ? 1 : 0;
|
|
|
|
break;
|
|
break;
|
|
- }
|
|
|
|
- limitHigh_State_prev = limitHigh_State_prev;
|
|
|
|
- return changed;
|
|
|
|
|
|
+ }
|
|
|
|
+ changed = limitHigh_State != limitHigh_State_prev ? 1 : 0;
|
|
|
|
+ limitHigh_State_prev = limitHigh_State;
|
|
|
|
+ return changed;
|
|
|
|
|
|
case EVT_ON_TARGET:
|
|
case EVT_ON_TARGET:
|
|
return runMode ? 0 : _currentStep == _targetStep;
|
|
return runMode ? 0 : _currentStep == _targetStep;
|
|
@@ -135,6 +134,7 @@ void Atm_AccelStepper::action( int id ) {
|
|
return;
|
|
return;
|
|
case ENT_ENABLED:
|
|
case ENT_ENABLED:
|
|
_isHoming = 0 ;
|
|
_isHoming = 0 ;
|
|
|
|
+ stepper_update();
|
|
if(last_trigger == EVT_ON_TARGET){push( connectors, ON_ONTARGET, 0, _currentStep, 0 );};
|
|
if(last_trigger == EVT_ON_TARGET){push( connectors, ON_ONTARGET, 0, _currentStep, 0 );};
|
|
push(connectors, ON_CHANGESTATE, 0, state(), 0);
|
|
push(connectors, ON_CHANGESTATE, 0, state(), 0);
|
|
push(connectors, ON_CHANGEPOSITION, 0, _currentStep, stepper->speed());
|
|
push(connectors, ON_CHANGEPOSITION, 0, _currentStep, stepper->speed());
|