leds.h (1132B)
1 #pragma once 2 3 #include <array> 4 #include <functional> 5 #include <cstdint> 6 7 namespace mc68k 8 { 9 class Port; 10 } 11 namespace mqLib 12 { 13 class Leds 14 { 15 public: 16 using ChangeCallback = std::function<void()>; 17 18 enum class Led 19 { 20 // group 1 2 3 4 5 21 /* led index 0 */ Osc1, Filters2, Inst1, Global, Play, 22 /* led index 1 */ Osc2, AmpFx, Inst2, Multi, Peek, 23 /* led index 2 */ Osc3, Env1, Inst3, Edit, Multimode, 24 /* led index 3 */ MixerRouting, Env2, Inst4, Sound, Shift, 25 /* led index 4 */ Filters1, Env3, ModMatrix, LFOs, Env4, 26 Power, 27 Count 28 }; 29 30 Leds() = default; 31 bool exec(const mc68k::Port& _portF, const mc68k::Port& _portGP, const mc68k::Port& _portE); 32 33 auto getLedState(Led _led) const { return m_ledState[static_cast<uint32_t>(_led)]; } 34 35 void setChangeCallback(const ChangeCallback& _callback) 36 { 37 m_changeCallback = _callback; 38 } 39 private: 40 bool setLed(uint32_t _index, uint32_t _value); 41 bool ret(bool _changed) const; 42 43 std::array<uint32_t, static_cast<uint32_t>(Led::Count)> m_ledState; 44 uint32_t m_stateF7; 45 ChangeCallback m_changeCallback; 46 }; 47 }