2021-03-06 22:06:09 +01:00
|
|
|
//
|
|
|
|
// Created by lukas on 06.03.21.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef LEDSTRIPINTERFACE_CLOCK_H
|
|
|
|
#define LEDSTRIPINTERFACE_CLOCK_H
|
|
|
|
|
2021-03-17 16:57:54 +00:00
|
|
|
#include "Arduino.h"
|
2021-03-06 22:06:09 +01:00
|
|
|
#include <Ticker.h>
|
|
|
|
#include "Adafruit_NeoPixel.h"
|
|
|
|
#include "Arduino.h"
|
2021-03-06 23:42:48 +01:00
|
|
|
#include "LoadAnimator.h"
|
2021-03-06 22:06:09 +01:00
|
|
|
|
2021-03-17 16:57:54 +00:00
|
|
|
// define the strip length of the wordclock
|
|
|
|
#define NUMPIXELS 108
|
|
|
|
// define the esp pin the stip is attached to
|
|
|
|
#define STRIPPIN D5
|
2021-03-06 22:06:09 +01:00
|
|
|
|
|
|
|
class Clock {
|
|
|
|
private:
|
|
|
|
Adafruit_NeoPixel strip{};
|
2021-03-06 23:42:48 +01:00
|
|
|
LoadAnimator animator;
|
2021-03-17 16:57:54 +00:00
|
|
|
Ticker refreshTicker;
|
|
|
|
|
|
|
|
bool twentyAfterSyntax;
|
|
|
|
bool clockAlwaysOn;
|
2021-03-06 22:06:09 +01:00
|
|
|
|
2021-03-17 16:57:54 +00:00
|
|
|
/**
|
|
|
|
* display the words which are always on (Es ist...)
|
|
|
|
*/
|
|
|
|
void paintAlwaysOnLeds();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* paint a specific word
|
|
|
|
* @param word word pointer to print
|
|
|
|
* @param color the color in which to print it
|
|
|
|
*/
|
2021-03-07 17:45:03 +01:00
|
|
|
void printWord(const std::vector<uint8_t>& word, uint32_t color);
|
2021-03-06 22:06:09 +01:00
|
|
|
|
2021-03-17 16:57:54 +00:00
|
|
|
/**
|
|
|
|
* logic to print the correct minute word and its corresponding wods
|
|
|
|
* @param minuteSelector a number between 0 - 11 representing the minute in 5min distances
|
|
|
|
* @param twentyAfterSyntax whether to use a twenty after syntax or a 10min before half syntax
|
|
|
|
*/
|
|
|
|
void printMinutes(uint8_t minuteSelector, bool twentyAfterSyntax);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* set the whole time of the clock
|
|
|
|
* @param hour hour to set (0-24)
|
|
|
|
* @param minute minute to set(0-59)
|
|
|
|
* @param twentyAfterSyntax whether to use a twenty after syntax or a 10min before half syntax
|
|
|
|
* @param alwaysClockWord print the UHR word always and not only on full hours
|
|
|
|
*/
|
|
|
|
void setTime(uint8_t hour, uint8_t minute, bool twentyAfterSyntax = false, bool alwaysClockWord = false);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* load the current time and set it onto the clock
|
|
|
|
*/
|
2021-03-07 17:45:03 +01:00
|
|
|
void refreshTime();
|
|
|
|
|
2021-03-06 22:06:09 +01:00
|
|
|
public:
|
|
|
|
Clock();
|
2021-03-07 19:41:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* initialize the strip and wordclock functions
|
|
|
|
*/
|
2021-03-06 22:06:09 +01:00
|
|
|
void init();
|
2021-03-07 19:41:56 +01:00
|
|
|
|
|
|
|
/**
|
2021-03-17 16:57:54 +00:00
|
|
|
* turn off the wordclock
|
2021-03-07 19:41:56 +01:00
|
|
|
*/
|
2021-03-07 17:45:03 +01:00
|
|
|
void turnOff();
|
2021-03-07 19:41:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* turn on the wordclock
|
|
|
|
*/
|
2021-03-07 17:45:03 +01:00
|
|
|
void turnOn();
|
2021-03-06 22:06:09 +01:00
|
|
|
|
2021-03-17 16:57:54 +00:00
|
|
|
void useTwentyAfterSyntax(bool twentyAFterSyntax);
|
|
|
|
void useAlwaysOnUhrSyntax(bool alwaysOnUhr);
|
|
|
|
|
|
|
|
void update();
|
2021-03-06 22:06:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // LEDSTRIPINTERFACE_CLOCK_H
|