2021-03-11 09:54:14 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-10-13 20:08:35 +00:00
|
|
|
#include "displayapp/screens/Screen.h"
|
2022-07-22 08:01:47 +00:00
|
|
|
#include <lvgl/lvgl.h>
|
2021-03-11 09:54:14 +00:00
|
|
|
|
2022-01-24 22:03:08 +00:00
|
|
|
#include <FreeRTOS.h>
|
2021-03-11 10:56:58 +00:00
|
|
|
#include "portmacro_cmsis.h"
|
2021-03-11 09:54:14 +00:00
|
|
|
|
2021-07-04 18:23:03 +00:00
|
|
|
#include "systemtask/SystemTask.h"
|
2021-03-12 19:24:53 +00:00
|
|
|
|
2021-03-11 09:54:14 +00:00
|
|
|
namespace Pinetime::Applications::Screens {
|
|
|
|
|
2021-03-20 21:42:13 +00:00
|
|
|
enum class States { Init, Running, Halted };
|
2021-03-11 09:54:14 +00:00
|
|
|
|
2021-03-12 08:43:13 +00:00
|
|
|
struct TimeSeparated_t {
|
|
|
|
int mins;
|
|
|
|
int secs;
|
2021-04-17 21:47:53 +00:00
|
|
|
int hundredths;
|
2021-03-12 08:43:13 +00:00
|
|
|
};
|
|
|
|
|
2021-03-11 09:54:14 +00:00
|
|
|
class StopWatch : public Screen {
|
|
|
|
public:
|
2021-07-04 18:23:03 +00:00
|
|
|
StopWatch(DisplayApp* app, System::SystemTask& systemTask);
|
2021-03-11 09:54:14 +00:00
|
|
|
~StopWatch() override;
|
2021-07-19 13:26:12 +00:00
|
|
|
void Refresh() override;
|
2021-04-17 21:47:53 +00:00
|
|
|
|
2021-03-11 22:41:24 +00:00
|
|
|
void playPauseBtnEventHandler(lv_event_t event);
|
2021-03-12 08:43:13 +00:00
|
|
|
void stopLapBtnEventHandler(lv_event_t event);
|
2021-07-04 18:23:03 +00:00
|
|
|
bool OnButtonPushed() override;
|
|
|
|
|
2022-04-09 10:57:58 +00:00
|
|
|
void Reset();
|
|
|
|
void Start();
|
|
|
|
void Pause();
|
2021-03-11 09:54:14 +00:00
|
|
|
|
|
|
|
private:
|
2021-07-04 18:23:03 +00:00
|
|
|
Pinetime::System::SystemTask& systemTask;
|
2022-07-22 08:01:47 +00:00
|
|
|
States currentState = States::Init;
|
2021-03-11 10:56:58 +00:00
|
|
|
TickType_t startTime;
|
2022-07-22 08:01:47 +00:00
|
|
|
TickType_t oldTimeElapsed = 0;
|
|
|
|
static constexpr int maxLapCount = 20;
|
|
|
|
TickType_t laps[maxLapCount + 1];
|
|
|
|
static constexpr int displayedLaps = 2;
|
|
|
|
int lapsDone = 0;
|
2021-03-12 08:43:13 +00:00
|
|
|
lv_obj_t *time, *msecTime, *btnPlayPause, *btnStopLap, *txtPlayPause, *txtStopLap;
|
2022-07-22 08:01:47 +00:00
|
|
|
lv_obj_t* lapText;
|
2021-07-19 13:26:12 +00:00
|
|
|
|
|
|
|
lv_task_t* taskRefresh;
|
2021-03-11 09:54:14 +00:00
|
|
|
};
|
2021-03-15 20:35:36 +00:00
|
|
|
}
|