iFix formatting

This commit is contained in:
root 2021-07-16 17:18:06 -05:00
parent 588a19a1ab
commit 1c80696746

View File

@ -129,36 +129,36 @@ void common_hal_pulseio_pulsein_interrupt(pulseio_pulsein_obj_t *self) {
rxfifo = pio_sm_get_blocking(self->state_machine.pio, self->state_machine.state_machine); rxfifo = pio_sm_get_blocking(self->state_machine.pio, self->state_machine.state_machine);
// translate from fifo to buffer // translate from fifo to buffer
if ((rxfifo == 0 && self->last_level == false) || (rxfifo == 0xffffffff && self->last_level == true)) { if ((rxfifo == 0 && self->last_level == false) || (rxfifo == 0xffffffff && self->last_level == true)) {
self->level_count = self->level_count + 32; self->level_count = self->level_count + 32;
} else { } else {
for (uint i = 0; i < 32; i++) { for (uint i = 0; i < 32; i++) {
bool level = (rxfifo & (1 << i)) >> i; bool level = (rxfifo & (1 << i)) >> i;
if (level == self->last_level) { if (level == self->last_level) {
self->level_count++; self->level_count++;
} else { } else {
result = self->level_count; result = self->level_count;
self->last_level = level; self->last_level = level;
self->level_count = 0; self->level_count = 0;
// Pulses that are longer than MAX_PULSE will return MAX_PULSE // Pulses that are longer than MAX_PULSE will return MAX_PULSE
if (result > MAX_PULSE) { if (result > MAX_PULSE) {
result = MAX_PULSE; result = MAX_PULSE;
}
// return pulses that are not too short
if (result > MIN_PULSE) {
self->buffer[self->buf_index] = (uint16_t)result;
if (self->len < self->maxlen) {
self->len++;
} }
if (self->buf_index < self->maxlen) { // return pulses that are not too short
self->buf_index++; if (result > MIN_PULSE) {
} else { self->buffer[self->buf_index] = (uint16_t)result;
self->start = 0; if (self->len < self->maxlen) {
self->buf_index = 0; self->len++;
}
if (self->buf_index < self->maxlen) {
self->buf_index++;
} else {
self->start = 0;
self->buf_index = 0;
}
} }
} }
} }
} }
}
// check for a pulse thats too long (MAX_PULSE us) or maxlen reached, and reset // check for a pulse thats too long (MAX_PULSE us) or maxlen reached, and reset
if ((self->level_count > MAX_PULSE) || (self->buf_index >= self->maxlen)) { if ((self->level_count > MAX_PULSE) || (self->buf_index >= self->maxlen)) {