LCOV - code coverage report
Current view: top level - src/Hardware - IncrementButton.cpp (source / functions) Hit Total Coverage
Test: 19d2efc7037c2e176feca44750a12594c76f466f Lines: 9 17 52.9 %
Date: 2019-11-24 14:50:27 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #include "IncrementButton.hpp"
       2             : 
       3             : BEGIN_CS_NAMESPACE
       4             : 
       5          12 : IncrementButton::State IncrementButton::updateImplementation() {
       6          12 :     Button::State incrState = button.update();
       7             : 
       8          12 :     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          12 :     } else if (incrState == Button::Rising) {
      14           4 :         longPressState = Initial;
      15          10 :     } else if (incrState == Button::Falling) {
      16           6 :         return Increment;
      17             :     } else { // if (incrState == Button::Pressed)
      18           0 :         if (longPressState == LongPress) {
      19             :             // still long pressed
      20           0 :             if (millis() - longPressRepeat >= LONG_PRESS_REPEAT_DELAY) {
      21           0 :                 longPressRepeat += LONG_PRESS_REPEAT_DELAY;
      22           0 :                 return Increment;
      23             :             }
      24           0 :         } else if (button.stableTime() >= LONG_PRESS_DELAY) {
      25             :             // long press starts
      26           0 :             longPressState = LongPress;
      27           0 :             longPressRepeat = millis();
      28           0 :             return Increment;
      29             :         }
      30             :     }
      31           6 :     return Nothing;
      32          12 : }
      33             : 
      34             : END_CS_NAMESPACE

Generated by: LCOV version 1.14-5-g4ff2ed6