LCOV - code coverage report
Current view: top level - src/AH/Hardware - IncrementButton.cpp (source / functions) Coverage Total Hit
Test: 73449d9b107c772cf65493691543348214e5d5eb Lines: 100.0 % 20 20
Test Date: 2026-06-06 17:44:35 Functions: 100.0 % 1 1
Legend: Lines:     hit not hit

            Line data    Source code
       1              : #include "IncrementButton.hpp"
       2              : 
       3              : BEGIN_AH_NAMESPACE
       4              : 
       5           16 : IncrementButton::State IncrementButton::updateImplementation() {
       6           16 :     Button::State incrState = button.update();
       7              : 
       8           16 :     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            2 :         return Nothing;
      14           14 :     } else if (incrState == Button::Rising) {
      15            4 :         auto res = longPressState == LongPress ? ReleasedLong : ReleasedShort;
      16            4 :         longPressState = Initial;
      17            4 :         return res;
      18           10 :     } else if (incrState == Button::Falling) {
      19            5 :         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 2.4-beta