From def0dcacd0b4bde3fc426fac0f6bb634fa0b6cb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20St=C3=A4ck?= Date: Tue, 23 Jul 2019 10:32:33 +0200 Subject: [PATCH] Remove global var for wireless power, add wl channel menu --- NuEVI/NuEVI.ino | 4 +--- NuEVI/globals.h | 1 - NuEVI/menu.cpp | 21 ++++++++++++++++++--- NuEVI/midi.cpp | 18 +++++++++++++++++- NuEVI/midi.h | 3 +-- 5 files changed, 37 insertions(+), 10 deletions(-) diff --git a/NuEVI/NuEVI.ino b/NuEVI/NuEVI.ino index 02c5260..a3cffbb 100644 --- a/NuEVI/NuEVI.ino +++ b/NuEVI/NuEVI.ino @@ -95,8 +95,6 @@ uint16_t gateOpenEnable = 0; uint16_t specialKeyEnable = 0; -uint16_t wlPower = 0; - int touch_Thr = 1300; byte ccList[11] = {0,1,2,7,11,1,2,7,11,74,20}; // OFF, Modulation, Breath, Volume, Expression (then same sent in hires), CC74 (cutoff/brightness), CC20 (UNO Cutoff) @@ -726,7 +724,7 @@ void loop() { } analogWrite(dacPin,constrain(cvPitch+map(pitchBend,0,16383,-84,84),0,4095)); analogWrite(pwmDacPin,breathCurve(map(constrain(pressureSensor,breathThrVal,breathMaxVal),breathThrVal,breathMaxVal,500,4095))); //starting at 0.6V to match use of cv from sensor, so recalibration of cv offset/scaler is not needed - else if(dacMode == DAC_MODE_BREATH) { // else breath CV on DAC pin, directly to unused pin of MIDI DIN jack + } else if(dacMode == DAC_MODE_BREATH) { // else breath CV on DAC pin, directly to unused pin of MIDI DIN jack analogWrite(dacPin,breathCurve(map(constrain(pressureSensor,breathThrVal,breathMaxVal),breathThrVal,breathMaxVal,0,4095))); } diff --git a/NuEVI/globals.h b/NuEVI/globals.h index 5d1954a..4cb0a8b 100644 --- a/NuEVI/globals.h +++ b/NuEVI/globals.h @@ -78,7 +78,6 @@ extern uint16_t trill3_interval; extern uint16_t fastBoot; extern uint16_t dacMode; -extern uint16_t wlPower; extern int touch_Thr; diff --git a/NuEVI/menu.cpp b/NuEVI/menu.cpp index c2a058b..1f908a8 100644 --- a/NuEVI/menu.cpp +++ b/NuEVI/menu.cpp @@ -530,15 +530,29 @@ const MenuEntrySub fastBootMenu = { , nullptr }; + +static uint16_t wireless_power=0; +static uint16_t wireless_channel=4; + const MenuEntrySub wlPowerMenu = { - MenuType::ESub, "WL POWER", "WL POWER", &wlPower, 0, 3, MenuEntryFlags::ENone, + MenuType::ESub, "WL POWER", "WL POWER", &wireless_power, 0, 3, MenuEntryFlags::ENone, [](SubMenuRef __unused, char* out, const char** __unused unit) { - numToString(-6*wlPower, out, true); + numToString(-6*wireless_power, out, true); }, - [](SubMenuRef __unused) { sendWLPower(wlPower); } + [](SubMenuRef __unused) { sendWLPower(wireless_power); } , nullptr }; +const MenuEntrySub wlChannelMenu = { + MenuType::ESub, "WL CHAN", "WL CHAN", &wireless_channel, 4, 80, MenuEntryFlags::ENone, + [](SubMenuRef __unused, char* out, const char** __unused unit) { + numToString(wireless_channel, out, false); + }, + [](SubMenuRef __unused) { sendWLChannel(wireless_channel); } + , nullptr +}; + + const MenuEntry* extrasMenuEntries[] = { (MenuEntry*)&legacyPBMenu, (MenuEntry*)&legacyBRMenu, @@ -549,6 +563,7 @@ const MenuEntry* extrasMenuEntries[] = { (MenuEntry*)&dacModeMenu, (MenuEntry*)&fastBootMenu, (MenuEntry*)&wlPowerMenu, + (MenuEntry*)&wlChannelMenu, }; const MenuPage extrasMenuPage = { diff --git a/NuEVI/midi.cpp b/NuEVI/midi.cpp index 8a49feb..56e8d74 100644 --- a/NuEVI/midi.cpp +++ b/NuEVI/midi.cpp @@ -163,4 +163,20 @@ void sendWLPower(const uint8_t level) { buf[5] = level; dinMIDIsendSysex(buf, 6); -} \ No newline at end of file +} + + +void sendWLChannel(const uint8_t channel) { + uint8_t buf[6] = { + 0x00, 0x21, 0x11, //Manufacturer id + 0x02, //TX02 + 0x05, //Set channel + 0x04 //Channel value (4-80) + }; + + if(channel<4 || channel>80) return; //Don't send invalid values + + buf[5] = channel; + dinMIDIsendSysex(buf, 6); + +} diff --git a/NuEVI/midi.h b/NuEVI/midi.h index 2b2e85f..800d1db 100644 --- a/NuEVI/midi.h +++ b/NuEVI/midi.h @@ -30,8 +30,7 @@ void dinMIDIsendProgramChange(uint8_t value, uint8_t ch); void dinMIDIsendPitchBend(uint16_t pb, uint8_t ch); void dinMIDIsendSysex(const uint8_t data[], const uint8_t length); - - void sendWLPower(const uint8_t level); +void sendWLChannel(const uint8_t channel); #endif