Merge pull request #7378 from DavePutz/issue_7325
Issue 7352 - set max value of a pulsein
This commit is contained in:
commit
0d3b7770d1
@ -41,7 +41,12 @@ STATIC void update_internal_buffer(pulseio_pulsein_obj_t *self) {
|
|||||||
length /= 4;
|
length /= 4;
|
||||||
for (size_t i = 0; i < length; i++) {
|
for (size_t i = 0; i < length; i++) {
|
||||||
uint16_t pos = (self->start + self->len) % self->maxlen;
|
uint16_t pos = (self->start + self->len) % self->maxlen;
|
||||||
self->buffer[pos] = items[i].duration0 * 3;
|
uint32_t val = items[i].duration0 * 3;
|
||||||
|
// make sure the value returned does not exceed the max uint16 value.
|
||||||
|
if (val > 65535) {
|
||||||
|
val = 65535;
|
||||||
|
}
|
||||||
|
self->buffer[pos] = (uint16_t)val;
|
||||||
if (self->len < self->maxlen) {
|
if (self->len < self->maxlen) {
|
||||||
self->len++;
|
self->len++;
|
||||||
} else {
|
} else {
|
||||||
@ -50,7 +55,11 @@ STATIC void update_internal_buffer(pulseio_pulsein_obj_t *self) {
|
|||||||
// Check if second item exists
|
// Check if second item exists
|
||||||
if (items[i].duration1) {
|
if (items[i].duration1) {
|
||||||
pos = (self->start + self->len) % self->maxlen;
|
pos = (self->start + self->len) % self->maxlen;
|
||||||
self->buffer[pos] = items[i].duration1 * 3;
|
val = items[i].duration1 * 3;
|
||||||
|
if (val > 65535) {
|
||||||
|
val = 65535;
|
||||||
|
}
|
||||||
|
self->buffer[pos] = (uint16_t)val;
|
||||||
if (self->len < self->maxlen) {
|
if (self->len < self->maxlen) {
|
||||||
self->len++;
|
self->len++;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user