-
-
Notifications
You must be signed in to change notification settings - Fork 952
/
StopWatch.h
74 lines (60 loc) · 1.88 KB
/
StopWatch.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#pragma once
#include "displayapp/screens/Screen.h"
#include <lvgl/lvgl.h>
#include <FreeRTOS.h>
#include "portmacro_cmsis.h"
#include "systemtask/SystemTask.h"
#include "systemtask/WakeLock.h"
#include "displayapp/apps/Apps.h"
#include "displayapp/Controllers.h"
#include "Symbols.h"
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::WakeLock wakeLock;
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;
};
}
template <>
struct AppTraits<Apps::StopWatch> {
static constexpr Apps app = Apps::StopWatch;
static constexpr const char* icon = Screens::Symbols::stopWatch;
static Screens::Screen* Create(AppControllers& controllers) {
return new Screens::StopWatch(*controllers.systemTask);
};
};
}
}