From 6982b07a1040ed8798f24b6924d15d82e03563d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?El=C3=ADas=20A=2E=20Angulo=20Klein?= Date: Sun, 18 Aug 2024 06:51:09 +0200 Subject: [PATCH] Error in compilation --- platformio.ini | 2 +- src/TimezonesGMT.h | 94 ++++++++++++++++++++++---------------------- src/Watchy.cpp | 17 ++++---- src/Watchy.h | 1 - src/Watchy32KRTC.cpp | 4 +- 5 files changed, 60 insertions(+), 58 deletions(-) diff --git a/platformio.ini b/platformio.ini index a3b174b5..d0373176 100644 --- a/platformio.ini +++ b/platformio.ini @@ -43,7 +43,7 @@ lib_deps = ; This is for v3 extends = env:base board = esp32-s3-devkitc-1 -build_flags = -DARDUINO_ESP32S3_DEV +build_flags = -DARDUINO_ESP32S3_DEV -Wunused-variable [env:v2_0] ; This is for v3 diff --git a/src/TimezonesGMT.h b/src/TimezonesGMT.h index 1493deac..7a673ca0 100644 --- a/src/TimezonesGMT.h +++ b/src/TimezonesGMT.h @@ -1,5 +1,5 @@ -#ifndef TIMEZONES_GMT_H -#define TIMEZONES_GMT_H +#ifndef TIMEZONESGMT_H +#define TIMEZONESGMT_H // This file is used to set up GMT based timezones. @@ -10,6 +10,8 @@ // Visit the link below. +namespace TimezonesGMT { + #ifndef TIMEZONES_NON_GMT_OVERRIDE #define TIMEZONES_NON_GMT_OVERRIDE 0 // 0: GMT, 1: Location timezone. #endif @@ -20,53 +22,53 @@ #define TIMEZONES_LENGTH 28 -typedef struct TZ { - const char* location; - const char* timezone; -} TZ; - + typedef struct TZ { + const char* location; + const char* timezone; + } TZ; -// https://raw.githubusercontent.com/nayarsystems/posix_tz_db/master/zones.csv -static TZ tz_override = { - "Europe/Madrid", - "CET-1CEST,M3.5.0,M10.5.0/3" -}; + // https://raw.githubusercontent.com/nayarsystems/posix_tz_db/master/zones.csv + static TZ tz_override = { + "Europe/Madrid", + "CET-1CEST,M3.5.0,M10.5.0/3" + }; -static TZ timeZones[] = { - {"Etc/GMT+0","GMT0"}, // 0 - {"Etc/GMT+1","<-01>1"}, // 1 - {"Etc/GMT+2","<-02>2"}, // 2 - {"Etc/GMT+3","<-03>3"}, // 3 - {"Etc/GMT+4","<-04>4"}, // 4 - {"Etc/GMT+5","<-05>5"}, // 5 - {"Etc/GMT+6","<-06>6"}, // 6 - {"Etc/GMT+7","<-07>7"}, // 7 - {"Etc/GMT+8","<-08>8"}, // 8 - {"Etc/GMT+9","<-09>9"}, // 9 - {"Etc/GMT+10","<-10>10"}, // 10 - {"Etc/GMT+11","<-11>11"}, // 11 - {"Etc/GMT+12","<-12>12"}, // 12 - {"Etc/GMT-0","GMT0"}, // 13 - {"Etc/GMT-1","<+01>-1"}, // 14 - {"Etc/GMT-2","<+02>-2"}, // 15 - {"Etc/GMT-3","<+03>-3"}, // 16 - {"Etc/GMT-4","<+04>-4"}, // 17 - {"Etc/GMT-5","<+05>-5"}, // 18 - {"Etc/GMT-6","<+06>-6"}, // 19 - {"Etc/GMT-7","<+07>-7"}, // 20 - {"Etc/GMT-8","<+08>-8"}, // 21 - {"Etc/GMT-9","<+09>-9"}, // 22 - {"Etc/GMT-10","<+10>-10"}, // 23 - {"Etc/GMT-11","<+11>-11"}, // 24 - {"Etc/GMT-12","<+12>-12"}, // 25 - {"Etc/GMT-13","<+13>-13"}, // 26 - {"Etc/GMT-14","<+14>-14"}, // 27 -}; + static TZ timeZones[TIMEZONES_LENGTH] = { + {"Etc/GMT+0","GMT0"}, // 0 + {"Etc/GMT+1","<-01>1"}, // 1 + {"Etc/GMT+2","<-02>2"}, // 2 + {"Etc/GMT+3","<-03>3"}, // 3 + {"Etc/GMT+4","<-04>4"}, // 4 + {"Etc/GMT+5","<-05>5"}, // 5 + {"Etc/GMT+6","<-06>6"}, // 6 + {"Etc/GMT+7","<-07>7"}, // 7 + {"Etc/GMT+8","<-08>8"}, // 8 + {"Etc/GMT+9","<-09>9"}, // 9 + {"Etc/GMT+10","<-10>10"}, // 10 + {"Etc/GMT+11","<-11>11"}, // 11 + {"Etc/GMT+12","<-12>12"}, // 12 + {"Etc/GMT-0","GMT0"}, // 13 + {"Etc/GMT-1","<+01>-1"}, // 14 + {"Etc/GMT-2","<+02>-2"}, // 15 + {"Etc/GMT-3","<+03>-3"}, // 16 + {"Etc/GMT-4","<+04>-4"}, // 17 + {"Etc/GMT-5","<+05>-5"}, // 18 + {"Etc/GMT-6","<+06>-6"}, // 19 + {"Etc/GMT-7","<+07>-7"}, // 20 + {"Etc/GMT-8","<+08>-8"}, // 21 + {"Etc/GMT-9","<+09>-9"}, // 22 + {"Etc/GMT-10","<+10>-10"}, // 23 + {"Etc/GMT-11","<+11>-11"}, // 24 + {"Etc/GMT-12","<+12>-12"}, // 25 + {"Etc/GMT-13","<+13>-13"}, // 26 + {"Etc/GMT-14","<+14>-14"}, // 27 + }; -static long OFFSETS_SEC[] = { - 0, 3600, 7200, 10800, 14400, 18000, 21600, 25200, 28800, 32400, 36000, 39600, 43200, 0, -3600, -7200, -10800, -14400, -18000, -21600, -25200, -28800, -32400, -36000, -39600, -43200, -46800, -50400 -}; + static long OFFSETS_SEC[TIMEZONES_LENGTH] = { + 0, 3600, 7200, 10800, 14400, 18000, 21600, 25200, 28800, 32400, 36000, 39600, 43200, 0, -3600, -7200, -10800, -14400, -18000, -21600, -25200, -28800, -32400, -36000, -39600, -43200, -46800, -50400 + }; -static int8_t tzIndex = TIMEZONES_SELECTED; + static int8_t tzIndex = TIMEZONES_SELECTED; +} #endif //TIMEZONES_GMT_H \ No newline at end of file diff --git a/src/Watchy.cpp b/src/Watchy.cpp index 83fc2cda..c0f29907 100644 --- a/src/Watchy.cpp +++ b/src/Watchy.cpp @@ -1,4 +1,5 @@ #include "Watchy.h" +#include "TimezonesGMT.h" #ifdef ARDUINO_ESP32S3_DEV Watchy32KRTC Watchy::RTC; @@ -506,7 +507,7 @@ void Watchy::setTime() { int8_t year = tmYearToY2k(currentTime.Year); #endif // gmt variable defaults to TIMEZONES_SELECTED if defined - int8_t gmt = OFFSETS_SEC[tzIndex] / 3600; + int8_t gmt = TimezonesGMT::OFFSETS_SEC[TimezonesGMT::tzIndex] / 3600; @@ -556,7 +557,7 @@ void Watchy::setTime() { day == 31 ? (day = 1) : day++; break; case SET_TZ: - tzIndex == TIMEZONES_LENGTH - 1 ? (tzIndex = 0) : tzIndex++; + TimezonesGMT::tzIndex == TIMEZONES_LENGTH - 1 ? (TimezonesGMT::tzIndex = 0) : TimezonesGMT::tzIndex++; break; default: break; @@ -582,7 +583,7 @@ void Watchy::setTime() { day == 1 ? (day = 31) : day--; break; case SET_TZ: - tzIndex == 0 ? (tzIndex = TIMEZONES_LENGTH - 1) : tzIndex--; + TimezonesGMT::tzIndex == 0 ? (TimezonesGMT::tzIndex = TIMEZONES_LENGTH - 1) : TimezonesGMT::tzIndex--; break; default: break; @@ -590,7 +591,7 @@ void Watchy::setTime() { } - gmt = OFFSETS_SEC[tzIndex] / 3600; + gmt = TimezonesGMT::OFFSETS_SEC[TimezonesGMT::tzIndex] / 3600; gmtOffset = gmt * 3600; display.fillScreen(GxEPD_BLACK); @@ -676,12 +677,12 @@ void Watchy::setTime() { tm.Second = 0; if(TIMEZONES_NON_GMT_OVERRIDE == 0){ - setenv("TZ", timeZones[tzIndex].timezone, 1); + setenv("TZ", TimezonesGMT::timeZones[TimezonesGMT::tzIndex].timezone, 1); } else{ if (TIMEZONES_NON_GMT_OVERRIDE == 1){ - setenv("TZ", tz_override.timezone, 1); - }else { - setenv("TZ", timeZones[TIMEZONES_SELECTED].timezone, 1); + setenv("TZ", TimezonesGMT::tz_override.timezone, 1); + } else { + setenv("TZ", TimezonesGMT::timeZones[TIMEZONES_SELECTED].timezone, 1); } } diff --git a/src/Watchy.h b/src/Watchy.h index d3f55ddc..95dc9a89 100644 --- a/src/Watchy.h +++ b/src/Watchy.h @@ -16,7 +16,6 @@ #include "bma.h" #include "config.h" #include "esp_chip_info.h" -#include "TimezonesGMT.h" #include "MoonPhase.h" #ifdef ARDUINO_ESP32S3_DEV #include "Watchy32KRTC.h" diff --git a/src/Watchy32KRTC.cpp b/src/Watchy32KRTC.cpp index d332b6ec..bce36079 100644 --- a/src/Watchy32KRTC.cpp +++ b/src/Watchy32KRTC.cpp @@ -5,9 +5,9 @@ Watchy32KRTC::Watchy32KRTC(){} void Watchy32KRTC::init() { if(TIMEZONES_NON_GMT_OVERRIDE == 0){ - setenv("TZ", timeZones[TIMEZONES_SELECTED].timezone, 1); + setenv("TZ", TimezonesGMT::timeZones[TIMEZONES_SELECTED].timezone, 1); } else if (TIMEZONES_NON_GMT_OVERRIDE == 1) { - setenv("TZ", tz_override.timezone, 1); + setenv("TZ", TimezonesGMT::tz_override.timezone, 1); } else { setenv("TZ", "GMT0", 1); }