fix buffer content and update when data arrives during update

This commit is contained in:
interfisch 2023-12-31 16:31:07 +01:00
parent 1e6036cde4
commit 5eaba03d2f
2 changed files with 19 additions and 3 deletions

View File

@ -42,6 +42,8 @@ private:
uint8_t orderArray[COLUMNS]; uint8_t orderArray[COLUMNS];
void serialPrintInt(uint16_t source); void serialPrintInt(uint16_t source);
bool isBuffersEqual();

View File

@ -657,11 +657,12 @@ UpdateReturn Image::updateByColumn(bool clearFirst, bool optimizeClear, bool opt
} }
}else{ //odd counter numbers are for setting }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) 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 flipdot.selectColumnSet(x); //lower column number is on the left
if (!optimizeSet) { 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{ }else{
flipdot.setRow(_colSet); //flip only currently not set dots in this column that have to be set 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(); 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; flag_updating=false;
update_counter=0; update_counter=0;
flag_redraw=false; flag_redraw=false;
if (!isBuffersEqual()) {
flag_updating=true; //update again if buffers not equal
return updating;
}
return finished; //finished return finished; //finished
} }
return updating; //not finished return updating; //not finished
} }
bool Image::isBuffersEqual() {
for (uint8_t x=0;x<COLUMNS;x++) {
if (frontBuffer[x]!=backBuffer[x]) {
return false;
}
}
return true;
}
void Image::loop_testDots() { void Image::loop_testDots() {