Skip to content

Commit

Permalink
fix NTP update bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthas committed Jun 18, 2022
1 parent ab4e047 commit 08d0771
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 38 deletions.
1 change: 0 additions & 1 deletion Clockface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ void Clockface::externalEvent(int type) {
mario.jump();
updateTime();
}

}

void Clockface::updateTime() {
Expand Down
2 changes: 1 addition & 1 deletion DateTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ void DateTime::begin()
Serial.println(tz);

this->ntp = new NTPClient(udp, tz * 3600);
setTime(ntp->getEpochTime());

ntp->begin();
ntp->forceUpdate();
setTime(ntp->getEpochTime());
}

void DateTime::update()
Expand Down
36 changes: 0 additions & 36 deletions mariobros-clock.ino
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>

#include "Clockface.h"
#include "WiFiConnect.h"
#include "DateTime.h"


#define EEPROM_SIZE 512

MatrixPanel_I2S_DMA *dma_display = nullptr;
Expand All @@ -16,12 +14,7 @@ uint16_t myBLACK = dma_display->color565(0, 0, 0);
uint16_t myWHITE = dma_display->color565(255, 255, 255);
uint16_t myBLUE = dma_display->color565(0, 0, 255);


const int touchThreshold = 40;
byte displayBright = 32;
bool touch8detected = false;
bool touch9detected = false;
unsigned long touchLastMillis = 0;

void displaySetup() {
HUB75_I2S_CFG mxconfig(
Expand All @@ -41,22 +34,6 @@ void displaySetup() {
dma_display->fillScreen(myBLACK);
}


void gotTouch8(){
touch8detected = (millis() - touchLastMillis > 1000);
}

void gotTouch9(){
touch9detected = (millis() - touchLastMillis > 1000);
}

void changeDisplayBright() {
displayBright += 32;
dma_display->setBrightness8(displayBright);
Serial.print("Bright set to ");
Serial.println(displayBright);
}

void setup() {

Serial.begin(115200);
Expand All @@ -78,22 +55,9 @@ void setup() {
dateTime.begin();

clockface->setup(&dateTime);

touchAttachInterrupt(T8, gotTouch8, touchThreshold);
touchAttachInterrupt(T9, gotTouch9, touchThreshold);
}

void loop() {
clockface->update();

if (touch8detected) {
touch8detected = false;
changeDisplayBright();
touchLastMillis = millis();
}
if (touch9detected) {
touch9detected = false;
clockface->externalEvent(0);
touchLastMillis = millis();
}
}

0 comments on commit 08d0771

Please sign in to comment.