2023-02-08 19:17:58 +00:00
|
|
|
#ifndef IMAGE_H
|
|
|
|
#define IMAGE_H
|
|
|
|
|
|
|
|
#include <Arduino.h>
|
|
|
|
|
|
|
|
#include "flipdot.h"
|
2023-11-23 21:47:45 +00:00
|
|
|
#include <string.h>
|
2023-02-08 19:17:58 +00:00
|
|
|
|
|
|
|
|
2023-02-13 18:05:24 +00:00
|
|
|
#define COLUMNS 75
|
2023-02-08 19:17:58 +00:00
|
|
|
#define ROWS 16
|
|
|
|
|
|
|
|
|
2023-02-11 16:31:49 +00:00
|
|
|
enum UpdateReturn {
|
|
|
|
wait,
|
|
|
|
finished,
|
|
|
|
nochange,
|
|
|
|
updating
|
|
|
|
};
|
|
|
|
|
2023-02-08 19:17:58 +00:00
|
|
|
class Image
|
|
|
|
{
|
|
|
|
|
|
|
|
private:
|
|
|
|
Flipdot flipdot;
|
|
|
|
|
2023-02-08 20:00:15 +00:00
|
|
|
//buffer is 16 bit because of 16 Rows
|
|
|
|
uint16_t frontBuffer[COLUMNS]; //1 is bright dot / set dot. 0 is black / cleared
|
2023-11-25 11:23:15 +00:00
|
|
|
uint16_t backBuffer[COLUMNS]; //least significant bit is bottom dot.
|
2023-02-08 19:17:58 +00:00
|
|
|
|
2023-02-08 20:00:15 +00:00
|
|
|
bool flag_updating; //when true, display flip is in progress. frontBuffer does not match backBuffer
|
2023-11-23 22:50:16 +00:00
|
|
|
bool flag_redraw; //when set true, settings for updating are overwritten such that all dots are cleared and set
|
2023-02-08 20:00:15 +00:00
|
|
|
|
|
|
|
uint8_t update_counter; //used for keeping track of progress for updating
|
2023-02-08 19:17:58 +00:00
|
|
|
|
|
|
|
int countz=0;
|
|
|
|
|
2023-02-08 20:00:15 +00:00
|
|
|
unsigned long lastUpdateMillis; //time when last dots where started flipping
|
|
|
|
|
2023-02-11 17:26:52 +00:00
|
|
|
unsigned long updateDelay;
|
2023-02-08 20:00:15 +00:00
|
|
|
|
2023-02-11 17:51:33 +00:00
|
|
|
uint8_t orderArray[COLUMNS];
|
|
|
|
|
2023-02-11 17:26:52 +00:00
|
|
|
void serialPrintInt(uint16_t source);
|
2023-12-31 15:31:07 +00:00
|
|
|
|
|
|
|
bool isBuffersEqual();
|
2023-02-08 20:29:10 +00:00
|
|
|
|
2023-02-08 19:17:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
Image();
|
|
|
|
void init();
|
|
|
|
|
2023-02-11 17:51:33 +00:00
|
|
|
UpdateReturn updateByColumn(bool clearFirst, bool optimizeClear, bool optimizeSet);
|
2023-02-08 19:17:58 +00:00
|
|
|
|
|
|
|
uint8_t getW(); //returns Columns
|
|
|
|
uint8_t getH(); //returns Rows
|
|
|
|
|
2023-02-11 17:51:33 +00:00
|
|
|
void resetOrder(bool ascending);
|
|
|
|
void shuffleOrder(uint8_t iterations);
|
|
|
|
|
2023-02-08 20:00:15 +00:00
|
|
|
void setBuffer_solid(bool set);
|
2023-02-13 18:58:45 +00:00
|
|
|
void setBufferColumn(uint8_t _colnum, uint16_t _rowdata);
|
2023-11-23 21:47:45 +00:00
|
|
|
void setBuffer_random(uint8_t brightness);
|
|
|
|
void setBuffer_byString(String data,String& error);
|
|
|
|
void setBuffer_byInt(String data,String& error);
|
2023-02-08 19:17:58 +00:00
|
|
|
|
2024-01-09 21:15:54 +00:00
|
|
|
void addBuffer_text(String text,uint8_t xoffset, uint8_t yoffset, uint8_t pfont=0);
|
2023-11-25 11:23:15 +00:00
|
|
|
|
2023-11-25 13:31:07 +00:00
|
|
|
void setBuffer_Preset_Bumblebee();
|
|
|
|
void setBuffer_Preset_Datamatrixctdo();
|
2023-11-22 18:32:33 +00:00
|
|
|
|
2023-09-20 17:22:59 +00:00
|
|
|
|
2023-02-08 19:17:58 +00:00
|
|
|
void loop_testDots();
|
|
|
|
void loop_drawClearTest();
|
2023-02-08 20:29:10 +00:00
|
|
|
|
2023-11-23 22:50:16 +00:00
|
|
|
void redraw();
|
|
|
|
|
2023-12-03 20:58:09 +00:00
|
|
|
void setDisplayMirror(bool x, bool y);
|
|
|
|
|
2023-02-11 17:51:33 +00:00
|
|
|
|
|
|
|
|
2023-02-08 20:29:10 +00:00
|
|
|
unsigned long updateDuration; //for statistics and debugging. time it took for one update (max)
|
2023-02-08 19:17:58 +00:00
|
|
|
};
|
|
|
|
|
2023-12-03 20:58:09 +00:00
|
|
|
|
2023-02-08 19:17:58 +00:00
|
|
|
#endif
|
|
|
|
|