added blinking dots
This commit is contained in:
@@ -87,6 +87,8 @@ void setup() {
|
|||||||
// ---------------------------
|
// ---------------------------
|
||||||
// LOOP
|
// LOOP
|
||||||
// ---------------------------
|
// ---------------------------
|
||||||
|
static bool colonOn = true;
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
static unsigned long lastUpdate = 0;
|
static unsigned long lastUpdate = 0;
|
||||||
static char lastTime[16] = "";
|
static char lastTime[16] = "";
|
||||||
@@ -95,6 +97,7 @@ void loop() {
|
|||||||
lastUpdate = millis();
|
lastUpdate = millis();
|
||||||
|
|
||||||
DateTime now = rtc.now();
|
DateTime now = rtc.now();
|
||||||
|
colonOn = !colonOn;
|
||||||
|
|
||||||
// Convert to 12-hour format
|
// Convert to 12-hour format
|
||||||
int hour12 = now.hour();
|
int hour12 = now.hour();
|
||||||
@@ -118,6 +121,24 @@ void loop() {
|
|||||||
Paint_DrawString_EN(15, 160, weekdaybuf, &Font24, BLACK, WHITE);
|
Paint_DrawString_EN(15, 160, weekdaybuf, &Font24, BLACK, WHITE);
|
||||||
Paint_DrawString_EN(15, 200, datebuf, &Font24, BLACK, WHITE);
|
Paint_DrawString_EN(15, 200, datebuf, &Font24, BLACK, WHITE);
|
||||||
|
|
||||||
|
int colonX = 10 + 2*(DIGIT_SIZE + 35);
|
||||||
|
int colonTopY = 50;
|
||||||
|
int colonBottomY = 100;
|
||||||
|
int colonW = 10;
|
||||||
|
int colonH = 10;
|
||||||
|
|
||||||
|
uint16_t colonColor = colonOn ? WHITE : BLACK;
|
||||||
|
|
||||||
|
// Top dot
|
||||||
|
Paint_DrawRectangle(colonX, colonTopY,
|
||||||
|
colonX + colonW, colonTopY + colonH,
|
||||||
|
colonColor, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
|
||||||
|
// Bottom dot
|
||||||
|
Paint_DrawRectangle(colonX, colonBottomY,
|
||||||
|
colonX + colonW, colonBottomY + colonH,
|
||||||
|
colonColor, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
|
||||||
// Only update digits that changed
|
// Only update digits that changed
|
||||||
if (strcmp(timebuf, lastTime) != 0) {
|
if (strcmp(timebuf, lastTime) != 0) {
|
||||||
|
|
||||||
@@ -148,15 +169,6 @@ void loop() {
|
|||||||
drawDigit(10 + size + 30, 20, size, h2, WHITE);
|
drawDigit(10 + size + 30, 20, size, h2, WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// COLON (always drawn)
|
|
||||||
Paint_DrawRectangle(10 + 2*(size + 35), 50,
|
|
||||||
10 + 2*(size + 35) + 10, 60,
|
|
||||||
WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
|
||||||
|
|
||||||
Paint_DrawRectangle(10 + 2*(size + 35), 100,
|
|
||||||
10 + 2*(size + 35) + 10, 110,
|
|
||||||
WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
|
||||||
|
|
||||||
// MIN tens
|
// MIN tens
|
||||||
if (lastTime[3] != timebuf[3]) {
|
if (lastTime[3] != timebuf[3]) {
|
||||||
drawDigit(10 + 2*(size + 30) + 30, 20, size, lastTime[3] - '0', BLACK);
|
drawDigit(10 + 2*(size + 30) + 30, 20, size, lastTime[3] - '0', BLACK);
|
||||||
|
|||||||
Reference in New Issue
Block a user