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 Momo Medical

Revision:
22:a09775c25890
Parent:
21:13e4824bc364
Child:
23:4a09554bdc1a
--- a/Sensorplate/main.cpp	Mon Oct 02 15:53:29 2017 +0000
+++ b/Sensorplate/main.cpp	Mon Oct 02 16:05:46 2017 +0000
@@ -61,7 +61,7 @@
 int k = 0;
 float acce[3];                      // Raw accelerometer data
 float gyro[3];                      // Raw gyroscope data
-char LED_colour;                                                            // Variable to set LED colour.
+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 speaker_state = 0, LED_red_state = 0, LED_yellow_state = 0, LED_green_state = 0, power_plug_state = 0;
@@ -73,10 +73,10 @@
 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, intensity;                                // 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 control_LED_intensity = 0;                                           // Variable between 0 and 1 to set the intensity of the LED's above the buttons.
+double intensity, control_LED_intensity = 0;                                           // Variable between 0 and 1 to set the intensity of the LED's above the buttons.
 
 /*************************** CODE ********************************/
 
@@ -88,6 +88,7 @@
         intensity = intensity_night;
     }
     control_LED_intensity = (intensity/100);
+    pc.printf("control_LED_intensity = %f\n", control_LED_intensity);
 }
 
 void serial_read()                                                          // Serial read for select LED intensity and colour.
@@ -387,13 +388,13 @@
     if (lock_state == 1) {
     } else {
         if (reposition == 0) {
-            reposition_LED = 1;
+            reposition_LED = control_LED_intensity;
         } else {
             reposition_LED = 0;
         }
 
         if (new_patient == 0) {
-            new_patient_LED = 1;
+            new_patient_LED = control_LED_intensity;
         } else {
             new_patient_LED = 0;
         }
@@ -521,8 +522,9 @@
     new_patient.rise(&timer_calibration);                                   // Falling edge for calibration algorithm option.
     delay.reset();                                                          // Delaytimer reset en start.
     delay.start();
-
-    lock_LED = 0.75;                                                        // Lock LED initialization.
+    
+    set_intensity();
+    lock_LED = control_LED_intensity;                                                        // Lock LED initialization.
 
     sample_cycle.attach_us(&read_adc, cycle_time);