2012-07-28 09:21:37 +02:00
|
|
|
/*
|
|
|
|
* Blinks the status LED.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
/**
|
2013-12-17 20:48:07 +01:00
|
|
|
* Blinks the status LEDs. Scans out the bit pattern LSB to MSB and
|
2012-07-28 09:21:37 +02:00
|
|
|
* stops when there's one set bit remaining. Use to set the period.
|
|
|
|
* New values take affect after reload.
|
|
|
|
*/
|
2013-12-27 21:35:37 +01:00
|
|
|
class Blinker {
|
|
|
|
public:
|
2012-07-28 09:21:37 +02:00
|
|
|
Blinker();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the pattern. Starts at next reload. Restarts on
|
|
|
|
* hitting the highest set bit.
|
|
|
|
*
|
|
|
|
* Examples:
|
|
|
|
* 0b101: on, off
|
|
|
|
* 0b1000001: on, off for five
|
|
|
|
* 0b1000101: on, off, on, off for three
|
|
|
|
*/
|
2013-12-27 21:35:37 +01:00
|
|
|
void set(uint8_t red, uint8_t green) {
|
|
|
|
red_reload_ = red;
|
|
|
|
green_reload_ = green;
|
|
|
|
}
|
2012-07-28 09:21:37 +02:00
|
|
|
|
|
|
|
/** Called on a periodic 100 ms timer. */
|
|
|
|
void tick();
|
|
|
|
|
2013-12-27 21:35:37 +01:00
|
|
|
private:
|
2013-12-17 20:48:07 +01:00
|
|
|
void update(bool red_on, bool green_on);
|
2012-07-28 09:21:37 +02:00
|
|
|
|
2013-12-17 20:48:07 +01:00
|
|
|
uint8_t red_;
|
|
|
|
uint8_t red_reload_;
|
|
|
|
uint8_t green_;
|
|
|
|
uint8_t green_reload_;
|
2012-07-28 09:21:37 +02:00
|
|
|
};
|