Stopwatch completed. Ready for PR

This commit is contained in:
panky-codes
2021-03-13 14:38:18 +01:00
parent 5d57b9054a
commit 02824d0671
5 changed files with 75 additions and 55 deletions

View File

@@ -60,8 +60,8 @@ std::unique_ptr<Screen> ApplicationList::CreateScreen2() {
{Symbols::asterisk, Apps::Meter},
{Symbols::paintbrush, Apps::Paint},
{Symbols::info, Apps::Notifications},
//TODO: Change it back
{Symbols::paddle, Apps::StopWatch},
//TODO: Need to find the right place based on comments from JF
{Symbols::stopWatch, Apps::StopWatch},
{"2", Apps::Twos}
}
};

View File

@@ -108,8 +108,7 @@ bool StopWatch::Refresh() {
lv_obj_set_event_cb(btnStopLap, stop_lap_event_handler);
lv_obj_align(btnStopLap, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 0);
txtStopLap = lv_label_create(btnStopLap, nullptr);
// TODO: Change to Lap symbol
lv_label_set_text(txtStopLap, Symbols::shoe);
lv_label_set_text(txtStopLap, Symbols::lapsFlag);
startTime = xTaskGetTickCount();
currentState = States::RUNNING;
@@ -118,8 +117,7 @@ bool StopWatch::Refresh() {
}
case States::RUNNING: {
lv_label_set_text(txtPlayPause, Symbols::pause);
// TODO: Change to Lap symbol
lv_label_set_text(txtStopLap, Symbols::shoe);
lv_label_set_text(txtStopLap, Symbols::lapsFlag);
const auto timeElapsed = calculateDelta(startTime, xTaskGetTickCount());
currentTimeSeparated = convertTicksToTimeSegments((oldTimeElapsed + timeElapsed));
@@ -149,8 +147,7 @@ bool StopWatch::Refresh() {
}
case States::HALTED: {
lv_label_set_text(txtPlayPause, Symbols::play);
// TODO: Change to stop button
lv_label_set_text(txtStopLap, Symbols::stepBackward);
lv_label_set_text(txtStopLap, Symbols::stop);
if (currentEvent == Events::PLAY) {
startTime = xTaskGetTickCount();
@@ -171,13 +168,6 @@ bool StopWatch::OnButtonPushed() {
return true;
}
bool StopWatch::OnTouchEvent(uint16_t x, uint16_t y) {
if (y < 60) {
playPauseBtnEventHandler(LV_EVENT_CLICKED);
}
return true;
}
void StopWatch::playPauseBtnEventHandler(lv_event_t event) {
if (event == LV_EVENT_CLICKED) {
if (currentState == States::INIT) {

View File

@@ -36,6 +36,9 @@ namespace Pinetime {
static constexpr const char* stepBackward = "\xEF\x81\x88";
static constexpr const char* play = "\xEF\x81\x8B";
static constexpr const char* pause = "\xEF\x81\x8C";
static constexpr const char* stop = "\xEF\x81\x8D";
static constexpr const char* stopWatch = "\xEF\x8B\xB2";
static constexpr const char* lapsFlag = "\xEF\x80\xA4";
}
}
}