Keith Stokely / Mbed 2 deprecated CP4_LDM_Test_Blue

Dependencies:   mbed

Committer:
kstokely
Date:
Mon Aug 24 14:17:58 2020 +0000
Revision:
2:a29fc54a61cb
Parent:
1:5c0202cb8e6d
Child:
3:5e0d2bf44533
CP4 LDM test for Blue LDM;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kstokely 0:c57b9d018b9f 1 #include "mbed.h"
kstokely 1:5c0202cb8e6d 2 #include <string>
kstokely 0:c57b9d018b9f 3
kstokely 0:c57b9d018b9f 4 Serial pc(USBTX, USBRX); // tx, rx
kstokely 2:a29fc54a61cb 5 Serial device(p9,p10);
kstokely 2:a29fc54a61cb 6 string pcstr;
kstokely 1:5c0202cb8e6d 7
kstokely 1:5c0202cb8e6d 8
kstokely 2:a29fc54a61cb 9 device.baud(38400);//Default for blue LDM
kstokely 2:a29fc54a61cb 10 pc.baud(9600);
kstokely 2:a29fc54a61cb 11 int main()
kstokely 2:a29fc54a61cb 12 {
kstokely 2:a29fc54a61cb 13 pc.printf("Mbed Test of CP4 LDM \n\r");
kstokely 1:5c0202cb8e6d 14
kstokely 2:a29fc54a61cb 15 while(1)
kstokely 2:a29fc54a61cb 16 {
kstokely 1:5c0202cb8e6d 17
kstokely 2:a29fc54a61cb 18 //Echo LDM output to PC
kstokely 2:a29fc54a61cb 19 if(device.readable())
kstokely 1:5c0202cb8e6d 20 {
kstokely 2:a29fc54a61cb 21 pc.putc(device.getc());
kstokely 1:5c0202cb8e6d 22 }
kstokely 1:5c0202cb8e6d 23
kstokely 2:a29fc54a61cb 24 //Read from PC termial and write commands to LDM
kstokely 2:a29fc54a61cb 25 if(pc.readable())
kstokely 1:5c0202cb8e6d 26 {
kstokely 2:a29fc54a61cb 27 pc.scanf("%s", pcstr.c_str() );
kstokely 2:a29fc54a61cb 28 char c = pcstr.c_str()[0];
kstokely 2:a29fc54a61cb 29
kstokely 2:a29fc54a61cb 30 //List of LDM Commands
kstokely 2:a29fc54a61cb 31
kstokely 2:a29fc54a61cb 32 //Take Single Measurement
kstokely 2:a29fc54a61cb 33 if( c == '[' )
kstokely 2:a29fc54a61cb 34 {
kstokely 2:a29fc54a61cb 35 pc.printf("iSM");
kstokely 2:a29fc54a61cb 36 }
kstokely 2:a29fc54a61cb 37 //Continuous Measurement
kstokely 2:a29fc54a61cb 38 if( c == 'c' )
kstokely 2:a29fc54a61cb 39 {
kstokely 2:a29fc54a61cb 40 pc.printf("iACM");
kstokely 2:a29fc54a61cb 41 }
kstokely 2:a29fc54a61cb 42 //Fast Continuous Measurement
kstokely 2:a29fc54a61cb 43 if( c == 'C' )
kstokely 2:a29fc54a61cb 44 {
kstokely 2:a29fc54a61cb 45 pc.printf("iFACM");
kstokely 2:a29fc54a61cb 46 }
kstokely 2:a29fc54a61cb 47 //Stop Measurement
kstokely 2:a29fc54a61cb 48 if ( c == 's' )
kstokely 2:a29fc54a61cb 49 {
kstokely 2:a29fc54a61cb 50 pc.printf("iHALT");
kstokely 2:a29fc54a61cb 51 }
kstokely 2:a29fc54a61cb 52 //Laser Pointer On
kstokely 2:a29fc54a61cb 53 if( c == ',' )
kstokely 2:a29fc54a61cb 54 {
kstokely 2:a29fc54a61cb 55 pc.printf("iLD:1");
kstokely 2:a29fc54a61cb 56 }
kstokely 2:a29fc54a61cb 57 //Laser Pointer Off
kstokely 2:a29fc54a61cb 58 if( c == '.' )
kstokely 2:a29fc54a61cb 59 {
kstokely 2:a29fc54a61cb 60 pc.printf("iLD:0");
kstokely 2:a29fc54a61cb 61 }
kstokely 1:5c0202cb8e6d 62 }
kstokely 1:5c0202cb8e6d 63
kstokely 1:5c0202cb8e6d 64
kstokely 1:5c0202cb8e6d 65
kstokely 0:c57b9d018b9f 66
kstokely 0:c57b9d018b9f 67 }
kstokely 0:c57b9d018b9f 68 }