Skip to content
This repository was archived by the owner on Oct 26, 2023. It is now read-only.

Commit 4da88ad

Browse files
committed
Change the data parameter from a byte to an integer to be able to fetch things like the delay time parameter (> 2000).
1 parent 270440e commit 4da88ad

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

MS3.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class MS3 : public USBH_MIDI {
171171
/**
172172
* Check if we've received any data.
173173
*/
174-
bool receive(unsigned long &parameter, byte &dataOut) {
174+
bool receive(unsigned long &parameter, int &dataOut) {
175175
byte
176176
incoming[MIDI_EVENT_PACKET_SIZE] = {0},
177177
data[MIDI_EVENT_PACKET_SIZE] = {0},
@@ -215,9 +215,9 @@ class MS3 : public USBH_MIDI {
215215
}
216216
dataOut = (byte) data[dataLength - 3];
217217

218-
// If the data is one byte longer, add 128 to the return value for a full byte range.
219-
if (dataLength == 16 && data[dataLength - 4] == 0x01) {
220-
dataOut += 128;
218+
// If the data is one byte longer, add x times 128 to the return value for a full integer range.
219+
if (dataLength == 16) {
220+
dataOut += data[dataLength - 4] * 128;
221221
}
222222

223223
return true;
@@ -280,7 +280,7 @@ class MS3 : public USBH_MIDI {
280280
* This is the main function for both receiving and sending data when
281281
* there's nothing to receive.
282282
*/
283-
byte update(unsigned long &parameter, byte &data) {
283+
byte update(unsigned long &parameter, int &data) {
284284

285285
// Are we ready?
286286
if (MS3::isReady()) {

examples/effect_state/effect_state.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ unsigned long timerStart = 0;
5858
/**
5959
* Incoming data handler.
6060
*/
61-
void parseData(unsigned long parameter, byte data) {
61+
void parseData(unsigned long parameter, int data) {
6262
switch (parameter) {
6363

6464
// Refresh all effect states on patch changes.
@@ -206,7 +206,7 @@ void loop() {
206206

207207
// The MS-3 library stores the parameter and data in these variables.
208208
unsigned long parameter = 0;
209-
byte data = 0;
209+
int data = 0;
210210

211211
// Check for incoming data or send a queued item.
212212
switch (MS3.update(parameter, data)) {

examples/force_patch_1/force_patch_1.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const unsigned long P_PATCH = 0x00010000;
2020
/**
2121
* Incoming data handler.
2222
*/
23-
void parseData(unsigned long parameter, byte data) {
23+
void parseData(unsigned long parameter, int data) {
2424
switch (parameter) {
2525
case P_PATCH:
2626
Serial.print(F("Patch number received: "));
@@ -64,7 +64,7 @@ void loop() {
6464

6565
// Check for incoming data or send a queued item.
6666
unsigned long parameter = 0;
67-
byte data = 0;
67+
int data = 0;
6868
switch (MS3.update(parameter, data)) {
6969

7070
// Fetch the current active patch on the MS-3.

0 commit comments

Comments
 (0)