From 9d2f1715dff671ad83fa9cd2ad986e7ca3fc850a Mon Sep 17 00:00:00 2001 From: harald42 Date: Tue, 6 Mar 2018 22:58:25 +0100 Subject: [PATCH] bugfix init e-paper --- examples/osd/arduino-epaper15/project-conf.h | 2 +- examples/osd/arduino-epaper15/sketch.pde | 56 ++++++++++++++++---- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/examples/osd/arduino-epaper15/project-conf.h b/examples/osd/arduino-epaper15/project-conf.h index 9fd0bd36f..b28e6237f 100644 --- a/examples/osd/arduino-epaper15/project-conf.h +++ b/examples/osd/arduino-epaper15/project-conf.h @@ -32,7 +32,7 @@ #ifndef 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 */ diff --git a/examples/osd/arduino-epaper15/sketch.pde b/examples/osd/arduino-epaper15/sketch.pde index 0e3e401e3..e335ba8bc 100644 --- a/examples/osd/arduino-epaper15/sketch.pde +++ b/examples/osd/arduino-epaper15/sketch.pde @@ -34,6 +34,8 @@ unsigned char image[1024]; Paint paint(image, 0, 0); // width should be the multiple of 8 Epd epd; +long second=0; + void setup (void) { // switch off the led @@ -64,10 +66,12 @@ void setup (void) * i.e. the next action of SetFrameMemory will set the other memory area * therefore you have to clear the frame memory twice. */ + printf("1"); epd.ClearFrameMemory(0xFF); // bit set = white, bit reset = black epd.DisplayFrame(); epd.ClearFrameMemory(0xFF); // bit set = white, bit reset = black epd.DisplayFrame(); + printf("2"); paint.SetRotate(ROTATE_0); paint.SetWidth(200); @@ -77,11 +81,15 @@ void setup (void) paint.Clear(COLORED); paint.DrawStringAt(30, 4, "Hello world!", &Font16, UNCOLORED); epd.SetFrameMemory(paint.GetImage(), 0, 10, paint.GetWidth(), paint.GetHeight()); - + + printf("3"); + paint.Clear(UNCOLORED); paint.DrawStringAt(30, 4, "e-Paper Demo", &Font16, COLORED); epd.SetFrameMemory(paint.GetImage(), 0, 30, paint.GetWidth(), paint.GetHeight()); + + printf("4"); paint.SetWidth(64); paint.SetHeight(64); @@ -91,25 +99,25 @@ void setup (void) paint.DrawLine(40, 0, 0, 50, COLORED); epd.SetFrameMemory(paint.GetImage(), 16, 60, paint.GetWidth(), paint.GetHeight()); + printf("5"); paint.Clear(UNCOLORED); paint.DrawCircle(32, 32, 30, COLORED); epd.SetFrameMemory(paint.GetImage(), 120, 60, paint.GetWidth(), paint.GetHeight()); + printf("6"); paint.Clear(UNCOLORED); paint.DrawFilledRectangle(0, 0, 40, 50, COLORED); epd.SetFrameMemory(paint.GetImage(), 16, 130, paint.GetWidth(), paint.GetHeight()); + printf("7"); paint.Clear(UNCOLORED); paint.DrawFilledCircle(32, 32, 30, COLORED); epd.SetFrameMemory(paint.GetImage(), 120, 130, paint.GetWidth(), paint.GetHeight()); 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 @@ -117,14 +125,40 @@ void setup (void) * 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. */ - epd.SetFrameMemory(IMAGE_DATA); - epd.DisplayFrame(); - epd.SetFrameMemory(IMAGE_DATA); - epd.DisplayFrame(); +// epd.SetFrameMemory(IMAGE_DATA); +// epd.DisplayFrame(); +// epd.SetFrameMemory(IMAGE_DATA); +// epd.DisplayFrame(); } 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); }