Merge remote-tracking branch 'origin/main'

This commit is contained in:
Hosted Weblate 2022-05-08 18:37:31 +02:00
commit 5dd5ebca55
No known key found for this signature in database
GPG Key ID: A3FAAA06E6569B4C
1 changed files with 4 additions and 2 deletions

View File

@ -147,9 +147,12 @@ void common_hal_pulseio_pulsein_interrupt(void *self_in) {
} }
// return pulses that are not too short // return pulses that are not too short
if (result > MIN_PULSE) { if (result > MIN_PULSE) {
self->buffer[self->buf_index] = (uint16_t)result; size_t buf_index = (self->start + self->len) % self->maxlen;
self->buffer[buf_index] = (uint16_t)result;
if (self->len < self->maxlen) { if (self->len < self->maxlen) {
self->len++; self->len++;
} else {
self->start = (self->start + 1) % self->maxlen;
} }
if (self->buf_index < self->maxlen) { if (self->buf_index < self->maxlen) {
self->buf_index++; self->buf_index++;
@ -169,7 +172,6 @@ void common_hal_pulseio_pulsein_interrupt(void *self_in) {
pio_sm_restart(self->state_machine.pio,self->state_machine.state_machine); pio_sm_restart(self->state_machine.pio,self->state_machine.state_machine);
pio_sm_set_enabled(self->state_machine.pio, self->state_machine.state_machine, true); pio_sm_set_enabled(self->state_machine.pio, self->state_machine.state_machine, true);
self->buf_index = 0; self->buf_index = 0;
self->start = 0;
} }
} }
void common_hal_pulseio_pulsein_resume(pulseio_pulsein_obj_t *self, void common_hal_pulseio_pulsein_resume(pulseio_pulsein_obj_t *self,