Skip to content

Commit 64b7640

Browse files
mtavenrathdAjaY85
andcommitted
Add support for Waveshare 1.54" ePaper
BREAKING CHANGE: The display type id for the Waveshare 1.54" ePaper changed from 5 to 6. Co-authored-by: dAjaY85 <[email protected]>
1 parent 21ec72f commit 64b7640

20 files changed

+2057
-46
lines changed

docs/DeviceProfiles/opendtu_fusion.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,5 +186,47 @@
186186
"data": 2,
187187
"clk": 1
188188
}
189+
},
190+
{
191+
"name": "OpenDTU Fusion v2 with CMT2300A, NRF24 and ePaper Display",
192+
"nrf24": {
193+
"miso": 48,
194+
"mosi": 35,
195+
"clk": 36,
196+
"irq": 47,
197+
"en": 38,
198+
"cs": 37
199+
},
200+
"cmt": {
201+
"clk": 6,
202+
"cs": 4,
203+
"fcs": 21,
204+
"sdio": 5,
205+
"gpio2": 3,
206+
"gpio3": 8
207+
},
208+
"eth": {
209+
"enabled": false,
210+
"phy_addr": -1,
211+
"power": -1,
212+
"mdc": -1,
213+
"mdio": -1,
214+
"type": 0,
215+
"clk_mode": 0
216+
},
217+
"led": {
218+
"led0": 17,
219+
"led1": 18
220+
},
221+
"display": {
222+
"type": 6,
223+
"data": 9,
224+
"clk": 10,
225+
"cs": 11,
226+
"reset": 13,
227+
"busy": 14,
228+
"dc": 12
229+
}
230+
189231
}
190232
]

include/Configuration.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ struct CONFIG_T {
144144
uint8_t Rotation;
145145
uint8_t Contrast;
146146
uint8_t Language;
147+
uint16_t UpdatePeriod;
147148
struct {
148149
uint32_t Duration;
149150
uint8_t Mode;

include/Datastore.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ class DatastoreClass {
5757
// True if all enabled inverters are reachable
5858
bool getIsAllEnabledReachable();
5959

60+
// Sum of all Producing Inverters
61+
uint8_t getTotalProducing();
62+
6063
private:
6164
void loop();
6265

@@ -80,6 +83,7 @@ class DatastoreClass {
8083
bool _isAllEnabledProducing = false;
8184
bool _isAllEnabledReachable = false;
8285
bool _isAtLeastOnePollEnabled = false;
86+
uint8_t _isProducing = false;
8387
};
8488

8589
extern DatastoreClass Datastore;

include/Display.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
#pragma once
3+
4+
#include "defaults.h"
5+
#include <Arduino.h>
6+
#include <TaskSchedulerDeclarations.h>
7+
8+
enum DisplayType_t {
9+
None,
10+
PCD8544,
11+
SSD1306,
12+
SH1106,
13+
SSD1309,
14+
ST7567_GM12864I_59N,
15+
ePaper154,
16+
DisplayType_Max,
17+
};
18+
19+
enum DiagramMode_t {
20+
Off,
21+
Small,
22+
Fullscreen,
23+
DisplayMode_Max,
24+
};
25+
26+
class DisplayClass {
27+
public:
28+
void init(Scheduler& scheduler, DisplayType_t _type, uint8_t _data, uint8_t _clk, uint8_t _cs, uint8_t _reset, uint8_t _busy, uint8_t _dc);
29+
30+
void setContrast(uint8_t contrast);
31+
void setStatus(bool turnOn);
32+
void setOrientation(uint8_t rotation = DISPLAY_ROTATION);
33+
void setLanguage(uint8_t language);
34+
void setUpdatePeriod(uint16_t updatePeriod);
35+
void setEnablePowerSafe(bool display_PowerSafe);
36+
void setEnableScreensaver(bool display_ScreenSaver);
37+
void setDiagramMode(DiagramMode_t mode);
38+
void setStartupDisplay();
39+
void DiagramUpdatePeriod();
40+
41+
private:
42+
bool _displayTurnedOn;
43+
44+
DisplayType_t _display_type = DisplayType_t::None;
45+
uint32_t _lastDisplayUpdate = 0;
46+
uint16_t _counterEPaper;
47+
uint16_t _settedUpdatePeriod = 10000; // Achtung, max 65535
48+
};
49+
50+
extern DisplayClass Display;

include/Display_Graphic.h

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22
#pragma once
33

4+
#include "Display.h"
45
#include "Display_Graphic_Diagram.h"
56
#include "defaults.h"
67
#include <TaskSchedulerDeclarations.h>
@@ -14,23 +15,6 @@
1415
#define CHART_POSX 80
1516
#define CHART_POSY 0
1617

17-
enum DisplayType_t {
18-
None,
19-
PCD8544,
20-
SSD1306,
21-
SH1106,
22-
SSD1309,
23-
ST7567_GM12864I_59N,
24-
DisplayType_Max,
25-
};
26-
27-
enum DiagramMode_t {
28-
Off,
29-
Small,
30-
Fullscreen,
31-
DisplayMode_Max,
32-
};
33-
3418
class DisplayGraphicClass {
3519
public:
3620
DisplayGraphicClass();
@@ -75,4 +59,4 @@ class DisplayGraphicClass {
7559
uint8_t _lineOffsets[5];
7660
};
7761

78-
extern DisplayGraphicClass Display;
62+
extern DisplayGraphicClass DisplayGraphic;

include/Display_ePaper.h

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
#pragma once
3+
4+
/// uncomment next line to use class GFX of library GFX_Root instead of Adafruit_GFX, to use less code and ram
5+
// #include <GFX.h>
6+
// base class GxEPD2_GFX can be used to pass references or pointers to the display instance as parameter, uses ~1.2k more code
7+
// enable GxEPD2_GFX base class
8+
#define ENABLE_GxEPD2_GFX 1
9+
10+
#include "Display.h"
11+
#include <GxEPD2_3C.h>
12+
#include <GxEPD2_BW.h>
13+
#include <SPI.h>
14+
#include <map>
15+
16+
// FreeFonts from Adafruit_GFX
17+
#include <Fonts/FreeSans12pt7b.h>
18+
#include <Fonts/FreeSans18pt7b.h>
19+
#include <Fonts/FreeSans24pt7b.h>
20+
#include <Fonts/FreeSans9pt7b.h>
21+
22+
#include "defaults.h"
23+
#include "imagedata.h"
24+
25+
// GDEW027C44 2.7 " b/w/r 176x264, IL91874
26+
// GDEH0154D67 1.54" b/w 200x200
27+
28+
class DisplayEPaperClass {
29+
public:
30+
DisplayEPaperClass();
31+
~DisplayEPaperClass();
32+
33+
void init(Scheduler& scheduler, DisplayType_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI);
34+
void loop();
35+
void fullRefresh();
36+
void setOrientation(uint8_t rotation);
37+
void setLanguage(uint8_t language);
38+
39+
private:
40+
void headlineIP();
41+
void actualPowerPaged(float _totalPower, float _totalYieldDay, float _totalYieldTotal, uint8_t _isprod);
42+
void lastUpdatePaged();
43+
44+
Task _loopTask;
45+
46+
const uint16_t _period = 10000;
47+
uint16_t _counterEPaper;
48+
49+
bool _changed = false;
50+
char _fmtText[35];
51+
String _settedIP;
52+
uint8_t _headfootline = 16;
53+
uint8_t _displayRotation = DISPLAY_ROTATION;
54+
uint8_t _display_language = DISPLAY_LANGUAGE;
55+
GxEPD2_GFX* _display;
56+
};
57+
58+
extern DisplayEPaperClass DisplayEPaper;

include/PinMapping.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ struct PinMapping_t {
3838
uint8_t display_clk;
3939
uint8_t display_cs;
4040
uint8_t display_reset;
41+
uint8_t display_busy; // for epaper
42+
uint8_t display_dc; // for epaper
4143
int8_t led[PINMAPPING_LED_COUNT];
4244
};
4345

include/defaults.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@
9999
#define DISPLAY_ROTATION 2U
100100
#define DISPLAY_CONTRAST 60U
101101
#define DISPLAY_LANGUAGE 0U
102+
#define DISPLAY_UPDATE 10000 // epaper
103+
102104
#define DISPLAY_DIAGRAM_DURATION (10UL * 60UL * 60UL)
103105
#define DISPLAY_DIAGRAM_MODE 1U
104106

include/imagedata.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
#pragma once
3+
4+
extern const unsigned char AhoyLogo[];
5+
extern const unsigned char OpenDTULogo[];
6+
extern const unsigned char myHoy[];
7+
extern const unsigned char mySigma[];
8+
extern const unsigned char mySun[];
9+
extern const unsigned char myToday[];
10+
extern const unsigned char myWR[];
11+
12+
extern const unsigned char gImage_1in54[];

0 commit comments

Comments
 (0)