Line data Source code
1 : #pragma once 2 : 3 : #include <AH/STL/cstdint> 4 : #include <Settings/NamespaceSettings.hpp> 5 : 6 : BEGIN_CS_NAMESPACE 7 : 8 : namespace Interfaces { 9 : 10 : /// Abstract interface for MIDI input elements that receive and store a 7-bit 11 : /// value. 12 : class IValue { 13 : public: 14 : /// @name Detecting changes 15 : /// @{ 16 : 17 : /// Check if the value was updated since the last time the dirty flag was 18 : /// cleared. 19 17 : bool getDirty() const { return dirty; } 20 : /// Clear the dirty flag. 21 11 : void clearDirty() { dirty = false; } 22 : 23 : /// @} 24 : 25 : virtual uint8_t getValue() const = 0; 26 : 27 : protected: 28 : bool dirty = true; 29 : }; 30 : 31 : /// Abstract interface for MIDI input elements that receive and store a 14-bit 32 : /// value. 33 : class IValue14 { 34 : public: 35 : /// @name Detecting changes 36 : /// @{ 37 : 38 : /// Check if the value was updated since the last time the dirty flag was 39 : /// cleared. 40 : bool getDirty() const { return dirty; } 41 : /// Clear the dirty flag. 42 : void clearDirty() { dirty = false; } 43 : 44 : /// @} 45 : 46 : virtual uint16_t getValue() const = 0; 47 : 48 : protected: 49 : bool dirty = true; 50 : }; 51 : 52 : namespace MCU { 53 : 54 : class IVPot { 55 : public: 56 : /// @name Detecting changes 57 : /// @{ 58 : 59 : /// Check if the value was updated since the last time the dirty flag was 60 : /// cleared. 61 : bool getDirty() const { return dirty; } 62 : /// Clear the dirty flag. 63 : void clearDirty() { dirty = false; } 64 : 65 : /// @} 66 : 67 : virtual bool getCenterLed() const = 0; 68 : virtual uint8_t getStartOn() const = 0; 69 : virtual uint8_t getStartOff() const = 0; 70 : 71 : protected: 72 : bool dirty = true; 73 : }; 74 : 75 : /** 76 : * @brief An abstract interface for VU meters. To allow for both floating 77 : * point values and integers, all values are integers under the hood. 78 : * 79 : * Using floats instead integers would be a strange choice as LED bar VU meters 80 : * have discrete levels. 81 : * Continuous "analog" VU meters can use or override the `getFloatValue()` 82 : * method. 83 : */ 84 : class IVU { 85 : public: 86 12 : IVU(uint8_t max, bool alwaysDirty = false) 87 12 : : max(max), alwaysDirty(alwaysDirty) {} 88 : 89 : /// @name Detecting changes 90 : /// @{ 91 : 92 : /// Check if the value was updated since the last time the dirty flag was 93 : /// cleared. 94 : bool getDirty() const { return dirty; } 95 : /// Clear the dirty flag. 96 : void clearDirty() { dirty = alwaysDirty; } 97 : 98 : /// @} 99 : 100 : /// Return the VU meter value as an integer. 101 : virtual uint8_t getValue() = 0; 102 : /// Return the overload status. 103 : virtual bool getOverload() = 0; 104 : /// Get the VU meter value as a floating point number. 105 1 : virtual float getFloatValue() { return (float)getValue() / getMax(); } 106 : /// Get the maximum value that this VU meter can return. 107 1 : uint8_t getMax() const { return max; } 108 : 109 : protected: 110 : uint8_t max; 111 : bool alwaysDirty; 112 : bool dirty = true; 113 : }; 114 : 115 : } // namespace MCU 116 : 117 : } // namespace Interfaces 118 : 119 : END_CS_NAMESPACE