Skip to content

Commit

Permalink
Error in compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
crossplatformdev committed Aug 18, 2024
1 parent cc7bbac commit fe8ce84
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 58 deletions.
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
94 changes: 48 additions & 46 deletions src/TimezonesGMT.h
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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
Expand All @@ -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
17 changes: 9 additions & 8 deletions src/Watchy.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Watchy.h"
#include "TimezonesGMT.h"

#ifdef ARDUINO_ESP32S3_DEV
Watchy32KRTC Watchy::RTC;
Expand Down Expand Up @@ -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;



Expand Down Expand Up @@ -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;
Expand All @@ -582,15 +583,15 @@ 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;
}
}


gmt = OFFSETS_SEC[tzIndex] / 3600;
gmt = TimezonesGMT::OFFSETS_SEC[TimezonesGMT::tzIndex] / 3600;
gmtOffset = gmt * 3600;

display.fillScreen(GxEPD_BLACK);
Expand Down Expand Up @@ -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);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/Watchy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/Watchy32KRTC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit fe8ce84

Please sign in to comment.