Skip to content

Commit 11ca885

Browse files
committed
window management
1 parent 9f7883e commit 11ca885

File tree

3 files changed

+16
-72
lines changed

3 files changed

+16
-72
lines changed

example/wsePaperV2.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ bool demoSineWave(int frameCount, long long start, Image image) {
113113
sprintf(message, "%d-fps", lastFPS);
114114
image.drawText(maxX - (17 * strlen(message)) - 1, minY + 1, message, &Font24, BLACK, WHITE);
115115

116-
d1.showImage(image,DEGREE_270);
116+
d1.showImage(image, DEGREE_270);
117117

118118
return ((now - start) < 8000);
119119
}
@@ -178,13 +178,13 @@ void display1Demo() {
178178

179179
chart.drawPieSlice(296*3/4,64, 48, d, d+45, WHITE, SOLID,1);
180180
chart.drawRectangle(296/2-12,64, 296/2+12,64+12, BLACK, NONE, SOLID,1);
181-
d1.showImagePartial(chart, DEGREE_90);
181+
d1.showImage(chart, DEGREE_90);
182182

183183
chart.drawPieSlice(296*3/4,64, 48, d, d+45, BLACK, SOLID,1);
184184
chart.drawText(296/2-12,64+6, drg, &Font12, BLACK, WHITE);
185185
chart.drawText(296*3/4+12,64, drg, &Font12, BLACK, WHITE);
186186

187-
d1.showImagePartial(chart, DEGREE_90);
187+
d1.showImage(chart, DEGREE_90);
188188
}
189189

190190
long long start = currentTimeMillis();

src/displays/DisplayWS_ePaper_v2.cpp

Lines changed: 10 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,22 @@ namespace udd {
160160
}
161161

162162

163+
163164
void addBit(int bit, _byte* byte, int val) {
164165
if (val>0) {
165166
(*byte) = (*byte) | (val << (7-bit));
166167
}
167168
}
168169

170+
void DisplayWS_ePaper_v2::showImage(Image& image) {
171+
Display::showImage(image);
172+
}
173+
174+
void DisplayWS_ePaper_v2::showImage(Image& image, Rotation rotation) {
175+
Display::showImage(image, rotation);
176+
}
177+
178+
169179
void DisplayWS_ePaper_v2::showImage(Image &image, Point p1, Point p2, Rotation rotation) {
170180

171181
fprintf(stderr, "ePaper showImage(%d,%d)\n", config.width, config.height);
@@ -254,73 +264,6 @@ namespace udd {
254264

255265

256266

257-
void DisplayWS_ePaper_v2::showImagePartial(Image image, Rotation rotation) {
258-
screenLock.lock();
259-
openSPI();
260-
digitalWrite(config.DC, 1);
261-
digitalWrite(config.CS, 0);
262-
263-
int width = config.width + config.xOffset;
264-
int height = config.height + config.yOffset;
265-
266-
267-
setPartReg();
268-
writeCommand(0x91); // set partial
269-
270-
271-
writeCommand(0x90); //resolution setting
272-
writeData(0); //x-start
273-
writeData(config.width - 1); //x-end
274-
275-
writeData(0);
276-
writeData(0); //y-start
277-
writeData(config.height / 256);
278-
writeData(config.height % 256 - 1); //y-end
279-
writeData(0x28);
280-
281-
// writeCommand(0x11); // swap images
282-
283-
writeCommand(0x10);
284-
285-
for (int y = 0; y < height; y++) {
286-
int bits = 0;
287-
_byte out = 0;
288-
for (int x = 0; x < width; ++x) {
289-
ColorType* ct = image.getPixel(x - config.xOffset, y - config.yOffset, rotation);
290-
int val=1;
291-
if (ct != NULL) {
292-
if (WHITE.equals(ct)) {
293-
val=1;
294-
}
295-
else if (BLACK.equals(ct)) {
296-
val=0;
297-
}
298-
else if (RED.equals(ct)) {
299-
val=1;
300-
} else {
301-
fprintf(stderr, "invalid color found at (%d,%d)\n", x, y);
302-
}
303-
}
304-
if (++bits % 8 == 0) {
305-
writeData(out);
306-
out=0;
307-
}
308-
addBit(bits%8, &out, val);
309-
}
310-
if (width%8 != 0) {
311-
writeData(out);
312-
}
313-
}
314-
315-
316-
317-
318-
enableDisplay();
319-
320-
digitalWrite(config.CS, 1);
321-
screenLock.unlock();
322-
}
323-
324267

325268

326269

src/displays/DisplayWS_ePaper_v2.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ namespace udd {
1717
void reset() override;
1818
void readBusy() override;
1919
void clearScreen(Color color) override;
20-
void showImage(Image& image, Point p1, Point p2, Rotation rotation);
21-
void showImagePartial(Image image, Rotation rotation);
20+
void showImage(Image& image) override;
21+
void showImage(Image& image, Rotation rotation) override;
22+
void showImage(Image& image, Point p1, Point p2, Rotation rotation) override;
2223
void EPD_SetFullReg();
2324
void setPartReg();
2425
void enableDisplay();

0 commit comments

Comments
 (0)