22
33#include " ../../MeshCore.h"
44
5- EInkDetectionResult E213Display::detectEInk ()
5+ BaseDisplay* E213Display::detectEInk ()
66{
77 // Test 1: Logic of BUSY pin
88
@@ -23,38 +23,37 @@ EInkDetectionResult E213Display::detectEInk()
2323 // Test complete. Release pin
2424 pinMode (DISP_RST, INPUT);
2525
26- if (busyLogic == LOW)
27- return V_LCMEN213EFC1;
28- else // busy HIGH
29- return V_E0213A367;
26+ if (busyLogic == LOW) {
27+ #ifdef VISION_MASTER_E213
28+ return new EInkDisplay_VisionMasterE213 ;
29+ #else
30+ return new EInkDisplay_WirelessPaperV1_1 ;
31+ #endif
32+ } else {// busy HIGH
33+ #ifdef VISION_MASTER_E213
34+ return new EInkDisplay_VisionMasterE213V1_1 ;
35+ #else
36+ return new EInkDisplay_WirelessPaperV1_1_1 ;
37+ #endif
38+ }
3039}
3140
32-
3341bool E213Display::begin () {
3442 if (_init) return true ;
3543
3644 powerOn ();
37- _version = detectEInk ();
38- if (_version==V_LCMEN213EFC1) {
39- display.begin ();
40- // Set to landscape mode rotated 180 degrees
41- display.setRotation (3 );
42- } else {
43- display1.begin ();
44- // Set to landscape mode rotated 180 degrees
45- display1.setRotation (3 );
45+ if (display==NULL ) {
46+ display = detectEInk ();
4647 }
47-
48+ display->begin ();
49+ // Set to landscape mode rotated 180 degrees
50+ display->setRotation (3 );
4851
4952 _init = true ;
5053 _isOn = true ;
5154
5255 clear ();
53- if (_version==V_LCMEN213EFC1) {
54- display.fastmodeOn (); // Enable fast mode for quicker (partial) updates
55- } else {
56- display1.fastmodeOn (); // Enable fast mode for quicker (partial) updates
57- }
56+ display->fastmodeOn (); // Enable fast mode for quicker (partial) updates
5857
5958 return true ;
6059}
@@ -93,73 +92,43 @@ void E213Display::turnOff() {
9392}
9493
9594void E213Display::clear () {
96- if (_version==V_LCMEN213EFC1) {
97- display.clear ();
98- } else {
99- display1.clear ();
100- }
95+ display->clear ();
96+
10197}
10298
10399void E213Display::startFrame (Color bkg) {
104100 // Fill screen with white first to ensure clean background
105- if (_version==V_LCMEN213EFC1) {
106- display.fillRect (0 , 0 , width (), height (), WHITE);
107- } else {
108- display1.fillRect (0 , 0 , width (), height (), WHITE);
109- }
101+ display->fillRect (0 , 0 , width (), height (), WHITE);
102+
110103 if (bkg == LIGHT) {
111104 // Fill with black if light background requested (inverted for e-ink)
112- if (_version==V_LCMEN213EFC1) {
113- display.fillRect (0 , 0 , width (), height (), BLACK);
114- } else {
115- display1.fillRect (0 , 0 , width (), height (), BLACK);
116- }
105+ display->fillRect (0 , 0 , width (), height (), BLACK);
117106 }
118107}
119108
120109void E213Display::setTextSize (int sz) {
121110 // The library handles text size internally
122- if (_version==V_LCMEN213EFC1) {
123- display.setTextSize (sz);
124- } else {
125- display1.setTextSize (sz);
126- }
111+ display->setTextSize (sz);
127112}
128113
129114void E213Display::setColor (Color c) {
130115 // implemented in individual display methods
131116}
132117
133118void E213Display::setCursor (int x, int y) {
134- if (_version==V_LCMEN213EFC1) {
135- display.setCursor (x, y);
136- } else {
137- display1.setCursor (x, y);
138- }
119+ display->setCursor (x, y);
139120}
140121
141122void E213Display::print (const char *str) {
142- if (_version==V_LCMEN213EFC1) {
143- display.print (str);
144- } else {
145- display1.print (str);
146- }
123+ display->print (str);
147124}
148125
149126void E213Display::fillRect (int x, int y, int w, int h) {
150- if (_version==V_LCMEN213EFC1) {
151- display.fillRect (x, y, w, h, BLACK);
152- } else {
153- display1.fillRect (x, y, w, h, BLACK);
154- }
127+ display->fillRect (x, y, w, h, BLACK);
155128}
156129
157130void E213Display::drawRect (int x, int y, int w, int h) {
158- if (_version==V_LCMEN213EFC1) {
159- display.drawRect (x, y, w, h, BLACK);
160- } else {
161- display1.drawRect (x, y, w, h, BLACK);
162- }
131+ display->drawRect (x, y, w, h, BLACK);
163132}
164133
165134void E213Display::drawXbm (int x, int y, const uint8_t *bits, int w, int h) {
@@ -177,11 +146,7 @@ void E213Display::drawXbm(int x, int y, const uint8_t *bits, int w, int h) {
177146
178147 // If the bit is set, draw the pixel
179148 if (bitSet) {
180- if (_version==V_LCMEN213EFC1) {
181- display.drawPixel (x + bx, y + by, BLACK);
182- } else {
183- display1.drawPixel (x + bx, y + by, BLACK);
184- }
149+ display->drawPixel (x + bx, y + by, BLACK);
185150 }
186151 }
187152 }
@@ -190,18 +155,10 @@ void E213Display::drawXbm(int x, int y, const uint8_t *bits, int w, int h) {
190155uint16_t E213Display::getTextWidth (const char *str) {
191156 int16_t x1, y1;
192157 uint16_t w, h;
193- if (_version==V_LCMEN213EFC1) {
194- display.getTextBounds (str, 0 , 0 , &x1, &y1, &w, &h);
195- } else {
196- display1.getTextBounds (str, 0 , 0 , &x1, &y1, &w, &h);
197- }
158+ display->getTextBounds (str, 0 , 0 , &x1, &y1, &w, &h);
198159 return w;
199160}
200161
201162void E213Display::endFrame () {
202- if (_version==V_LCMEN213EFC1) {
203- display.update ();
204- } else {
205- display1.update ();
206- }
163+ display->update ();
207164}
0 commit comments