flipdot/flipcontrol_esp32/include/image.h

90 lines
2.0 KiB
C++

#ifndef IMAGE_H
#define IMAGE_H
#include <Arduino.h>
#include "flipdot.h"
#include <string.h>
#define COLUMNS 75
#define ROWS 16
enum UpdateReturn {
wait,
finished,
nochange,
updating
};
class Image
{
private:
Flipdot flipdot;
//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]; //least significant bit is bottom dot.
bool flag_updating; //when true, display flip is in progress. frontBuffer does not match backBuffer
bool flag_redraw; //when set true, settings for updating are overwritten such that all dots are cleared and set
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 updateDelay;
uint8_t orderArray[COLUMNS];
void serialPrintInt(uint16_t source);
public:
Image();
void init();
UpdateReturn updateByColumn(bool clearFirst, bool optimizeClear, bool optimizeSet);
uint8_t getW(); //returns Columns
uint8_t getH(); //returns Rows
void resetOrder(bool ascending);
void shuffleOrder(uint8_t iterations);
void setBuffer_solid(bool set);
void setBufferColumn(uint8_t _colnum, uint16_t _rowdata);
void setBuffer_random(uint8_t brightness);
void setBuffer_byString(String data,String& error);
void setBuffer_byInt(String data,String& error);
void addBuffer_text(String text,uint8_t xoffset, uint8_t yoffset);
void setBuffer_Image1();
void setBuffer_Image2();
void setBuffer_Image3();
void setBuffer_Image4();
void setBuffer_Image5();
void setBuffer_Image6();
void setBuffer_Image7();
void setBuffer_Image8();
void loop_testDots();
void loop_drawClearTest();
void redraw();
unsigned long updateDuration; //for statistics and debugging. time it took for one update (max)
};
#endif