Browse Source

more work, add secrets.h, use NTP

main
Julia Luna 11 months ago
parent
commit
d7e11e464c
Signed by: julia GPG Key ID: 6A0C04FA9A7D7582
  1. 35
      src/Watchy_Julia.cpp
  2. 11
      src/Watchy_Julia.h
  3. 10
      src/secrets.h

35
src/Watchy_Julia.cpp

@ -9,17 +9,23 @@ bool DARK = SIMPLE_DARKMODE;
#define BG (DARK ? GxEPD_BLACK : GxEPD_WHITE)
#define FG (DARK ? GxEPD_WHITE : GxEPD_BLACK)
#if NTP_ENABLE
RTC_DATA_ATTR int NTPSyncCounter = NTP_SYNC_INTERVAL;
#endif
WatchyJulia::WatchyJulia() = default;
void WatchyJulia::drawWatchFace() {
if (ADAPTIVE_DARKMODE) {
setAdaptiveDarkmode();
}
preDraw();
#if ADAPTIVE_DARKMODE
setAdaptiveDarkmode();
#endif
display.fillScreen(BG);
display.setTextColor(FG);
drawStatusBar();
drawTime();
drawDate();
postDraw();
}
void WatchyJulia::drawTime() {
@ -123,3 +129,26 @@ int16_t WatchyJulia::drawSBIcon(const icon &i, int16_t x, bool reverseSpace) {
void WatchyJulia::setAdaptiveDarkmode() {
DARK = (6 >= currentTime.Hour && 21 <= currentTime.Hour);
}
void WatchyJulia::preDraw() {
connectWiFi();
#if NTP_ENABLE
if (NTPSyncCounter >= NTP_SYNC_INTERVAL) {
if (WIFI_CONFIGURED) {
configTzTime(TIME_ZONE, NTP_SERVER);
struct tm timeinfo;
getLocalTime(&timeinfo);
time_t t = mktime(&timeinfo);
RTC.set(t);
NTPSyncCounter = 0;
}
} else {
NTPSyncCounter++;
}
#endif
}
void WatchyJulia::postDraw() {
}

11
src/Watchy_Julia.h

@ -9,6 +9,7 @@
#include "icons.h"
#include <Fonts/FreeSans18pt7b.h>
#include <Fonts/FreeSans12pt7b.h>
#include "secrets.h"
#define ADAPTIVE_DARKMODE true
#define SIMPLE_DARKMODE true // doesn't matter if ADAPTIVE_DARKMODE is true
@ -25,9 +26,14 @@
#define BATTERY_THRESHOLD_1 3.8
#define GOTIFY_SERVER_URL "https://push.julia.network"
#define GOTIFY_CLIENT_TOKEN "CBd************"
#define GOTIFY_CLIENT_TOKEN SECRET_GOTIFY_TOKEN
#define GOTIFY_PRIORITY_APP_ID 10
#define NTP_ENABLE true
#define NTP_SYNC_INTERVAL 30 // minutes
#define NTP_SERVER "pool.ntp.org"
#define TIME_ZONE "Europe/Berlin"
class WatchyJulia : public Watchy {
public:
WatchyJulia();
@ -36,6 +42,9 @@ public:
void drawDate();
void drawStatusBar();
void preDraw();
void postDraw();
// void getNotifs();
private:
int16_t drawBattery(int16_t x, bool reverseSpace);

10
src/secrets.h

@ -0,0 +1,10 @@
//
// Created by julia on 13.06.21.
//
#ifndef PAIN_SECRETS_H
#define PAIN_SECRETS_H
#define SECRET_GOTIFY_TOKEN ""
#endif //PAIN_SECRETS_H
Loading…
Cancel
Save