File tree Expand file tree Collapse file tree 3 files changed +13
-8
lines changed Expand file tree Collapse file tree 3 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -128,3 +128,14 @@ void Encoder::init(){
128
128
129
129
}
130
130
131
+
132
+ void Encoder::enableInterrupt (){
133
+ // interupt intitialisation
134
+ // A callback and B callback
135
+ attachInterrupt (digitalPinToInterrupt (pinA), []() {
136
+ encoder.handleA ();
137
+ }, CHANGE);
138
+ attachInterrupt (digitalPinToInterrupt (pinB), []() {
139
+ encoder.handleB ();
140
+ }, CHANGE);
141
+ }
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ class Encoder{
29
29
void handleA ();
30
30
// B channel
31
31
void handleB ();
32
+ void enableInterrupt ();
32
33
33
34
// encoder getters
34
35
// shaft velocity getter
Original file line number Diff line number Diff line change @@ -27,14 +27,7 @@ void setup() {
27
27
// initialise encoder hardware
28
28
encoder.init ();
29
29
30
- // interupt intitialisation
31
- // A callback and B callback
32
- attachInterrupt (digitalPinToInterrupt (encoder.pinA ), []() {
33
- encoder.handleA ();
34
- }, CHANGE);
35
- attachInterrupt (digitalPinToInterrupt (encoder.pinB ), []() {
36
- encoder.handleB ();
37
- }, CHANGE);
30
+ encoder.enableInterrupt ();
38
31
39
32
// set driver type
40
33
// DriverType::unipolar
You can’t perform that action at this time.
0 commit comments