Skip to content

Commit

Permalink
Force an update of CCs on config request.
Browse files Browse the repository at this point in the history
When we get a config request over sysex, force a midi write
in 1s time.
  • Loading branch information
infovore committed Apr 3, 2023
1 parent 8a8cda5 commit 09f4929
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions firmware/16n_faderbank_firmware/16n_faderbank_firmware.ino
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ const int adcResolutionBits = 13; // 13 bit ADC resolution on Teensy 3.2
int faderMin;
int faderMax;

bool shouldSendForcedControlUpdate = false;
int sendForcedControlAt;

// variables for i2c master mode
// memory of the last unshifted value
int lastValue[channelCount];
Expand Down Expand Up @@ -314,6 +317,16 @@ void loop()
}
}

if(shouldSendForcedControlUpdate && (millis() > sendForcedControlAt)) {
// it's now time to send a forced control update, so...

// disable this
shouldSendForcedControlUpdate = false;

// this will force a write the next time the midiWrite callback fires.
forceMidiWrite = true;
}

// read loop using the i counter
for (int i = 0; i < channelCount; i++)
{
Expand Down
5 changes: 5 additions & 0 deletions firmware/16n_faderbank_firmware/sysex.ino
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ void processIncomingSysex(byte* sysexData, unsigned size) {
// 1F = "1nFo" - please send me your current config
D(Serial.println("Got an 1nFo request"));
sendCurrentState();

// also, in 1s time, please send the current state
// of the controls, so the editor looks nice.
shouldSendForcedControlUpdate = true;
sendForcedControlAt = millis() + 1000;
break;
case 0x0e:
// 0E - c0nfig Edit - here is a new config
Expand Down

0 comments on commit 09f4929

Please sign in to comment.