2021-03-11 04:54:14 -05:00
|
|
|
#pragma once
|
|
|
|
|
2021-10-13 16:08:35 -04:00
|
|
|
#include "displayapp/screens/Screen.h"
|
2022-07-22 04:01:47 -04:00
|
|
|
#include <lvgl/lvgl.h>
|
2021-03-11 04:54:14 -05:00
|
|
|
|
2022-01-24 17:03:08 -05:00
|
|
|
#include <FreeRTOS.h>
|
2021-03-11 05:56:58 -05:00
|
|
|
#include "portmacro_cmsis.h"
|
2021-03-11 04:54:14 -05:00
|
|
|
|
2021-07-04 14:23:03 -04:00
|
|
|
#include "systemtask/SystemTask.h"
|
2023-12-19 11:53:48 -05:00
|
|
|
#include "displayapp/apps/Apps.h"
|
2023-10-23 14:12:34 -04:00
|
|
|
#include "displayapp/Controllers.h"
|
|
|
|
#include "Symbols.h"
|
2021-03-12 14:24:53 -05:00
|
|
|
|
2023-10-23 14:12:34 -04:00
|
|
|
namespace Pinetime {
|
|
|
|
namespace Applications {
|
|
|
|
namespace Screens {
|
|
|
|
|
|
|
|
enum class States { Init, Running, Halted };
|
|
|
|
|
|
|
|
struct TimeSeparated_t {
|
|
|
|
int hours;
|
|
|
|
int mins;
|
|
|
|
int secs;
|
|
|
|
int hundredths;
|
|
|
|
};
|
|
|
|
|
|
|
|
class StopWatch : public Screen {
|
|
|
|
public:
|
|
|
|
explicit StopWatch(System::SystemTask& systemTask);
|
|
|
|
~StopWatch() override;
|
|
|
|
void Refresh() override;
|
|
|
|
|
|
|
|
void playPauseBtnEventHandler();
|
|
|
|
void stopLapBtnEventHandler();
|
|
|
|
bool OnButtonPushed() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void SetInterfacePaused();
|
|
|
|
void SetInterfaceRunning();
|
|
|
|
void SetInterfaceStopped();
|
|
|
|
|
|
|
|
void Reset();
|
|
|
|
void Start();
|
|
|
|
void Pause();
|
|
|
|
|
|
|
|
Pinetime::System::SystemTask& systemTask;
|
|
|
|
States currentState = States::Init;
|
|
|
|
TickType_t startTime;
|
|
|
|
TickType_t oldTimeElapsed = 0;
|
|
|
|
TickType_t blinkTime = 0;
|
|
|
|
static constexpr int maxLapCount = 20;
|
|
|
|
TickType_t laps[maxLapCount + 1];
|
|
|
|
static constexpr int displayedLaps = 2;
|
|
|
|
int lapsDone = 0;
|
|
|
|
lv_obj_t *time, *msecTime, *btnPlayPause, *btnStopLap, *txtPlayPause, *txtStopLap;
|
|
|
|
lv_obj_t* lapText;
|
|
|
|
bool isHoursLabelUpdated = false;
|
|
|
|
|
|
|
|
lv_task_t* taskRefresh;
|
|
|
|
};
|
|
|
|
}
|
2023-11-01 16:06:26 -04:00
|
|
|
|
2023-10-23 14:12:34 -04:00
|
|
|
template <>
|
|
|
|
struct AppTraits<Apps::StopWatch> {
|
|
|
|
static constexpr Apps app = Apps::StopWatch;
|
|
|
|
static constexpr const char* icon = Screens::Symbols::stopWatch;
|
2023-11-01 16:06:26 -04:00
|
|
|
|
2023-10-23 14:12:34 -04:00
|
|
|
static Screens::Screen* Create(AppControllers& controllers) {
|
|
|
|
return new Screens::StopWatch(*controllers.systemTask);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
2021-03-15 16:35:36 -04:00
|
|
|
}
|