2019-05-29 13:44:54 +00:00
|
|
|
#ifndef sevenSegmentClock_h_included
|
|
|
|
#define sevenSegmentClock_h_included
|
|
|
|
|
|
|
|
#include <Adafruit_NeoPixel.h>
|
|
|
|
|
|
|
|
// avoid flickering of the display:
|
2019-06-03 14:54:56 +00:00
|
|
|
#define TIME_BETWEEN_DISPLAY_UPDATES_ms 100
|
|
|
|
#define BLINK_OFF_TIME_ms 200
|
|
|
|
#define BLINK_ON_TIME_ms 200
|
2019-05-29 13:44:54 +00:00
|
|
|
#define defaultLedDataPin 2
|
|
|
|
class SevenSegmentClock {
|
|
|
|
public:
|
|
|
|
SevenSegmentClock() { LedDataPin=defaultLedDataPin; init(); };
|
|
|
|
SevenSegmentClock(uint8_t dataPin) { LedDataPin=dataPin; init(); };
|
|
|
|
void begin(void);
|
|
|
|
void displayTime(int hour, int minute);
|
2019-05-30 19:30:49 +00:00
|
|
|
void displayUpdate(void);
|
2019-05-29 13:44:54 +00:00
|
|
|
//void setClockSpeed(int _msPerModelSecond) { msPerModelSecond = _msPerModelSecond; setClockSpeed("x"); };
|
2019-05-30 19:30:49 +00:00
|
|
|
enum BlinkMode { NoBlinking, ClockBlinking, SeperatorBlinking, DecimalPointBlinking };
|
|
|
|
void setBlinkMode(BlinkMode _blinkMode) { blinkMode = _blinkMode; };
|
2019-05-29 13:44:54 +00:00
|
|
|
void setClockHalted(bool halted) { clockHalted = halted; };
|
2019-06-04 18:41:41 +00:00
|
|
|
enum Color { Black, Red, Green, Blue, White };
|
|
|
|
void setColor(Color color);
|
|
|
|
Color getColor(void) { return currentColorHandle; };
|
2019-05-29 13:44:54 +00:00
|
|
|
static uint32_t red, green, blue, white, black;
|
|
|
|
enum ClockDisplayStatus { Off, Booting, Halted, StandardClock, FastClock };
|
|
|
|
void displayDigit(unsigned int digitNum, char c);
|
|
|
|
void displaySeperator(char seperatorCharacter);
|
2019-06-04 18:41:41 +00:00
|
|
|
void setBrightness(uint8_t b) { brightness=b; initColors(b); };
|
|
|
|
uint8_t getBrightness(void) { return brightness; };
|
2019-05-29 13:44:54 +00:00
|
|
|
private:
|
2019-06-04 18:41:41 +00:00
|
|
|
void init(void) { displayStatus = Off; clockHour=12; clockMinute=34; setClockHalted(true); currentColorHandle = Blue; currentColor = blue; };
|
2019-05-29 13:44:54 +00:00
|
|
|
static uint8_t LedDataPin;
|
|
|
|
static Adafruit_NeoPixel *strip;
|
2019-05-30 19:30:49 +00:00
|
|
|
static BlinkMode blinkMode;
|
2019-06-04 18:41:41 +00:00
|
|
|
static uint8_t brightness;
|
2019-05-29 13:44:54 +00:00
|
|
|
ClockDisplayStatus displayStatus;
|
|
|
|
int clockHour;
|
|
|
|
int clockMinute;
|
|
|
|
bool clockHalted;
|
2019-06-04 18:41:41 +00:00
|
|
|
Color currentColorHandle;
|
2019-05-29 13:44:54 +00:00
|
|
|
uint32_t currentColor;
|
|
|
|
void displaySegment(unsigned int ledAddress, uint32_t color);
|
2019-06-04 18:41:41 +00:00
|
|
|
void initColors(uint8_t _brightness);
|
2019-05-29 13:44:54 +00:00
|
|
|
};
|
|
|
|
#endif
|