File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ void StepDirListener::init(){
13
13
}
14
14
15
15
void StepDirListener::enableInterrupt (void (*doA)()){
16
- attachInterrupt (digitalPinToInterrupt (pin_step), doA, CHANGE );
16
+ attachInterrupt (digitalPinToInterrupt (pin_step), doA, polarity );
17
17
}
18
18
19
19
void StepDirListener::attach (float * variable){
@@ -22,15 +22,15 @@ void StepDirListener::attach(float* variable){
22
22
23
23
void StepDirListener::handle (){
24
24
// read step status
25
- bool step = digitalRead (pin_step);
25
+ // bool step = digitalRead(pin_step);
26
26
// update counter only on rising edge
27
- if (step && step != step_active){
28
- if (digitalRead (pin_dir))
27
+ // if(step && step != step_active){
28
+ if (digitalRead (pin_dir))
29
29
count++;
30
- else
30
+ else
31
31
count--;
32
- }
33
- step_active = step;
32
+ // }
33
+ // step_active = step;
34
34
// if attached variable update it
35
35
if (attached_variable) *attached_variable = getValue ();
36
36
}
Original file line number Diff line number Diff line change @@ -47,11 +47,13 @@ class StepDirListener
47
47
int pin_step; // !< step pin
48
48
int pin_dir; // !< direction pin
49
49
long count; // !< current counter value - should be set to 0 for homing
50
+ PinStatus polarity = RISING; // !< polarity of the step pin
50
51
51
52
private:
52
53
float * attached_variable = nullptr ; // !< pointer to the attached variable
53
54
float counter_to_value; // !< step counter to value
54
- bool step_active = 0 ; // !< current step pin status (HIGH/LOW) - debouncing variable
55
+ // bool step_active = 0; //!< current step pin status (HIGH/LOW) - debouncing variable
56
+
55
57
};
56
58
57
59
#endif
You can’t perform that action at this time.
0 commit comments