LCOV - code coverage report
Current view: top level - src/Selectors - IncrementSelector.hpp (source / functions) Hit Total Coverage
Test: 19d2efc7037c2e176feca44750a12594c76f466f Lines: 25 25 100.0 %
Date: 2019-11-24 14:50:27 Functions: 14 23 60.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "Selector.hpp"
       4             : #include <Hardware/IncrementButton.hpp>
       5             : 
       6             : BEGIN_CS_NAMESPACE
       7             : 
       8             : template <setting_t N, class Callback = EmptySelectorCallback>
       9           4 : class GenericIncrementSelector : public GenericSelector<N, Callback> {
      10             :     using Parent = GenericSelector<N, Callback>;
      11             : 
      12             :   public:
      13           4 :     GenericIncrementSelector(Selectable<N> &selectable,
      14             :                              const Callback &callback,
      15             :                              const IncrementButton &button,
      16             :                              Wrap wrap = Wrap::Wrap)
      17           8 :         : GenericSelector<N, Callback>{selectable, callback}, button{button},
      18          12 :           wrap{wrap} {}
      19             : 
      20           2 :     void begin() override {
      21           2 :         Parent::begin();
      22           2 :         button.begin();
      23           2 :     }
      24             : 
      25          12 :     void update() override {
      26          12 :         if (button.update() == IncrementButton::Increment)
      27           6 :             this->increment(wrap);
      28          12 :     }
      29             : 
      30             :     IncrementButton::State getButtonState() const { return button.getState(); }
      31             : 
      32             : #ifdef INDIVIDUAL_BUTTON_INVERT
      33             :     void invert() { button.invert(); }
      34             : #endif
      35             : 
      36             :   private:
      37             :     IncrementButton button;
      38             :     Wrap wrap;
      39             : };
      40             : 
      41             : // -------------------------------------------------------------------------- //
      42             : 
      43             : /**
      44             :  * @brief   Selector with one button that increments the selection.
      45             :  * 
      46             :  * @htmlonly 
      47             :  * <object type="image/svg+xml" data="../../selector-increment-LED.svg"></object>
      48             :  * @endhtmlonly
      49             :  * 
      50             :  * @ingroup Selectors 
      51             :  * 
      52             :  * @tparam  N 
      53             :  *          The number of settings.
      54             :  */
      55             : template <setting_t N>
      56           6 : class IncrementSelector : virtual public GenericIncrementSelector<N> {
      57             :   public:
      58           2 :     IncrementSelector(Selectable<N> &selectable, const IncrementButton &button,
      59             :                       Wrap wrap = Wrap::Wrap)
      60           2 :         : GenericIncrementSelector<N>{
      61           2 :               selectable,
      62             :               {},
      63           2 :               button,
      64           2 :               wrap,
      65           4 :           } {}
      66             : 
      67           1 :     IncrementSelector(Selectable<N> &selectable, const Button &button,
      68             :                       Wrap wrap = Wrap::Wrap)
      69           1 :         : GenericIncrementSelector<N>{
      70           1 :               selectable,
      71             :               {},
      72           1 :               button,
      73           1 :               wrap,
      74           2 :           } {}
      75             : };
      76             : 
      77             : END_CS_NAMESPACE

Generated by: LCOV version 1.14-5-g4ff2ed6