mirror of
https://github.com/bbswitzer/PianoProject
synced 2026-10-21 16:03:05 -04:00
sustain is now functional
This commit is contained in:
+1
-1
@@ -12,7 +12,7 @@
|
||||
#include "bluetooth.h"
|
||||
#include "main.h"
|
||||
#pragma GCC diagnostic pop
|
||||
const bool DEBUG_MODE = true;
|
||||
const bool DEBUG_MODE = false;
|
||||
|
||||
void resetAll()
|
||||
{
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
-1
@@ -51,7 +51,7 @@ void decodeBluetooth(int lengthM, uint8_t* message)
|
||||
} else if(message[index] == CONTROL_CHANGE_BYTE && message[index + 1] == SUSTAIN_DATA_BYTE)
|
||||
{
|
||||
uint8_t sustainVelocityIndex = index + 2;
|
||||
//sustain.prepareToSchedule(message[sustainVelocityIndex]);
|
||||
sustain.prepareToSchedule(message[sustainVelocityIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -90,12 +90,12 @@ void Sustain::scheduleSustain(bool state)
|
||||
|
||||
if(state)
|
||||
{
|
||||
instances++;
|
||||
if(msAndDelay - sustainOnMs >= schedule[OFF].back()) //if sustain can be scheduled with current scheduling
|
||||
{
|
||||
schedule[ACTIVATION].push_back(msAndDelay - sustainOnMs);
|
||||
schedule[ON]. push_back(msAndDelay);
|
||||
timeSinceActivation = ms;
|
||||
instances++;
|
||||
} else if(msAndDelay - sustainOffMs - sustainOnMs >= schedule[ON].back()) //if current scheduling can be modified to still schedule the sustain
|
||||
{
|
||||
schedule[ON]. push_back(msAndDelay - sustainOnMs - sustainOffMs);
|
||||
@@ -105,10 +105,11 @@ void Sustain::scheduleSustain(bool state)
|
||||
schedule[ACTIVATION].push_back(msAndDelay - sustainOnMs);
|
||||
schedule[ON]. push_back(msAndDelay);
|
||||
timeSinceActivation = ms;
|
||||
instances++;
|
||||
}
|
||||
} else if(instances > 0) //if sustain off command and sustain is not already off
|
||||
{
|
||||
instances == 0;
|
||||
instances = 0;
|
||||
if(msAndDelay - sustainOffMs >= schedule[ON].back()) //if sustain can be ideally deactivated
|
||||
{
|
||||
schedule[DEACTIVATION].push_back(msAndDelay - sustainOffMs);
|
||||
|
||||
Reference in New Issue
Block a user