mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-10-24 23:48:31 -04:00
Added battery level handling in top bar.
This commit is contained in:
1 parent
9199849629
commit
eb22011bdb
13 files changed
+111
-27
No files matched your search
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
#include "i18/i18.hpp"
|
||||
#include "AppWindow.hpp"
|
||||
#include "Application.hpp"
|
||||
|
||||
namespace gui {
|
||||
|
||||
@@ -28,6 +29,7 @@ void AppWindow::destroyInterface() {
|
||||
|
||||
void AppWindow::rebuild() {
|
||||
}
|
||||
|
||||
void AppWindow::buildInterface() {
|
||||
bottomBar = new gui::BottomBar( this, 0, 599-50, 480, 50 );
|
||||
bottomBar->setActive( BottomBar::Side::LEFT, false );
|
||||
@@ -40,4 +42,44 @@ void AppWindow::buildInterface() {
|
||||
topBar->setActive(TopBar::Elements::SIGNAL, false );
|
||||
}
|
||||
|
||||
uint32_t AppWindow::calculateBatteryLavel( uint32_t percentage ) {
|
||||
if( percentage <=5 )
|
||||
return 0;
|
||||
if( percentage <=27 )
|
||||
return 1;
|
||||
if( percentage <=50 )
|
||||
return 2;
|
||||
if( percentage <=73 )
|
||||
return 3;
|
||||
if( percentage <=95 )
|
||||
return 4;
|
||||
|
||||
return 5;
|
||||
}
|
||||
|
||||
//updates battery level in the window
|
||||
bool AppWindow::updateBatteryLevel( uint32_t percentage ) {
|
||||
//get old value of battery level, calcualte new level and comapre both
|
||||
//if they are different make a change and return true, otherwise return false;
|
||||
uint32_t oldLevel = topBar->getBatteryLevel();
|
||||
uint32_t newLevel = calculateBatteryLavel( percentage );
|
||||
if( oldLevel != newLevel ) {
|
||||
topBar->setBatteryLevel( newLevel );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
//updates battery level in the window
|
||||
bool AppWindow::updateSignalStrength( uint32_t strength ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::list<DrawCommand*> AppWindow::buildDrawList() {
|
||||
//update top bar and bottom bar
|
||||
topBar->setBatteryLevel( topBar->getBatteryLevel());
|
||||
|
||||
return Window::buildDrawList();
|
||||
}
|
||||
|
||||
} /* namespace gui */
|
||||
Reference in new issue
Block a user