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