TimerController: Rename to Timer
This commit is contained in:
parent
661ffbeb1e
commit
40f7e1c7be
|
@ -472,7 +472,7 @@ list(APPEND SOURCE_FILES
|
||||||
components/firmwarevalidator/FirmwareValidator.cpp
|
components/firmwarevalidator/FirmwareValidator.cpp
|
||||||
components/motor/MotorController.cpp
|
components/motor/MotorController.cpp
|
||||||
components/settings/Settings.cpp
|
components/settings/Settings.cpp
|
||||||
components/timer/TimerController.cpp
|
components/timer/Timer.cpp
|
||||||
components/alarm/AlarmController.cpp
|
components/alarm/AlarmController.cpp
|
||||||
components/fs/FS.cpp
|
components/fs/FS.cpp
|
||||||
drivers/Cst816s.cpp
|
drivers/Cst816s.cpp
|
||||||
|
@ -537,7 +537,7 @@ list(APPEND RECOVERY_SOURCE_FILES
|
||||||
components/ble/MotionService.cpp
|
components/ble/MotionService.cpp
|
||||||
components/firmwarevalidator/FirmwareValidator.cpp
|
components/firmwarevalidator/FirmwareValidator.cpp
|
||||||
components/settings/Settings.cpp
|
components/settings/Settings.cpp
|
||||||
components/timer/TimerController.cpp
|
components/timer/Timer.cpp
|
||||||
components/alarm/AlarmController.cpp
|
components/alarm/AlarmController.cpp
|
||||||
drivers/Cst816s.cpp
|
drivers/Cst816s.cpp
|
||||||
FreeRTOS/port.c
|
FreeRTOS/port.c
|
||||||
|
@ -653,7 +653,7 @@ set(INCLUDE_FILES
|
||||||
components/ble/MotionService.h
|
components/ble/MotionService.h
|
||||||
components/ble/weather/WeatherService.h
|
components/ble/weather/WeatherService.h
|
||||||
components/settings/Settings.h
|
components/settings/Settings.h
|
||||||
components/timer/TimerController.h
|
components/timer/Timer.h
|
||||||
components/alarm/AlarmController.h
|
components/alarm/AlarmController.h
|
||||||
drivers/Cst816s.h
|
drivers/Cst816s.h
|
||||||
FreeRTOS/portmacro.h
|
FreeRTOS/portmacro.h
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
#include "components/timer/TimerController.h"
|
#include "components/timer/Timer.h"
|
||||||
|
|
||||||
using namespace Pinetime::Controllers;
|
using namespace Pinetime::Controllers;
|
||||||
|
|
||||||
TimerController::TimerController(void* const timerData, TimerCallbackFunction_t timerCallbackFunction) {
|
Timer::Timer(void* const timerData, TimerCallbackFunction_t timerCallbackFunction) {
|
||||||
timer = xTimerCreate("Timer", 1, pdFALSE, timerData, timerCallbackFunction);
|
timer = xTimerCreate("Timer", 1, pdFALSE, timerData, timerCallbackFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimerController::StartTimer(std::chrono::milliseconds duration) {
|
void Timer::StartTimer(std::chrono::milliseconds duration) {
|
||||||
xTimerChangePeriod(timer, pdMS_TO_TICKS(duration.count()), 0);
|
xTimerChangePeriod(timer, pdMS_TO_TICKS(duration.count()), 0);
|
||||||
xTimerStart(timer, 0);
|
xTimerStart(timer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::chrono::milliseconds TimerController::GetTimeRemaining() {
|
std::chrono::milliseconds Timer::GetTimeRemaining() {
|
||||||
if (IsRunning()) {
|
if (IsRunning()) {
|
||||||
TickType_t remainingTime = xTimerGetExpiryTime(timer) - xTaskGetTickCount();
|
TickType_t remainingTime = xTimerGetExpiryTime(timer) - xTaskGetTickCount();
|
||||||
return std::chrono::milliseconds(remainingTime * 1000 / configTICK_RATE_HZ);
|
return std::chrono::milliseconds(remainingTime * 1000 / configTICK_RATE_HZ);
|
||||||
|
@ -19,10 +19,10 @@ std::chrono::milliseconds TimerController::GetTimeRemaining() {
|
||||||
return std::chrono::milliseconds(0);
|
return std::chrono::milliseconds(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimerController::StopTimer() {
|
void Timer::StopTimer() {
|
||||||
xTimerStop(timer, 0);
|
xTimerStop(timer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TimerController::IsRunning() {
|
bool Timer::IsRunning() {
|
||||||
return (xTimerIsTimerActive(timer) == pdTRUE);
|
return (xTimerIsTimerActive(timer) == pdTRUE);
|
||||||
}
|
}
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
namespace Controllers {
|
namespace Controllers {
|
||||||
class TimerController {
|
class Timer {
|
||||||
public:
|
public:
|
||||||
TimerController(void* timerData, TimerCallbackFunction_t timerCallbackFunction);
|
Timer(void* timerData, TimerCallbackFunction_t timerCallbackFunction);
|
||||||
|
|
||||||
void StartTimer(std::chrono::milliseconds duration);
|
void StartTimer(std::chrono::milliseconds duration);
|
||||||
|
|
|
@ -95,7 +95,7 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
|
||||||
touchHandler {touchHandler},
|
touchHandler {touchHandler},
|
||||||
filesystem {filesystem},
|
filesystem {filesystem},
|
||||||
lvgl {lcd, filesystem},
|
lvgl {lcd, filesystem},
|
||||||
timerController(this, TimerCallback) {
|
timer(this, TimerCallback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayApp::Start(System::BootErrors error) {
|
void DisplayApp::Start(System::BootErrors error) {
|
||||||
|
@ -452,7 +452,7 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
|
||||||
Screens::Notifications::Modes::Preview);
|
Screens::Notifications::Modes::Preview);
|
||||||
break;
|
break;
|
||||||
case Apps::Timer:
|
case Apps::Timer:
|
||||||
currentScreen = std::make_unique<Screens::Timer>(timerController);
|
currentScreen = std::make_unique<Screens::Timer>(timer);
|
||||||
break;
|
break;
|
||||||
case Apps::Alarm:
|
case Apps::Alarm:
|
||||||
currentScreen = std::make_unique<Screens::Alarm>(alarmController, settingsController.GetClockType(), *systemTask, motorController);
|
currentScreen = std::make_unique<Screens::Alarm>(alarmController, settingsController.GetClockType(), *systemTask, motorController);
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include "components/firmwarevalidator/FirmwareValidator.h"
|
#include "components/firmwarevalidator/FirmwareValidator.h"
|
||||||
#include "components/settings/Settings.h"
|
#include "components/settings/Settings.h"
|
||||||
#include "displayapp/screens/Screen.h"
|
#include "displayapp/screens/Screen.h"
|
||||||
#include "components/timer/TimerController.h"
|
#include "components/timer/Timer.h"
|
||||||
#include "components/alarm/AlarmController.h"
|
#include "components/alarm/AlarmController.h"
|
||||||
#include "touchhandler/TouchHandler.h"
|
#include "touchhandler/TouchHandler.h"
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ namespace Pinetime {
|
||||||
|
|
||||||
Pinetime::Controllers::FirmwareValidator validator;
|
Pinetime::Controllers::FirmwareValidator validator;
|
||||||
Pinetime::Components::LittleVgl lvgl;
|
Pinetime::Components::LittleVgl lvgl;
|
||||||
Pinetime::Controllers::TimerController timerController;
|
Pinetime::Controllers::Timer timer;
|
||||||
|
|
||||||
TaskHandle_t taskHandle;
|
TaskHandle_t taskHandle;
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ static void btnEventHandler(lv_obj_t* obj, lv_event_t event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer::Timer(Controllers::TimerController& timerController) : timerController {timerController} {
|
Timer::Timer(Controllers::Timer& timerController) : timer {timerController} {
|
||||||
|
|
||||||
lv_obj_t* colonLabel = lv_label_create(lv_scr_act(), nullptr);
|
lv_obj_t* colonLabel = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_font(colonLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
|
lv_obj_set_style_local_text_font(colonLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
|
||||||
|
@ -85,7 +85,7 @@ void Timer::MaskReset() {
|
||||||
buttonPressing = false;
|
buttonPressing = false;
|
||||||
// A click event is processed before a release event,
|
// A click event is processed before a release event,
|
||||||
// so the release event would override the "Pause" text without this check
|
// so the release event would override the "Pause" text without this check
|
||||||
if (!timerController.IsRunning()) {
|
if (!timer.IsRunning()) {
|
||||||
lv_label_set_text_static(txtPlayPause, "Start");
|
lv_label_set_text_static(txtPlayPause, "Start");
|
||||||
}
|
}
|
||||||
maskPosition = 0;
|
maskPosition = 0;
|
||||||
|
@ -103,8 +103,8 @@ void Timer::UpdateMask() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Timer::Refresh() {
|
void Timer::Refresh() {
|
||||||
if (timerController.IsRunning()) {
|
if (timer.IsRunning()) {
|
||||||
auto secondsRemaining = std::chrono::duration_cast<std::chrono::seconds>(timerController.GetTimeRemaining());
|
auto secondsRemaining = std::chrono::duration_cast<std::chrono::seconds>(timer.GetTimeRemaining());
|
||||||
minuteCounter.SetValue(secondsRemaining.count() / 60);
|
minuteCounter.SetValue(secondsRemaining.count() / 60);
|
||||||
secondCounter.SetValue(secondsRemaining.count() % 60);
|
secondCounter.SetValue(secondsRemaining.count() % 60);
|
||||||
} else if (buttonPressing && xTaskGetTickCount() > pressTime + pdMS_TO_TICKS(150)) {
|
} else if (buttonPressing && xTaskGetTickCount() > pressTime + pdMS_TO_TICKS(150)) {
|
||||||
|
@ -132,15 +132,15 @@ void Timer::SetTimerStopped() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Timer::ToggleRunning() {
|
void Timer::ToggleRunning() {
|
||||||
if (timerController.IsRunning()) {
|
if (timer.IsRunning()) {
|
||||||
auto secondsRemaining = std::chrono::duration_cast<std::chrono::seconds>(timerController.GetTimeRemaining());
|
auto secondsRemaining = std::chrono::duration_cast<std::chrono::seconds>(timer.GetTimeRemaining());
|
||||||
minuteCounter.SetValue(secondsRemaining.count() / 60);
|
minuteCounter.SetValue(secondsRemaining.count() / 60);
|
||||||
secondCounter.SetValue(secondsRemaining.count() % 60);
|
secondCounter.SetValue(secondsRemaining.count() % 60);
|
||||||
timerController.StopTimer();
|
timer.StopTimer();
|
||||||
SetTimerStopped();
|
SetTimerStopped();
|
||||||
} else if (secondCounter.GetValue() + minuteCounter.GetValue() > 0) {
|
} else if (secondCounter.GetValue() + minuteCounter.GetValue() > 0) {
|
||||||
auto timerDuration = std::chrono::minutes(minuteCounter.GetValue()) + std::chrono::seconds(secondCounter.GetValue());
|
auto timerDuration = std::chrono::minutes(minuteCounter.GetValue()) + std::chrono::seconds(secondCounter.GetValue());
|
||||||
timerController.StartTimer(timerDuration);
|
timer.StartTimer(timerDuration);
|
||||||
Refresh();
|
Refresh();
|
||||||
SetTimerRunning();
|
SetTimerRunning();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,12 @@
|
||||||
#include "displayapp/widgets/Counter.h"
|
#include "displayapp/widgets/Counter.h"
|
||||||
#include <lvgl/lvgl.h>
|
#include <lvgl/lvgl.h>
|
||||||
|
|
||||||
#include "components/timer/TimerController.h"
|
#include "components/timer/Timer.h"
|
||||||
|
|
||||||
namespace Pinetime::Applications::Screens {
|
namespace Pinetime::Applications::Screens {
|
||||||
class Timer : public Screen {
|
class Timer : public Screen {
|
||||||
public:
|
public:
|
||||||
Timer(Controllers::TimerController& timerController);
|
Timer(Controllers::Timer& timerController);
|
||||||
~Timer() override;
|
~Timer() override;
|
||||||
void Refresh() override;
|
void Refresh() override;
|
||||||
void Reset();
|
void Reset();
|
||||||
|
@ -24,7 +24,7 @@ namespace Pinetime::Applications::Screens {
|
||||||
void SetTimerRunning();
|
void SetTimerRunning();
|
||||||
void SetTimerStopped();
|
void SetTimerStopped();
|
||||||
void UpdateMask();
|
void UpdateMask();
|
||||||
Controllers::TimerController& timerController;
|
Controllers::Timer& timer;
|
||||||
|
|
||||||
lv_obj_t* btnPlayPause;
|
lv_obj_t* btnPlayPause;
|
||||||
lv_obj_t* txtPlayPause;
|
lv_obj_t* txtPlayPause;
|
||||||
|
|
Loading…
Reference in a new issue