Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 1000 Bytes

README.md

File metadata and controls

34 lines (26 loc) · 1000 Bytes

Arduino Avail

Method for comparing two milliseconds to each other for asserting true/false criteria.

Example:

unsigned long lastTimestamp = 123455; // in milliseconds
unsigned long margin = 150; // milliseconds before needing to do something

if (Avail::millis(&margin, &lastTimestamp)) {
    // do stuff after waiting the length of 'margin'
} else {
    // continue looping through code
}

If you need to know whether or not a rollover has occurred with the millis() counter, do the following:

unsigned long lastTimestamp = 123455; // in milliseconds
unsigned long margin = 150; // milliseconds before needing to do something
bool rollover; // this will be assigned the approrpiate flag when being passed by reference

if (Avail::millis(&margin, &lastTimestamp, rollover)) {
    // do stuff after waiting the length of 'margin'
} else {
    // continue looping through code
}

if (rollover) {
    // perform other necessary logic
}