reeeeeeeeeeeeeee
Dependencies: MotionSensor mbed
Fork of Assignment2_ver3 by
Hardware.cpp@9:751e39d24c39, 2016-11-29 (annotated)
- Committer:
- weebgrammers
- Date:
- Tue Nov 29 22:06:14 2016 +0000
- Revision:
- 9:751e39d24c39
- Parent:
- 8:45befd2bb1e5
r
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
oopakhooo | 3:641eefd1110b | 1 | #include "Hardware.h" |
oopakhooo | 3:641eefd1110b | 2 | #include "mbed.h" |
oopakhooo | 3:641eefd1110b | 3 | |
weebgrammers | 7:6dc42e1a2a81 | 4 | #define LOW 0 |
weebgrammers | 7:6dc42e1a2a81 | 5 | #define HIGH 1 |
weebgrammers | 8:45befd2bb1e5 | 6 | |
weebgrammers | 9:751e39d24c39 | 7 | //#include "pinmap.h" |
weebgrammers | 9:751e39d24c39 | 8 | //#include "FXOS8700Q.h" |
weebgrammers | 8:45befd2bb1e5 | 9 | |
weebgrammers | 8:45befd2bb1e5 | 10 | //////////////////////////////////////////////////////// |
weebgrammers | 9:751e39d24c39 | 11 | //FXOS8700Q_acc acc(PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); |
weebgrammers | 8:45befd2bb1e5 | 12 | |
weebgrammers | 8:45befd2bb1e5 | 13 | /* Constants and Declares */ |
weebgrammers | 9:751e39d24c39 | 14 | //int numCount; |
weebgrammers | 9:751e39d24c39 | 15 | //int const MAX_NUM_COUNTS = 3; |
weebgrammers | 9:751e39d24c39 | 16 | //int const TIMING_PERIOD = 20; // Sensor polling interval |
weebgrammers | 8:45befd2bb1e5 | 17 | |
weebgrammers | 9:751e39d24c39 | 18 | //uint8_t motion_exceeded_threshold = 0; |
weebgrammers | 8:45befd2bb1e5 | 19 | /////////////////////////////////////////// |
oopakhooo | 4:f0a11480f39f | 20 | DigitalOut output_pin_A(LED3); |
weebgrammers | 7:6dc42e1a2a81 | 21 | DigitalOut output_pin_V(LED2); |
weebgrammers | 7:6dc42e1a2a81 | 22 | /*=== Analog In ===*/ |
weebgrammers | 7:6dc42e1a2a81 | 23 | AnalogIn atrialIn (A0); // Pin A0 |
weebgrammers | 7:6dc42e1a2a81 | 24 | AnalogIn ventricleIn (A1); // Pin A1 |
weebgrammers | 7:6dc42e1a2a81 | 25 | AnalogIn leadImpedence (A2); // Pin A2 |
weebgrammers | 7:6dc42e1a2a81 | 26 | AnalogIn atr_rect_signal (A3); // Pin A3 |
weebgrammers | 7:6dc42e1a2a81 | 27 | AnalogIn vent_rect_signal (A4); // Pin A4 |
weebgrammers | 7:6dc42e1a2a81 | 28 | |
weebgrammers | 7:6dc42e1a2a81 | 29 | /*=== Digital In ===*/ |
weebgrammers | 7:6dc42e1a2a81 | 30 | DigitalIn atria_cmp_detect (PTC16); // Pin D0 |
weebgrammers | 7:6dc42e1a2a81 | 31 | DigitalIn vent_cmp_detect (PTC17); // Pin D1 |
weebgrammers | 7:6dc42e1a2a81 | 32 | |
weebgrammers | 7:6dc42e1a2a81 | 33 | /*=== PWM Out ===*/ |
weebgrammers | 7:6dc42e1a2a81 | 34 | /* DigitalOut is used for the REF Signal |
weebgrammers | 7:6dc42e1a2a81 | 35 | * due to absence of PWM capabilities of Pins D2 and D4 |
weebgrammers | 7:6dc42e1a2a81 | 36 | * on the FRDM-K64F Board |
weebgrammers | 7:6dc42e1a2a81 | 37 | */ |
weebgrammers | 7:6dc42e1a2a81 | 38 | DigitalOut pacing_ref_pwm (PTB9); // Pin D2 (PTB9) |
weebgrammers | 7:6dc42e1a2a81 | 39 | PwmOut vent_ref_pwm (PTA1); // Pin D3 |
weebgrammers | 7:6dc42e1a2a81 | 40 | DigitalOut atria_ref_pwm (PTB23); // Pin D4 |
weebgrammers | 7:6dc42e1a2a81 | 41 | |
weebgrammers | 7:6dc42e1a2a81 | 42 | |
weebgrammers | 7:6dc42e1a2a81 | 43 | /*=== Digital Out ===*/ |
weebgrammers | 7:6dc42e1a2a81 | 44 | DigitalOut pace_charge_ctrl (PTA2); // Pin D5 |
weebgrammers | 7:6dc42e1a2a81 | 45 | DigitalOut z_atria_ctrl (PTC2); // Pin D6 |
weebgrammers | 7:6dc42e1a2a81 | 46 | DigitalOut z_vent_ctrl (PTC3); // Pin D7 |
weebgrammers | 7:6dc42e1a2a81 | 47 | |
weebgrammers | 7:6dc42e1a2a81 | 48 | DigitalOut atr_pace_ctrl (PTC12); // Pin D8 |
weebgrammers | 7:6dc42e1a2a81 | 49 | DigitalOut vent_pace_ctrl (PTC4); // Pin D9 |
weebgrammers | 7:6dc42e1a2a81 | 50 | DigitalOut pace_grnd_ctrl (PTD0); // Pin D10 |
weebgrammers | 7:6dc42e1a2a81 | 51 | DigitalOut atr_grnd_ctrl (PTD2); // Pin D11 |
weebgrammers | 7:6dc42e1a2a81 | 52 | DigitalOut vent_grnd_ctrl (PTD3); // Pin D12 |
weebgrammers | 7:6dc42e1a2a81 | 53 | DigitalOut frontend_ctrl (PTD1); // Pin D13 |
weebgrammers | 7:6dc42e1a2a81 | 54 | |
weebgrammers | 7:6dc42e1a2a81 | 55 | /*=== On-Board Tri-LED ===*/ |
weebgrammers | 7:6dc42e1a2a81 | 56 | DigitalOut rled (LED_RED); |
weebgrammers | 7:6dc42e1a2a81 | 57 | DigitalOut gled (LED_GREEN); |
weebgrammers | 7:6dc42e1a2a81 | 58 | DigitalOut bled (LED_BLUE); |
weebgrammers | 7:6dc42e1a2a81 | 59 | |
weebgrammers | 7:6dc42e1a2a81 | 60 | |
weebgrammers | 7:6dc42e1a2a81 | 61 | void send_data(Serial &pc,PaceHeart &Pacer){ |
weebgrammers | 7:6dc42e1a2a81 | 62 | |
weebgrammers | 7:6dc42e1a2a81 | 63 | pc.printf ("%c",(char)Pacer.get_p_pacingState()); |
weebgrammers | 7:6dc42e1a2a81 | 64 | pc.printf ("%c",(char)Pacer.get_p_pacingMode()); |
weebgrammers | 7:6dc42e1a2a81 | 65 | pc.printf ("%c",(char)Pacer.get_p_hysteresis()); |
weebgrammers | 7:6dc42e1a2a81 | 66 | pc.printf ("%c%c",(char)((int)(Pacer.get_p_hysteresisInterval()/128)),(char)(Pacer.get_p_hysteresisInterval()%128)); |
weebgrammers | 7:6dc42e1a2a81 | 67 | pc.printf ("%c%c",(char)((int)(Pacer.get_p_lowrateInterval()/128)),(char)((int)(Pacer.get_p_lowrateInterval())%128)); |
weebgrammers | 7:6dc42e1a2a81 | 68 | pc.printf ("%c%c",(char)((int)(Pacer.get_p_vPaceAmp())/128),(char)((int)(Pacer.get_p_vPaceAmp())%128)); |
weebgrammers | 7:6dc42e1a2a81 | 69 | 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 |
weebgrammers | 7:6dc42e1a2a81 | 70 | pc.printf ("%c%c\n",(char)((int)(Pacer.get_p_VRP()/128)),(char)(Pacer.get_p_VRP()%128)); |
weebgrammers | 7:6dc42e1a2a81 | 71 | return; |
weebgrammers | 7:6dc42e1a2a81 | 72 | } |
weebgrammers | 7:6dc42e1a2a81 | 73 | void request_data(Serial &pc,PaceHeart &Pacer){ //implement limit later |
weebgrammers | 7:6dc42e1a2a81 | 74 | char d[14]; |
weebgrammers | 7:6dc42e1a2a81 | 75 | int e = 0; |
weebgrammers | 7:6dc42e1a2a81 | 76 | pc.scanf("%s",&d); |
weebgrammers | 7:6dc42e1a2a81 | 77 | pc.printf("%c",'e');//end |
weebgrammers | 7:6dc42e1a2a81 | 78 | e = (int)d[0]; |
weebgrammers | 7:6dc42e1a2a81 | 79 | //Pacer.set_p_pacingState(e); |
weebgrammers | 7:6dc42e1a2a81 | 80 | e = (int)d[1]; |
weebgrammers | 7:6dc42e1a2a81 | 81 | // Pacer.set_p_pacingMode(e); |
weebgrammers | 7:6dc42e1a2a81 | 82 | e = (int)d[2]; |
weebgrammers | 7:6dc42e1a2a81 | 83 | Pacer.set_p_hysteresis(e); |
weebgrammers | 7:6dc42e1a2a81 | 84 | e = (int)d[3]*128+(int)d[4]; |
weebgrammers | 7:6dc42e1a2a81 | 85 | Pacer.set_p_hysteresisInterval(e); |
weebgrammers | 7:6dc42e1a2a81 | 86 | e = (int)d[5]*128+(int)d[6]; |
weebgrammers | 7:6dc42e1a2a81 | 87 | Pacer.set_p_lowrateInterval(e); |
weebgrammers | 7:6dc42e1a2a81 | 88 | e = (int)d[7]*128+(int)d[8]; |
weebgrammers | 7:6dc42e1a2a81 | 89 | Pacer.set_p_vPaceAmp((double)e); |
weebgrammers | 7:6dc42e1a2a81 | 90 | e = (int)d[9]*128+(int)d[10]; |
weebgrammers | 7:6dc42e1a2a81 | 91 | Pacer.set_p_vPaceWidth((double)e/10.0); |
weebgrammers | 7:6dc42e1a2a81 | 92 | e = (int)d[11]*128+(int)d[12]; |
weebgrammers | 7:6dc42e1a2a81 | 93 | Pacer.set_p_VRP(e); |
weebgrammers | 7:6dc42e1a2a81 | 94 | } |
weebgrammers | 7:6dc42e1a2a81 | 95 | |
weebgrammers | 7:6dc42e1a2a81 | 96 | |
weebgrammers | 7:6dc42e1a2a81 | 97 | void stream_A(Serial &pc){ |
weebgrammers | 7:6dc42e1a2a81 | 98 | int amp = (int)(3450*vent_rect_signal); |
weebgrammers | 7:6dc42e1a2a81 | 99 | pc.printf("%c%c\n",(char)(amp/128),(char)(amp%128)); |
weebgrammers | 7:6dc42e1a2a81 | 100 | } |
weebgrammers | 7:6dc42e1a2a81 | 101 | |
weebgrammers | 7:6dc42e1a2a81 | 102 | void stream_V(Serial &pc){ |
weebgrammers | 7:6dc42e1a2a81 | 103 | int amp = (int)(3450*ventricleIn); |
weebgrammers | 7:6dc42e1a2a81 | 104 | pc.printf("%c%c\n",(char)(amp/128),(char)(amp%128)); |
weebgrammers | 7:6dc42e1a2a81 | 105 | } |
weebgrammers | 7:6dc42e1a2a81 | 106 | |
weebgrammers | 7:6dc42e1a2a81 | 107 | void stream(Serial &pc, char mode){ |
weebgrammers | 7:6dc42e1a2a81 | 108 | char c; |
weebgrammers | 7:6dc42e1a2a81 | 109 | while(1){ |
weebgrammers | 7:6dc42e1a2a81 | 110 | if(pc.readable()!=0){ |
weebgrammers | 7:6dc42e1a2a81 | 111 | c = pc.getc(); |
weebgrammers | 7:6dc42e1a2a81 | 112 | if(c=='q'){ |
weebgrammers | 7:6dc42e1a2a81 | 113 | stream_A(pc); |
weebgrammers | 7:6dc42e1a2a81 | 114 | output_pin_V=!output_pin_V; |
weebgrammers | 7:6dc42e1a2a81 | 115 | } |
weebgrammers | 7:6dc42e1a2a81 | 116 | else if(c=='w'){ |
weebgrammers | 7:6dc42e1a2a81 | 117 | return; |
weebgrammers | 7:6dc42e1a2a81 | 118 | } |
weebgrammers | 7:6dc42e1a2a81 | 119 | } |
weebgrammers | 7:6dc42e1a2a81 | 120 | } |
weebgrammers | 7:6dc42e1a2a81 | 121 | } |
weebgrammers | 7:6dc42e1a2a81 | 122 | |
weebgrammers | 7:6dc42e1a2a81 | 123 | void Check_serial(Serial &pc,PaceHeart &Pacer){ |
weebgrammers | 7:6dc42e1a2a81 | 124 | char c = pc.getc(); |
weebgrammers | 7:6dc42e1a2a81 | 125 | if(c=='r'){//send params |
weebgrammers | 7:6dc42e1a2a81 | 126 | send_data(pc,Pacer); |
weebgrammers | 7:6dc42e1a2a81 | 127 | } |
weebgrammers | 7:6dc42e1a2a81 | 128 | else if(c=='s') {//set params |
weebgrammers | 7:6dc42e1a2a81 | 129 | request_data(pc,Pacer); |
weebgrammers | 7:6dc42e1a2a81 | 130 | } |
weebgrammers | 7:6dc42e1a2a81 | 131 | else if(c=='q'){ //stream egram |
weebgrammers | 7:6dc42e1a2a81 | 132 | stream(pc,c); |
weebgrammers | 7:6dc42e1a2a81 | 133 | } |
weebgrammers | 7:6dc42e1a2a81 | 134 | } |
weebgrammers | 7:6dc42e1a2a81 | 135 | |
weebgrammers | 7:6dc42e1a2a81 | 136 | |
weebgrammers | 7:6dc42e1a2a81 | 137 | void Output_A(double amp, double wid){ |
weebgrammers | 7:6dc42e1a2a81 | 138 | vent_ref_pwm = 0.5f; |
weebgrammers | 7:6dc42e1a2a81 | 139 | vent_ref_pwm.pulsewidth(2); |
weebgrammers | 7:6dc42e1a2a81 | 140 | /*AnalogOut aout(p18); //sets up pin 18 as an analogue output |
weebgrammers | 7:6dc42e1a2a81 | 141 | AnalogueIn ain(p15); //sets up pin 15 and an analogue input |
weebgrammers | 7:6dc42e1a2a81 | 142 | |
weebgrammers | 7:6dc42e1a2a81 | 143 | int main(){ |
weebgrammers | 7:6dc42e1a2a81 | 144 | aout=0.5; //sets output to 0.5*VCC |
weebgrammers | 7:6dc42e1a2a81 | 145 | while(1){ //sets up a loop |
weebgrammers | 7:6dc42e1a2a81 | 146 | if (ain>0.3){ //tests whether the input is above 0.3 |
weebgrammers | 7:6dc42e1a2a81 | 147 | aout=0; //sets the output to 0 |
weebgrammers | 7:6dc42e1a2a81 | 148 | } |
weebgrammers | 7:6dc42e1a2a81 | 149 | aout = 0.5; |
weebgrammers | 7:6dc42e1a2a81 | 150 | wait(1); |
weebgrammers | 7:6dc42e1a2a81 | 151 | aout = 0;*/ |
weebgrammers | 7:6dc42e1a2a81 | 152 | // test the voltage on the initialized analog pin |
weebgrammers | 7:6dc42e1a2a81 | 153 | // and if greater than 0.3 * VCC set the digital pin |
weebgrammers | 7:6dc42e1a2a81 | 154 | // to a logic 1 otherwise a logic 0 |
weebgrammers | 7:6dc42e1a2a81 | 155 | } |
weebgrammers | 7:6dc42e1a2a81 | 156 | void Output_V(double amp,double wid){ |
weebgrammers | 7:6dc42e1a2a81 | 157 | //vent_ref_pwm = 0.5f; |
weebgrammers | 7:6dc42e1a2a81 | 158 | //vent_ref_pwm.pulsewidth(2); |
weebgrammers | 7:6dc42e1a2a81 | 159 | atr_grnd_ctrl = LOW; |
weebgrammers | 7:6dc42e1a2a81 | 160 | vent_grnd_ctrl = LOW; |
weebgrammers | 7:6dc42e1a2a81 | 161 | |
weebgrammers | 7:6dc42e1a2a81 | 162 | /* Stage 1: Ref PWM On */ |
weebgrammers | 7:6dc42e1a2a81 | 163 | pacing_ref_pwm = HIGH; |
weebgrammers | 7:6dc42e1a2a81 | 164 | wait_ms(10); |
weebgrammers | 7:6dc42e1a2a81 | 165 | |
weebgrammers | 7:6dc42e1a2a81 | 166 | /* Stage 2: Charge CTRL on */ |
weebgrammers | 7:6dc42e1a2a81 | 167 | pace_charge_ctrl = HIGH; |
weebgrammers | 7:6dc42e1a2a81 | 168 | wait_ms(10); |
weebgrammers | 7:6dc42e1a2a81 | 169 | |
weebgrammers | 7:6dc42e1a2a81 | 170 | vent_pace_ctrl = HIGH; |
weebgrammers | 7:6dc42e1a2a81 | 171 | |
weebgrammers | 7:6dc42e1a2a81 | 172 | // Pace Duration |
weebgrammers | 7:6dc42e1a2a81 | 173 | wait_us(wid/10); |
weebgrammers | 7:6dc42e1a2a81 | 174 | |
weebgrammers | 7:6dc42e1a2a81 | 175 | // Shut off Pace |
weebgrammers | 7:6dc42e1a2a81 | 176 | vent_pace_ctrl = LOW; |
weebgrammers | 7:6dc42e1a2a81 | 177 | |
weebgrammers | 7:6dc42e1a2a81 | 178 | atr_pace_ctrl = LOW; |
weebgrammers | 7:6dc42e1a2a81 | 179 | vent_pace_ctrl = LOW; |
weebgrammers | 7:6dc42e1a2a81 | 180 | atr_grnd_ctrl = HIGH; |
weebgrammers | 7:6dc42e1a2a81 | 181 | vent_grnd_ctrl = HIGH; |
weebgrammers | 7:6dc42e1a2a81 | 182 | wait_ms(50); |
weebgrammers | 7:6dc42e1a2a81 | 183 | |
weebgrammers | 7:6dc42e1a2a81 | 184 | |
weebgrammers | 7:6dc42e1a2a81 | 185 | /* Stage 2: Ref PWM LOW */ |
weebgrammers | 7:6dc42e1a2a81 | 186 | pacing_ref_pwm = LOW; |
weebgrammers | 7:6dc42e1a2a81 | 187 | wait_ms(100); |
weebgrammers | 7:6dc42e1a2a81 | 188 | |
weebgrammers | 7:6dc42e1a2a81 | 189 | /* Stage 3: Charge CTRL off */ |
weebgrammers | 7:6dc42e1a2a81 | 190 | pace_charge_ctrl = LOW; |
weebgrammers | 7:6dc42e1a2a81 | 191 | wait_ms(10); |
weebgrammers | 7:6dc42e1a2a81 | 192 | |
weebgrammers | 7:6dc42e1a2a81 | 193 | /* Stage 4: Ground OFF */ |
weebgrammers | 7:6dc42e1a2a81 | 194 | atr_grnd_ctrl = LOW; |
weebgrammers | 7:6dc42e1a2a81 | 195 | vent_grnd_ctrl = LOW; |
weebgrammers | 7:6dc42e1a2a81 | 196 | |
weebgrammers | 7:6dc42e1a2a81 | 197 | output_pin_V=!output_pin_V; |
weebgrammers | 7:6dc42e1a2a81 | 198 | /*AnalogOut aout(p18); //sets up pin 18 as an analogue output |
weebgrammers | 7:6dc42e1a2a81 | 199 | AnalogueIn ain(p15); //sets up pin 15 and an analogue input |
weebgrammers | 7:6dc42e1a2a81 | 200 | |
weebgrammers | 7:6dc42e1a2a81 | 201 | int main(){ |
weebgrammers | 7:6dc42e1a2a81 | 202 | aout=0.5; //sets output to 0.5*VCC |
weebgrammers | 7:6dc42e1a2a81 | 203 | while(1){ //sets up a loop |
weebgrammers | 7:6dc42e1a2a81 | 204 | if (ain>0.3){ //tests whether the input is above 0.3 |
weebgrammers | 7:6dc42e1a2a81 | 205 | aout=0; //sets the output to 0 |
weebgrammers | 7:6dc42e1a2a81 | 206 | } |
weebgrammers | 7:6dc42e1a2a81 | 207 | aout = 0.5; |
weebgrammers | 7:6dc42e1a2a81 | 208 | wait(1); |
weebgrammers | 7:6dc42e1a2a81 | 209 | aout = 0;*/ |
weebgrammers | 8:45befd2bb1e5 | 210 | } |
weebgrammers | 8:45befd2bb1e5 | 211 | /////////////////////////////////////////////////////////////////////////////////////////////// |
weebgrammers | 8:45befd2bb1e5 | 212 | |
weebgrammers | 9:751e39d24c39 | 213 | /*void initialize_motion () { |
weebgrammers | 8:45befd2bb1e5 | 214 | acc.enable(); |
weebgrammers | 8:45befd2bb1e5 | 215 | } |
weebgrammers | 8:45befd2bb1e5 | 216 | |
weebgrammers | 8:45befd2bb1e5 | 217 | bool isMotionThresholdExceeded () { |
weebgrammers | 8:45befd2bb1e5 | 218 | return motion_exceeded_threshold; |
weebgrammers | 8:45befd2bb1e5 | 219 | } |
weebgrammers | 8:45befd2bb1e5 | 220 | |
weebgrammers | 8:45befd2bb1e5 | 221 | void resetMotionDetection () { |
weebgrammers | 8:45befd2bb1e5 | 222 | motion_exceeded_threshold = 0; |
weebgrammers | 8:45befd2bb1e5 | 223 | } |
weebgrammers | 8:45befd2bb1e5 | 224 | |
weebgrammers | 8:45befd2bb1e5 | 225 | /**** Function: a_count |
weebgrammers | 8:45befd2bb1e5 | 226 | * return: void |
weebgrammers | 8:45befd2bb1e5 | 227 | * parameters: none |
weebgrammers | 8:45befd2bb1e5 | 228 | * A function called if motion detection interrupt flag is set. Maintains |
weebgrammers | 8:45befd2bb1e5 | 229 | * a global counter and sets a timer to keep track of number of flags within |
weebgrammers | 8:45befd2bb1e5 | 230 | * timing limit. |
weebgrammers | 8:45befd2bb1e5 | 231 | */ |
weebgrammers | 9:751e39d24c39 | 232 | /*void a_count(void) { |
weebgrammers | 9:751e39d24c39 | 233 | /* step 1 increment the counter |
weebgrammers | 8:45befd2bb1e5 | 234 | numCount++; |
weebgrammers | 8:45befd2bb1e5 | 235 | |
weebgrammers | 8:45befd2bb1e5 | 236 | |
weebgrammers | 8:45befd2bb1e5 | 237 | if (numCount >= MAX_NUM_COUNTS) { |
weebgrammers | 8:45befd2bb1e5 | 238 | rled = !rled; // toggle LEDs to show acceleration threshold reached |
weebgrammers | 8:45befd2bb1e5 | 239 | gled = !gled; // toggle LEDS to show acceleration threshold reached |
weebgrammers | 8:45befd2bb1e5 | 240 | |
weebgrammers | 8:45befd2bb1e5 | 241 | motion_exceeded_threshold = 1; |
weebgrammers | 8:45befd2bb1e5 | 242 | } |
weebgrammers | 8:45befd2bb1e5 | 243 | } |
weebgrammers | 8:45befd2bb1e5 | 244 | |
weebgrammers | 8:45befd2bb1e5 | 245 | void motion_thread () { |
weebgrammers | 8:45befd2bb1e5 | 246 | while(true) { |
weebgrammers | 8:45befd2bb1e5 | 247 | |
weebgrammers | 8:45befd2bb1e5 | 248 | float xAcc, yAcc, zAcc; |
weebgrammers | 8:45befd2bb1e5 | 249 | acc.getX(&xAcc); |
weebgrammers | 8:45befd2bb1e5 | 250 | acc.getY(&yAcc); |
weebgrammers | 8:45befd2bb1e5 | 251 | acc.getZ(&zAcc); |
weebgrammers | 8:45befd2bb1e5 | 252 | float magtd = xAcc*xAcc + yAcc*yAcc + zAcc*zAcc; |
weebgrammers | 8:45befd2bb1e5 | 253 | |
weebgrammers | 8:45befd2bb1e5 | 254 | if (magtd > 3.0f) { // Greater than (1.5G of Accel.)^2 |
weebgrammers | 8:45befd2bb1e5 | 255 | a_count(); // increment acceleration event counter |
weebgrammers | 8:45befd2bb1e5 | 256 | } |
weebgrammers | 8:45befd2bb1e5 | 257 | |
weebgrammers | 8:45befd2bb1e5 | 258 | } |
weebgrammers | 9:751e39d24c39 | 259 | }*/ |