From 71b31c78fbe5393705f1cf27423e36aed07a5be4 Mon Sep 17 00:00:00 2001 From: Patric Gruber Date: Sat, 31 Aug 2024 00:40:58 +0200 Subject: [PATCH] use switch case --- src/heartratetask/HeartRateTask.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/heartratetask/HeartRateTask.cpp b/src/heartratetask/HeartRateTask.cpp index f79ff6cc..fc28bb6e 100644 --- a/src/heartratetask/HeartRateTask.cpp +++ b/src/heartratetask/HeartRateTask.cpp @@ -64,10 +64,18 @@ void HeartRateTask::Work() { } } - if (state == States::BackgroundWaiting) { - HandleBackgroundWaiting(); - } else if (state == States::BackgroundMeasuring || state == States::Measuring) { - HandleSensorData(&lastBpm); + switch (state) { + case States::BackgroundWaiting: + HandleBackgroundWaiting(); + break; + case States::BackgroundMeasuring: + case States::Measuring: + HandleSensorData(&lastBpm); + break; + case States::Idle: + case States::Running: + // nothing to do -> ignore + break; } } }