Fully move to new NTP thingy
This commit is contained in:
parent
dc0e6d8bf4
commit
3c35b5b204
13
README.md
13
README.md
|
@ -97,17 +97,8 @@ it displays something like a clock.
|
||||||
* There are four pixels around the bottom that move every 5 seconds
|
* There are four pixels around the bottom that move every 5 seconds
|
||||||
|
|
||||||
|
|
||||||
Update
|
Updating Firmware
|
||||||
------
|
-----------------
|
||||||
|
|
||||||
You can upload a new version of the firmware.
|
|
||||||
Reset the device,
|
|
||||||
and select the "Update" button instead of configuring WiFi.
|
|
||||||
Then you can upload the new .bin firmware file.
|
|
||||||
|
|
||||||
You may have to reconfigure networking after this.
|
|
||||||
|
|
||||||
### Uploading from CLI
|
|
||||||
|
|
||||||
python3 esptool.py --chip esp32 --port "/dev/ttyUSB0" --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x1000 wallart.ino.bootloader.bin 0x8000 wallart.ino.partitions.bin 0xe000 boot_app0.bin 0x10000 wallart.ino.bin
|
python3 esptool.py --chip esp32 --port "/dev/ttyUSB0" --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x1000 wallart.ino.bootloader.bin 0x8000 wallart.ino.partitions.bin 0xe000 boot_app0.bin 0x10000 wallart.ino.bin
|
||||||
|
|
||||||
|
|
11
network.cpp
11
network.cpp
|
@ -2,6 +2,7 @@
|
||||||
#include <WiFiManager.h>
|
#include <WiFiManager.h>
|
||||||
#include <WiFiManagerTz.h>
|
#include <WiFiManagerTz.h>
|
||||||
#include <esp_wifi.h>
|
#include <esp_wifi.h>
|
||||||
|
#include <esp_sntp.h>
|
||||||
#include <HTTPClient.h>
|
#include <HTTPClient.h>
|
||||||
#include <WiFiClientSecure.h>
|
#include <WiFiClientSecure.h>
|
||||||
#include "network.h"
|
#include "network.h"
|
||||||
|
@ -13,11 +14,17 @@ void network_reset() {
|
||||||
wfm.resetSettings();
|
wfm.resetSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_time_available(struct timeval *t)
|
|
||||||
{
|
bool time_was_accurate_once = false;
|
||||||
|
bool clock_is_set() {
|
||||||
|
return time_was_accurate_once;
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_time_available(struct timeval *t) {
|
||||||
struct tm timeInfo;
|
struct tm timeInfo;
|
||||||
getLocalTime(&timeInfo, 1000);
|
getLocalTime(&timeInfo, 1000);
|
||||||
Serial.println(&timeInfo, "%A, %B %d %Y %H:%M:%S %Z %z ");
|
Serial.println(&timeInfo, "%A, %B %d %Y %H:%M:%S %Z %z ");
|
||||||
|
time_was_accurate_once = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void network_setup(char *password) {
|
void network_setup(char *password) {
|
||||||
|
|
|
@ -8,3 +8,4 @@ void network_setup(char *password);
|
||||||
bool connected();
|
bool connected();
|
||||||
void pause(uint32_t dwMs);
|
void pause(uint32_t dwMs);
|
||||||
void netget(int count);
|
void netget(int count);
|
||||||
|
bool clock_is_set();
|
||||||
|
|
17
timezones.h
17
timezones.h
|
@ -1,17 +0,0 @@
|
||||||
#include <Timezone.h>
|
|
||||||
|
|
||||||
TimeChangeRule usEDT = {"EDT", Second, Sun, Mar, 2, -240};
|
|
||||||
TimeChangeRule usEST = {"EST", First, Sun, Nov, 2, -300};
|
|
||||||
Timezone TZ_US_Eastern(usEDT, usEST);
|
|
||||||
|
|
||||||
TimeChangeRule usCDT = {"CDT", Second, Sun, Mar, 2, -300};
|
|
||||||
TimeChangeRule usCST = {"CST", First, Sun, Nov, 2, -360};
|
|
||||||
Timezone TZ_US_Central(usCDT, usCST);
|
|
||||||
|
|
||||||
TimeChangeRule usMDT = {"MDT", Second, Sun, Mar, 2, -360};
|
|
||||||
TimeChangeRule usMST = {"MST", First, Sun, Nov, 2, -420};
|
|
||||||
Timezone TZ_US_Mountain(usMDT, usMST);
|
|
||||||
|
|
||||||
TimeChangeRule usPDT = {"EDT", Second, Sun, Mar, 2, -420};
|
|
||||||
TimeChangeRule usPST = {"EST", First, Sun, Nov, 2, -480};
|
|
||||||
Timezone TZ_US_Pacific(usPDT, usPST);
|
|
36
wallart.ino
36
wallart.ino
|
@ -10,7 +10,6 @@
|
||||||
#define NEOPIXEL_PIN 32
|
#define NEOPIXEL_PIN 32
|
||||||
#define GRIDLEN 64
|
#define GRIDLEN 64
|
||||||
#define WFM_PASSWORD "artsy fartsy"
|
#define WFM_PASSWORD "artsy fartsy"
|
||||||
#define TIMEZONE TZ_US_Eastern
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The hours when the day begins and ends.
|
* The hours when the day begins and ends.
|
||||||
|
@ -274,18 +273,22 @@ void spinner(int count=32) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void displayTime(unsigned long duration = 20 * SECOND) {
|
void displayTime(unsigned long duration = 20*SECOND) {
|
||||||
if (timeStatus() != timeSet) return;
|
if (!clock_is_set()) return;
|
||||||
unsigned long end = millis() + duration;
|
unsigned long end = millis() + duration;
|
||||||
|
|
||||||
FastLED.clear();
|
FastLED.clear();
|
||||||
|
|
||||||
while (millis() < end) {
|
while (millis() < end) {
|
||||||
int hh = hour();
|
struct tm info;
|
||||||
int mmss = now() % 3600;
|
getLocalTime(&info);
|
||||||
|
|
||||||
|
int hh = info.tm_hour;
|
||||||
|
int mmss = (info.tm_min * 60) + info.tm_sec;
|
||||||
uint8_t hue = HUE_YELLOW;
|
uint8_t hue = HUE_YELLOW;
|
||||||
|
|
||||||
// Top: Hours
|
// Top: Hours
|
||||||
if (isPM()) {
|
if (hh >= 12) {
|
||||||
hue = HUE_ORANGE;
|
hue = HUE_ORANGE;
|
||||||
hh -= 12;
|
hh -= 12;
|
||||||
}
|
}
|
||||||
|
@ -298,10 +301,10 @@ void displayTime(unsigned long duration = 20 * SECOND) {
|
||||||
|
|
||||||
// Outer: 5s
|
// Outer: 5s
|
||||||
uint8_t s = (mmss/5) % 5;
|
uint8_t s = (mmss/5) % 5;
|
||||||
grid[64 - 7 - 1] = CHSV(HUE_PURPLE, 128, (s==1)?96:0);
|
grid[64 - 7 - 1] = CHSV(HUE_GREEN, 128, (s==1)?96:0);
|
||||||
grid[64 - 15 - 1] = CHSV(HUE_PURPLE, 128, (s==2)?96:0);
|
grid[64 - 15 - 1] = CHSV(HUE_GREEN, 128, (s==2)?96:0);
|
||||||
grid[64 - 8 - 1] = CHSV(HUE_PURPLE, 128, (s==3)?96:0);
|
grid[64 - 8 - 1] = CHSV(HUE_GREEN, 128, (s==3)?96:0);
|
||||||
grid[64 - 0 - 1] = CHSV(HUE_PURPLE, 128, (s==4)?96:0);
|
grid[64 - 0 - 1] = CHSV(HUE_GREEN, 128, (s==4)?96: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
|
||||||
|
@ -339,11 +342,11 @@ void loop() {
|
||||||
uint8_t getprob = 4;
|
uint8_t getprob = 4;
|
||||||
bool conn = connected();
|
bool conn = connected();
|
||||||
bool day = true;
|
bool day = true;
|
||||||
timeStatus_t ts = timeStatus();
|
|
||||||
|
|
||||||
if (ts == timeSet) {
|
if (clock_is_set()) {
|
||||||
int hh = hour();
|
struct tm info;
|
||||||
day = ((hh >= DAY_BEGIN) && (hh < DAY_END));
|
getLocalTime(&info);
|
||||||
|
day = ((info.tm_hour >= DAY_BEGIN) && (info.tm_hour < DAY_END));
|
||||||
}
|
}
|
||||||
FastLED.setBrightness(day?DAY_BRIGHTNESS:NIGHT_BRIGHTNESS);
|
FastLED.setBrightness(day?DAY_BRIGHTNESS:NIGHT_BRIGHTNESS);
|
||||||
|
|
||||||
|
@ -352,8 +355,9 @@ void loop() {
|
||||||
getprob = 16;
|
getprob = 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ts == timeSet) && (!day || p.Pick(4))) {
|
if (!day && clock_is_set()) {
|
||||||
// At night, only ever show the clock
|
displayTime();
|
||||||
|
} else if (p.Pick(4) && clock_is_set()) {
|
||||||
displayTime(2 * MINUTE);
|
displayTime(2 * MINUTE);
|
||||||
} else if (p.Pick(getprob)) {
|
} else if (p.Pick(getprob)) {
|
||||||
netget();
|
netget();
|
||||||
|
|
Loading…
Reference in New Issue