2021-03-11 04:54:14 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Screen.h"
|
|
|
|
#include "components/datetime/DateTimeController.h"
|
|
|
|
#include "../LittleVgl.h"
|
|
|
|
|
2021-03-11 05:56:58 -05:00
|
|
|
#include "FreeRTOS.h"
|
|
|
|
#include "portmacro_cmsis.h"
|
2021-03-11 04:54:14 -05:00
|
|
|
|
|
|
|
namespace Pinetime::Applications::Screens {
|
|
|
|
|
|
|
|
enum class States { INIT, RUNNING, HALTED };
|
|
|
|
|
|
|
|
enum class Events { PLAY, PAUSE, STOP };
|
|
|
|
|
2021-03-12 03:43:13 -05:00
|
|
|
struct TimeSeparated_t {
|
|
|
|
int mins;
|
|
|
|
int secs;
|
|
|
|
int msecs;
|
|
|
|
};
|
|
|
|
|
2021-03-11 04:54:14 -05:00
|
|
|
class StopWatch : public Screen {
|
|
|
|
public:
|
|
|
|
StopWatch(DisplayApp* app, const Pinetime::Controllers::DateTime& dateTime);
|
|
|
|
~StopWatch() override;
|
|
|
|
bool Refresh() override;
|
|
|
|
bool OnButtonPushed() override;
|
|
|
|
bool OnTouchEvent(uint16_t x, uint16_t y) override;
|
2021-03-11 17:41:24 -05:00
|
|
|
void playPauseBtnEventHandler(lv_event_t event);
|
2021-03-12 03:43:13 -05:00
|
|
|
void stopLapBtnEventHandler(lv_event_t event);
|
2021-03-11 04:54:14 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
const Pinetime::Controllers::DateTime& dateTime;
|
|
|
|
bool running;
|
|
|
|
States currentState;
|
|
|
|
Events currentEvent;
|
2021-03-11 05:56:58 -05:00
|
|
|
TickType_t startTime;
|
2021-03-11 17:41:24 -05:00
|
|
|
TickType_t oldTimeElapsed;
|
2021-03-12 03:43:13 -05:00
|
|
|
TimeSeparated_t timeSeparated; // Holds Mins, Secs, millisecs
|
|
|
|
int lapNr;
|
|
|
|
lv_obj_t *time, *msecTime, *btnPlayPause, *btnStopLap, *txtPlayPause, *txtStopLap;
|
|
|
|
lv_obj_t *lapOneText, *lapTwoText;
|
2021-03-11 04:54:14 -05:00
|
|
|
};
|
|
|
|
}
|