LCOV - code coverage report
Current view: top level - src/AH/Hardware - IncrementButton.cpp (source / functions) Hit Total Coverage
Test: 90a1b9beff85a60dc6ebcea034a947a845e56960 Lines: 18 18 100.0 %
Date: 2019-11-30 15:53:32 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14-5-g4ff2ed6