LCOV - code coverage report
Current view: top level - src/AH/Hardware - IncrementButton.cpp (source / functions) Hit Total Coverage
Test: 00f463b534fbea22f0b596e091a60715679e3064 Lines: 20 20 100.0 %
Date: 2024-11-03 16:33:35 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #include "IncrementButton.hpp"
       2             : 
       3             : BEGIN_AH_NAMESPACE
       4             : 
       5          10 : IncrementButton::State IncrementButton::updateImplementation() {
       6          10 :     Button::State incrState = button.update();
       7             : 
       8          10 :     if (incrState == Button::Released) {
       9             :         // Button released, don't do anything
      10             :         // This one is first to minimize overhead
      11             :         // because most of the time, the button will
      12             :         // be released
      13           1 :         return Nothing;
      14           9 :     } else if (incrState == Button::Rising) {
      15           2 :         auto res = longPressState == LongPress ? ReleasedLong : ReleasedShort;
      16           2 :         longPressState = Initial;
      17           2 :         return res;
      18           7 :     } else if (incrState == Button::Falling) {
      19           2 :         return IncrementShort;
      20             :     } else { // if (incrState == Button::Pressed)
      21           5 :         auto now = millis();
      22           5 :         if (longPressState == LongPress) {
      23             :             // still long pressed
      24           2 :             if (now - longPressRepeat >= LONG_PRESS_REPEAT_DELAY) {
      25           1 :                 longPressRepeat += LONG_PRESS_REPEAT_DELAY;
      26           1 :                 return IncrementHold;
      27             :             }
      28           3 :         } else if (button.stableTime(now) >= LONG_PRESS_DELAY) {
      29             :             // long press starts
      30           1 :             longPressState = LongPress;
      31           1 :             longPressRepeat = now;
      32           1 :             return IncrementLong;
      33             :         }
      34             :     }
      35           3 :     return Nothing;
      36             : }
      37             : 
      38             : END_AH_NAMESPACE

Generated by: LCOV version 1.15