Tone Demo for PWM library use slider for control on KL46Z

Dependencies:   SLCD TSI mbed

Fork of keyer_test_v3 by Stanley Cohen

Revision:
1:6f0197189fcc
Parent:
0:6c16ec0e7b9d
--- a/keyer_test_v3.cpp	Tue Dec 16 03:14:27 2014 +0000
+++ b/keyer_test_v3.cpp	Fri Dec 19 16:34:51 2014 +0000
@@ -14,7 +14,7 @@
 #define IAMMESS     "IAMB"
 #define NULLMESS    "111"  // LCD idle message
 #define FIXEDWPM    13
-#define LOWSPEED   5
+#define LOWSPEED    5
 #define SPPEDINT    25.0 // This gives a max speed of 30 - 5 + 25
 
 #define STATECOEF   2
@@ -22,6 +22,9 @@
 #define DIT         1
 #define DAH         2
 #define IAM         3
+#define SIDETONE    0.0014  //seconds
+#define TONEON      0.50
+#define TONEOFF     0.0
 
 SLCD slcd; //define LCD display
 // keyer test
@@ -32,6 +35,7 @@
 DigitalIn DitPaddle(PTD6);
 DigitalOut led(LED_RED);
 DigitalOut outPin(PTC9); //J1-16
+PwmOut soundOut(PTC9);
 int KeyState = IDLE;
 
 
@@ -44,9 +48,11 @@
 void makeDit (float dotLen,DigitalOut outChannel, DigitalOut cloneChannel) {
     outChannel.write(CHANNELON);
     cloneChannel.write(CHANNELON);
+    soundOut.write(TONEON);
     wait(dotLen);
     outChannel.write(CHANNELOFF);
     cloneChannel.write(CHANNELOFF);
+    soundOut.write(TONEOFF);
     wait(float(DOT)*dotLen);
     return;
 }
@@ -54,9 +60,11 @@
 void makeDah (float dotLen,DigitalOut outChannel, DigitalOut cloneChannel) {
     outChannel.write(CHANNELON);
     cloneChannel.write(CHANNELON);
+    soundOut.write(TONEON);
     wait(float(DASH)*dotLen);
     outChannel.write(CHANNELOFF);
     cloneChannel.write(CHANNELOFF);
+    soundOut.write(TONEOFF);
     wait(float(DOT)*dotLen);
     return;
 }
@@ -73,6 +81,8 @@
     float tempValue;
     int lastKeyHit = DIT;
     
+    soundOut.period(SIDETONE);
+    
     
     elementLen = BASESPEED / (float) wpm;