Skip to content

Commit 1a2ce27

Browse files
committed
raspberrypi: Drop support for auto-reversing swapped encoder
1 parent fc86475 commit 1a2ce27

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,14 @@ STATIC void incrementalencoder_interrupt_handler(void *self_in);
6060
void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencoder_obj_t *self,
6161
const mcu_pin_obj_t *pin_a, const mcu_pin_obj_t *pin_b) {
6262
mp_obj_t pins[] = {MP_OBJ_FROM_PTR(pin_a), MP_OBJ_FROM_PTR(pin_b)};
63-
bool swap = false;
6463
if (!common_hal_rp2pio_pins_are_sequential(2, pins)) {
6564
pins[0] = MP_OBJ_FROM_PTR(pin_b);
6665
pins[1] = MP_OBJ_FROM_PTR(pin_a);
67-
swap = true;
6866
if (!common_hal_rp2pio_pins_are_sequential(2, pins)) {
6967
mp_raise_RuntimeError(translate("Pins must be sequential"));
7068
}
7169
}
7270

73-
self->swap = swap;
7471
self->position = 0;
7572
self->quarter_count = 0;
7673

@@ -113,12 +110,12 @@ void common_hal_rotaryio_incrementalencoder_deinit(rotaryio_incrementalencoder_o
113110
}
114111

115112
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;
117114
}
118115

119116
void common_hal_rotaryio_incrementalencoder_set_position(rotaryio_incrementalencoder_obj_t *self,
120117
mp_int_t new_position) {
121-
self->position = self->swap ? -new_position : new_position;
118+
self->position = new_position;
122119
}
123120

124121
STATIC void incrementalencoder_interrupt_handler(void *self_in) {

ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,4 @@ typedef struct {
3737
uint8_t last_state : 4; // <old A><old B><new A><new B>
3838
int8_t quarter_count : 4; // count intermediate transitions between detents
3939
mp_int_t position;
40-
bool swap;
4140
} rotaryio_incrementalencoder_obj_t;

0 commit comments

Comments
 (0)