new

Dependencies:   mbed

Revision:
2:94a34bcf8f09
Parent:
1:461a4f04db9b
Child:
3:b5c5c73c5bbf
--- a/main.cpp	Thu Feb 19 18:33:11 2015 +0000
+++ b/main.cpp	Sun Feb 22 18:05:52 2015 +0000
@@ -22,14 +22,20 @@
 DigitalIn col4(p17);
 Timer t1;
 
-//map
+//map for keypad and DTMF
 map<int, char> keypadMap;
 map<int, char *> dtmfMap; 
 
-//global
+//global on for PWMl (low freqency)
 int on = 0;
 
-//Mores Code -> Character Map
+//Map for keypad
+//First 4 bits corrospond to active column
+//Last 4 bits corrospond to active row
+
+//DTMF
+//Maps the current input to appropriate two
+//frequencies
 void init(){
         keypadMap[0x11]='1';
         keypadMap[0x12]='2';
@@ -66,6 +72,8 @@
         dtmfMap[0x88]="1633,941"; //D
 }
 
+//Flip function is attached to ticker to flip
+//PWMl (low Frequency)
 void flip() {
     if(on == 1)
         PWMl = !PWMl;
@@ -116,7 +124,7 @@
                             cur_input |= 0x80;
                             break; 
                             }
-        }
+                }
         
    
      
@@ -140,6 +148,8 @@
                     if(c != 0){
                         pc.printf("%c\r",c);  //print input and char
                     }
+                    
+                    //Assign freql and freqh based on current input
                     float freqh,freql;
                     char *freq = dtmfMap[cur_input];
                     sscanf(freq,"%f,%f",&freqh,&freql);
@@ -147,11 +157,10 @@
                     
               
                     
-                    //PWMl.period(1/freql);               // set PWM period to user specified for low tone
-                    //PWMl=0.5;                         // set duty cycle to 50%
+                    //Set the low frequency on ticker
                     on = 1;
-                    PWMcont.attach(&flip, (1/freql)); // the address of the function to be attached (flip) and the interval (1/freql)
-                    
+                    PWMcont.attach(&flip, (1/(2*freql))); // the address of the function to be attached (flip) and the interval (1/freql)
+                    //Set the high frequency on PWMout 
                     PWMh.period(1/freqh);               // set PWM period to user specified for high tone
                     PWMh=0.5;                         // set duty cycle to 50%
                     
@@ -165,7 +174,6 @@
                 on = 0;
              } 
        
-     
      //Maintain the past input
      prev_input = cur_input;