Merge pull request #28 from Trasselfrisyr/wlpower

Menu option to set midibeam power level
This commit is contained in:
John Stäck 2019-07-22 12:05:00 +02:00 committed by GitHub
commit 6844341d77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 0 deletions

View file

@ -90,6 +90,8 @@ 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)

View file

@ -73,6 +73,8 @@ extern byte currentRotation;
extern uint16_t rotations[4];
extern uint16_t parallel; // semitones
extern uint16_t wlPower;
extern int touch_Thr;
extern unsigned long cursorBlinkTime; // the last time the cursor was toggled

View file

@ -501,11 +501,22 @@ const MenuEntrySub specialKeyMenu = {
, nullptr
};
const MenuEntrySub wlPowerMenu = {
MenuType::ESub, "WL POWER", "WL POWER", &wlPower, 0, 3, MenuEntryFlags::ENone,
[](SubMenuRef __unused, char* out, const char** __unused unit) {
numToString(-6*wlPower, out, true);
},
[](SubMenuRef __unused) { sendWLPower(wlPower); }
, nullptr
};
const MenuEntry* extrasMenuEntries[] = {
(MenuEntry*)&legacyPBMenu,
(MenuEntry*)&legacyBRMenu,
(MenuEntry*)&gateOpenMenu,
(MenuEntry*)&specialKeyMenu,
(MenuEntry*)&wlPowerMenu,
};
const MenuPage extrasMenuPage = {

View file

@ -140,3 +140,27 @@ void dinMIDIsendAfterTouch(uint8_t value, uint8_t ch) {
void dinMIDIsendProgramChange(uint8_t value, uint8_t ch) {
midiSend2B((0xC0 | ch), value);
}
void dinMIDIsendSysex(const uint8_t data[], const uint8_t length) {
MIDI_SERIAL.write(0xF0); //Sysex command
for(int i=0; i<length; ++i) {
MIDI_SERIAL.write(data[i]);
}
MIDI_SERIAL.write(0xF7); //Sysex end
}
void sendWLPower(const uint8_t level) {
uint8_t buf[6] = {
0x00, 0x21, 0x11, //Manufacturer id
0x02, //TX02
0x02, //Set power level
0x00 //Power level value (0-3)
};
if(level>3) return; //Don't send invalid values
buf[5] = level;
dinMIDIsendSysex(buf, 6);
}

View file

@ -28,5 +28,10 @@ void dinMIDIsendNoteOff(uint8_t note, uint8_t vel, uint8_t ch);
void dinMIDIsendAfterTouch(uint8_t value, uint8_t ch);
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);
#endif