Blue LDM test for CP4

Dependencies:   mbed

Committer:
kstokely
Date:
Tue Aug 25 17:56:25 2020 +0000
Revision:
3:5e0d2bf44533
Parent:
2:a29fc54a61cb
Update for Blue LDM Control;

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 3:5e0d2bf44533 9
kstokely 2:a29fc54a61cb 10 int main()
kstokely 2:a29fc54a61cb 11 {
kstokely 3:5e0d2bf44533 12 device.baud(38400);//Default for blue LDM
kstokely 3:5e0d2bf44533 13 pc.baud(9600);
kstokely 2:a29fc54a61cb 14 pc.printf("Mbed Test of CP4 LDM \n\r");
kstokely 1:5c0202cb8e6d 15
kstokely 2:a29fc54a61cb 16 while(1)
kstokely 2:a29fc54a61cb 17 {
kstokely 1:5c0202cb8e6d 18
kstokely 2:a29fc54a61cb 19 //Echo LDM output to PC
kstokely 2:a29fc54a61cb 20 if(device.readable())
kstokely 1:5c0202cb8e6d 21 {
kstokely 2:a29fc54a61cb 22 pc.putc(device.getc());
kstokely 1:5c0202cb8e6d 23 }
kstokely 1:5c0202cb8e6d 24
kstokely 2:a29fc54a61cb 25 //Read from PC termial and write commands to LDM
kstokely 2:a29fc54a61cb 26 if(pc.readable())
kstokely 1:5c0202cb8e6d 27 {
kstokely 2:a29fc54a61cb 28 pc.scanf("%s", pcstr.c_str() );
kstokely 2:a29fc54a61cb 29 char c = pcstr.c_str()[0];
kstokely 3:5e0d2bf44533 30 pc.printf("Mbed Command Received: %c\n\r",c);
kstokely 2:a29fc54a61cb 31 //List of LDM Commands
kstokely 2:a29fc54a61cb 32
kstokely 2:a29fc54a61cb 33 //Take Single Measurement
kstokely 2:a29fc54a61cb 34 if( c == '[' )
kstokely 2:a29fc54a61cb 35 {
kstokely 3:5e0d2bf44533 36 pc.printf("iSM\n\r");
kstokely 3:5e0d2bf44533 37 device.printf("iSM\n\r");
kstokely 3:5e0d2bf44533 38 }
kstokely 3:5e0d2bf44533 39 if (c == 'm')
kstokely 3:5e0d2bf44533 40 {
kstokely 3:5e0d2bf44533 41 pc.printf("iSET:5,1\n\r");
kstokely 3:5e0d2bf44533 42 device.printf("iSET:5,1\n\r");
kstokely 3:5e0d2bf44533 43 }
kstokely 3:5e0d2bf44533 44 if (c == 'n')
kstokely 3:5e0d2bf44533 45 {
kstokely 3:5e0d2bf44533 46 pc.printf("iSET:5,0\n\r");
kstokely 3:5e0d2bf44533 47 device.printf("iSET:5,0\n\r");
kstokely 2:a29fc54a61cb 48 }
kstokely 2:a29fc54a61cb 49 //Continuous Measurement
kstokely 2:a29fc54a61cb 50 if( c == 'c' )
kstokely 2:a29fc54a61cb 51 {
kstokely 3:5e0d2bf44533 52 pc.printf("iACM\n\r");
kstokely 3:5e0d2bf44533 53 device.printf("iACM\n\r");
kstokely 2:a29fc54a61cb 54 }
kstokely 2:a29fc54a61cb 55 //Fast Continuous Measurement
kstokely 2:a29fc54a61cb 56 if( c == 'C' )
kstokely 2:a29fc54a61cb 57 {
kstokely 3:5e0d2bf44533 58 pc.printf("iFACM\n\r");
kstokely 3:5e0d2bf44533 59 device.printf("iFACM\n\r");
kstokely 2:a29fc54a61cb 60 }
kstokely 2:a29fc54a61cb 61 //Stop Measurement
kstokely 2:a29fc54a61cb 62 if ( c == 's' )
kstokely 2:a29fc54a61cb 63 {
kstokely 3:5e0d2bf44533 64 pc.printf("iHALT\n\r");
kstokely 3:5e0d2bf44533 65 device.printf("iHALT\n\r");
kstokely 2:a29fc54a61cb 66 }
kstokely 2:a29fc54a61cb 67 //Laser Pointer On
kstokely 2:a29fc54a61cb 68 if( c == ',' )
kstokely 2:a29fc54a61cb 69 {
kstokely 3:5e0d2bf44533 70 pc.printf("iLD:1\n\r");
kstokely 3:5e0d2bf44533 71 device.printf("iLD:1\n\r");
kstokely 2:a29fc54a61cb 72 }
kstokely 2:a29fc54a61cb 73 //Laser Pointer Off
kstokely 2:a29fc54a61cb 74 if( c == '.' )
kstokely 2:a29fc54a61cb 75 {
kstokely 3:5e0d2bf44533 76 pc.printf("iLD:0\n\r");
kstokely 3:5e0d2bf44533 77 device.printf("iLD:0\n\r");
kstokely 2:a29fc54a61cb 78 }
kstokely 1:5c0202cb8e6d 79 }
kstokely 1:5c0202cb8e6d 80
kstokely 1:5c0202cb8e6d 81
kstokely 1:5c0202cb8e6d 82
kstokely 0:c57b9d018b9f 83
kstokely 0:c57b9d018b9f 84 }
kstokely 0:c57b9d018b9f 85 }