Skip to content

Commit

Permalink
Queue up to 3 poll requests, Readme update
Browse files Browse the repository at this point in the history
Using 3 queued poll requests we can be sure to not miss any change
by interrupt or manually triggered poll. See #59
  • Loading branch information
crycode-de committed Dec 21, 2023
1 parent 3b91474 commit 4ef3323
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,12 @@ doPoll (): Promise<void>;
Manually poll changed inputs from the PCF8574/PCF8574A/PCF8575 IC.

If a change on an input is detected, an `input` Event will be emitted with a data object containing the `pin` and the new `value`.

This have to be called frequently enough if you don't use a GPIO for interrupt detection.
If you poll again before the last poll was completed, the new poll will be queued up an get executed if the current poll is done.

Poll requests will be queued internally up to 4 total requests (one active and three waiting) including polls triggered by interrupts.
If you try to trigger a poll while the queue is already full, the new poll will be rejected.
This is due to not have too many unnecessary polls.


### isPolling()
Expand Down
2 changes: 1 addition & 1 deletion src/pcf857x.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export abstract class PCF857x<PinNumber extends PCF8574.PinNumber | PCF8575.PinN
private _currentlyPolling: boolean = false;

/** PromiseQueue to handle requested polls in order. */
private _pollQueue: PromiseQueue = new PromiseQueue(1);
private _pollQueue: PromiseQueue = new PromiseQueue(3);

/** Pin number of GPIO to detect interrupts, or null by default. */
private _gpioPin: number | null = null;
Expand Down

0 comments on commit 4ef3323

Please sign in to comment.