Tweaks from jepler
This commit is contained in:
parent
a6fb0beaa9
commit
7dfcae6067
@ -79,12 +79,9 @@ static void pulsein_handler(uint8_t num) {
|
|||||||
self->first_edge = false;
|
self->first_edge = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
uint32_t total_diff = current_count + 0xffff * (current_overflow - self->last_overflow) - self->last_count;
|
uint32_t total_diff = current_count + 0x10000 * (current_overflow - self->last_overflow) - self->last_count;
|
||||||
// Cap duration at 16 bits.
|
// Cap duration at 16 bits.
|
||||||
uint16_t duration = 0xffff;
|
uint16_t duration = MIN(0xffff, total_diff);
|
||||||
if (total_diff < duration) {
|
|
||||||
duration = total_diff;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t i = (self->start + self->len) % self->maxlen;
|
uint16_t i = (self->start + self->len) % self->maxlen;
|
||||||
self->buffer[i] = duration;
|
self->buffer[i] = duration;
|
||||||
|
Loading…
Reference in New Issue
Block a user