TODO relay handling

master
unicod 3 years ago
parent 8fd7e19933
commit 2011259079

@ -63,6 +63,13 @@ const uint8_t pinGndChOn2 = 10;
const uint8_t pinLedChOn2 = 11;
const uint8_t pinBtnChOn2 = 12;
/***************************************************************************//**
* @brief Relay
*******************************************************************************/
const uint8_t pinRelay1 = 13;
const uint8_t pinRelay2 = A7;
TimedPin RelayMute(pinRelay2);
/***************************************************************************//**
* @brief LED
*******************************************************************************/
@ -80,7 +87,7 @@ bool MidiCfgTxOnly; /// duplex or only tx configuration (without MIDI rx lin
MixerMuteState AirMutes[2] = {
MixerMuteState(22, &LedChOn1, BTN_CH_ON1, EV_UI_RX_MUTE_CH1_ON, EV_UI_RX_MUTE_CH1_OFF),
MixerMuteState(23, &LedChOn2, BTN_CH_ON2, EV_UI_RX_MUTE_CH2_ON, EV_UI_RX_MUTE_CH2_OFF)
MixerMuteStateRly(23, &LedChOn2, &RelayMute, BTN_CH_ON2, EV_UI_RX_MUTE_CH2_ON, EV_UI_RX_MUTE_CH2_OFF)
};
MixerFaderState AirFaders[2] = {
@ -133,11 +140,16 @@ void setup() {
pinMode(pinBtnChOn1, INPUT_PULLUP);
pinMode(pinBtnChOn2, INPUT_PULLUP);
pinMode(pinRelay1, OUTPUT);
pinMode(pinRelay2, OUTPUT);
pinMode(pinGndDec1, OUTPUT);
pinMode(pinGndInc2, OUTPUT);
pinMode(pinGndDec2, OUTPUT);
pinMode(pinGndChOn1, OUTPUT);
pinMode(pinGndChOn2, OUTPUT);
digitalWrite(pinRelay1, LOW);
digitalWrite(pinRelay2, LOW);
digitalWrite(pinGndDec1, LOW);
digitalWrite(pinGndInc2, LOW);
digitalWrite(pinGndDec2, LOW);
@ -151,6 +163,7 @@ void setup() {
LedDec1.begin();
LedInc2.begin();
LedDec2.begin();
RelayMute.begin();
MIDI.setHandleControlChange(MidiCCHandler);
MIDI.begin(MIDI_CHANNEL_OMNI); // Initiate MIDI communications, listen to all channels
@ -212,6 +225,7 @@ void loop() {
LedDec1.update();
LedInc2.update();
LedDec2.update();
RelayMute.update();
}
// execute every 100ms ******************************************************
if (Tmr100ms.Check(t)) {

@ -170,11 +170,7 @@ void UiSt_Home(UI_SM* const me, uint16_t event) {
for (uint_fast8_t i=0; i<ELEMCNT(AirMutes); i++) {
MixerMuteState& mute = AirMutes[i];
if (btn == mute.UiButton) {
mute.MuteLocal = !mute.MuteLocal;
uint16_t t_on = 950;
uint16_t t_off = 50;
if (mute.MuteLocal) { t_on = 50; t_off = 950; }
mute.Led->Blink(t_on, t_off);
mute.ToggleState();
MIDI.sendControlChange(mute.MidiCtrlNr, mute.MuteLocal ? 127 : 0, 2);
}
}

18
ui.h

@ -63,6 +63,24 @@ struct MixerMuteState {
MixerMuteState(uint8_t ctrl_nr, TimedPin* led, BTN_CODES button = BTN_MAX, uint16_t uieventon = EV_NO_EVENT, uint16_t uieventoff = EV_NO_EVENT) :
MuteMixer(false), MuteLocal(false), MidiCtrlNr(ctrl_nr), UiButton(button), UiEventOn(uieventon), UiEventOff(uieventoff), Led(led) { }
void ToggleState() {
MuteLocal = !MuteLocal;
uint16_t t_on = 950;
uint16_t t_off = 50;
if (MuteLocal) { t_on = 50; t_off = 950; }
Led->Blink(t_on, t_off);
}
};
struct MixerMuteStateRly : MixerMuteState {
MixerMuteStateRly(uint8_t ctrl_nr, TimedPin* led, TimedPin* relay, BTN_CODES button = BTN_MAX, uint16_t uieventon = EV_NO_EVENT, uint16_t uieventoff = EV_NO_EVENT) :
MixerMuteState(ctrl_nr, led, button, uieventon, uieventoff), Relay(relay) { }
void ToggleState() {
MixerMuteState::ToggleState();
Relay->Set(MuteLocal);
}
TimedPin* Relay;
};
/***************************************************************************//**

Loading…
Cancel
Save