LCOV - code coverage report
Current view: top level - src/MIDI_Outputs - NoteButtonMatrix.hpp (source / functions) Hit Total Coverage
Test: 3a807a259ebe0769dd942f7f612dca5273937539 Lines: 2 2 100.0 %
Date: 2024-03-24 17:16:54 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <MIDI_Outputs/Abstract/MIDIButtonMatrix.hpp>
       4             : #include <MIDI_Senders/DigitalNoteSender.hpp>
       5             : 
       6             : BEGIN_CS_NAMESPACE
       7             : 
       8             : /**
       9             :  * @brief   A class of MIDIOutputElement%s that read the input from a **matrix
      10             :  *          of momentary push buttons or switches**, and send out MIDI **Note**
      11             :  *          events.
      12             :  * 
      13             :  * A Note On event is sent when a button is pressed, and a Note Off event is 
      14             :  * sent when a button is released.  
      15             :  * Crude software debouncing is implemented by limiting the refresh rate.  
      16             :  * This version cannot be banked.  
      17             :  *
      18             :  * @ingroup MIDIOutputElements
      19             :  * 
      20             :  * @tparam  NumRows
      21             :  *          The number of rows of the matrix.
      22             :  * @tparam  NumCols
      23             :  *          The number of columns of the matrix.
      24             :  */
      25             : template <uint8_t NumRows, uint8_t NumCols>
      26             : class NoteButtonMatrix
      27             :     : public MIDIButtonMatrix<DigitalNoteSender, NumRows, NumCols> {
      28             :   public:
      29             :     /**
      30             :      * @brief   Create a new NoteButtonMatrix object with the given pins,
      31             :      *          note numbers and channel.
      32             :      *
      33             :      * @param   rowPins
      34             :      *          A list of pin numbers connected to the rows of the button
      35             :      *          matrix.  
      36             :      *          **⚠** These pins will be driven LOW as outputs (Lo-Z).
      37             :      * @param   colPins
      38             :      *          A list of pin numbers connected to the columns of the button
      39             :      *          matrix.  
      40             :      *          These pins will be used as inputs (Hi-Z), and the
      41             :      *          internal pull-up resistor will be enabled.
      42             :      * @param   notes
      43             :      *          A 2-dimensional array of the same dimensions as the button
      44             :      *          matrix that contains the note number of each button. [0, 127]
      45             :      * @param   channelCN
      46             :      *          The MIDI channel [1, 16] and Cable Number [Cable_1, Cable_16].
      47             :      * @param   velocity
      48             :      *          The velocity of the MIDI Note events.
      49             :      */
      50           2 :     NoteButtonMatrix(const PinList<NumRows> &rowPins,
      51             :                      const PinList<NumCols> &colPins,
      52             :                      const AddressMatrix<NumRows, NumCols> &notes,
      53             :                      MIDIChannelCable channelCN = {Channel_1, Cable_1},
      54             :                      uint8_t velocity = 0x7F)
      55             :         : MIDIButtonMatrix<DigitalNoteSender, NumRows, NumCols> {
      56             :               rowPins, colPins, notes, channelCN, {velocity},
      57           2 :           } {}
      58             : 
      59             :     /// Set the velocity of the MIDI Note events.
      60             :     void setVelocity(uint8_t velocity) { this->sender.setVelocity(velocity); }
      61             :     /// Get the velocity of the MIDI Note events.
      62             :     uint8_t getVelocity() const { return this->sender.getVelocity(); }
      63             : };
      64             : 
      65             : END_CS_NAMESPACE

Generated by: LCOV version 1.15