File tree Expand file tree Collapse file tree 2 files changed +2
-6
lines changed
ports/raspberrypi/common-hal/rotaryio Expand file tree Collapse file tree 2 files changed +2
-6
lines changed Original file line number Diff line number Diff line change @@ -60,17 +60,14 @@ STATIC void incrementalencoder_interrupt_handler(void *self_in);
60
60
void common_hal_rotaryio_incrementalencoder_construct (rotaryio_incrementalencoder_obj_t * self ,
61
61
const mcu_pin_obj_t * pin_a , const mcu_pin_obj_t * pin_b ) {
62
62
mp_obj_t pins [] = {MP_OBJ_FROM_PTR (pin_a ), MP_OBJ_FROM_PTR (pin_b )};
63
- bool swap = false;
64
63
if (!common_hal_rp2pio_pins_are_sequential (2 , pins )) {
65
64
pins [0 ] = MP_OBJ_FROM_PTR (pin_b );
66
65
pins [1 ] = MP_OBJ_FROM_PTR (pin_a );
67
- swap = true;
68
66
if (!common_hal_rp2pio_pins_are_sequential (2 , pins )) {
69
67
mp_raise_RuntimeError (translate ("Pins must be sequential" ));
70
68
}
71
69
}
72
70
73
- self -> swap = swap ;
74
71
self -> position = 0 ;
75
72
self -> quarter_count = 0 ;
76
73
@@ -113,12 +110,12 @@ void common_hal_rotaryio_incrementalencoder_deinit(rotaryio_incrementalencoder_o
113
110
}
114
111
115
112
mp_int_t common_hal_rotaryio_incrementalencoder_get_position (rotaryio_incrementalencoder_obj_t * self ) {
116
- return self -> swap ? - self -> position : self -> position ;
113
+ return self -> position ;
117
114
}
118
115
119
116
void common_hal_rotaryio_incrementalencoder_set_position (rotaryio_incrementalencoder_obj_t * self ,
120
117
mp_int_t new_position ) {
121
- self -> position = self -> swap ? - new_position : new_position ;
118
+ self -> position = new_position ;
122
119
}
123
120
124
121
STATIC void incrementalencoder_interrupt_handler (void * self_in ) {
Original file line number Diff line number Diff line change @@ -37,5 +37,4 @@ typedef struct {
37
37
uint8_t last_state : 4 ; // <old A><old B><new A><new B>
38
38
int8_t quarter_count : 4 ; // count intermediate transitions between detents
39
39
mp_int_t position ;
40
- bool swap ;
41
40
} rotaryio_incrementalencoder_obj_t ;
You can’t perform that action at this time.
0 commit comments