4
4
// include library, include base class, make path known
5
5
#include < GxEPD.h>
6
6
#include < GxGDEW029T5/GxGDEW029T5.h> // 2.9" b/w IL0373
7
+ #include < Fonts/FreeMonoBold9pt7b.h>
7
8
8
9
#include < GxIO/GxIO_SPI/GxIO_SPI.h>
9
10
#include < GxIO/GxIO.h>
@@ -37,10 +38,12 @@ DHT dht(DHTPIN, DHTTYPE);
37
38
38
39
const uint32_t getWeatherInfoPeriod = 10 * 60 * 1000 ;
39
40
const uint32_t getCurrentTempPeriod = 1 * 60 * 1000 ;
41
+ const uint32_t writeCurrentTempPeriod = 5 * 60 * 1000 ;
40
42
41
43
struct {
42
44
uint64_t getWeatherInfoJpeg;
43
45
uint64_t getCurrentTemp;
46
+ uint64_t writeCurrentTemp;
44
47
} lastExecDate;
45
48
46
49
@@ -50,6 +53,8 @@ void setup()
50
53
Serial.println ();
51
54
Serial.println (" setup" );
52
55
display.init (74880 ); // enable diagnostic output on Serial
56
+ display.setFont (&FreeMonoBold9pt7b);
57
+ display.setTextColor (GxEPD_BLACK);
53
58
54
59
WiFi.begin (SECRET_SSID, SECRET_SSID_PASSWORD);
55
60
@@ -89,13 +94,22 @@ void loop()
89
94
Serial.println (" getWeatherInfoJpeg()" );
90
95
getWeatherInfoJpeg ();
91
96
lastExecDate.getWeatherInfoJpeg = now;
97
+ Serial.println (" writeCurrentTemp()" );
98
+ writeCurrentTemp ();
99
+ lastExecDate.writeCurrentTemp = now;
92
100
}
93
101
if (lastExecDate.getCurrentTemp == 0 || now - lastExecDate.getCurrentTemp > getCurrentTempPeriod)
94
102
{
95
103
Serial.println (" getCurrentTemp()" );
96
104
getCurrentTemp ();
97
105
lastExecDate.getCurrentTemp = now;
98
106
}
107
+ if (lastExecDate.writeCurrentTemp == 0 || now - lastExecDate.writeCurrentTemp > writeCurrentTempPeriod)
108
+ {
109
+ Serial.println (" writeCurrentTemp()" );
110
+ writeCurrentTemp ();
111
+ lastExecDate.writeCurrentTemp = now;
112
+ }
99
113
}
100
114
101
115
void getWeatherInfoJpeg (){
@@ -139,4 +153,22 @@ void getCurrentTemp()
139
153
ambient.set (1 , t);
140
154
ambient.set (2 , h);
141
155
ambient.send ();
142
- }
156
+ }
157
+
158
+ void writeCurrentTemp () {
159
+ int posX = 180 ;
160
+ int posY = 124 ;
161
+ int boxW = 100 ;
162
+ int boxH = 20 ;
163
+
164
+ float t = dht.readTemperature ();
165
+ float h = dht.readHumidity ();
166
+ Serial.printf (" temp:%.1f, humi:%.1f\n " , t, h);
167
+
168
+ display.setRotation (3 );
169
+ display.setCursor (posX, posY);
170
+ display.fillRect (posX, posY - boxH , boxW, boxH + 2 , GxEPD_WHITE);
171
+ display.printf (" %.1fC/%.0f%%" , t, h);
172
+ display.updateWindow (posX, posY - boxH, boxW, boxH + 2 , true );
173
+ display.powerDown ();
174
+ }
0 commit comments