LCOV - code coverage report
Current view: top level - src/MIDI_Outputs/Bankable - NoteButtons.hpp (source / functions) Hit Total Coverage
Test: 90a1b9beff85a60dc6ebcea034a947a845e56960 Lines: 5 5 100.0 %
Date: 2019-11-30 15:53:32 Functions: 2 3 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <MIDI_Outputs/Bankable/Abstract/MIDIButtons.hpp>
       4             : #include <MIDI_Senders/DigitalNoteSender.hpp>
       5             : 
       6             : BEGIN_CS_NAMESPACE
       7             : 
       8             : namespace Bankable {
       9             : 
      10             : /**
      11             :  * @brief   A class of MIDIOutputElement%s that read the input of a **collection 
      12             :  *          of momentary push buttons or switches**, and send out MIDI **Note** 
      13             :  *          events.
      14             :  * 
      15             :  * A Note On event is sent when a button is pressed, and a Note Off
      16             :  * event is sent when a button is released.  
      17             :  * The buttons are debounced in software.  
      18             :  * This version can be banked.
      19             :  * 
      20             :  * @tparam  NUMBER_OF_BUTTONS
      21             :  *          The number of buttons in the collection.
      22             :  *
      23             :  * @ingroup BankableMIDIOutputElements
      24             :  */
      25             : template <uint8_t NUMBER_OF_BUTTONS>
      26           1 : class NoteButtons : public MIDIButtons<DigitalNoteSender, NUMBER_OF_BUTTONS> {
      27             :   public:
      28             :     /**
      29             :      * @brief   Create a new Bankable NoteButtons object with the given pins,
      30             :      *          the given controller number and channel.
      31             :      *
      32             :      * @param   config
      33             :      *          The bank configuration to use: the bank to add this element to,
      34             :      *          and whether to change the address, channel or cable number.
      35             :      * @param   buttons
      36             :      *          An list of digital input pins with the buttons connected.  
      37             :      *          The internal pull-up resistors will be enabled.
      38             :      * @param   baseAddress
      39             :      *          The MIDI address of the first button, containing the note
      40             :      *          number [0, 127], channel [CHANNEL_1, CHANNEL_16], and optional 
      41             :      *          cable number [0, 15].
      42             :      * @param   incrementAddress
      43             :      *          The number of addresses to increment for each next button.  
      44             :      *          E.g. if `baseAddress` is 8, and `incrementAddress` is 2,
      45             :      *          then the first button will send on address 8, the second
      46             :      *          button will send on address 10, button three on address 12, etc.
      47             :      * @param   velocity
      48             :      *          The velocity of the MIDI Note events.
      49             :      */
      50           1 :     NoteButtons(const OutputBankConfig &config,
      51             :                 const Array<AH::Button, NUMBER_OF_BUTTONS> &buttons,
      52             :                 const MIDICNChannelAddress &baseAddress,
      53             :                 const RelativeMIDICNChannelAddress &incrementAddress,
      54             :                 uint8_t velocity = 0x7F)
      55           1 :         : MIDIButtons<DigitalNoteSender, NUMBER_OF_BUTTONS>{
      56           1 :               config, buttons, baseAddress, incrementAddress, {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             : } // namespace Bankable
      66             : 
      67             : END_CS_NAMESPACE

Generated by: LCOV version 1.14-5-g4ff2ed6