uint8_t noteMap[256];
uint8_t finalTouchStates=0;
void setNoteMap()
{
memset(noteMap, 0, 256);
noteMap[0b00000000] = 0; //None - ○|○○○|○○○○
noteMap[0b11111111] = 60; // C4 - ●|●●●|●●●●
noteMap[0b11111011] = 61; // C#4 - ●|●●●|●○●●
noteMap[0b11111110] = 62; // D4 - ●|●●●|●●●○
noteMap[0b11111101] = 63; // D#4 - ●|●●●|●●○●
noteMap[0b11111100] = 64; // E4 - ●|●●●|●●○○
noteMap[0b11111000] = 65; // F4 - ●|●●●|●○○○
noteMap[0b11110100] = 66; // F#4 - ●|●●●|○●○○
//noteMap[0b11110110] = 66; // F#4 - ●|●●●|○●●○
//noteMap[0b11110111] = 66; // F#4 - ●|●●●|○●●●
noteMap[0b11110000] = 67; // G4 - ●|●●●|○○○○
//noteMap[0b11110101] = 67; // G4 - ●|●●●|○●○●
noteMap[0b11101000] = 68; // G#4 - ●|●●○|●○○○
noteMap[0b11101100] = 68; // G#4 - ●|●●○|●●○○
noteMap[0b11100000] = 69; // A4 - ●|●●○|○○○○
noteMap[0b11010000] = 70; // A#4 - ●|●○●|○○○○
noteMap[0b11000000] = 71; // B4 - ●|●○○|○○○○
noteMap[0b10100000] = 72; // C5 - ●|○●○|○○○○
noteMap[0b10000000] = 73; // C#5 - ●|○○○|○○○○
noteMap[0b00100000] = 74; // D5 - ○|○●○|○○○○
noteMap[0b01111100] = 76; // E5 - ○|●●●|●●○○
noteMap[0b01111000] = 77; // F5 - ○|●●●|●○○○
noteMap[0b01110100] = 78; // F#5 - ○|●●●|○●○○
noteMap[0b01110000] = 79; // G5 - ○|●●●|○○○○
noteMap[0b01101000] = 80; // G#5 - ○|●●○|●○○○
noteMap[0b01100000] = 81; // A5 - ○|●●○|○○○○
noteMap[0b01010000] = 82; // A#5 - ○|●○●|○○○○
noteMap[0b01000000] = 83; // B5 - ○|●○○|○○○○
noteMap[0b01000001] = 254;//menu - ○|●○○|○○○●
}
uint8_t logicGetNote(uint8_t touchState)
{
uint8_t k;
for (k=touchState; k >= 0; k--)
{ if (noteMap[k]== 0)
{Serial.println("k:"+ String(k));}
else {Serial.println(k,BIN); break;}
}
return noteMap[k];
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
setNoteMap();
delay(1000);
Serial.println(logicGetNote(0b11110101));
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}