|
|
@ -12,8 +12,9 @@ namespace {
|
|
|
|
|
|
|
|
|
|
|
|
const int hundredths = (timeElapsedCentis % 100);
|
|
|
|
const int hundredths = (timeElapsedCentis % 100);
|
|
|
|
const int secs = (timeElapsedCentis / 100) % 60;
|
|
|
|
const int secs = (timeElapsedCentis / 100) % 60;
|
|
|
|
const int mins = (timeElapsedCentis / 100) / 60;
|
|
|
|
const int mins = ((timeElapsedCentis / 100) / 60) % 60;
|
|
|
|
return TimeSeparated_t {mins, secs, hundredths};
|
|
|
|
const int hours = ((timeElapsedCentis / 100) / 60) / 60;
|
|
|
|
|
|
|
|
return TimeSeparated_t {hours, mins, secs, hundredths};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void play_pause_event_handler(lv_obj_t* obj, lv_event_t event) {
|
|
|
|
void play_pause_event_handler(lv_obj_t* obj, lv_event_t event) {
|
|
|
@ -110,6 +111,12 @@ void StopWatch::SetInterfaceStopped() {
|
|
|
|
lv_label_set_text_static(time, "00:00");
|
|
|
|
lv_label_set_text_static(time, "00:00");
|
|
|
|
lv_label_set_text_static(msecTime, "00");
|
|
|
|
lv_label_set_text_static(msecTime, "00");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isHoursLabelUpdated) {
|
|
|
|
|
|
|
|
lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
|
|
|
|
|
|
|
|
lv_obj_realign(time);
|
|
|
|
|
|
|
|
isHoursLabelUpdated = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lv_label_set_text_static(lapText, "");
|
|
|
|
lv_label_set_text_static(lapText, "");
|
|
|
|
lv_label_set_text_static(txtPlayPause, Symbols::play);
|
|
|
|
lv_label_set_text_static(txtPlayPause, Symbols::play);
|
|
|
|
lv_label_set_text_static(txtStopLap, Symbols::lapsFlag);
|
|
|
|
lv_label_set_text_static(txtStopLap, Symbols::lapsFlag);
|
|
|
@ -146,7 +153,16 @@ void StopWatch::Refresh() {
|
|
|
|
laps[lapsDone] = oldTimeElapsed + xTaskGetTickCount() - startTime;
|
|
|
|
laps[lapsDone] = oldTimeElapsed + xTaskGetTickCount() - startTime;
|
|
|
|
|
|
|
|
|
|
|
|
TimeSeparated_t currentTimeSeparated = convertTicksToTimeSegments(laps[lapsDone]);
|
|
|
|
TimeSeparated_t currentTimeSeparated = convertTicksToTimeSegments(laps[lapsDone]);
|
|
|
|
lv_label_set_text_fmt(time, "%02d:%02d", currentTimeSeparated.mins, currentTimeSeparated.secs);
|
|
|
|
if (currentTimeSeparated.hours == 0) {
|
|
|
|
|
|
|
|
lv_label_set_text_fmt(time, "%02d:%02d", currentTimeSeparated.mins, currentTimeSeparated.secs);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
lv_label_set_text_fmt(time, "%02d:%02d:%02d", currentTimeSeparated.hours, currentTimeSeparated.mins, currentTimeSeparated.secs);
|
|
|
|
|
|
|
|
if (!isHoursLabelUpdated) {
|
|
|
|
|
|
|
|
lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
|
|
|
|
|
|
|
|
lv_obj_realign(time);
|
|
|
|
|
|
|
|
isHoursLabelUpdated = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
lv_label_set_text_fmt(msecTime, "%02d", currentTimeSeparated.hundredths);
|
|
|
|
lv_label_set_text_fmt(msecTime, "%02d", currentTimeSeparated.hundredths);
|
|
|
|
} else if (currentState == States::Halted) {
|
|
|
|
} else if (currentState == States::Halted) {
|
|
|
|
const TickType_t currentTime = xTaskGetTickCount();
|
|
|
|
const TickType_t currentTime = xTaskGetTickCount();
|
|
|
@ -183,7 +199,11 @@ void StopWatch::stopLapBtnEventHandler() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TimeSeparated_t times = convertTicksToTimeSegments(laps[i]);
|
|
|
|
TimeSeparated_t times = convertTicksToTimeSegments(laps[i]);
|
|
|
|
char buffer[16];
|
|
|
|
char buffer[16];
|
|
|
|
sprintf(buffer, "#%2d %2d:%02d.%02d\n", i + 1, times.mins, times.secs, times.hundredths);
|
|
|
|
if (times.hours == 0) {
|
|
|
|
|
|
|
|
sprintf(buffer, "#%2d %2d:%02d.%02d\n", i + 1, times.mins, times.secs, times.hundredths);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
sprintf(buffer, "#%2d %2d:%02d:%02d.%02d\n", i + 1, times.hours, times.mins, times.secs, times.hundredths);
|
|
|
|
|
|
|
|
}
|
|
|
|
lv_label_ins_text(lapText, LV_LABEL_POS_LAST, buffer);
|
|
|
|
lv_label_ins_text(lapText, LV_LABEL_POS_LAST, buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (currentState == States::Halted) {
|
|
|
|
} else if (currentState == States::Halted) {
|
|
|
|