Compare commits

...

3 Commits

Author SHA1 Message Date
Paul Warren 5fdd4285e7 Extra lines and old code removed 2022-12-06 22:50:14 +11:00
Paul Warren 4b93757d38 ArduionJson 6 bits 2022-12-06 22:50:14 +11:00
Paul Warren a8a28f0af2 Newer build options 2022-12-06 22:50:14 +11:00
2 changed files with 40 additions and 38 deletions

View File

@ -2,14 +2,21 @@
opt=$1
case $opt in
-u) arduino --upload -v --port /dev/ttyUSB0 --board esp8266:esp8266:d1:baud=460800,ip=lm6f esp_time.ino
-u) arduino --upload -v --port /dev/ttyUSB0 --board esp8266:esp8266:d1_mini:baud=460800,ip=lm6f esp_time.ino
;;
*) arduino --verify -v --board esp8266:esp8266:d1:baud=460800,ip=lm6f esp_time.ino
*) arduino --verify -v --board esp8266:esp8266:d1_mini:baud=460800,ip=lm6f esp_time.ino
;;
esac
#arduino-builder -compile -logger=machine -hardware /usr/share/arduino/hardware -hardware /home/pwarren/.arduino15/packages -tools /usr/share/arduino/hardware/tools/avr -tools /home/pwarren/.arduino15/packages -libraries /home/pwarren/Arduino/libraries -
#fqbn=esp8266:esp8266:d1_mini:xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=3232,non32xfer=fast,eesz=4M2M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=921600
#-ide-version=10813 -build-path /tmp/arduino_build_776166 -warnings=all -build-cache /tmp/arduino_cache_36351 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.mkspiffs.path=/home/pwarren/.arduino15/packages/esp8266/tools/mkspiffs/3.0.4-gcc10.3-1757bed -prefs=runtime.tools.mkspiffs-3.0.4-gcc10.3-1757bed.path=/home/pwarren/.arduino15/packages/esp8266/tools/mkspiffs/3.0.4-gcc10.3-1757bed -prefs=runtime.tools.xtensa-lx106-elf-gcc.path=/home/pwarren/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed -prefs=runtime.tools.xtensa-lx106-elf-gcc-3.0.4-gcc10.3-1757bed.path=/home/pwarren/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed -prefs=runtime.tools.mklittlefs.path=/home/pwarren/.arduino15/packages/esp8266/tools/mklittlefs/3.0.4-gcc10.3-1757bed -prefs=runtime.tools.mklittlefs-3.0.4-gcc10.3-1757bed.path=/home/pwarren/.arduino15/packages/esp8266/tools/mklittlefs/3.0.4-gcc10.3-1757bed -prefs=runtime.tools.python3.path=/home/pwarren/.arduino15/packages/esp8266/tools/python3/3.7.2-post1 -prefs=runtime.tools.python3-3.7.2-post1.path=/home/pwarren/.arduino15/packages/esp8266/tools/python3/3.7.2-post1 -verbose /home/pwarren/Projects/esp_time/esp_time.ino

View File

@ -46,7 +46,7 @@ WiFiUDP ntpUDP;
HTTPClient http;
NTPClient timeClient(ntpUDP, "pi.lan", 0, 60000); //use internal ntp server, update every 10 minutes, taking in to account the 9 seconds it takes to update the screen for the current time
//NTPClient timeClient(ntpUDP, "au.pool.ntp.org", 0, 60000); //use internal ntp server, update every 10 minutes
//NTPClient timeClient(ntpUDP, "au.pool.ntp.org", 0, 60000); //use external ntp server, update every 10 minutes
// defined in "credentials.h"
const char* ssid = ssid_name; // The SSID (name) of your Wi-Fi network
@ -250,72 +250,67 @@ void printDateTime(int update_epd)
void weatherUpdate(void) {
char buf[64];
const size_t capacity = 4*JSON_OBJECT_SIZE(3) + JSON_OBJECT_SIZE(4) + 150;
DynamicJsonBuffer jsonBuffer(capacity);
DynamicJsonDocument jsonBuffer(capacity);
http.begin(wfclient, ds_url);
int httpCode = http.GET();
if (httpCode > 0) {
JsonObject& root = jsonBuffer.parseObject(http.getString());
if (!root.success()) {
Serial.print(F("parseObject() failed: "));
auto error = deserializeJson(jsonBuffer, http.getString());
if (error) {
Serial.print("Failed to parse json");
return;
}
}
http.end();
JsonObject& today = root["today"];
const char* today_day = today["day"]; // "Wednesday"
const char* today_icon = today["icon"]; // "sunny.jpg"
const char* today_max = today["max"]; // "27"
JsonObject& tomorrow = root["tomorrow"];
const char* tomorrow_day = tomorrow["day"]; // "Thursday"
const char* tomorrow_icon = tomorrow["icon"]; // "sunny.jpg"
const char* tomorrow_max = tomorrow["max"]; // "31"
const char* today_day = jsonBuffer["today"]["day"]; // "Wednesday"
const char* today_icon = jsonBuffer["today"]["icon"]; // "sunny.jpg"
const char* today_max = jsonBuffer["today"]["max"]; // "27"
const char* tomorrow_day = jsonBuffer["tomorrow"]["day"]; // "Thursday"
const char* tomorrow_icon = jsonBuffer["tomorrow"]["icon"]; // "sunny.jpg"
const char* tomorrow_max = jsonBuffer["tomorrow"]["max"]; // "31"
const char* day_after_day = jsonBuffer["day_after"]["day"]; // "Friday"
const char* day_after_icon = jsonBuffer["day_after"]["icon"]; // "pcloud.jpg"
const char* day_after_max = jsonBuffer["day_after"]["max"]; // "33"
current_outside = jsonBuffer["current"]["outside"];
current_bedroom = jsonBuffer["current"]["bedroom"];
current_lounge = jsonBuffer["current"]["lounge"];
JsonObject& day_after = root["day_after"];
const char* day_after_day = day_after["day"]; // "Friday"
const char* day_after_icon = day_after["icon"]; // "pcloud.jpg"
const char* day_after_max = day_after["max"]; // "33"
JsonObject& current = root["current"];
current_outside = current["outside"];
current_bedroom = current["bedroom"];
current_lounge = current["lounge"];
Serial.println("Updating EPD with weather");
epd_set_en_font(ASCII64);
//Today
epd_disp_bitmap(today_icon, 0, 290);
epd_disp_string(today_day, 0, 536);
epd_disp_string(today_max, 75, 460);
//Tomorrow
epd_disp_bitmap(tomorrow_icon, 267, 290);
epd_disp_string(tomorrow_day, 260, 536);
epd_disp_string(tomorrow_max, 352, 460);
//Day After
epd_disp_bitmap(day_after_icon, 533, 290);
epd_disp_string(day_after_day, 533, 536);
epd_disp_string(day_after_max, 615, 460);
Serial.println("Adding Temps");
sprintf(buf, "E: %s I: %s",
current_outside,
current_lounge);
current_outside,
current_lounge);
Serial.println(buf);
epd_disp_string(buf, 500, 225);
} else {
Serial.print("Error on HTTP Request: ");
Serial.println(httpCode);
}
}
void loop() {