add return enum for update function
This commit is contained in:
parent
5b344a6b4e
commit
9ff297bd6c
|
@ -12,6 +12,13 @@
|
|||
|
||||
#define UPDATE_INTERVAL 5 //TODO: remove this
|
||||
|
||||
enum UpdateReturn {
|
||||
wait,
|
||||
finished,
|
||||
nochange,
|
||||
updating
|
||||
};
|
||||
|
||||
class Image
|
||||
{
|
||||
|
||||
|
@ -39,7 +46,7 @@ public:
|
|||
Image();
|
||||
void init();
|
||||
|
||||
bool updateByColumn(bool direction, bool clearFirst, bool optimizeClear, bool optimizeSet);
|
||||
UpdateReturn updateByColumn(bool direction, bool clearFirst, bool optimizeClear, bool optimizeSet);
|
||||
|
||||
uint8_t getW(); //returns Columns
|
||||
uint8_t getH(); //returns Rows
|
||||
|
|
|
@ -56,15 +56,15 @@ void Image::setBuffer_random(uint8_t randomness)
|
|||
|
||||
}
|
||||
|
||||
bool Image::updateByColumn(bool direction, bool clearFirst, bool optimizeClear, bool optimizeSet)
|
||||
UpdateReturn Image::updateByColumn(bool direction, bool clearFirst, bool optimizeClear, bool optimizeSet)
|
||||
{
|
||||
|
||||
if (!flag_updating) {
|
||||
return 1; //finished
|
||||
return nochange; //finished
|
||||
}
|
||||
|
||||
if (millis()-lastUpdateMillis<updateInterval){ //too early
|
||||
return 0; //not finished
|
||||
return wait; //not finished
|
||||
}
|
||||
|
||||
|
||||
|
@ -97,9 +97,9 @@ bool Image::updateByColumn(bool direction, bool clearFirst, bool optimizeClear,
|
|||
if (update_counter/2>=getW()) { //reached last column
|
||||
flag_updating=false;
|
||||
update_counter=0;
|
||||
return 1; //finished
|
||||
return finished; //finished
|
||||
}
|
||||
return 0; //not finished
|
||||
return updating; //not finished
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -42,16 +42,14 @@ void loop() {
|
|||
}
|
||||
|
||||
|
||||
static bool last_result;
|
||||
bool result=flip.updateByColumn(0,0,0,0); //0=not finished, 1=finished
|
||||
if (result && !last_result) //just finished
|
||||
UpdateReturn result=flip.updateByColumn(0,0,0,0); //0=not finished, 1=finished
|
||||
if (result == finished) //just finished
|
||||
{
|
||||
unsigned long duration=millis()-last_change;
|
||||
Serial.print("Last Change took "); Serial.print(duration); Serial.println(" ms");
|
||||
Serial.print("Update max took "); Serial.print(flip.updateDuration); Serial.println(" ms");
|
||||
flip.updateDuration=0; //reset
|
||||
}
|
||||
last_result=result;
|
||||
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue