Bluenet
5.7.0
Bluenet, firmware for nRF52 smart home devices
|
Increment administration object with 'none' value default. More...
#include <cs_Lollipop.h>
Public Member Functions | |
Lollipop (uint16_t m) | |
Lollipop (uint16_t v, uint16_t m) | |
Lollipop (const Lollipop &l)=default | |
bool | operator< (const Lollipop &other) |
Lollipop & | operator++ () |
Lollipop | operator++ (int) |
Static Public Member Functions | |
static uint16_t | next (uint16_t currentValue, uint16_t maxValue) |
Return the next value given the current value. More... | |
static bool | isNewer (uint16_t previousValue, uint16_t currentValue, uint16_t maxValue) |
Returns true when current value is newer than previous value. More... | |
Private Attributes | |
uint16_t | val |
uint16_t | max |
Increment administration object with 'none' value default.
Once operator ++ is called, this->val will never be equal to 0 again.
Lollipop will roll over after max value.
uint8_t max = 10; Lollipop l(max); Lollipop r(max);
if r.max != l.max, false is returned. if r.val and l.val are in range [1,..max], the expression l < r is true iff. r.val is in the range [(l.val+1)max, ..., (l.val+max/2) max]
else, if l.val == 0, l<r is true else, if r.val == 0, l<r is false.
E.g.
Warning: max == 0, 1 and 255 don't work as expected.
|
inline |
|
inline |
|
default |
|
inlinestatic |
Returns true when current value is newer than previous value.
This is always false when currentValue is 0. This is true when previousValue is 0.
|
inlinestatic |
Return the next value given the current value.
Rolls over at maxValue and skips 0.
|
inline |
|
inline |
|
inline |
|
private |
|
private |