h

Dependencies:   mbed

Fork of HelloWorld by judo ~

Committer:
oopakhooo
Date:
Wed Nov 16 21:44:03 2016 +0000
Revision:
5:afabac4fce1b
Parent:
4:f0a11480f39f
serial params to interface

Who changed what in which revision?

UserRevisionLine numberNew contents of line
oopakhooo 3:641eefd1110b 1 #include "Hardware.h"
oopakhooo 3:641eefd1110b 2 #include "mbed.h"
oopakhooo 3:641eefd1110b 3
oopakhooo 4:f0a11480f39f 4 DigitalOut output_pin_A(LED3);
oopakhooo 5:afabac4fce1b 5 DigitalOut output_pin_V(LED2);
oopakhooo 5:afabac4fce1b 6
oopakhooo 5:afabac4fce1b 7 /*
oopakhooo 5:afabac4fce1b 8 void send_egram_data(Serial &pc,PaceHeart &Pacer){
oopakhooo 5:afabac4fce1b 9 int *amp = Pacer.get_egram_amp;
oopakhooo 5:afabac4fce1b 10 int *wid = Pacer.get_egram_wid;
oopakhooo 5:afabac4fce1b 11 int size = Pacer.get_egram_size;
oopakhooo 5:afabac4fce1b 12 for(int i = 0; i<size;i++){
oopakhooo 5:afabac4fce1b 13 pc.printf ("%c%c",(char)((int)(amp[i])/128),(char)((int)(amp[i])%128));
oopakhooo 5:afabac4fce1b 14 pc.printf ("%c%c",(char)((int)(10.0*wid[i])/128),(char)((int)(10.0*wid[i])%128));
oopakhooo 5:afabac4fce1b 15 }
oopakhooo 5:afabac4fce1b 16 pc.printf("\n");
oopakhooo 5:afabac4fce1b 17 pc.printf("%c\n",(char)size); datachk
oopakhooo 5:afabac4fce1b 18 }
oopakhooo 5:afabac4fce1b 19 */
oopakhooo 5:afabac4fce1b 20 void send_data(Serial &pc,PaceHeart &Pacer){
oopakhooo 5:afabac4fce1b 21
oopakhooo 5:afabac4fce1b 22 pc.printf ("%c",(char)Pacer.get_p_pacingState());
oopakhooo 5:afabac4fce1b 23 pc.printf ("%c",(char)Pacer.get_p_pacingMode());
oopakhooo 5:afabac4fce1b 24 pc.printf ("%c",(char)Pacer.get_p_hysteresis());
oopakhooo 5:afabac4fce1b 25 pc.printf ("%c%c",(char)((int)(Pacer.get_p_hysteresisInterval()/128)),(char)(Pacer.get_p_hysteresisInterval()%128));
oopakhooo 5:afabac4fce1b 26 pc.printf ("%c%c",(char)((int)(Pacer.get_lowrateInterval()/128)),(char)(Pacer.get_lowrateInterval()%128));
oopakhooo 5:afabac4fce1b 27 pc.printf ("%c%c",(char)((int)(Pacer.get_p_vPaceAmp())/128),(char)((int)(Pacer.get_p_vPaceAmp())%128));
oopakhooo 5:afabac4fce1b 28 pc.printf ("%c%c",(char)((int)(10.0*Pacer.get_p_vPaceWidth())/128),(char)((int)(10.0*Pacer.get_p_vPaceWidth())%128));//10*pace width
oopakhooo 5:afabac4fce1b 29 pc.printf ("%c%c\n",(char)((int)(Pacer.get_p_VRP()/128)),(char)(Pacer.get_p_VRP()%128));
oopakhooo 5:afabac4fce1b 30 return;
oopakhooo 5:afabac4fce1b 31 }
oopakhooo 5:afabac4fce1b 32 void request_data(Serial &pc,PaceHeart &Pacer){ //implement limit later
oopakhooo 5:afabac4fce1b 33 char d[14];
oopakhooo 5:afabac4fce1b 34 int e = 0;
oopakhooo 5:afabac4fce1b 35 pc.scanf("%s",&d);
oopakhooo 5:afabac4fce1b 36 pc.printf("%c",'e');//end
oopakhooo 5:afabac4fce1b 37 e = (int)d[0];
oopakhooo 5:afabac4fce1b 38 Pacer.set_p_pacingState(e);
oopakhooo 5:afabac4fce1b 39 e = (int)d[1];
oopakhooo 5:afabac4fce1b 40 Pacer.set_p_pacingMode(e);
oopakhooo 5:afabac4fce1b 41 e = (int)d[2];
oopakhooo 5:afabac4fce1b 42 Pacer.set_p_hysteresis(e);
oopakhooo 5:afabac4fce1b 43 e = (int)d[3]*128+(int)d[4];
oopakhooo 5:afabac4fce1b 44 Pacer.set_p_hysteresisInterval(e);
oopakhooo 5:afabac4fce1b 45 e = (int)d[5]*128+(int)d[6];
oopakhooo 5:afabac4fce1b 46 Pacer.set_lowrateInterval(e);
oopakhooo 5:afabac4fce1b 47 e = (int)d[7]*128+(int)d[8];
oopakhooo 5:afabac4fce1b 48 Pacer.set_p_vPaceAmp((double)e);
oopakhooo 5:afabac4fce1b 49 e = (int)d[9]*128+(int)d[10];
oopakhooo 5:afabac4fce1b 50 Pacer.set_p_vPaceWidth((double)e/10.0);
oopakhooo 5:afabac4fce1b 51 e = (int)d[11]*128+(int)d[12];
oopakhooo 5:afabac4fce1b 52 Pacer.set_p_VRP(e);
oopakhooo 5:afabac4fce1b 53 }
oopakhooo 5:afabac4fce1b 54 void Check_serial(Serial &pc,PaceHeart &Pacer){
oopakhooo 5:afabac4fce1b 55 char c = pc.getc();
oopakhooo 5:afabac4fce1b 56 if(c=='r'){//send params
oopakhooo 5:afabac4fce1b 57 send_data(pc,Pacer);
oopakhooo 5:afabac4fce1b 58 }
oopakhooo 5:afabac4fce1b 59 else if(c=='s') {//set params
oopakhooo 5:afabac4fce1b 60 request_data(pc,Pacer);
oopakhooo 5:afabac4fce1b 61 }
oopakhooo 5:afabac4fce1b 62 }