From a3f5922478a8d8990df5573dd9bc55ad9f60edd4 Mon Sep 17 00:00:00 2001 From: unicod Date: Fri, 21 Oct 2022 22:01:08 +0200 Subject: [PATCH] Air Fader (volume) handling * LED + INC/DEC button handling --- XAirMixerControl.ino | 49 ++++++++++++++++++++++----- ui.cpp | 12 +++++++ ui.h | 81 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+), 8 deletions(-) diff --git a/XAirMixerControl.ino b/XAirMixerControl.ino index aa46430..3429eac 100644 --- a/XAirMixerControl.ino +++ b/XAirMixerControl.ino @@ -38,30 +38,46 @@ Tmr Tmr1s = { .Period = 1000 }; * @brief Button - port assignment *******************************************************************************/ const uint8_t pinBtnChOn1 = 2; -const uint8_t pinBtnChOn2 = 3; +const uint8_t pinLedChOn1 = 3; -const uint8_t pinBtnInc1 = 8; -const uint8_t pinBtnDec1 = 9; -const uint8_t pinBtnInc2 = 10; -const uint8_t pinBtnDec2 = 11; +const uint8_t pinBtnChOn2 = 4; +const uint8_t pinLedChOn2 = 5; + +const uint8_t pinBtnInc1 = 6; +const uint8_t pinLedInc1 = 7; +const uint8_t pinBtnDec1 = 8; +const uint8_t pinLedDec1 = 9; + +const uint8_t pinBtnInc2 = A0; +const uint8_t pinLedInc2 = A1; +const uint8_t pinBtnDec2 = A2; +const uint8_t pinLedDec2 = A3; /***************************************************************************//** * @brief LED *******************************************************************************/ TimedPin LedBoard(LED_BUILTIN); -TimedPin LedChOn1(A0, true); -TimedPin LedChOn2(A1, true); +TimedPin LedChOn1(pinLedChOn1, true); +TimedPin LedChOn2(pinLedChOn2, true); +TimedPin LedInc1(pinLedInc1, true); +TimedPin LedDec1(pinLedDec1, true); +TimedPin LedInc2(pinLedInc2, true); +TimedPin LedDec2(pinLedDec2, true); bool MidiCfgTxOnly; /// duplex or only tx configuration (without MIDI rx line) MixerMuteState AirMutes[2] = { - //MixerMuteState(23, &LedBoard), MixerMuteState(21, &LedChOn1, BTN_CH_ON1, EV_UI_RX_MUTE_CH1_ON, EV_UI_RX_MUTE_CH1_OFF), MixerMuteState(22, &LedChOn2, BTN_CH_ON2, EV_UI_RX_MUTE_CH2_ON, EV_UI_RX_MUTE_CH2_OFF) }; +MixerFaderState AirFaders[2] = { + MixerFaderState(0, 90, 100, 110, &LedInc1, &LedDec1, BTN_INC1, BTN_DEC1), + MixerFaderState(1, 90, 100, 110, &LedInc2, &LedDec2, BTN_INC2, BTN_DEC2) +}; + /***************************************************************************//** * @brief MIDI instance (serial port) *******************************************************************************/ @@ -69,6 +85,15 @@ MIDI_CREATE_DEFAULT_INSTANCE(); // ----------------------------------------------------------------------------- void MidiCCHandler(byte channel, byte ctrl_no, byte val) { + if (channel == 1) { // Faders: ch=1 + for (uint_fast8_t i=0; i serialMIDI; extern MIDI_NAMESPACE::MidiInterface> MIDI; extern MixerMuteState AirMutes[2]; +extern MixerFaderState AirFaders[2]; // Typedefs ==================================================================== @@ -173,6 +174,17 @@ void UiSt_Home(UI_SM* const me, uint16_t event) { MIDI.sendControlChange(mute.MidiCtrlNr, mute.MuteLocal ? 0 : 127, 2); } } + for (uint_fast8_t i=0; i FaderStd) { + t_on = 950; + t_off = 50; + } + LedInc->Blink(t_on, t_off); + + t_on = 950; + t_off = 50; + if (FaderLocal < FaderStd) { + t_on = 950; + t_off = 50; + } + LedDec->Blink(t_on, t_off); + } + void VolumeReceived(uint8_t vol) { + FaderMixer = vol; + FaderLocal = vol; + LedInc->Set((vol > FaderStd)); + LedDec->Set((vol < FaderStd)); + } + bool VolumeInc() { + if (FaderLocal < FaderMax) { + FaderLocal++; + LedUpdateVolSent(); + return true; + } + return false; + } + bool VolumeDec() { + if (FaderLocal > FaderMin) { + FaderLocal--; + LedUpdateVolSent(); + return true; + } + return false; + } +}; + extern void UI_Init();