diff --git a/flipcontrol_esp32/include/image.h b/flipcontrol_esp32/include/image.h index 8903370..8ec02da 100644 --- a/flipcontrol_esp32/include/image.h +++ b/flipcontrol_esp32/include/image.h @@ -42,6 +42,8 @@ private: uint8_t orderArray[COLUMNS]; void serialPrintInt(uint16_t source); + + bool isBuffersEqual(); diff --git a/flipcontrol_esp32/src/image.cpp b/flipcontrol_esp32/src/image.cpp index 7a5d4bf..973fcb1 100644 --- a/flipcontrol_esp32/src/image.cpp +++ b/flipcontrol_esp32/src/image.cpp @@ -657,11 +657,12 @@ UpdateReturn Image::updateByColumn(bool clearFirst, bool optimizeClear, bool opt } }else{ //odd counter numbers are for setting - uint16_t _colSet=backBuffer[x]& ~frontBuffer[x]; + uint16_t backBuffer_x=backBuffer[x]; //store buffer, because it may change when different data arrives during setting dots + 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 + 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 } @@ -671,7 +672,7 @@ UpdateReturn Image::updateByColumn(bool clearFirst, bool optimizeClear, bool opt } lastUpdateMillis=millis(); - frontBuffer[x]=backBuffer[x]; //flip current column in buffer + frontBuffer[x]=backBuffer_x; //flip current column in buffer } } @@ -685,11 +686,24 @@ UpdateReturn Image::updateByColumn(bool clearFirst, bool optimizeClear, bool opt flag_updating=false; update_counter=0; flag_redraw=false; + if (!isBuffersEqual()) { + flag_updating=true; //update again if buffers not equal + return updating; + } + return finished; //finished } return updating; //not finished } +bool Image::isBuffersEqual() { + for (uint8_t x=0;x