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

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <Banks/BankAddresses.hpp>
       4             : #include <MIDI_Outputs/Bankable/Abstract/MIDIButtonLatched.hpp>
       5             : #include <MIDI_Senders/DigitalNoteSender.hpp>
       6             : 
       7             : BEGIN_CS_NAMESPACE
       8             : 
       9             : namespace Bankable {
      10             : 
      11             : /**
      12             :  * @brief   A class of MIDIOutputElement%s that read the input of a **momentary
      13             :  *          push button**, and send out MIDI **Note** events.
      14             :  * 
      15             :  * It latches the input, so press once to enable, press again to disable 
      16             :  * (toggle).
      17             :  * 
      18             :  * The switch is debounced in software.  
      19             :  * This version can be banked.  
      20             :  * 
      21             :  * @tparam  NumBanks
      22             :  *          The number of banks.
      23             :  *
      24             :  * @ingroup BankableMIDIOutputElements
      25             :  */
      26             : template <uint8_t NumBanks>
      27             : class NoteButtonLatched
      28             :     : public MIDIButtonLatched<NumBanks, SingleAddress, DigitalNoteSender> {
      29             :   public:
      30             :     /**
      31             :      * @brief   Create a new bankable NoteButtonLatched object on the given pin 
      32             :      *          and with address.
      33             :      * 
      34             :      * @param   config
      35             :      *          The bank to add this element to.
      36             :      * @param   pin
      37             :      *          The digital input pin to read from.  
      38             :      *          The internal pull-up resistor will be enabled.
      39             :      * @param   address
      40             :      *          The MIDI address containing the note number [0, 127], 
      41             :      *          channel [Channel_1, Channel_16], and optional cable number 
      42             :      *          [Cable_1, Cable_16].
      43             :      * @param   velocity
      44             :      *          The velocity of the MIDI Note events.
      45             :      */
      46           1 :     NoteButtonLatched(BankConfig<NumBanks> config, pin_t pin,
      47             :                       MIDIAddress address, uint8_t velocity = 0x7F)
      48             :         : MIDIButtonLatched<NumBanks, SingleAddress, DigitalNoteSender> {
      49             :               {config, address},
      50             :               pin,
      51             :               {velocity},
      52           1 :           } {}
      53             : 
      54             :     /// Set the velocity of the MIDI Note events.
      55             :     void setVelocity(uint8_t velocity) { this->sender.setVelocity(velocity); }
      56             :     /// Get the velocity of the MIDI Note events.
      57             :     uint8_t getVelocity() const { return this->sender.getVelocity(); }
      58             : };
      59             : 
      60             : } // namespace Bankable
      61             : 
      62             : END_CS_NAMESPACE

Generated by: LCOV version 1.15