Core features possibly done

This commit is contained in:
Aadi Desai 2022-03-25 17:16:43 +00:00
parent a9c40e69f0
commit 3c8c3def94
No known key found for this signature in database
GPG key ID: CFFFE425830EF4D9
3 changed files with 42 additions and 11 deletions

View file

@ -19,6 +19,7 @@ class Knob {
int getRotation();
void updateRotation(bool ANew, bool BNew);
void setRotation(int newRotation);
void changeLimitsVolume(int newMinimum, int newMaximum);
};

View file

@ -14,6 +14,11 @@ int Knob::getRotation() {
return Knob::rotation;
};
void Knob::setRotation(int newRotation) {
rotation = newRotation;
rotationInternal = newRotation;
};
void Knob::updateRotation(bool ANew, bool BNew) {
if (A == ANew && B == BNew)
return; // No change, do not update values
@ -79,7 +84,8 @@ void Knob::changeLimitsVolume(int newMinimum, int newMaximum) {
rotation = rotation << 1;
} else if (newMaximum < maximum) {
rotation = rotation >> 1;
}else{}
} else {
}
minimum = newMinimum;
maximum = newMaximum;
};

View file

@ -182,6 +182,7 @@ void CAN_RX_ISR() {
uint8_t ISR_RX_Message[8];
uint32_t ISR_rxID;
CAN_RX(ISR_rxID, ISR_RX_Message);
if (isMainSynth)
xQueueSendFromISR(msgInQ, ISR_RX_Message, nullptr);
}
@ -193,12 +194,15 @@ void decodeTask(void *pvParameters) {
activeNotes[(RX_Message[1] - 1) * 12 + RX_Message[2]] = true;
latestKey = (RX_Message[1] - 1) * 12 + RX_Message[2];
currentStepSize = stepSizes[latestKey];
} else { // Released
} else if (RX_Message[0] == 0x52) { // Released
activeNotes[(RX_Message[1] - 1) * 12 + RX_Message[2]] = false;
if (latestKey == (RX_Message[1] - 1) * 12 + RX_Message[2]) {
latestKey = 0;
currentStepSize = stepSizes[latestKey]; // Atomic Store
}
} else if (RX_Message[0] == 0x4D) { // Main Synth Announce
isMainSynth = false;
K2.setRotation(1);
}
}
}
@ -213,6 +217,17 @@ void keyChangedSendTXMessage(uint8_t octave, uint8_t key, bool pressed) {
}
TX_Message[1] = octave;
TX_Message[2] = key;
if (isMainSynth) {
xQueueSend(msgInQ, TX_Message, 0);
} else {
CAN_TX(canID, TX_Message);
}
}
//
void announceMainSynth() {
uint8_t TX_Message[8] = {0};
TX_Message[0] = 0x4D; // "M"
CAN_TX(canID, TX_Message);
}
@ -240,6 +255,9 @@ void scanKeysTask(void *pvParameters) {
}
}
}
if (keyArray[5] & 0x1 && isMainSynth) {
announceMainSynth();
}
if (volumeFiner) {
K3.changeLimitsVolume(0, 10);
} else {
@ -294,12 +312,18 @@ void displayUpdateTask(void *pvParameters) {
// Print volume indicator above knob 3
if (!volumeFiner) {
u8g2.drawXBM(116, 22, 13, 9, volumes[volume]);
u8g2.drawXBM(112, 22, 13, 9, volumes[volume]);
} else {
u8g2.setCursor(117, 30);
u8g2.print(volume);
}
if (!isMainSynth) {
u8g2.drawHLine(1, 6, 26);
u8g2.drawHLine(36, 26, 18);
u8g2.drawHLine(110, 26, 16);
}
u8g2.sendBuffer(); // transfer internal memory to the display
digitalToggle(LED_BUILTIN); // Toggle LED to show display update rate
}
@ -340,7 +364,7 @@ void setup() {
#pragma endregion
#pragma region CAN Setup
msgInQ = xQueueCreate(36, 8);
CAN_Init(true);
CAN_Init(false);
setCANFilter(0x123, 0x7ff);
CAN_RegisterRX_ISR(CAN_RX_ISR);
CAN_Start();