bugfix init e-paper

This commit is contained in:
harald42 2018-03-06 22:58:25 +01:00
parent 02177f65e1
commit 9d2f1715df
2 changed files with 46 additions and 12 deletions

View file

@ -32,7 +32,7 @@
#ifndef PROJECT_RPL_WEB_CONF_H_ #ifndef PROJECT_RPL_WEB_CONF_H_
#define PROJECT_RPL_WEB_CONF_H_ #define PROJECT_RPL_WEB_CONF_H_
#define LOOP_INTERVAL (30 * CLOCK_SECOND) #define LOOP_INTERVAL (1* CLOCK_SECOND)
/* For Debug: Dont allow MCU sleeping between channel checks */ /* For Debug: Dont allow MCU sleeping between channel checks */

View file

@ -34,6 +34,8 @@ unsigned char image[1024];
Paint paint(image, 0, 0); // width should be the multiple of 8 Paint paint(image, 0, 0); // width should be the multiple of 8
Epd epd; Epd epd;
long second=0;
void setup (void) void setup (void)
{ {
// switch off the led // switch off the led
@ -64,10 +66,12 @@ void setup (void)
* i.e. the next action of SetFrameMemory will set the other memory area * i.e. the next action of SetFrameMemory will set the other memory area
* therefore you have to clear the frame memory twice. * therefore you have to clear the frame memory twice.
*/ */
printf("1");
epd.ClearFrameMemory(0xFF); // bit set = white, bit reset = black epd.ClearFrameMemory(0xFF); // bit set = white, bit reset = black
epd.DisplayFrame(); epd.DisplayFrame();
epd.ClearFrameMemory(0xFF); // bit set = white, bit reset = black epd.ClearFrameMemory(0xFF); // bit set = white, bit reset = black
epd.DisplayFrame(); epd.DisplayFrame();
printf("2");
paint.SetRotate(ROTATE_0); paint.SetRotate(ROTATE_0);
paint.SetWidth(200); paint.SetWidth(200);
@ -78,10 +82,14 @@ void setup (void)
paint.DrawStringAt(30, 4, "Hello world!", &Font16, UNCOLORED); paint.DrawStringAt(30, 4, "Hello world!", &Font16, UNCOLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 10, paint.GetWidth(), paint.GetHeight()); epd.SetFrameMemory(paint.GetImage(), 0, 10, paint.GetWidth(), paint.GetHeight());
printf("3");
paint.Clear(UNCOLORED); paint.Clear(UNCOLORED);
paint.DrawStringAt(30, 4, "e-Paper Demo", &Font16, COLORED); paint.DrawStringAt(30, 4, "e-Paper Demo", &Font16, COLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 30, paint.GetWidth(), paint.GetHeight()); epd.SetFrameMemory(paint.GetImage(), 0, 30, paint.GetWidth(), paint.GetHeight());
printf("4");
paint.SetWidth(64); paint.SetWidth(64);
paint.SetHeight(64); paint.SetHeight(64);
@ -91,25 +99,25 @@ void setup (void)
paint.DrawLine(40, 0, 0, 50, COLORED); paint.DrawLine(40, 0, 0, 50, COLORED);
epd.SetFrameMemory(paint.GetImage(), 16, 60, paint.GetWidth(), paint.GetHeight()); epd.SetFrameMemory(paint.GetImage(), 16, 60, paint.GetWidth(), paint.GetHeight());
printf("5");
paint.Clear(UNCOLORED); paint.Clear(UNCOLORED);
paint.DrawCircle(32, 32, 30, COLORED); paint.DrawCircle(32, 32, 30, COLORED);
epd.SetFrameMemory(paint.GetImage(), 120, 60, paint.GetWidth(), paint.GetHeight()); epd.SetFrameMemory(paint.GetImage(), 120, 60, paint.GetWidth(), paint.GetHeight());
printf("6");
paint.Clear(UNCOLORED); paint.Clear(UNCOLORED);
paint.DrawFilledRectangle(0, 0, 40, 50, COLORED); paint.DrawFilledRectangle(0, 0, 40, 50, COLORED);
epd.SetFrameMemory(paint.GetImage(), 16, 130, paint.GetWidth(), paint.GetHeight()); epd.SetFrameMemory(paint.GetImage(), 16, 130, paint.GetWidth(), paint.GetHeight());
printf("7");
paint.Clear(UNCOLORED); paint.Clear(UNCOLORED);
paint.DrawFilledCircle(32, 32, 30, COLORED); paint.DrawFilledCircle(32, 32, 30, COLORED);
epd.SetFrameMemory(paint.GetImage(), 120, 130, paint.GetWidth(), paint.GetHeight()); epd.SetFrameMemory(paint.GetImage(), 120, 130, paint.GetWidth(), paint.GetHeight());
epd.DisplayFrame(); epd.DisplayFrame();
delay(2000); // delay(2000);
if (epd.Init(lut_partial_update) != 0) {
printf("e-Paper init failed");
return;
}
/** /**
* there are 2 memory areas embedded in the e-paper display * there are 2 memory areas embedded in the e-paper display
@ -117,14 +125,40 @@ void setup (void)
* i.e. the next action of SetFrameMemory will set the other memory area * i.e. the next action of SetFrameMemory will set the other memory area
* therefore you have to set the frame memory and refresh the display twice. * therefore you have to set the frame memory and refresh the display twice.
*/ */
epd.SetFrameMemory(IMAGE_DATA); // epd.SetFrameMemory(IMAGE_DATA);
epd.DisplayFrame(); // epd.DisplayFrame();
epd.SetFrameMemory(IMAGE_DATA); // epd.SetFrameMemory(IMAGE_DATA);
epd.DisplayFrame(); // epd.DisplayFrame();
} }
void loop (void) void loop (void)
{ {
char time_string[] = {'0', '0', ':', '0', '0', '\0'};
second ++;
if (second == 2) {
if (epd.Init(lut_partial_update) != 0) {
printf("e-Paper init failed");
return;
}
epd.SetFrameMemory(IMAGE_DATA);
epd.DisplayFrame();
epd.SetFrameMemory(IMAGE_DATA);
epd.DisplayFrame();
printf("init end\n");
}
time_string[0] = second / 60 / 10 + '0';
time_string[1] = second / 60 % 10 + '0';
time_string[3] = second % 60 / 10 + '0';
time_string[4] = second % 60 % 10 + '0';
paint.SetWidth(32);
paint.SetHeight(96);
paint.SetRotate(ROTATE_270);
paint.Clear(UNCOLORED);
paint.DrawStringAt(0, 4, time_string, &Font24, COLORED);
epd.SetFrameMemory(paint.GetImage(), 80, 72, paint.GetWidth(), paint.GetHeight());
epd.DisplayFrame();
printf("%d ",second);
} }