Works to change an octave higher ONLY when you hold down the button_need to figure out how to CHANGE with toggling with button

Dependencies:   SLCD TSI mbed

Fork of slider_diatonic_v1 by Stanley Cohen

Files at this revision

API Documentation at this revision

Comitter:
destradafilm
Date:
Mon Feb 23 04:49:39 2015 +0000
Parent:
3:f68e9cdfaf2d
Commit message:
slider_diatonic_changing Octaves

Changed in this revision

slider_diatonic_v1.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/slider_diatonic_v1.cpp	Wed Feb 18 15:27:17 2015 +0000
+++ b/slider_diatonic_v1.cpp	Mon Feb 23 04:49:39 2015 +0000
@@ -26,10 +26,14 @@
 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};
+float diatonicScale2[NUMTONES] ={493.88, 523.25,587.33,659.25,698.46,783.99,880.00,987.77,1046.50,1174.66};
 SLCD slcd; //define LCD display
 
 TSISensor tsiScaling; // Capacitive sensor/slider
 
+// changes
+DigitalIn RtButton(PTC3); // make RIGHT button interrrupt
+int RtbuttonState; // switch changes when RtButton is pressed
 
 PwmOut led(LED_RED);
 DigitalOut outPin(PTC9); //J1-16
@@ -58,7 +62,11 @@
 */
     scaleIndex = (int)(NUMTONES * scaling);
     if (scaleIndex != oldScaleIndex) {
+        if(RtbuttonState == false){
         toneFreq = diatonicScale[scaleIndex];
+        } else {
+        toneFreq = diatonicScale2[scaleIndex];
+        }
         tonePeriod = 1.0/toneFreq;  
         soundOut.period(tonePeriod); // adjusting period
         soundOut.write(TONEON); // there is a setup time for both period and DF
@@ -100,6 +108,9 @@
     dataTimer.reset(); 
      
     while (true) {
+        
+        RtbuttonState = RtButton; // button is pulled up so false is when button is pushed it's inverted to avoid confusion downstream
+        
         if (dataTimer.read_ms() > DATATIME){ // check to see if enough time has passed
                                             // to read the touch pad
             tempValue = tsiScaling.readPercentage();