Code cleanup (#466)

* Code cleanup
* Remove override again
This commit is contained in:
Riku Isokoski 2021-07-25 17:54:05 +03:00 committed by GitHub
parent 34949a47c5
commit ec2469a6c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 42 additions and 66 deletions

View file

@ -202,7 +202,7 @@ void DisplayApp::Refresh() {
break; break;
case Messages::TimerDone: case Messages::TimerDone:
if (currentApp == Apps::Timer) { if (currentApp == Apps::Timer) {
auto *timer = static_cast<Screens::Timer*>(currentScreen.get()); auto* timer = static_cast<Screens::Timer*>(currentScreen.get());
timer->setDone(); timer->setDone();
} else { } else {
LoadApp(Apps::Timer, DisplayApp::FullRefreshDirections::Down); LoadApp(Apps::Timer, DisplayApp::FullRefreshDirections::Down);
@ -268,7 +268,7 @@ void DisplayApp::Refresh() {
} }
} }
if(nextApp != Apps::None) { if (nextApp != Apps::None) {
LoadApp(nextApp, nextDirection); LoadApp(nextApp, nextDirection);
nextApp = Apps::None; nextApp = Apps::None;
} }
@ -383,8 +383,8 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
break; break;
case Apps::SysInfo: case Apps::SysInfo:
currentScreen = currentScreen = std::make_unique<Screens::SystemInfo>(
std::make_unique<Screens::SystemInfo>(this, dateTimeController, batteryController, brightnessController, bleController, watchdog, motionController); this, dateTimeController, batteryController, brightnessController, bleController, watchdog, motionController);
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
break; break;
case Apps::FlashLight: case Apps::FlashLight:
@ -429,7 +429,7 @@ void DisplayApp::IdleState() {
} }
void DisplayApp::PushMessage(Messages msg) { void DisplayApp::PushMessage(Messages msg) {
if(in_isr()) { if (in_isr()) {
BaseType_t xHigherPriorityTaskWoken; BaseType_t xHigherPriorityTaskWoken;
xHigherPriorityTaskWoken = pdFALSE; xHigherPriorityTaskWoken = pdFALSE;
xQueueSendFromISR(msgQueue, &msg, &xHigherPriorityTaskWoken); xQueueSendFromISR(msgQueue, &msg, &xHigherPriorityTaskWoken);
@ -471,7 +471,7 @@ void DisplayApp::SetTouchMode(DisplayApp::TouchModes mode) {
} }
void DisplayApp::PushMessageToSystemTask(Pinetime::System::Messages message) { void DisplayApp::PushMessageToSystemTask(Pinetime::System::Messages message) {
if(systemTask != nullptr) if (systemTask != nullptr)
systemTask->PushMessage(message); systemTask->PushMessage(message);
} }

View file

@ -15,8 +15,6 @@ namespace Pinetime {
bool Refresh() override; bool Refresh() override;
private: private:
bool running = true;
lv_obj_t* labelText = nullptr; lv_obj_t* labelText = nullptr;
lv_point_t pageIndicatorBasePoints[2]; lv_point_t pageIndicatorBasePoints[2];
lv_point_t pageIndicatorPoints[2]; lv_point_t pageIndicatorPoints[2];

View file

@ -36,7 +36,6 @@ Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionContr
labelStep = lv_label_create(lv_scr_act(), NULL); labelStep = lv_label_create(lv_scr_act(), NULL);
lv_obj_align(labelStep, chart, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); lv_obj_align(labelStep, chart, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
lv_label_set_text(labelStep, "Steps ---"); lv_label_set_text(labelStep, "Steps ---");
} }
Motion::~Motion() { Motion::~Motion() {
@ -50,13 +49,12 @@ bool Motion::Refresh() {
lv_label_set_text_fmt(labelStep, "Steps %lu", motionController.NbSteps()); lv_label_set_text_fmt(labelStep, "Steps %lu", motionController.NbSteps());
lv_label_set_text_fmt(label, "X #FF0000 %d# Y #008000 %d# Z #FFFF00 %d#", motionController.X() / 0x10, motionController.Y() / 0x10, motionController.Z() / 0x10); lv_label_set_text_fmt(label,
"X #FF0000 %d# Y #008000 %d# Z #FFFF00 %d#",
motionController.X() / 0x10,
motionController.Y() / 0x10,
motionController.Z() / 0x10);
lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 10); lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 10);
return running; return running;
} }
bool Motion::OnButtonPushed() {
running = false;
return true;
}

View file

@ -18,7 +18,6 @@ namespace Pinetime {
~Motion() override; ~Motion() override;
bool Refresh() override; bool Refresh() override;
bool OnButtonPushed() override;
private: private:
Controllers::MotionController& motionController; Controllers::MotionController& motionController;
@ -29,9 +28,6 @@ namespace Pinetime {
lv_obj_t* label; lv_obj_t* label;
lv_obj_t* labelStep; lv_obj_t* labelStep;
static constexpr uint8_t nbStepsBufferSize = 9;
char nbStepsBuffer[nbStepsBufferSize + 1];
bool running = true;
}; };
} }
} }

View file

@ -5,13 +5,10 @@
using namespace Pinetime::Applications::Screens; using namespace Pinetime::Applications::Screens;
Steps::Steps( Steps::Steps(Pinetime::Applications::DisplayApp* app,
Pinetime::Applications::DisplayApp *app,
Controllers::MotionController& motionController, Controllers::MotionController& motionController,
Controllers::Settings &settingsController) Controllers::Settings& settingsController)
: Screen(app), : Screen(app), motionController {motionController}, settingsController {settingsController} {
motionController{motionController},
settingsController{settingsController} {
stepsArc = lv_arc_create(lv_scr_act(), nullptr); stepsArc = lv_arc_create(lv_scr_act(), nullptr);
@ -34,12 +31,12 @@ Steps::Steps(
lv_label_set_text_fmt(lSteps, "%li", stepsCount); lv_label_set_text_fmt(lSteps, "%li", stepsCount);
lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -20); lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -20);
lv_obj_t * lstepsL = lv_label_create(lv_scr_act(), nullptr); lv_obj_t* lstepsL = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(lstepsL, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111)); lv_obj_set_style_local_text_color(lstepsL, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111));
lv_label_set_text_static(lstepsL, "Steps"); lv_label_set_text_static(lstepsL, "Steps");
lv_obj_align(lstepsL, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 10); lv_obj_align(lstepsL, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
lv_obj_t * lstepsGoal = lv_label_create(lv_scr_act(), nullptr); lv_obj_t* lstepsGoal = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(lstepsGoal, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_CYAN); lv_obj_set_style_local_text_color(lstepsGoal, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_CYAN);
lv_label_set_text_fmt(lstepsGoal, "Goal\n%lu", settingsController.GetStepsGoal()); lv_label_set_text_fmt(lstepsGoal, "Goal\n%lu", settingsController.GetStepsGoal());
lv_label_set_align(lstepsGoal, LV_LABEL_ALIGN_CENTER); lv_label_set_align(lstepsGoal, LV_LABEL_ALIGN_CENTER);

View file

@ -70,11 +70,6 @@ bool SystemInfo::Refresh() {
return running; return running;
} }
bool SystemInfo::OnButtonPushed() {
running = false;
return true;
}
bool SystemInfo::OnTouchEvent(Pinetime::Applications::TouchEvents event) { bool SystemInfo::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return screens.OnTouchEvent(event); return screens.OnTouchEvent(event);
} }

View file

@ -31,12 +31,9 @@ namespace Pinetime {
Pinetime::Controllers::MotionController& motionController); Pinetime::Controllers::MotionController& motionController);
~SystemInfo() override; ~SystemInfo() override;
bool Refresh() override; bool Refresh() override;
bool OnButtonPushed() override;
bool OnTouchEvent(TouchEvents event) override; bool OnTouchEvent(TouchEvents event) override;
private: private:
bool running = true;
Pinetime::Controllers::DateTime& dateTimeController; Pinetime::Controllers::DateTime& dateTimeController;
Pinetime::Controllers::Battery& batteryController; Pinetime::Controllers::Battery& batteryController;
Pinetime::Controllers::BrightnessController& brightnessController; Pinetime::Controllers::BrightnessController& brightnessController;

View file

@ -27,7 +27,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
batteryController {batteryController}, batteryController {batteryController},
dateTimeController {dateTimeController}, dateTimeController {dateTimeController},
brightness {brightness}, brightness {brightness},
motorController{motorController}, motorController {motorController},
settingsController {settingsController} { settingsController {settingsController} {
// Time // Time
@ -154,10 +154,6 @@ void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
} }
} }
bool QuickSettings::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return false;
}
bool QuickSettings::Refresh() { bool QuickSettings::Refresh() {
return running; return running;
} }

View file

@ -29,7 +29,6 @@ namespace Pinetime {
bool Refresh() override; bool Refresh() override;
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
void OnButtonEvent(lv_obj_t* object, lv_event_t event); void OnButtonEvent(lv_obj_t* object, lv_event_t event);
void UpdateScreen(); void UpdateScreen();