#include "image.h" Image::Image() { } void Image::serialPrintInt(uint16_t source) { for(uint8_t i = 0; i < 16; i++) Serial.print((source & (1 << i)) > 0); } void Image::init() { flipdot.init(); //sets pin modes etc. flag_updating=false; update_counter=0; updateDelay=10; resetOrder(true); } uint8_t Image::getW() { return COLUMNS; } uint8_t Image::getH() { return ROWS; } void Image::setBuffer_solid(bool set) { for (uint8_t x=0;x=COLUMNS) { Serial.println("colnum too high"); }else{ backBuffer[_colnum]=_rowdata; //all white flag_updating=true; //make update run } } void Image::setBuffer_random(uint8_t randomness) { for (uint8_t x=0;x0) { //at least on dot has to be cleared in this column flipdot.setRow(0); flipdot.selectColumnClear(x); if (!flipdot.clearSelectedColumn()) { Serial.println("Error clearing column!"); } lastUpdateMillis=millis(); frontBuffer[x]=0; } }else{ //odd counter numbers are for setting uint16_t _colSet=backBuffer[x]& ~frontBuffer[x]; if (!optimizeSet || _colSet>0) { //at least on dot has to be set in this column (if optimize is enabled) flipdot.selectColumnSet(x); //lower column number is on the left if (!optimizeSet) { flipdot.setRow(backBuffer[x]); //flip all set dots in this column }else{ flipdot.setRow(_colSet); //flip only currently not set dots in this column that have to be set } if (!flipdot.setSelectedDot()) { Serial.println("Error setting dots!"); } lastUpdateMillis=millis(); frontBuffer[x]=backBuffer[x]; //flip current column in buffer } } update_counter++; //next column unsigned long _duration=millis()-functionStartMillis; //how long it took to shift data and flip dots in this update updateDuration=max(updateDuration,_duration); //store maximum value if (update_counter/2>=getW()) { //reached last column flag_updating=false; update_counter=0; return finished; //finished } return updating; //not finished } void Image::loop_testDots() { static bool init=false; if (!init) { flipdot.setRow(0); Serial.println("Clearing Display"); for (int l=0;l