Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of slider_diatonic_v1 by
Revision 4:922d6f8fe95f, committed 2015-02-25
- Comitter:
- bomalley
- Date:
- Wed Feb 25 18:28:52 2015 +0000
- Parent:
- 3:f68e9cdfaf2d
- Commit message:
- HW 7.1
Changed in this revision
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
slider_diatonic_v1.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/mbed.bld Wed Feb 18 15:27:17 2015 +0000 +++ b/mbed.bld Wed Feb 25 18:28:52 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/9ad691361fac \ No newline at end of file
--- a/slider_diatonic_v1.cpp Wed Feb 18 15:27:17 2015 +0000 +++ b/slider_diatonic_v1.cpp Wed Feb 25 18:28:52 2015 +0000 @@ -23,6 +23,13 @@ #define LEDPERIOD 0.001 //#define PRINTDEBUG +#define NUMOCTS 1 +//Button --> +#define BUTOFF 1 +#define BUTON 0 +#define BUTTON PTC3 +#define PUSHTIME 1000 //wait to check for button press + Serial pc(USBTX, USBRX); float diatonicScale[NUMTONES] = {246.94, 261.63,293.66,329.63,349.23,392.00,440.00,493.88,523.25,587.33}; @@ -41,7 +48,16 @@ float tonePeriod; float toneFreq = SIDETONE; +//Timers--> +Timer buttonTimer;//checks for button state change after set amout of time. +//buttons --> + +int LButtonState = BUTOFF; //Set the button state to off +DigitalIn LftButton(BUTTON); //PTC3 + +//Octave changer --> +int octaveState = NUMOCTS; //Not sure what value this should be void LCDMessNoDwell(char *lMess){ slcd.Home(); @@ -98,8 +114,20 @@ // Start data timer dataTimer.start(); dataTimer.reset(); - + buttonTimer.start(); //checks for button state change after set amout of time. + buttonTimer.reset(); + while (true) { + + if(buttonTimer.read_ms() > PUSHTIME) { + //check button first + LButtonState = !LftButton; //button is off or on + if(LButtonState) { + octaveState++; + octaveState = octaveState % NUMOCTS; + } + } + if (dataTimer.read_ms() > DATATIME){ // check to see if enough time has passed // to read the touch pad tempValue = tsiScaling.readPercentage(); @@ -109,7 +137,8 @@ lightAdjust(tempValue); } else { soundOut.write(TONEOFF); // set dutyfactor to 0% - LCDMessNoDwell("SOFF"); + sprintf(lcdData, "%4d", octaveState + 1); + LCDMessNoDwell("lcdData"); } dataTimer.reset(); }