From 3bb37dc83faa07ad0c1249a60e0a992a709974be Mon Sep 17 00:00:00 2001 From: Fisch Date: Wed, 8 Feb 2023 21:00:15 +0100 Subject: [PATCH] implement basic update by column function --- flipcontrol_esp32/include/image.h | 14 ++++++-- flipcontrol_esp32/src/image.cpp | 59 +++++++++++++++++++++++++++++++ flipcontrol_esp32/src/main.cpp | 23 ++++++++++++ 3 files changed, 94 insertions(+), 2 deletions(-) diff --git a/flipcontrol_esp32/include/image.h b/flipcontrol_esp32/include/image.h index fa15be9..8c1ac66 100644 --- a/flipcontrol_esp32/include/image.h +++ b/flipcontrol_esp32/include/image.h @@ -10,7 +10,7 @@ #define ROWS 16 -#define UPDATE_INTERVAL 5 +#define UPDATE_INTERVAL 5 //TODO: remove this class Image { @@ -18,11 +18,20 @@ class Image private: Flipdot flipdot; - bool frontBuffer[16][16]; + //buffer is 16 bit because of 16 Rows + uint16_t frontBuffer[COLUMNS]; //1 is bright dot / set dot. 0 is black / cleared + uint16_t backBuffer[COLUMNS]; + bool flag_updating; //when true, display flip is in progress. frontBuffer does not match backBuffer + + uint8_t update_counter; //used for keeping track of progress for updating int countz=0; + unsigned long lastUpdateMillis; //time when last dots where started flipping + + unsigned long updateInterval; + public: @@ -34,6 +43,7 @@ public: uint8_t getW(); //returns Columns uint8_t getH(); //returns Rows + void setBuffer_solid(bool set); void loop_testDots(); void loop_drawClearTest(); diff --git a/flipcontrol_esp32/src/image.cpp b/flipcontrol_esp32/src/image.cpp index 8909746..d797259 100644 --- a/flipcontrol_esp32/src/image.cpp +++ b/flipcontrol_esp32/src/image.cpp @@ -11,6 +11,10 @@ Image::Image() void Image::init() { flipdot.init(); //sets pin modes etc. + + flag_updating=false; + update_counter=0; + updateInterval=50; } uint8_t Image::getW() { @@ -21,6 +25,61 @@ uint8_t Image::getH() { return ROWS; } +void Image::setBuffer_solid(bool set) +{ + for (uint8_t x=0;x=getW()) { //reached last column + flag_updating=false; + update_counter=0; + return 1; //finished + } + return 0; //not finished +} void Image::loop_testDots() { diff --git a/flipcontrol_esp32/src/main.cpp b/flipcontrol_esp32/src/main.cpp index 30a78ce..f9c7666 100644 --- a/flipcontrol_esp32/src/main.cpp +++ b/flipcontrol_esp32/src/main.cpp @@ -25,7 +25,29 @@ void setup() { void loop() { loopmillis = millis(); + static unsigned long last_change=0; + static bool color=0; + if (loopmillis-last_change >= 10000) + { + Serial.print("Change to Solid color ="); Serial.println(color); + flip.setBuffer_solid(color); + color=1-color; + last_change=loopmillis; + } + + + if (loopmillis > last_update + UPDATE_INTERVAL) + { + Serial.print("UpdateByColumn "); + bool result=flip.updateByColumn(0,0,0,0); + Serial.println(result); + + last_update=loopmillis; + } + + + /* if (loopmillis > last_update + UPDATE_INTERVAL) { flip.loop_drawClearTest(); @@ -33,6 +55,7 @@ void loop() { last_update=loopmillis; } + */