Pilot 1 working code (excluding new patient after calculation). %d changed in %f sensordata serial log.
Dependencies: ADS1015 MPU6050 PixelArray mbed
Fork of Momo_New by
Diff: Sensorplate/main.cpp
- Revision:
- 25:96c34634abda
- Parent:
- 24:782c4dc4a3ff
- Child:
- 26:9e130f7ee829
--- a/Sensorplate/main.cpp Mon Oct 02 16:25:29 2017 +0000 +++ b/Sensorplate/main.cpp Tue Oct 03 08:53:56 2017 +0000 @@ -63,7 +63,7 @@ float gyro[3]; // Raw gyroscope data char LED_colour = 'g'; // Variable to set LED colour. bool lock_state = 0, lock_flag = 0, mute_state = 0, alarm = 0, calibration_flag = 0, intensity_select = 0; // Boolean variables for states logging. -bool mute_flag = 0, new_patient_flag = 0, reposition_flag = 0, sensorplate_connect = 0; +bool mute_flag = 0, new_patient_flag = 0, reposition_flag = 0; bool speaker_state = 0, LED_red_state = 0, LED_yellow_state = 0, LED_green_state = 0, power_plug_state = 0; bool speaker_logged = 0, LED_red_logged = 0, LED_yellow_logged = 0, LED_green_logged = 0, power_plug_logged = 0; int locktime_ms = 2000; // Waittime for lock user interface in ms. @@ -73,7 +73,7 @@ int delay_lock_interface = 3000*60; // Delay for non using interface locktime. int speaker_active_ms = 750; // Time to iterate speaker on and off when alarm occurs. int alarm_voltage = 5867; // Needed voltage for alarm expressed as a digital 15 bit value (=20% of max battery voltage) -int red_var, green_var, blue_var; // Variables to set LED intensity. +int red_var, green_var, blue_var; // Variables to set LED intensity. short batteryvoltage_current = 0, batteryvoltage_last = 0, powervoltage_current, powervoltage_last; // Variables to manage batteryvoltage. int intensity_day = 50, intensity_night = 25; // Intensity settings for LED's to wall. double intensity, control_LED_intensity = 0; // Variable between 0 and 1 to set the intensity of the LED's above the buttons. @@ -403,7 +403,7 @@ void read_voltage() { - if (power_plug_state == 1) { // If supplyvoltage (readed from input) is greater then the setted alarmvoltage. + if (power_plug_state == 1) { // If supplyvoltage (readed from input) is greater then the setted alarmvoltage. alarm = 0; // Alarm is off. speaker_state = 0; } else { @@ -434,7 +434,7 @@ } batteryvoltage_current = adsAccu.readADC_SingleEnded(0); // Read channel 0 from external ADC. - powervoltage_current = adsAccu.readADC_SingleEnded(1); // Read channel 1 from external ADC. + powervoltage_current = adsAccu.readADC_SingleEnded(1); // Read channel 1 from external ADC. if (powervoltage_current < 20000) { power_plug_state = 0; @@ -448,7 +448,7 @@ t.reset(); t.start(); - if (sensorplate_connect == 1) { + if (pel.readADC_SingleEnded(0) > 0) { elec[0] = pel.readADC_SingleEnded(0); // First PE readout for (k = 0; k < 4; k = k + 1) { @@ -488,7 +488,7 @@ while(t.read_us()<(4*(cycle_time/5))) {} // Wait untill 80% of cycle - if (sensorplate_connect == 1) { + if (pel.readADC_SingleEnded(0) > 0) { elec[4] = pel.readADC_SingleEnded(0); // Fifth PE readout } @@ -501,7 +501,7 @@ int main() { - wait_ms(boot_delay_ms); // Wait to boot sensorplate first + wait_ms(boot_delay_ms); // Wait to boot sensorplate first i2c.frequency(i2c_freq); i2cAccu.frequency(i2c_freq); pc.baud(baud); @@ -523,7 +523,7 @@ delay.start(); set_intensity(); - lock_LED = control_LED_intensity; // Lock LED initialization. + lock_LED = control_LED_intensity; // Lock LED initialization. sample_cycle.attach_us(&read_adc, cycle_time);