Improve stopwatch (#432)

* Improve stopwatch more

* Make sure sleep gets reenabled

* Cleanup and clang-format
This commit is contained in:
Riku Isokoski
2021-07-04 21:23:03 +03:00
committed by GitHub
parent ab59b9b830
commit 61a4642221
3 changed files with 94 additions and 119 deletions

View File

@@ -8,13 +8,12 @@
#include "portmacro_cmsis.h"
#include <array>
#include "systemtask/SystemTask.h"
namespace Pinetime::Applications::Screens {
enum class States { Init, Running, Halted };
enum class Events { Play, Pause, Stop };
struct TimeSeparated_t {
int mins;
int secs;
@@ -63,23 +62,28 @@ namespace Pinetime::Applications::Screens {
class StopWatch : public Screen {
public:
StopWatch(DisplayApp* app);
StopWatch(DisplayApp* app, System::SystemTask& systemTask);
~StopWatch() override;
bool Refresh() override;
void playPauseBtnEventHandler(lv_event_t event);
void stopLapBtnEventHandler(lv_event_t event);
bool OnButtonPushed() override;
void reset();
void start();
void pause();
private:
Pinetime::System::SystemTask& systemTask;
TickType_t timeElapsed;
bool running;
States currentState;
Events currentEvent;
TickType_t startTime;
TickType_t oldTimeElapsed;
TimeSeparated_t currentTimeSeparated; // Holds Mins, Secs, millisecs
LapTextBuffer_t<2> lapBuffer;
int lapNr;
bool lapPressed;
int lapNr = 0;
lv_obj_t *time, *msecTime, *btnPlayPause, *btnStopLap, *txtPlayPause, *txtStopLap;
lv_obj_t *lapOneText, *lapTwoText;
};