From 8b5ff04fa58faafa854251a5ced5d9774711310b Mon Sep 17 00:00:00 2001 From: Fisch Date: Wed, 8 Feb 2023 20:17:58 +0100 Subject: [PATCH] create wrapper class for image functions --- flipcontrol_esp32/include/flipdot.h | 20 ++-- flipcontrol_esp32/include/image.h | 43 +++++++ flipcontrol_esp32/src/flipdot.cpp | 8 ++ flipcontrol_esp32/src/image.cpp | 169 ++++++++++++++++++++++++++++ flipcontrol_esp32/src/main.cpp | 161 ++------------------------ 5 files changed, 237 insertions(+), 164 deletions(-) create mode 100644 flipcontrol_esp32/include/image.h create mode 100644 flipcontrol_esp32/src/image.cpp diff --git a/flipcontrol_esp32/include/flipdot.h b/flipcontrol_esp32/include/flipdot.h index d62e85d..65a16f3 100644 --- a/flipcontrol_esp32/include/flipdot.h +++ b/flipcontrol_esp32/include/flipdot.h @@ -45,18 +45,19 @@ class Flipdot { private: - int blafoo; - + bool HBridgeOK(); + void resetColumns(); + void shiftOutSlow(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val); + uint16_t row; //controls shift registers on own controller pcb + uint8_t col[COLUMNBYTES]; //column drivers and shift registers on annax pcb public: Flipdot(); void init(); - - void shiftOutSlow(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val); bool clearSelectedColumn(); bool setSelectedDot(); @@ -64,15 +65,10 @@ public: void selectColumnSet(uint8_t selcolumn); void selectColumn(uint8_t selcolumn, bool clear); - bool HBridgeOK(); - void shiftData(); - - void resetColumns(); + void setRow(uint16_t _row); + uint16_t getRow(); - - uint16_t row; //controls shift registers on own controller pcb - - uint8_t col[COLUMNBYTES]; //column drivers and shift registers on annax pcb + void shiftData(); }; #endif diff --git a/flipcontrol_esp32/include/image.h b/flipcontrol_esp32/include/image.h new file mode 100644 index 0000000..fa15be9 --- /dev/null +++ b/flipcontrol_esp32/include/image.h @@ -0,0 +1,43 @@ +#ifndef IMAGE_H +#define IMAGE_H + +#include + +#include "flipdot.h" + + +#define COLUMNS 50 +#define ROWS 16 + + +#define UPDATE_INTERVAL 5 + +class Image +{ + +private: + Flipdot flipdot; + + bool frontBuffer[16][16]; + + + int countz=0; + + + +public: + Image(); + void init(); + + bool updateByColumn(bool direction, bool clearFirst, bool optimizeClear, bool optimizeSet); + + uint8_t getW(); //returns Columns + uint8_t getH(); //returns Rows + + + void loop_testDots(); + void loop_drawClearTest(); +}; + +#endif + diff --git a/flipcontrol_esp32/src/flipdot.cpp b/flipcontrol_esp32/src/flipdot.cpp index 8e38c11..1308c4a 100644 --- a/flipcontrol_esp32/src/flipdot.cpp +++ b/flipcontrol_esp32/src/flipdot.cpp @@ -158,4 +158,12 @@ void Flipdot::resetColumns() { for (uint8_t i=0;i last_update + UPDATE_INTERVAL) { - - Serial.print("count="); - Serial.print(countz);Serial.print(": "); + flip.loop_drawClearTest(); + //loop_testDots(); - //setting colX to 128, 32, 8,2 (or a combination of), then appling 12V to driver and GND to Clear, clears these colums - // this applies +12v to selected columns - //setting colX to 64,16,4,1 (or a combination of), then setting row shift registers to some setting sets the selected dots - // this applies GND to selected columns - //reset pin on annax board input should be used (not pulled to gnd for a short time) after dots have been flipped (to disable potentially activated transistors) - - - //cycle testing set dots - flipdot.selectColumnSet(countz/ROWS); //lower column number is on the left - flipdot.row=pow(2, (countz)%ROWS);//low significant bits are lower rows (when connector at top) - - - - - /*Serial.print("Row="); Serial.print(row); Serial.print(" Col="); - for (uint8_t i=0;i<7;i++) { - Serial.print(","); Serial.print(col[i]); - } - Serial.println();*/ - //reset pin on ribbon cable high (12Vpullup/open), then low (via Transistor) - - unsigned long starttime=micros(); - - flipdot.shiftData(); - - - flipdot.setSelectedDot(); - - - unsigned long shiftduration=micros()-starttime; - Serial.println(""); - Serial.print("Duration="); Serial.println(shiftduration); - - - last_update=loopmillis; - countz++; - - if (countz>=ROWS*COLUMNS) { - countz=0; - init=false; - } - } + } -