do not display battery untils values are ready

Signed-off-by: Vincent-FK <vincent.buso@funkey-project.com>
This commit is contained in:
Vincent-FK 2020-03-12 23:22:37 +01:00
parent 260178ef44
commit e7e4be0d11
2 changed files with 6 additions and 2 deletions

View File

@ -89,6 +89,7 @@ bool Battery::noBat_ = false;
bool Battery::prevNoBat_ = false;
float Battery::currentWaitTime_ = 0.0f;
bool Battery::mustRender_ = false;
bool Battery::valuesReady_ = false;
Battery::Battery(Page &p, Configuration &config, float reloadPeriod, SDL_Color fontColor, float scaleX, float scaleY)
@ -342,6 +343,8 @@ void Battery::update(float dt)
noBat_ = !isBatConnected();
charging_ = isUsbConnected();
valuesReady_ = true;
currentWaitTime_ = 0.0f;
}
@ -379,7 +382,7 @@ void Battery::draw()
Component::draw();
if(texture_)
if(texture_ && valuesReady_)
{
SDL_Rect rect;
rect.x = static_cast<int>(baseViewInfo.XRelativeToOrigin());
@ -418,7 +421,7 @@ bool Battery::mustRender( )
{
if ( Component::mustRender( ) ) return true;
if ( mustRender_ && baseViewInfo.Alpha > 0.0f )
if ( mustRender_ && baseViewInfo.Alpha > 0.0f && valuesReady_ )
{
mustRender_ = false;
return true;

View File

@ -44,4 +44,5 @@ protected:
static bool prevCharging_;
static bool noBat_;
static bool prevNoBat_;
static bool valuesReady_;
};