Skip to content
Snippets Groups Projects
Commit 52701fd9 authored by Fabrice Weinberg's avatar Fabrice Weinberg
Browse files

Reset state values when calling setFrames Fixing #34

parent bf5cb507
No related branches found
No related tags found
No related merge requests found
......@@ -95,22 +95,20 @@ void OLEDDisplayUi::setFrameAnimation(AnimationDirection dir) {
this->frameAnimationDirection = dir;
}
void OLEDDisplayUi::setFrames(FrameCallback* frameFunctions, uint8_t frameCount) {
this->frameCount = frameCount;
this->frameFunctions = frameFunctions;
this->frameCount = frameCount;
this->resetState();
}
// -/----- Overlays ------\-
void OLEDDisplayUi::setOverlays(OverlayCallback* overlayFunctions, uint8_t overlayCount){
this->overlayCount = overlayCount;
this->overlayFunctions = overlayFunctions;
this->overlayCount = overlayCount;
}
// -/----- Loading Process -----\-
void OLEDDisplayUi::runLoadingProcess(LoadingStage* stages, uint8_t stagesCount) {
display->setTextAlignment(TEXT_ALIGN_CENTER);
display->setFont(ArialMT_Plain_10);
uint8_t progress = 0;
uint8_t increment = 100 / stagesCount;
......@@ -206,6 +204,14 @@ void OLEDDisplayUi::tick() {
this->display->display();
}
void OLEDDisplayUi::resetState() {
this->state.lastUpdate = 0;
this->state.ticksSinceLastStateSwitch = 0;
this->state.frameState = FIXED;
this->state.currentFrame = 0;
this->state.isIndicatorDrawen = true;
}
void OLEDDisplayUi::drawFrame(){
switch (this->state.frameState){
case IN_TRANSITION: {
......
......@@ -135,7 +135,9 @@ class OLEDDisplayUi {
// Loading screen
LoadingDrawFunction loadingDrawFunction = [](OLEDDisplay *display, LoadingStage* stage, uint8_t progress) {
display->drawString(64, 20, stage->process);
display->setTextAlignment(TEXT_ALIGN_CENTER);
display->setFont(ArialMT_Plain_10);
display->drawString(64, 18, stage->process);
display->drawProgressBar(4, 32, 120, 8, progress);
};
......@@ -150,6 +152,7 @@ class OLEDDisplayUi {
void drawFrame();
void drawOverlays();
void tick();
void resetState();
public:
......@@ -255,7 +258,7 @@ class OLEDDisplayUi {
* Set the function that will draw each step
* in the loading animation
*/
void setLoadingDrawFunction(LoadingDrawFunction stage);
void setLoadingDrawFunction(LoadingDrawFunction loadingFunction);
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment