Did some arithmetic to have the clock segments consistent
This commit is contained in:
parent
4b1b5620be
commit
d16613cb5d
|
@ -1 +1,4 @@
|
||||||
.vscode
|
debug.cfg
|
||||||
|
debug_custom.json
|
||||||
|
esp32.svd
|
||||||
|
.vscode/
|
||||||
|
|
15
README.md
15
README.md
|
@ -49,6 +49,21 @@ A happy setup will cycle through each color once,
|
||||||
and then display orange for a while.
|
and then display orange for a while.
|
||||||
|
|
||||||
|
|
||||||
|
Clock
|
||||||
|
-----
|
||||||
|
|
||||||
|
At night,
|
||||||
|
and sometimes during the day,
|
||||||
|
it displays something like a clock.
|
||||||
|
You will need to tell it your time zone.
|
||||||
|
It doesn't do daylight saving time, sorry.
|
||||||
|
I suggest you set it to standard time and pretend it's in sync with the sun.
|
||||||
|
|
||||||
|
* Each pixel in the top row is 1 hour (3600 seconds)
|
||||||
|
* Each pixel in the middle row is 5 minutes (300 seconds)
|
||||||
|
* Each pixel in the bottom row is 25 seconds
|
||||||
|
* There are four pixels around the bottom that move every 5 seconds
|
||||||
|
|
||||||
Philosophy
|
Philosophy
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
|
33
wallart.ino
33
wallart.ino
|
@ -250,15 +250,28 @@ void displayTime(unsigned long duration = 20 * SECOND) {
|
||||||
while (millis() < end) {
|
while (millis() < end) {
|
||||||
timeClient.update();
|
timeClient.update();
|
||||||
int hh = timeClient.getHours();
|
int hh = timeClient.getHours();
|
||||||
int mm = timeClient.getMinutes();
|
int mmss = timeClient.getMinutes()*60 + timeClient.getSeconds();
|
||||||
int ss = timeClient.getSeconds();
|
|
||||||
uint8_t hue = HUE_YELLOW;
|
uint8_t hue = HUE_YELLOW;
|
||||||
|
|
||||||
|
// Top: Hours
|
||||||
if (hh >= 12) {
|
if (hh >= 12) {
|
||||||
hue = HUE_ORANGE;
|
hue = HUE_ORANGE;
|
||||||
hh -= 12;
|
hh -= 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Middle: 5m (300s)
|
||||||
|
uint8_t mm = (mmss/300) % 12;
|
||||||
|
|
||||||
|
// Bottom: 25s
|
||||||
|
uint8_t ss = (mmss/25) % 12;
|
||||||
|
|
||||||
|
// Outer: 5s
|
||||||
|
uint8_t s = (mmss/5) % 5;
|
||||||
|
grid[64 - 7 - 1] = CHSV(HUE_PURPLE, 64, (s==1)?64:0);
|
||||||
|
grid[64 - 15 - 1] = CHSV(HUE_PURPLE, 64, (s==2)?64:0);
|
||||||
|
grid[64 - 8 - 1] = CHSV(HUE_PURPLE, 64, (s==3)?64:0);
|
||||||
|
grid[64 - 0 - 1] = CHSV(HUE_PURPLE, 64, (s==4)?64:0);
|
||||||
|
|
||||||
for (int i = 0; i < 12; i++) {
|
for (int i = 0; i < 12; i++) {
|
||||||
// Omit first and last position on a row
|
// Omit first and last position on a row
|
||||||
int pos = i + 1;
|
int pos = i + 1;
|
||||||
|
@ -267,8 +280,8 @@ void displayTime(unsigned long duration = 20 * SECOND) {
|
||||||
}
|
}
|
||||||
|
|
||||||
grid[pos + 0] = CHSV(hue, 255, (i<hh)?128:48);
|
grid[pos + 0] = CHSV(hue, 255, (i<hh)?128:48);
|
||||||
grid[pos + 24] = CHSV(HUE_RED, 255, (i<mm/5)?128:48);
|
grid[pos + 24] = CHSV(HUE_RED, 255, (i<mm)?128:48);
|
||||||
grid[pos + 48] = CHSV(HUE_PINK, 128, (i<ss/5)?96:48);
|
grid[pos + 48] = CHSV(HUE_PINK, 128, (i<ss)?96:48);
|
||||||
}
|
}
|
||||||
FastLED.show();
|
FastLED.show();
|
||||||
|
|
||||||
|
@ -298,11 +311,15 @@ void loop() {
|
||||||
}
|
}
|
||||||
FastLED.setBrightness(day?DAY_BRIGHTNESS:NIGHT_BRIGHTNESS);
|
FastLED.setBrightness(day?DAY_BRIGHTNESS:NIGHT_BRIGHTNESS);
|
||||||
|
|
||||||
|
// If we don't yet have net art, try a little harder to get it.
|
||||||
if ((NetArtFrames == 0) || !conn) {
|
if ((NetArtFrames == 0) || !conn) {
|
||||||
getprob = 16;
|
getprob = 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p.Pick(getprob)) {
|
if (!day || p.Pick(4)) {
|
||||||
|
// At night, only ever show the clock
|
||||||
|
displayTime(2 * MINUTE);
|
||||||
|
} else if (p.Pick(getprob)) {
|
||||||
netget();
|
netget();
|
||||||
} else if (day && p.Pick(4)) {
|
} else if (day && p.Pick(4)) {
|
||||||
// These can be hella bright
|
// These can be hella bright
|
||||||
|
@ -324,7 +341,5 @@ void loop() {
|
||||||
cm5(8);
|
cm5(8);
|
||||||
} else if (p.Pick(2)) {
|
} else if (p.Pick(2)) {
|
||||||
cm5(16);
|
cm5(16);
|
||||||
} else if (p.Pick(4)) {
|
}
|
||||||
displayTime(1 * MINUTE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue