LCOV - code coverage report
Current view: top level - src/MIDI_Outputs/Abstract - MIDIButtonMatrix.hpp (source / functions) Hit Total Coverage
Test: 90a1b9beff85a60dc6ebcea034a947a845e56960 Lines: 14 14 100.0 %
Date: 2019-11-30 15:53:32 Functions: 9 18 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <AH/Hardware/ButtonMatrix.hpp>
       4             : #include <Def/Def.hpp>
       5             : #include <MIDI_Outputs/Abstract/MIDIOutputElement.hpp>
       6             : 
       7             : BEGIN_CS_NAMESPACE
       8             : 
       9             : /**
      10             :  * @brief   MIDIButtonMatrix
      11             :  * @todo    Documentation.
      12             :  * @see     AH::ButtonMatrix
      13             :  */
      14             : template <class Sender, uint8_t nb_rows, uint8_t nb_cols>
      15           3 : class MIDIButtonMatrix : public MIDIOutputElement,
      16             :                          public AH::ButtonMatrix<nb_rows, nb_cols> {
      17             : 
      18             :   protected:
      19             :     /**
      20             :      * @brief
      21             :      * @todo    Documentation
      22             :      */
      23           3 :     MIDIButtonMatrix(const PinList<nb_rows> &rowPins,
      24             :                      const PinList<nb_cols> &colPins,
      25             :                      const AddressMatrix<nb_rows, nb_cols> &addresses,
      26             :                      MIDICNChannel channelCN, const Sender &sender)
      27           3 :         : AH::ButtonMatrix<nb_rows, nb_cols>(rowPins, colPins),
      28           6 :           addresses(addresses), baseChannelCN(channelCN), sender{sender} {}
      29             : 
      30             :   public:
      31           1 :     void begin() final override { AH::ButtonMatrix<nb_rows, nb_cols>::begin(); }
      32             : 
      33           2 :     void update() final override {
      34           2 :         AH::ButtonMatrix<nb_rows, nb_cols>::update();
      35           2 :     }
      36             : 
      37             :   private:
      38           2 :     void onButtonChanged(uint8_t row, uint8_t col, bool state) final override {
      39           2 :         int8_t address = addresses[row][col];
      40           2 :         if (state == LOW)
      41           1 :             sender.sendOn({address, baseChannelCN});
      42             :         else
      43           1 :             sender.sendOff({address, baseChannelCN});
      44           2 :     }
      45             : 
      46             :     AddressMatrix<nb_rows, nb_cols> addresses;
      47             :     const MIDICNChannel baseChannelCN;
      48             : 
      49             :   public:
      50             :     Sender sender;
      51             : };
      52             : 
      53             : END_CS_NAMESPACE

Generated by: LCOV version 1.14-5-g4ff2ed6