Skip to content

Commit 08d0771

Browse files
committed
fix NTP update bug
1 parent ab4e047 commit 08d0771

File tree

3 files changed

+1
-38
lines changed

3 files changed

+1
-38
lines changed

Clockface.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ void Clockface::externalEvent(int type) {
7070
mario.jump();
7171
updateTime();
7272
}
73-
7473
}
7574

7675
void Clockface::updateTime() {

DateTime.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ void DateTime::begin()
1515
Serial.println(tz);
1616

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

2019
ntp->begin();
2120
ntp->forceUpdate();
21+
setTime(ntp->getEpochTime());
2222
}
2323

2424
void DateTime::update()

mariobros-clock.ino

-36
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
2-
32
#include "Clockface.h"
43
#include "WiFiConnect.h"
54
#include "DateTime.h"
65

7-
86
#define EEPROM_SIZE 512
97

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

19-
20-
const int touchThreshold = 40;
2117
byte displayBright = 32;
22-
bool touch8detected = false;
23-
bool touch9detected = false;
24-
unsigned long touchLastMillis = 0;
2518

2619
void displaySetup() {
2720
HUB75_I2S_CFG mxconfig(
@@ -41,22 +34,6 @@ void displaySetup() {
4134
dma_display->fillScreen(myBLACK);
4235
}
4336

44-
45-
void gotTouch8(){
46-
touch8detected = (millis() - touchLastMillis > 1000);
47-
}
48-
49-
void gotTouch9(){
50-
touch9detected = (millis() - touchLastMillis > 1000);
51-
}
52-
53-
void changeDisplayBright() {
54-
displayBright += 32;
55-
dma_display->setBrightness8(displayBright);
56-
Serial.print("Bright set to ");
57-
Serial.println(displayBright);
58-
}
59-
6037
void setup() {
6138

6239
Serial.begin(115200);
@@ -78,22 +55,9 @@ void setup() {
7855
dateTime.begin();
7956

8057
clockface->setup(&dateTime);
81-
82-
touchAttachInterrupt(T8, gotTouch8, touchThreshold);
83-
touchAttachInterrupt(T9, gotTouch9, touchThreshold);
8458
}
8559

8660
void loop() {
8761
clockface->update();
8862

89-
if (touch8detected) {
90-
touch8detected = false;
91-
changeDisplayBright();
92-
touchLastMillis = millis();
93-
}
94-
if (touch9detected) {
95-
touch9detected = false;
96-
clockface->externalEvent(0);
97-
touchLastMillis = millis();
98-
}
9963
}

0 commit comments

Comments
 (0)