aboutsummaryrefslogtreecommitdiffstats
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/stopwatch/StopWatchController.cpp8
-rw-r--r--src/components/stopwatch/StopWatchController.h14
2 files changed, 11 insertions, 11 deletions
diff --git a/src/components/stopwatch/StopWatchController.cpp b/src/components/stopwatch/StopWatchController.cpp
index 4979ee68..d21f6508 100644
--- a/src/components/stopwatch/StopWatchController.cpp
+++ b/src/components/stopwatch/StopWatchController.cpp
@@ -22,7 +22,7 @@ void StopWatchController::Clear() {
currentState = StopWatchStates::Cleared;
timeElapsedPreviously = 0;
- for (int i = 0; i < histSize; i++) {
+ for (uint8_t i = 0; i < histSize; i++) {
history[i].number = 0;
history[i].timeSinceStart = 0;
}
@@ -38,12 +38,12 @@ void StopWatchController::AddLapToHistory() {
history[0].number = ++maxLapNumber % lapNumberBoundary;
}
-int StopWatchController::GetMaxLapNumber() {
+uint16_t StopWatchController::GetMaxLapNumber() {
return maxLapNumber;
}
-std::optional<LapInfo> StopWatchController::GetLapFromHistory(int index) {
- if (index < 0 || index >= histSize || history[index].number == 0) {
+std::optional<LapInfo> StopWatchController::GetLapFromHistory(uint8_t index) {
+ if (index >= histSize || history[index].number == 0) {
return {};
}
return history[index];
diff --git a/src/components/stopwatch/StopWatchController.h b/src/components/stopwatch/StopWatchController.h
index bcc9b551..5c52cf5e 100644
--- a/src/components/stopwatch/StopWatchController.h
+++ b/src/components/stopwatch/StopWatchController.h
@@ -15,7 +15,7 @@ namespace Pinetime {
enum class StopWatchStates { Cleared, Running, Paused };
struct LapInfo {
- int number = 0; // Used to label the lap
+ uint16_t number = 0; // Used to label the lap
TickType_t timeSinceStart = 0; // Excluding pauses
};
@@ -36,10 +36,10 @@ namespace Pinetime {
void AddLapToHistory();
/// Returns maxLapNumber
- int GetMaxLapNumber();
+ uint16_t GetMaxLapNumber();
/// Indexes into lap history, with 0 being the latest lap.
- std::optional<LapInfo> GetLapFromHistory(int index);
+ std::optional<LapInfo> GetLapFromHistory(uint8_t index);
bool IsRunning();
bool IsCleared();
@@ -47,7 +47,7 @@ namespace Pinetime {
private:
// Time at which stopwatch wraps around to zero (1000 hours)
- static constexpr TickType_t elapsedTimeBoundary = (TickType_t) configTICK_RATE_HZ * 60 * 60 * 1000;
+ static constexpr TickType_t elapsedTimeBoundary = static_cast<TickType_t>(configTICK_RATE_HZ) * 60 * 60 * 1000;
// Current state of stopwatch
StopWatchStates currentState = StopWatchStates::Cleared;
// Start time of current duration
@@ -56,13 +56,13 @@ namespace Pinetime {
TickType_t timeElapsedPreviously;
// Maximum number of stored laps
- static constexpr int histSize = 4;
+ static constexpr uint8_t histSize = 4;
// Value at which lap numbers wrap around to zero
- static constexpr int lapNumberBoundary = 1000;
+ static constexpr uint16_t lapNumberBoundary = 1000;
// Lap storage
Utility::CircularBuffer<LapInfo, histSize> history;
// Highest lap number; less than lapNumberBoundary, may exceed histSize
- int maxLapNumber;
+ uint16_t maxLapNumber;
};
}
}