
Bluetooth Enabled Keyboard/Synthesizer for mbed
Dependencies: mbed 4DGL-uLCD-SE SDFileSystem mbed-rtos
Diff: main.cpp
- Revision:
- 4:406f59c6a1a6
- Parent:
- 3:3aba1d783730
- Child:
- 5:afd67e985df0
--- a/main.cpp Wed Apr 27 22:40:03 2016 +0000 +++ b/main.cpp Thu Apr 28 01:30:43 2016 +0000 @@ -98,7 +98,7 @@ while(1) { //check for a new button message ready if((keyPress == C_NOTE_KEY) && (readyFlag)){ // button Z pressed - PC.printf("Got n Z"); + PC.printf("Got a Z"); write_to_SDCard('C'); readyFlag = false; // Play note that corresponds to Z @@ -106,72 +106,108 @@ else if((keyPress == D_NOTE_KEY) && (readyFlag)){ // button X pressed PC.printf("Got an X"); write_to_SDCard('D'); + readyFlag = false; // Play note that corresponds to X } else if((keyPress == E_NOTE_KEY) && (readyFlag)){ // button C pressed // Play note that corresponds to C // Make note of which note was played in file on SD Card write_to_SDCard('E'); + readyFlag = false; } else if((keyPress == F_NOTE_KEY) && (readyFlag)){ // button V pressed // Play note that corresponds to V // Make note of which note was played in file on SD Card write_to_SDCard('F'); + readyFlag = false; } else if((keyPress == G_NOTE_KEY) && (readyFlag)){ // button B pressed // Play note that corresponds to B // Make note of which note was played in file on SD Card write_to_SDCard('G'); + readyFlag = false; } else if((keyPress == A_NOTE_KEY) && (readyFlag)){ // button N pressed // Play note that corresponds to N // Make note of which note was played in file on SD Card write_to_SDCard('A'); + readyFlag = false; } else if((keyPress == B_NOTE_KEY) && (readyFlag)){ // button M pressed // Play note that corresponds to M // Make note of which note was played in file on SD Card write_to_SDCard('B'); + readyFlag = false; } else if((keyPress == RAISE_OCTAVE_KEY) && (readyFlag)){ // button O pressed // Raise an octave + if(currentOcatve < 7) currentOctave++; } + else + printf("Cannot raise octave above 7.\r\n"); else if((keyPress == LOWER_OCTAVE_KEY) && (readyFlag)){ // button L pressed // Lower an octave + if(currentOctave > 1) currentOctave--; + else + printf("Cannot lower octave below 1.\r\n"); } else if((keyPress == RAISE_ATTACK_KEY) && (readyFlag)){ // button Q pressed // Raise Attack Value + if(currentAttackVal < 5) currentAttackVal++; + else + printf("Cannot raise value above 5.\r\n"); } else if((keyPress == LOWER_ATTACK_KEY) && (readyFlag)){ // button A pressed // Lower Attack Value + if(currentAttackVal > 1) currentAttackVal--; + else + printf("Cannot lower value below 1.\r\n"; } else if((keyPress == RAISE_DELAY_KEY) && (readyFlag)){ // button W pressed // Raise Delay Value + if(currentDelayVal < 5) currentDelayVal++; + else + printf("Cannot raise value above 5.\r\n"); } else if((keyPress == LOWER_DELAY_KEY) && (readyFlag)){ // button S pressed // Lower Delay Value + if(currentDelayVal > 1) currentDelayVal--; + else + printf("Cannot lower value below 1.\r\n"; } else if((keyPress == RAISE_SUSTAIN_KEY) && (readyFlag)){ // button E pressed // Raise Sustain Value + if(currentSustainVal < 5) currentSustainVal++; + else + printf("Cannot raise value above 5.\r\n"); } else if((keyPress == LOWER_SUSTAIN_KEY) && (readyFlag)){ // button D pressed // Lower Sustain Value + if(currentSustainVal > 1) currentSustainVal--; + else + printf("Cannot lower value below 1.\r\n"; } else if((keyPress == RAISE_RELEASE_KEY) && (readyFlag)){ // button R pressed // Raise Release Value + if(currentReleaseVal < 5) currentReleaseVal++; + else + printf("Cannot raise value above 5.\r\n"); } else if((keyPress == LOWER_RELEASE_KEY) && (readyFlag)){ // button F pressed // Lower Release Value + if(currentReleaseVal > 1) currentReleaseVal--; + else + printf("Cannot lower value below 1.\r\n"; } else if((keyPress == CHANGE_WAVESHAPE_UP) && (readyFlag)){ // button T pressed // Change waveform shape to next waveform type