Nucleo-transfer

Dependencies:   ADS1015 MPU6050 PixelArray PixelArray-Nucleo mbed WS2813

Fork of Nucleo-transfer by Momo Medical

Committer:
Ishy
Date:
Fri Mar 09 11:39:53 2018 +0000
Revision:
60:2f7e82c6f916
Parent:
58:8cfa736d8553
Child:
64:065e2a679bad
Child:
66:88c910cd4d9e
Added co-author

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ricardo_95 36:d10f368d037b 1 /********************* CODE INFORMATON ******************************
ricardo_95 34:1614f4f2b841 2 Date of creation: 30-09-2017
ricardo_95 34:1614f4f2b841 3 Authors: Danny Eldering & Ricardo Molenaar
Ishy 60:2f7e82c6f916 4 co-authors: Menno Gravemaker & Ishvara Lalta
ricardo_95 34:1614f4f2b841 5 (c) Copyright by Momo Medical BV.
ricardo_95 34:1614f4f2b841 6
ricardo_95 45:7ebe860702b4 7 Current version name: 2.1.4
ricardo_95 45:7ebe860702b4 8 Date of modification: 8-1-2018
ricardo_95 36:d10f368d037b 9 Purpose of this file: Code for LPC1768 microcontroller for controlling buttons, LED's and communicate to PI
ricardo_95 45:7ebe860702b4 10 Update ‘what’s new in this version?’: Sensorplate connection test changed from software to hardware check.
deldering95 48:aca02ef5cd01 11 ADC readout for accu deleted.
ricardo_95 36:d10f368d037b 12 Todo: -> Fix LED issue (yellow and red flashes at random moments);
deldering95 43:d09814c177a0 13 -> Optimize functions / improve readability;
ricardo_95 36:d10f368d037b 14 -> Split functions in seperate files?;
ricardo_95 36:d10f368d037b 15 -> Fix when sensorplate is not connected;
ricardo_95 36:d10f368d037b 16 -> Rule 570: if statement change to turn off LED's when power is plugged out (also related to rule 106).
ricardo_95 36:d10f368d037b 17 -> For the speaker two outputs of the uC are used. Add MOSFET with external supply and control these by uC?
ricardo_95 36:d10f368d037b 18 Source file: http://mbed.com/
ricardo_95 33:df21cb8dc5c7 19
ricardo_95 36:d10f368d037b 20 Information files:
deldering95 43:d09814c177a0 21 (1) Flowchart:
ricardo_95 36:d10f368d037b 22 (2) Table serial communication: https://docs.google.com/spreadsheets/d/1kHlithHxtoMDGvbcdH8vwSw5W5ArxlwDPsyfra1dtQM/edit?usp=drive_web
deldering95 43:d09814c177a0 23 (3) Technical manual CU-/software:
ricardo_95 12:7b3a5940f911 24 */
ricardo_95 12:7b3a5940f911 25
ricardo_95 21:13e4824bc364 26 /************************ CONFIG ***********************************/
ricardo_95 21:13e4824bc364 27
ricardo_95 36:d10f368d037b 28 #include "mbed.h" // Include files and define parameters.
DEldering 0:c0e44c46c573 29 #include "Adafruit_ADS1015.h"
DEldering 0:c0e44c46c573 30 #include "MPU6050.h"
ricardo_95 33:df21cb8dc5c7 31 #include "MPU6050_belt.h"
deldering95 43:d09814c177a0 32 #include "PixelArray.h"
deldering95 43:d09814c177a0 33 #include "WS2812.h"
ricardo_95 37:d8f7b2b5719a 34
deldering95 43:d09814c177a0 35 #define WS2812_BUF 3
deldering95 43:d09814c177a0 36 #define NUM_COLORS 5
deldering95 43:d09814c177a0 37 #define NUM_LEDS_PER_COLOR 3
deldering95 48:aca02ef5cd01 38 #define NUMBER_LED_FRONT (3)
ricardo_95 7:dba5091c8b7d 39 #define ONE_COLOR
ricardo_95 7:dba5091c8b7d 40
ricardo_95 46:a0e6e088a50a 41 InterruptIn button_lock(PC_1); // Input on intterupt base decleration.
ricardo_95 46:a0e6e088a50a 42 InterruptIn button_reposition(PC_3);
Ishy 41:5380ada94ec6 43 InterruptIn button_mute(PC_2);
ricardo_95 46:a0e6e088a50a 44 InterruptIn button_new_patient(PC_0);
ricardo_95 7:dba5091c8b7d 45
deldering95 43:d09814c177a0 46 DigitalIn intensity_code(PA_12);
deldering95 43:d09814c177a0 47 DigitalIn colour_code_1(PA_11);
deldering95 43:d09814c177a0 48 DigitalIn colour_code_0(PB_12);
deldering95 57:fac732476810 49 InterruptIn testpin_sensorplate(PC_6);
deldering95 43:d09814c177a0 50
deldering95 43:d09814c177a0 51 DigitalOut LED_on_dev_board1(LED1); // Decleration of digital outputs.
ricardo_95 36:d10f368d037b 52 DigitalOut LED_on_dev_board2(LED2);
ricardo_95 36:d10f368d037b 53 DigitalOut LED_on_dev_board3(LED3);
ricardo_95 36:d10f368d037b 54 DigitalOut LED_on_dev_board4(LED4);
deldering95 43:d09814c177a0 55 DigitalOut speaker1(PC_12); // relatie aangeven!
deldering95 43:d09814c177a0 56 //neopixel::PixelArray indicator_LEDs(PA_7);
deldering95 43:d09814c177a0 57 PixelArray px(WS2812_BUF);
deldering95 51:69087c44e8ac 58 //WS2812 ws(PA_7, WS2812_BUF, 3, 9, 9, 6);
deldering95 53:54c882995514 59 WS2812 ws(PA_7, WS2812_BUF, 3, 9, 9, 6);
deldering95 43:d09814c177a0 60
deldering95 51:69087c44e8ac 61 PwmOut lock_feedback_LED(PB_13); //(PB_1); // Declaration of pulse with modulation outputs.
deldering95 51:69087c44e8ac 62 PwmOut mute_feedback_LED(PB_14); //(PB_15);
deldering95 51:69087c44e8ac 63 PwmOut new_patient_feedback_LED(PB_15); //(PB_14);
deldering95 51:69087c44e8ac 64 PwmOut reposition_feedback_LED(PB_1); //(PB_13);
ricardo_95 36:d10f368d037b 65
ricardo_95 37:d8f7b2b5719a 66 Timer button_lock_hold_timer; // Timer for time lock button should be pressed.
ricardo_95 36:d10f368d037b 67 Timer button_calibration_hold_timer; // Timer for calibration function (new patient holding 5 seconds).
deldering95 43:d09814c177a0 68 Timer delay_between_button_pressed; // Timer for time between two buttons (to prevent pressing buttons simultaneously).
ricardo_95 36:d10f368d037b 69 Timer speaker_timer; // Timer for speaker activation.
ricardo_95 36:d10f368d037b 70 Timer piezo_electric_sample_timer; // Timer for equally time-spaced samples.
deldering95 48:aca02ef5cd01 71 Timer Knight_Rider_Timer;
deldering95 43:d09814c177a0 72 /*
ricardo_95 36:d10f368d037b 73 The code underneath this commentbox has some fixed parameters for serial/ADC reading:
ricardo_95 36:d10f368d037b 74 -> The address for the angle_device_reference_belt is set to 0x68 in the file MPU6050_belt (rule number: 19);
ricardo_95 36:d10f368d037b 75 -> The adress for the angle_device_sensorplate is set to 0x69 in the file MPU6050.h (rule number: 19);
ricardo_95 36:d10f368d037b 76 -> This is because of using the same I2C line;
ricardo_95 36:d10f368d037b 77 -> For detailed information/questions about this item, please read the technical manual or contact: Ricardo Molenaar | ricardo.molenaar@gmail.com
ricardo_95 36:d10f368d037b 78 */
Ishy 41:5380ada94ec6 79 I2C i2c_sensorplate_adc(PB_9, PB_8); // I2C for sensorplate.
ricardo_95 46:a0e6e088a50a 80 MPU6050_belt angle_device_sensorplate(PB_9, PB_8); // i2c pins // i2c address hardcoded 0x68.
Ishy 41:5380ada94ec6 81 MPU6050_belt angle_device_reference_belt(PB_9, PB_8); // i2c pins // i2c address hardcoded 0x69.
ricardo_95 36:d10f368d037b 82 Adafruit_ADS1115 piezo_resistive_adc1(&i2c_sensorplate_adc, 0x48); // i2c pins, i2c address.
ricardo_95 36:d10f368d037b 83 Adafruit_ADS1115 piezo_resistive_adc2(&i2c_sensorplate_adc, 0x49); // i2c pins, i2c address.
ricardo_95 36:d10f368d037b 84 Adafruit_ADS1115 piezo_electric_adc(&i2c_sensorplate_adc, 0x4B); // i2c pins, i2c address.
deldering95 43:d09814c177a0 85 Serial usb_serial(SERIAL_TX, SERIAL_RX); // tx, rx
deldering95 43:d09814c177a0 86 Serial pi_serial(PC_10, PC_11); // tx, rx
ricardo_95 36:d10f368d037b 87 Ticker total_readout_cycle; // Polling cycle.
deldering95 43:d09814c177a0 88 // End of commentbox related to the serial configuration/ADC reading components.
ricardo_95 34:1614f4f2b841 89
ricardo_95 12:7b3a5940f911 90 int boot_delay_ms = 500;
Ishy 42:673ddef4cfa4 91 int total_readout_cycle_time_us = 100000; // Cycle time in us.
deldering95 48:aca02ef5cd01 92 int total_knight_rider_cycle_time_ms = 1000;
ricardo_95 39:cff99a9b7237 93 int i2c__frequency = 400000; // I2C Frequency.
ricardo_95 36:d10f368d037b 94 int baud_rate = 115200; // Baud rate.
ricardo_95 36:d10f368d037b 95 short piezo_resistive_array[8] = {0,0,0,0,0,0,0,0}; // 8 PR sensors 1 time per cycle.
deldering95 58:8cfa736d8553 96 short piezo_electric_array[6] = {0,0,0,0,0,0}; // 1 PE sensor 5 times per cycle.
ricardo_95 36:d10f368d037b 97 int angle = 0; // Accelerometer Z-axis.
ricardo_95 37:d8f7b2b5719a 98 float accelerometer_sensorplate[3] = {0.0, 0.0, 0.0}; // Raw accelerometer data.
ricardo_95 36:d10f368d037b 99 float gyroscope_sensorplate[3]; // Raw gyroscope data.
ricardo_95 36:d10f368d037b 100 float accelerometer_reference_belt[3]; // Raw accelerometer data from belt.
ricardo_95 36:d10f368d037b 101 float gyroscope_reference_belt[3]; // Raw gyroscope data from belt.
deldering95 51:69087c44e8ac 102 int colourbuf[NUM_COLORS] = {0xff0000,0x00ff00,0x0000ff,0xffa500,0xffffff}; // hex codes for the different colours
deldering95 44:dcbde3175a37 103 char LED_colour = 'w'; // Variable to set LED colour (standard set to green, untill PI sends other character). Other possible colours: red ('r') & yellow ('y').
ricardo_95 37:d8f7b2b5719a 104 bool lock_state = false, lock_flag = 0, mute_state = 0, alarm = 0, calibration_flag = 0, intensity_select = 1; // Boolean variables for logging states.
Ishy 55:b74e7076d7a0 105 bool mute_flag = 0, new_patient_flag = 0, reposition_flag = 0, new_patient_lock_flag = 0, reposition_lock_flag = 0, mute_lock_flag; // Flag variables.
ricardo_95 21:13e4824bc364 106 bool speaker_state = 0, LED_red_state = 0, LED_yellow_state = 0, LED_green_state = 0, power_plug_state = 0;
Ishy 55:b74e7076d7a0 107 bool auto_lock_led_logged = 0, lock_is_logged = 0, speaker_logged = 0, LED_red_logged = 0, LED_yellow_logged = 0, LED_green_logged = 0, power_plug_logged = 0; // is toevoegen
ricardo_95 36:d10f368d037b 108 int locktime_ms = 2000; // Waittime for lock user interface in ms.
deldering95 48:aca02ef5cd01 109 int calibrationtime_ms = 2000; // Time to press new_patient button for calibration system.
ricardo_95 37:d8f7b2b5719a 110 int calibration_flash = 0; // Variable for flash LED's to indicate calibration.
deldering95 48:aca02ef5cd01 111 int lock_flash = 0;
Ishy 55:b74e7076d7a0 112 int buttondelay_ms = 250; // Button delay in ms. Default: 750
ricardo_95 36:d10f368d037b 113 int delay_lock_interface = 3000*60; // Delay for non using interface locktime.
ricardo_95 36:d10f368d037b 114 int speaker_active_ms = 750; // Time to iterate speaker on and off when alarm occurs.
ricardo_95 38:764847892afc 115 int alarm_voltage = 2400; // Needed voltage for alarm expressed as a digital 15 bit value (= 20% of max battery voltage).
ricardo_95 37:d8f7b2b5719a 116 int LED_red_intensity = 0, LED_blue_intensity = 0, LED_green_intensity = 0; // Variables to set LED intensity.
ricardo_95 45:7ebe860702b4 117 //short batteryvoltage_current = 0, batteryvoltage_last = 0, powervoltage_current, powervoltage_last; // Variables to manage batteryvoltage. Maybe change current to other?
ricardo_95 45:7ebe860702b4 118 //const int digital_value_ADC_powervoltage_unplugged = 15000; // Digital value to set the indicating LEDs to wall blue (should be set off later). const in hoofdletters
deldering95 51:69087c44e8ac 119 int intensity_day = 20, intensity_night = 5; // Intensity settings for LED's to wall.
ricardo_95 38:764847892afc 120 double intensity = 0.0, control_LED_intensity = 0.0; // Variable between 0 and 1 to set the intensity of the LED's above the buttons. Intensity change to smart name!
deldering95 44:dcbde3175a37 121 int colour_code = 0b00;
deldering95 44:dcbde3175a37 122 bool pi_active = false;
ricardo_95 33:df21cb8dc5c7 123 /*************************** TEST ********************************/
ricardo_95 36:d10f368d037b 124 // Verify algoritm function: for belt activation, set test_belt 1 (connect pin p20 to 3.3V).
deldering95 43:d09814c177a0 125 Timer test_timer;
Ishy 41:5380ada94ec6 126 DigitalIn test_pin(PA_11, PullDown);
ricardo_95 33:df21cb8dc5c7 127
deldering95 43:d09814c177a0 128 // Variable to set if belt is used to test algorithm:
deldering95 43:d09814c177a0 129 bool test_belt = 0;
ricardo_95 33:df21cb8dc5c7 130
deldering95 43:d09814c177a0 131 // Set test mode on (log functions to pc serial: interrupts, LED intensity and serial messages):
Ishy 55:b74e7076d7a0 132 bool test_mode = 1;
ricardo_95 34:1614f4f2b841 133
ricardo_95 36:d10f368d037b 134 // Variable for connection test (should be changed):
ricardo_95 46:a0e6e088a50a 135 bool connection_test_sensorplate;
ricardo_95 33:df21cb8dc5c7 136
ricardo_95 21:13e4824bc364 137 /*************************** CODE ********************************/
ricardo_95 7:dba5091c8b7d 138
ricardo_95 36:d10f368d037b 139 void set_intensity_LEDs() // Function to set the intensity for the LED's.
ricardo_95 7:dba5091c8b7d 140 {
ricardo_95 11:73c6def38fbd 141 if (intensity_select == 1) {
ricardo_95 12:7b3a5940f911 142 intensity = intensity_day;
ricardo_95 12:7b3a5940f911 143 } else {
ricardo_95 12:7b3a5940f911 144 intensity = intensity_night;
ricardo_95 7:dba5091c8b7d 145 }
ricardo_95 21:13e4824bc364 146 control_LED_intensity = (intensity/100);
ricardo_95 34:1614f4f2b841 147
ricardo_95 37:d8f7b2b5719a 148 if (test_mode == 1) { // If statement for test purposal LED_intensity values. if def gebruiken voor testmode
Ishy 55:b74e7076d7a0 149 // usb_serial.printf("Intensity LED's shines to wall = %f\n", intensity);
Ishy 55:b74e7076d7a0 150 // usb_serial.printf("Intensity LED's above buttons = %f\n", control_LED_intensity);
ricardo_95 33:df21cb8dc5c7 151 }
ricardo_95 7:dba5091c8b7d 152 }
ricardo_95 7:dba5091c8b7d 153
ricardo_95 36:d10f368d037b 154 void serial_read() // Function for serial read for select LED intensity and colour.
ricardo_95 12:7b3a5940f911 155 {
deldering95 43:d09814c177a0 156 colour_code = (colour_code_1 << 1 | colour_code_0);
deldering95 48:aca02ef5cd01 157 if(colour_code != 0b00 && pi_active == false) {
deldering95 48:aca02ef5cd01 158 pi_active = true;
deldering95 48:aca02ef5cd01 159 }
deldering95 48:aca02ef5cd01 160 if(pi_active) {
deldering95 48:aca02ef5cd01 161 intensity_select = intensity_code;
deldering95 48:aca02ef5cd01 162 switch(colour_code) {
deldering95 48:aca02ef5cd01 163 case 0b11 :
deldering95 48:aca02ef5cd01 164 LED_colour = 'y';
deldering95 48:aca02ef5cd01 165 break;
deldering95 48:aca02ef5cd01 166 case 0b10 :
deldering95 48:aca02ef5cd01 167 LED_colour = 'b';
deldering95 48:aca02ef5cd01 168 break;
deldering95 48:aca02ef5cd01 169 case 0b01 :
deldering95 48:aca02ef5cd01 170 LED_colour = 'g';
deldering95 48:aca02ef5cd01 171 break;
deldering95 48:aca02ef5cd01 172 case 0b00 :
deldering95 48:aca02ef5cd01 173 LED_colour = 'r';
deldering95 48:aca02ef5cd01 174 break;
deldering95 48:aca02ef5cd01 175 default :
deldering95 48:aca02ef5cd01 176 LED_colour = 'w';
deldering95 48:aca02ef5cd01 177 break;
deldering95 48:aca02ef5cd01 178 }
deldering95 48:aca02ef5cd01 179 }
ricardo_95 34:1614f4f2b841 180
deldering95 43:d09814c177a0 181 if (test_mode == 1) { // If statement for test purposal.
Ishy 55:b74e7076d7a0 182 // usb_serial.printf("Intensity_select = %d en LED_colour = %d\n", intensity_select, LED_colour);
deldering95 43:d09814c177a0 183 }
ricardo_95 34:1614f4f2b841 184
deldering95 43:d09814c177a0 185 if (test_mode == 0) {
deldering95 48:aca02ef5cd01 186 //usb_serial.printf("Message: %s\n", message);
deldering95 48:aca02ef5cd01 187 usb_serial.printf("Intensity_select = %d en LED_colour = %d\n", intensity_select, LED_colour);
deldering95 43:d09814c177a0 188
ricardo_95 11:73c6def38fbd 189 }
ricardo_95 11:73c6def38fbd 190 }
ricardo_95 11:73c6def38fbd 191
deldering95 58:8cfa736d8553 192 void serial_log() // Function for serial logging. See link to table with code declarations above in code.
deldering95 58:8cfa736d8553 193 {
Ishy 55:b74e7076d7a0 194
Ishy 55:b74e7076d7a0 195 if (reposition_flag == 1) { // If statement to control logging for reposition button.
ricardo_95 36:d10f368d037b 196 pi_serial.printf(">01\n");
ricardo_95 34:1614f4f2b841 197
deldering95 43:d09814c177a0 198 if (test_mode == 1) { // If statement for test purposal.
ricardo_95 36:d10f368d037b 199 usb_serial.printf(">01\n");
ricardo_95 33:df21cb8dc5c7 200 }
ricardo_95 34:1614f4f2b841 201
Ishy 55:b74e7076d7a0 202 reposition_flag = 0;
Ishy 55:b74e7076d7a0 203 }
deldering95 58:8cfa736d8553 204
Ishy 55:b74e7076d7a0 205 if (reposition_lock_flag == 1) { // If statement to control logging for reposition button.
Ishy 55:b74e7076d7a0 206 pi_serial.printf(">10\n");
Ishy 55:b74e7076d7a0 207
Ishy 55:b74e7076d7a0 208 if (test_mode == 1) { // If statement for test purposal.
Ishy 55:b74e7076d7a0 209 usb_serial.printf(">10\n");
Ishy 55:b74e7076d7a0 210 }
Ishy 55:b74e7076d7a0 211
Ishy 55:b74e7076d7a0 212 reposition_lock_flag = 0;
ricardo_95 19:3b5999fa7b7e 213 }
ricardo_95 12:7b3a5940f911 214
ricardo_95 36:d10f368d037b 215 if (new_patient_flag == 1) { // If statement to control logging for new patient button.
Ishy 55:b74e7076d7a0 216 pi_serial.printf(">02\n");
Ishy 55:b74e7076d7a0 217
Ishy 55:b74e7076d7a0 218 if (test_mode == 1) { // If statement for test purposal.
Ishy 55:b74e7076d7a0 219 usb_serial.printf(">02\n");
Ishy 55:b74e7076d7a0 220 }
Ishy 55:b74e7076d7a0 221
Ishy 55:b74e7076d7a0 222 new_patient_flag = 0;
Ishy 55:b74e7076d7a0 223 }
deldering95 58:8cfa736d8553 224
Ishy 55:b74e7076d7a0 225 if (new_patient_lock_flag == 1) { // If statement to control logging for new patient button.
Ishy 55:b74e7076d7a0 226 pi_serial.printf(">20\n");
Ishy 55:b74e7076d7a0 227
Ishy 55:b74e7076d7a0 228 if (test_mode == 1) { // If statement for test purposal.
Ishy 55:b74e7076d7a0 229 usb_serial.printf(">20\n");
Ishy 55:b74e7076d7a0 230 }
Ishy 55:b74e7076d7a0 231
Ishy 55:b74e7076d7a0 232 new_patient_lock_flag = 0;
Ishy 55:b74e7076d7a0 233 }
Ishy 55:b74e7076d7a0 234 // The new calibration button trigger
Ishy 55:b74e7076d7a0 235 if (mute_flag == 1) { // If statement to control logging for new patient button.
ricardo_95 36:d10f368d037b 236 pi_serial.printf(">03\n");
ricardo_95 34:1614f4f2b841 237
deldering95 43:d09814c177a0 238 if (test_mode == 1) { // If statement for test purposal.
ricardo_95 36:d10f368d037b 239 usb_serial.printf(">03\n");
ricardo_95 33:df21cb8dc5c7 240 }
ricardo_95 34:1614f4f2b841 241
Ishy 55:b74e7076d7a0 242 mute_flag = 0;
ricardo_95 7:dba5091c8b7d 243 }
Ishy 55:b74e7076d7a0 244 // The new calibration button trigger
Ishy 55:b74e7076d7a0 245 if (mute_lock_flag == 1) { // If statement to control logging for new patient button.
Ishy 55:b74e7076d7a0 246 pi_serial.printf(">30\n");
ricardo_95 34:1614f4f2b841 247
deldering95 43:d09814c177a0 248 if (test_mode == 1) { // If statement for test purposal.
Ishy 55:b74e7076d7a0 249 usb_serial.printf(">30\n");
ricardo_95 33:df21cb8dc5c7 250 }
ricardo_95 34:1614f4f2b841 251
Ishy 55:b74e7076d7a0 252 mute_lock_flag = 0;
Ishy 55:b74e7076d7a0 253 }
deldering95 58:8cfa736d8553 254
Ishy 55:b74e7076d7a0 255 if (lock_flag == 1 && !lock_is_logged) {
Ishy 55:b74e7076d7a0 256 if (lock_state == 0) // If statement to control logging for lock button.
Ishy 55:b74e7076d7a0 257 pi_serial.printf(">04\n");
Ishy 55:b74e7076d7a0 258 else if(lock_state == 1)
Ishy 55:b74e7076d7a0 259 pi_serial.printf(">40\n");
Ishy 55:b74e7076d7a0 260
Ishy 55:b74e7076d7a0 261 if (test_mode == 1) {
Ishy 55:b74e7076d7a0 262 if (lock_state == 0) // If statement to control logging for lock button.
Ishy 55:b74e7076d7a0 263 usb_serial.printf(">04\n");
Ishy 55:b74e7076d7a0 264 else if(lock_state == 1)
Ishy 55:b74e7076d7a0 265 usb_serial.printf(">40\n"); // If statement for test purposal.
Ishy 55:b74e7076d7a0 266 }
Ishy 55:b74e7076d7a0 267 lock_is_logged = 1;
ricardo_95 7:dba5091c8b7d 268 }
ricardo_95 12:7b3a5940f911 269
ricardo_95 36:d10f368d037b 270 if (LED_red_logged != LED_red_state) { // If statement to control logging for LED_red.
ricardo_95 12:7b3a5940f911 271 if (LED_red_state == 1) {
Ishy 55:b74e7076d7a0 272 pi_serial.printf("&01\n");
ricardo_95 9:514a44bf510f 273 LED_red_logged = LED_red_state;
ricardo_95 34:1614f4f2b841 274 if (test_mode == 1) {
Ishy 55:b74e7076d7a0 275 usb_serial.printf("&01\n");
ricardo_95 34:1614f4f2b841 276 }
ricardo_95 12:7b3a5940f911 277 }
deldering95 43:d09814c177a0 278
ricardo_95 9:514a44bf510f 279 if (LED_red_state == 0) {
Ishy 55:b74e7076d7a0 280 pi_serial.printf("&10\n");
ricardo_95 12:7b3a5940f911 281 LED_red_logged = LED_red_state;
ricardo_95 34:1614f4f2b841 282 if (test_mode == 1) {
Ishy 55:b74e7076d7a0 283 usb_serial.printf("&10\n");
ricardo_95 34:1614f4f2b841 284 }
ricardo_95 9:514a44bf510f 285 }
ricardo_95 8:bf0f7a6fb1fd 286 }
ricardo_95 12:7b3a5940f911 287
ricardo_95 36:d10f368d037b 288 if (LED_yellow_logged != LED_yellow_state) { // If statement to control logging for LED_yellow.
deldering95 43:d09814c177a0 289 if (LED_yellow_state == 1) {
Ishy 55:b74e7076d7a0 290 pi_serial.printf("&02\n");
ricardo_95 9:514a44bf510f 291 LED_yellow_logged = LED_yellow_state;
ricardo_95 34:1614f4f2b841 292 if (test_mode == 1) {
Ishy 55:b74e7076d7a0 293 usb_serial.printf("&02\n");
ricardo_95 34:1614f4f2b841 294 }
ricardo_95 12:7b3a5940f911 295 }
ricardo_95 9:514a44bf510f 296 if (LED_yellow_state == 0) {
Ishy 55:b74e7076d7a0 297 pi_serial.printf("&20\n");
ricardo_95 12:7b3a5940f911 298 LED_yellow_logged = LED_yellow_state;
ricardo_95 34:1614f4f2b841 299 if (test_mode == 1) {
Ishy 55:b74e7076d7a0 300 usb_serial.printf("&20\n");
ricardo_95 34:1614f4f2b841 301 }
ricardo_95 9:514a44bf510f 302 }
ricardo_95 7:dba5091c8b7d 303 }
ricardo_95 12:7b3a5940f911 304
ricardo_95 36:d10f368d037b 305 if (LED_green_logged != LED_green_state) { // If statement to control logging for LED_green.
ricardo_95 12:7b3a5940f911 306 if (LED_green_state == 1) {
Ishy 55:b74e7076d7a0 307 pi_serial.printf("&03\n");
ricardo_95 9:514a44bf510f 308 LED_green_logged = LED_green_state;
deldering95 43:d09814c177a0 309
ricardo_95 34:1614f4f2b841 310 if (test_mode == 1) {
Ishy 55:b74e7076d7a0 311 usb_serial.printf("&03\n");
ricardo_95 34:1614f4f2b841 312 }
ricardo_95 12:7b3a5940f911 313 }
deldering95 43:d09814c177a0 314
ricardo_95 9:514a44bf510f 315 if (LED_green_state == 0) {
Ishy 55:b74e7076d7a0 316 pi_serial.printf("&30\n");
ricardo_95 12:7b3a5940f911 317 LED_green_logged = LED_green_state;
deldering95 43:d09814c177a0 318
ricardo_95 34:1614f4f2b841 319 if (test_mode == 1) {
Ishy 55:b74e7076d7a0 320 usb_serial.printf("&30\n");
ricardo_95 34:1614f4f2b841 321 }
ricardo_95 9:514a44bf510f 322 }
ricardo_95 7:dba5091c8b7d 323 }
ricardo_95 12:7b3a5940f911 324
deldering95 43:d09814c177a0 325 if (speaker_logged != speaker_state) { // If statement to control logging for speaker.
ricardo_95 12:7b3a5940f911 326 if (speaker_state == 1) {
Ishy 55:b74e7076d7a0 327 pi_serial.printf("&04\n");
ricardo_95 9:514a44bf510f 328 speaker_logged = speaker_state;
deldering95 43:d09814c177a0 329
ricardo_95 36:d10f368d037b 330 if (test_mode == 1) { // If statement for test purposal.
Ishy 55:b74e7076d7a0 331 usb_serial.printf("&04\n");
ricardo_95 34:1614f4f2b841 332 }
ricardo_95 12:7b3a5940f911 333 }
deldering95 43:d09814c177a0 334
ricardo_95 9:514a44bf510f 335 if (speaker_state == 0) {
Ishy 55:b74e7076d7a0 336 pi_serial.printf("&40\n");
ricardo_95 12:7b3a5940f911 337 speaker_logged = speaker_state;
deldering95 43:d09814c177a0 338
ricardo_95 36:d10f368d037b 339 if (test_mode == 1) { // If statement for test purposal.
Ishy 55:b74e7076d7a0 340 usb_serial.printf("&40\n");
ricardo_95 34:1614f4f2b841 341 }
ricardo_95 9:514a44bf510f 342 }
ricardo_95 8:bf0f7a6fb1fd 343 }
ricardo_95 9:514a44bf510f 344
Ishy 55:b74e7076d7a0 345 // if (power_plug_logged != power_plug_state) { // If statement to control the logging for the state of the power plug.
Ishy 55:b74e7076d7a0 346 // if (power_plug_state == 1) {
Ishy 55:b74e7076d7a0 347 // pi_serial.printf("#08\n");
Ishy 55:b74e7076d7a0 348 //
Ishy 55:b74e7076d7a0 349 // if (test_mode == 1) { // If statement for test purposal.
Ishy 55:b74e7076d7a0 350 // usb_serial.printf("#08\n");
Ishy 55:b74e7076d7a0 351 // }
Ishy 55:b74e7076d7a0 352 // power_plug_logged = power_plug_state;
Ishy 55:b74e7076d7a0 353 // }
Ishy 55:b74e7076d7a0 354 //
Ishy 55:b74e7076d7a0 355 // if (power_plug_state == 0) {
Ishy 55:b74e7076d7a0 356 // pi_serial.printf("#80\n");
Ishy 55:b74e7076d7a0 357 //
Ishy 55:b74e7076d7a0 358 // if (test_mode == 1) { // If statement for test purposal.
Ishy 55:b74e7076d7a0 359 // usb_serial.printf("#80\n");
Ishy 55:b74e7076d7a0 360 // }
Ishy 55:b74e7076d7a0 361 // power_plug_logged = power_plug_state;
Ishy 55:b74e7076d7a0 362 // }
Ishy 55:b74e7076d7a0 363 // }
deldering95 58:8cfa736d8553 364
deldering95 43:d09814c177a0 365 if (connection_test_sensorplate == 1) { // If statement for sending serial information sensorplate data when connection test is active.
deldering95 43:d09814c177a0 366 // Receiving order sensor information: 8 resistive sensors, 5 electric readings. Is splitted in two parts - part 1/2.
deldering95 58:8cfa736d8553 367 pi_serial.printf("!,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,\n", piezo_resistive_array[0], piezo_resistive_array[1], piezo_resistive_array[2], piezo_resistive_array[3], piezo_resistive_array[4], piezo_resistive_array[5], piezo_resistive_array[6], piezo_resistive_array[7], piezo_electric_array[0], piezo_electric_array[1], piezo_electric_array[2], piezo_electric_array[3], piezo_electric_array[4], piezo_electric_array[5]); // print all to serial port
deldering95 43:d09814c177a0 368
ricardo_95 34:1614f4f2b841 369 if (test_mode == 1) {
deldering95 58:8cfa736d8553 370 usb_serial.printf("!,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,\n", piezo_resistive_array[0], piezo_resistive_array[1], piezo_resistive_array[2], piezo_resistive_array[3], piezo_resistive_array[4], piezo_resistive_array[5], piezo_resistive_array[6], piezo_resistive_array[7], piezo_electric_array[0], piezo_electric_array[1], piezo_electric_array[2], piezo_electric_array[3], piezo_electric_array[4],piezo_electric_array[5]); // print all to serial port
ricardo_95 34:1614f4f2b841 371 }
deldering95 53:54c882995514 372 } else {
deldering95 58:8cfa736d8553 373 pi_serial.printf("!,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,\n",0,0,0,0,0,0,0,0,0,0,0,0,0,0);
Ishy 56:97dea631c5f2 374 if (test_mode == 1) {
deldering95 58:8cfa736d8553 375 usb_serial.printf("!,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,\n",0,0,0,0,0,0,0,0,0,0,0,0,0,0); // print all to serial port
Ishy 56:97dea631c5f2 376 }
ricardo_95 28:b4bee068780d 377 }
ricardo_95 34:1614f4f2b841 378
DEldering 0:c0e44c46c573 379 }
DEldering 0:c0e44c46c573 380
deldering95 43:d09814c177a0 381 void colour_select_indicating_LED_wall(char nLED_colour) // Function to select the colour for LED's to wall (values comes from algorithm).
ricardo_95 21:13e4824bc364 382 {
ricardo_95 36:d10f368d037b 383 set_intensity_LEDs(); // Call function set_intensity_LEDs to set the intensity for LED's to wall and above buttons.
deldering95 43:d09814c177a0 384 ws.setII(2.55*intensity);
deldering95 43:d09814c177a0 385 switch(nLED_colour) {
deldering95 43:d09814c177a0 386 case 'r' :
deldering95 43:d09814c177a0 387 px.SetAll(colourbuf[0]);
Ishy 55:b74e7076d7a0 388 LED_red_state = 1;
Ishy 55:b74e7076d7a0 389 LED_yellow_state = 0;
deldering95 43:d09814c177a0 390 break;
deldering95 43:d09814c177a0 391 case 'g' :
deldering95 43:d09814c177a0 392 px.SetAll(colourbuf[1]);
Ishy 55:b74e7076d7a0 393 LED_green_state = 1;
Ishy 55:b74e7076d7a0 394 LED_red_state = 0;
deldering95 43:d09814c177a0 395 break;
deldering95 43:d09814c177a0 396 case 'b' :
deldering95 43:d09814c177a0 397 px.SetAll(colourbuf[2]);
deldering95 43:d09814c177a0 398 break;
deldering95 43:d09814c177a0 399 case 'y' :
deldering95 43:d09814c177a0 400 px.SetAll(colourbuf[3]);
Ishy 55:b74e7076d7a0 401 LED_yellow_state = 1;
Ishy 55:b74e7076d7a0 402 LED_green_state = 0;
deldering95 43:d09814c177a0 403 break;
deldering95 43:d09814c177a0 404 default :
deldering95 43:d09814c177a0 405 px.SetAll(colourbuf[4]);
deldering95 43:d09814c177a0 406 }
deldering95 43:d09814c177a0 407
deldering95 43:d09814c177a0 408 if (calibration_flash >= 1) {
deldering95 43:d09814c177a0 409 if ((calibration_flash % 2) == 0) {
deldering95 48:aca02ef5cd01 410 px.SetAll(colourbuf[2]);
deldering95 43:d09814c177a0 411 } else {
deldering95 43:d09814c177a0 412 ws.setII(0);
deldering95 43:d09814c177a0 413 }
deldering95 43:d09814c177a0 414 calibration_flash--;
deldering95 43:d09814c177a0 415 }
deldering95 51:69087c44e8ac 416 //for (int z=WS2812_BUF; z >= 0 ; z--) {
deldering95 53:54c882995514 417 ws.write_offsets(px.getBuf(),0,0,0);
deldering95 51:69087c44e8ac 418 //}
ricardo_95 21:13e4824bc364 419 }
ricardo_95 21:13e4824bc364 420
ricardo_95 36:d10f368d037b 421 void trigger_lock() // If rising edge lock button is detected start locktimer.
ricardo_95 21:13e4824bc364 422 {
ricardo_95 34:1614f4f2b841 423 if (test_mode == 1) {
ricardo_95 36:d10f368d037b 424 usb_serial.printf("Lock triggered.\n");
ricardo_95 34:1614f4f2b841 425 }
Ishy 55:b74e7076d7a0 426 if (lock_state == 0) pi_serial.printf(">44\n");
Ishy 55:b74e7076d7a0 427 else if (lock_state == 1) pi_serial.printf(">00\n");
ricardo_95 36:d10f368d037b 428 button_lock_hold_timer.reset();
ricardo_95 36:d10f368d037b 429 button_lock_hold_timer.start();
ricardo_95 36:d10f368d037b 430 delay_between_button_pressed.reset();
ricardo_95 36:d10f368d037b 431 delay_between_button_pressed.start();
ricardo_95 21:13e4824bc364 432 }
ricardo_95 21:13e4824bc364 433
ricardo_95 36:d10f368d037b 434 void end_timer_lock_button() // End timer lock.
ricardo_95 21:13e4824bc364 435 {
deldering95 43:d09814c177a0 436 if (test_mode == 1) { // If statement for test purposal.
ricardo_95 36:d10f368d037b 437 usb_serial.printf("Lock released.\n");
ricardo_95 36:d10f368d037b 438 }
ricardo_95 36:d10f368d037b 439 lock_flag = 0; // Set lock_flag off.
Ishy 55:b74e7076d7a0 440 lock_is_logged = 0;
ricardo_95 36:d10f368d037b 441 button_lock_hold_timer.stop(); // Stop and reset holdtimer
ricardo_95 36:d10f368d037b 442 button_lock_hold_timer.reset();
ricardo_95 36:d10f368d037b 443 }
ricardo_95 36:d10f368d037b 444
ricardo_95 36:d10f368d037b 445 void reposition_button_triggered()
ricardo_95 36:d10f368d037b 446 {
ricardo_95 36:d10f368d037b 447 if (lock_state == 1 | (delay_between_button_pressed.read_ms() < buttondelay_ms)) { // Control statement for lock interface and delay for non using buttons at the same time.
deldering95 48:aca02ef5cd01 448 lock_flash = 10;
deldering95 58:8cfa736d8553 449 }
deldering95 58:8cfa736d8553 450
Ishy 55:b74e7076d7a0 451 delay_between_button_pressed.reset();
Ishy 55:b74e7076d7a0 452 delay_between_button_pressed.start();
Ishy 55:b74e7076d7a0 453 if (test_mode == 1) { // If statement for test purposal.
Ishy 55:b74e7076d7a0 454 usb_serial.printf("Reposition triggered.\n");
Ishy 55:b74e7076d7a0 455 LED_on_dev_board1 = !LED_on_dev_board1;
Ishy 55:b74e7076d7a0 456 }
deldering95 58:8cfa736d8553 457
deldering95 58:8cfa736d8553 458 if (lock_state == 1) reposition_lock_flag = 1;
deldering95 58:8cfa736d8553 459 else {
ricardo_95 21:13e4824bc364 460 reposition_flag = 1;
ricardo_95 36:d10f368d037b 461 reposition_feedback_LED = control_LED_intensity;
Ishy 55:b74e7076d7a0 462 pi_serial.printf("&05\n");
deldering95 58:8cfa736d8553 463 if(test_mode == 1) usb_serial.printf("&05\n");
ricardo_95 21:13e4824bc364 464 }
ricardo_95 21:13e4824bc364 465 }
ricardo_95 21:13e4824bc364 466
deldering95 43:d09814c177a0 467 void rise_reposition() // Interrupt for rising edge reposition function (deactivation; active low).
ricardo_95 21:13e4824bc364 468 {
deldering95 43:d09814c177a0 469 if (test_mode == 1) { // If statement for test purposal.
ricardo_95 36:d10f368d037b 470 usb_serial.printf("Reposition released.\n");
ricardo_95 34:1614f4f2b841 471 }
deldering95 58:8cfa736d8553 472
Ishy 55:b74e7076d7a0 473 if (reposition_feedback_LED != 0) {
Ishy 55:b74e7076d7a0 474 pi_serial.printf("&50\n");
deldering95 58:8cfa736d8553 475
Ishy 55:b74e7076d7a0 476 if(test_mode == 1) usb_serial.printf("&50\n");
Ishy 55:b74e7076d7a0 477 }
deldering95 58:8cfa736d8553 478
ricardo_95 36:d10f368d037b 479 reposition_feedback_LED = 0;
ricardo_95 21:13e4824bc364 480 }
Ishy 55:b74e7076d7a0 481 //TODO rename to calibration
ricardo_95 36:d10f368d037b 482 void mute_button_triggered()
ricardo_95 21:13e4824bc364 483 {
ricardo_95 21:13e4824bc364 484
ricardo_95 36:d10f368d037b 485 if (lock_state == 1 | (delay_between_button_pressed.read_ms() < buttondelay_ms)) { // Control statement for lock interface and delay for non using buttons at the same time.
deldering95 48:aca02ef5cd01 486 lock_flash = 10;
Ishy 55:b74e7076d7a0 487 }
deldering95 58:8cfa736d8553 488
Ishy 55:b74e7076d7a0 489 delay_between_button_pressed.reset();
Ishy 55:b74e7076d7a0 490 delay_between_button_pressed.start();
Ishy 55:b74e7076d7a0 491 button_calibration_hold_timer.reset(); // inline ?
Ishy 55:b74e7076d7a0 492 button_calibration_hold_timer.start();
deldering95 58:8cfa736d8553 493
Ishy 55:b74e7076d7a0 494 if (lock_state == 1) {
Ishy 55:b74e7076d7a0 495 mute_lock_flag = 1;
Ishy 55:b74e7076d7a0 496 }
deldering95 58:8cfa736d8553 497
Ishy 55:b74e7076d7a0 498 else {
deldering95 58:8cfa736d8553 499 mute_feedback_LED = control_LED_intensity;
deldering95 58:8cfa736d8553 500 pi_serial.printf("&07\n");
deldering95 58:8cfa736d8553 501 if (test_mode == 1) usb_serial.printf("&07\n");
deldering95 58:8cfa736d8553 502 mute_flag = 1;
Ishy 55:b74e7076d7a0 503 }
deldering95 58:8cfa736d8553 504
Ishy 55:b74e7076d7a0 505 if (test_mode == 1) { // If statement for test purposal.
Ishy 55:b74e7076d7a0 506 usb_serial.printf("Calibration triggered\n");
Ishy 55:b74e7076d7a0 507 LED_on_dev_board1 = !LED_on_dev_board1;
Ishy 55:b74e7076d7a0 508 }
deldering95 43:d09814c177a0 509
deldering95 58:8cfa736d8553 510
ricardo_95 21:13e4824bc364 511 }
ricardo_95 21:13e4824bc364 512
deldering95 51:69087c44e8ac 513 void rise_mute() // Interrupt for rising edge reposition function (deactivation; active low).
ricardo_95 21:13e4824bc364 514 {
deldering95 43:d09814c177a0 515 if (test_mode == 1) { // If statement for test purposal.
Ishy 55:b74e7076d7a0 516 usb_serial.printf("Calibration released.\n");
ricardo_95 34:1614f4f2b841 517 }
Ishy 55:b74e7076d7a0 518 if(lock_state == 0 && mute_feedback_LED != 0) {
Ishy 55:b74e7076d7a0 519 pi_serial.printf("&70\n");
Ishy 55:b74e7076d7a0 520 if (test_mode == 1) usb_serial.printf("&70\n");
Ishy 55:b74e7076d7a0 521 }
deldering95 58:8cfa736d8553 522
deldering95 51:69087c44e8ac 523 mute_feedback_LED = 0;
ricardo_95 21:13e4824bc364 524
deldering95 43:d09814c177a0 525 button_calibration_hold_timer.stop(); // Timer reset for calibration function of new patient button.
ricardo_95 36:d10f368d037b 526 button_calibration_hold_timer.reset();
ricardo_95 21:13e4824bc364 527
ricardo_95 36:d10f368d037b 528 if (lock_state == 1 | (delay_between_button_pressed.read_ms() < buttondelay_ms)) { // Control statement for lock interface and delay for non using buttons at the same time.
ricardo_95 21:13e4824bc364 529 } else {
ricardo_95 21:13e4824bc364 530 if (calibration_flag == 0) {
ricardo_95 21:13e4824bc364 531
deldering95 43:d09814c177a0 532 if (LED_on_dev_board1 == 0) { // If statement for test purposal.
ricardo_95 36:d10f368d037b 533 LED_on_dev_board1 = 1;
ricardo_95 21:13e4824bc364 534 } else {
ricardo_95 36:d10f368d037b 535 LED_on_dev_board1 = 0;
ricardo_95 21:13e4824bc364 536 }
ricardo_95 21:13e4824bc364 537
ricardo_95 21:13e4824bc364 538 } else {
ricardo_95 21:13e4824bc364 539 calibration_flag = 0;
ricardo_95 21:13e4824bc364 540 }
ricardo_95 21:13e4824bc364 541 }
deldering95 51:69087c44e8ac 542
deldering95 51:69087c44e8ac 543 }
deldering95 51:69087c44e8ac 544
deldering95 51:69087c44e8ac 545 void trigger_new_patient() // Function to trigger hold timer for new patient and calibration function.
deldering95 51:69087c44e8ac 546 {
deldering95 51:69087c44e8ac 547
deldering95 51:69087c44e8ac 548 if (lock_state == 1 | (delay_between_button_pressed.read_ms() < buttondelay_ms)) {
deldering95 51:69087c44e8ac 549 lock_flash = 10;
Ishy 55:b74e7076d7a0 550 }
deldering95 58:8cfa736d8553 551
Ishy 55:b74e7076d7a0 552 delay_between_button_pressed.reset();
Ishy 55:b74e7076d7a0 553 delay_between_button_pressed.start();
deldering95 58:8cfa736d8553 554
Ishy 55:b74e7076d7a0 555 if (lock_state == 1) new_patient_lock_flag = 1;
Ishy 55:b74e7076d7a0 556 else {
Ishy 55:b74e7076d7a0 557 new_patient_feedback_LED = control_LED_intensity;
Ishy 55:b74e7076d7a0 558 pi_serial.printf("&06\n");
deldering95 51:69087c44e8ac 559 new_patient_flag = 1;
deldering95 58:8cfa736d8553 560
deldering95 58:8cfa736d8553 561 if(test_mode == 1) {
Ishy 55:b74e7076d7a0 562 usb_serial.printf("&06\n");
deldering95 51:69087c44e8ac 563 }
deldering95 51:69087c44e8ac 564 }
deldering95 58:8cfa736d8553 565
Ishy 55:b74e7076d7a0 566 if (test_mode == 1) { // If statement for test purposal.
Ishy 55:b74e7076d7a0 567 usb_serial.printf("New patient triggered.\n");
Ishy 55:b74e7076d7a0 568 }
deldering95 58:8cfa736d8553 569
deldering95 51:69087c44e8ac 570 }
deldering95 51:69087c44e8ac 571
deldering95 51:69087c44e8ac 572 void activate_new_patient_function() // Timer calibration function.
deldering95 51:69087c44e8ac 573 {
deldering95 51:69087c44e8ac 574 if (test_mode == 1) { // If statement for test purposal.
deldering95 51:69087c44e8ac 575 usb_serial.printf("New patient released.\n");
deldering95 58:8cfa736d8553 576
Ishy 55:b74e7076d7a0 577 }
deldering95 58:8cfa736d8553 578
Ishy 55:b74e7076d7a0 579 if (new_patient_feedback_LED != 0) {
Ishy 55:b74e7076d7a0 580 pi_serial.printf("&60\n");
Ishy 55:b74e7076d7a0 581 if(test_mode) usb_serial.printf("&60\n");
deldering95 51:69087c44e8ac 582 }
deldering95 51:69087c44e8ac 583 new_patient_feedback_LED = 0;
ricardo_95 21:13e4824bc364 584 }
ricardo_95 21:13e4824bc364 585
deldering95 43:d09814c177a0 586 void timer_functions() // Function which contains statements using timers.
ricardo_95 21:13e4824bc364 587 {
deldering95 48:aca02ef5cd01 588 if (button_lock == 1) {
deldering95 44:dcbde3175a37 589 button_lock_hold_timer.stop();
deldering95 44:dcbde3175a37 590 button_lock_hold_timer.reset();
deldering95 44:dcbde3175a37 591 }
ricardo_95 36:d10f368d037b 592 if ((button_lock_hold_timer.read_ms() > locktime_ms) && lock_flag == 0 && button_lock == 0) { // If statement for lock function.
ricardo_95 21:13e4824bc364 593 lock_flag = 1;
ricardo_95 36:d10f368d037b 594 LED_on_dev_board2 = !LED_on_dev_board2;
ricardo_95 21:13e4824bc364 595 lock_state = !lock_state;
deldering95 43:d09814c177a0 596
deldering95 43:d09814c177a0 597 if (lock_state == 0) { // If statement to control lock feedback LED above button.
ricardo_95 36:d10f368d037b 598 lock_feedback_LED = control_LED_intensity;
Ishy 55:b74e7076d7a0 599 pi_serial.printf("&08\n");
deldering95 58:8cfa736d8553 600 if(test_mode == 1) usb_serial.printf("&08\n");
ricardo_95 21:13e4824bc364 601 } else {
ricardo_95 36:d10f368d037b 602 lock_feedback_LED = 0;
Ishy 55:b74e7076d7a0 603 pi_serial.printf("&80\n");
Ishy 55:b74e7076d7a0 604 if(test_mode == 1) usb_serial.printf("&80\n");
ricardo_95 21:13e4824bc364 605 }
ricardo_95 21:13e4824bc364 606 }
ricardo_95 21:13e4824bc364 607
deldering95 51:69087c44e8ac 608 if (button_mute == 1) {
deldering95 44:dcbde3175a37 609 button_calibration_hold_timer.stop();
deldering95 44:dcbde3175a37 610 button_calibration_hold_timer.reset();
deldering95 44:dcbde3175a37 611 }
deldering95 44:dcbde3175a37 612
deldering95 51:69087c44e8ac 613 if ((button_calibration_hold_timer.read_ms() > calibrationtime_ms) && calibration_flag == 0 && button_mute == 0 && lock_state == 0) { // If statement for calibration algorithm.
ricardo_95 21:13e4824bc364 614 calibration_flag = 1;
ricardo_95 21:13e4824bc364 615 calibration_flash = 11;
deldering95 58:8cfa736d8553 616
Ishy 55:b74e7076d7a0 617 if (test_mode == 1) { // If statement for test purposal.
ricardo_95 36:d10f368d037b 618 usb_serial.printf("Calibrate triggered.\n");
ricardo_95 34:1614f4f2b841 619 }
Ishy 55:b74e7076d7a0 620 pi_serial.printf(">33\n");
deldering95 58:8cfa736d8553 621
ricardo_95 21:13e4824bc364 622 }
ricardo_95 21:13e4824bc364 623
ricardo_95 36:d10f368d037b 624 if (delay_between_button_pressed.read_ms() > delay_lock_interface) { // If buttons are not pressed for 3 minutes, set lock active.
ricardo_95 21:13e4824bc364 625 lock_state = 1;
ricardo_95 36:d10f368d037b 626 LED_on_dev_board2 = 1;
ricardo_95 36:d10f368d037b 627 lock_feedback_LED = 0;
deldering95 58:8cfa736d8553 628 if (!auto_lock_led_logged) {
Ishy 55:b74e7076d7a0 629 pi_serial.printf("&80\n");
Ishy 55:b74e7076d7a0 630 if(test_mode == 1) usb_serial.printf("&80\n");
Ishy 55:b74e7076d7a0 631 auto_lock_led_logged = 1;
Ishy 55:b74e7076d7a0 632 }
Ishy 55:b74e7076d7a0 633 } else {
deldering95 58:8cfa736d8553 634 auto_lock_led_logged = 0;
ricardo_95 21:13e4824bc364 635 }
ricardo_95 21:13e4824bc364 636 }
ricardo_95 21:13e4824bc364 637
ricardo_95 36:d10f368d037b 638 void set_userinterface_LED() // Control functions for LED above buttons (added because of failures).
ricardo_95 21:13e4824bc364 639 {
ricardo_95 21:13e4824bc364 640 if (lock_state == 1) {
ricardo_95 21:13e4824bc364 641 } else {
ricardo_95 36:d10f368d037b 642 if (button_reposition == 0) {
ricardo_95 36:d10f368d037b 643 reposition_feedback_LED = control_LED_intensity;
ricardo_95 21:13e4824bc364 644 } else {
ricardo_95 36:d10f368d037b 645 reposition_feedback_LED = 0;
ricardo_95 21:13e4824bc364 646 }
ricardo_95 21:13e4824bc364 647
ricardo_95 36:d10f368d037b 648 if (button_new_patient == 0) {
ricardo_95 36:d10f368d037b 649 new_patient_feedback_LED = control_LED_intensity;
ricardo_95 21:13e4824bc364 650 } else {
ricardo_95 36:d10f368d037b 651 new_patient_feedback_LED = 0;
ricardo_95 21:13e4824bc364 652 }
ricardo_95 21:13e4824bc364 653 }
deldering95 48:aca02ef5cd01 654 if (lock_flash >= 1 && lock_state == 1) {
deldering95 48:aca02ef5cd01 655 if ((lock_flash % 2) == 0) {
deldering95 48:aca02ef5cd01 656 lock_feedback_LED = control_LED_intensity;
Ishy 55:b74e7076d7a0 657 pi_serial.printf("&08\n");
Ishy 55:b74e7076d7a0 658 if(test_mode == 1) usb_serial.printf("&08\n");
deldering95 48:aca02ef5cd01 659 } else {
deldering95 48:aca02ef5cd01 660 lock_feedback_LED = 0;
Ishy 55:b74e7076d7a0 661 pi_serial.printf("&80\n");
Ishy 55:b74e7076d7a0 662 if(test_mode == 1) usb_serial.printf("&80\n");
ricardo_95 21:13e4824bc364 663 }
deldering95 48:aca02ef5cd01 664 lock_flash--;
deldering95 48:aca02ef5cd01 665 } else {
deldering95 48:aca02ef5cd01 666 lock_flash = 0;
ricardo_95 21:13e4824bc364 667 }
ricardo_95 21:13e4824bc364 668 }
ricardo_95 21:13e4824bc364 669
deldering95 57:fac732476810 670 void sensorplate_detached()
deldering95 57:fac732476810 671 {
deldering95 58:8cfa736d8553 672 if(piezo_electric_sample_timer.read_us() > total_readout_cycle_time_us) {
deldering95 58:8cfa736d8553 673 NVIC_SystemReset();
deldering95 58:8cfa736d8553 674 }
deldering95 57:fac732476810 675 }
deldering95 57:fac732476810 676
deldering95 57:fac732476810 677
deldering95 43:d09814c177a0 678 int main() // Main function. inline function "Momo Init" bijvoorbeeld
deldering95 43:d09814c177a0 679 {
deldering95 57:fac732476810 680 serial_read();
deldering95 51:69087c44e8ac 681 ws.useII(WS2812::GLOBAL); // use global intensity scaling
deldering95 51:69087c44e8ac 682 set_intensity_LEDs(); // Initialize intensity for user interface LED's and LED's shines to wall.
deldering95 51:69087c44e8ac 683 colour_select_indicating_LED_wall(LED_colour);
deldering95 53:54c882995514 684
deldering95 48:aca02ef5cd01 685 speaker1 = 1;
ricardo_95 36:d10f368d037b 686 wait_ms(boot_delay_ms); // Wait to boot sensorplate first.
deldering95 48:aca02ef5cd01 687 speaker1 = 0;
ricardo_95 39:cff99a9b7237 688 i2c_sensorplate_adc.frequency(i2c__frequency); // Set frequency for i2c connection to sensorplate (variable is declared in config part).
ricardo_95 36:d10f368d037b 689 usb_serial.baud(baud_rate); // Set serial USB connection baud rate (variable is declared in config part).
ricardo_95 36:d10f368d037b 690 pi_serial.baud(baud_rate); // Same as line 697, but now for serial PI connection.
ricardo_95 36:d10f368d037b 691 piezo_resistive_adc1.setGain(GAIN_TWOTHIRDS); // Set ranges of ADC to +/-6.144V (end is marked with #):
deldering95 43:d09814c177a0 692 piezo_resistive_adc2.setGain(GAIN_TWOTHIRDS);
deldering95 51:69087c44e8ac 693 piezo_electric_adc.setGain(GAIN_TWO);
deldering95 43:d09814c177a0 694 pi_serial.format(8, SerialBase::None, 1); // Set serial communication line with PI.
ricardo_95 7:dba5091c8b7d 695
deldering95 57:fac732476810 696 testpin_sensorplate.mode(PullUp);
deldering95 43:d09814c177a0 697 button_lock.mode(PullUp);
deldering95 43:d09814c177a0 698 button_reposition.mode(PullUp);
deldering95 43:d09814c177a0 699 button_mute.mode(PullUp);
deldering95 43:d09814c177a0 700 button_new_patient.mode(PullUp);
deldering95 43:d09814c177a0 701
deldering95 57:fac732476810 702 testpin_sensorplate.fall(&sensorplate_detached);
ricardo_95 36:d10f368d037b 703 button_lock.fall(&trigger_lock); // Interrupt for rising edge lock button.
ricardo_95 36:d10f368d037b 704 button_lock.rise(&end_timer_lock_button);
ricardo_95 36:d10f368d037b 705 button_reposition.fall(&reposition_button_triggered);
ricardo_95 36:d10f368d037b 706 button_reposition.rise(&rise_reposition);
ricardo_95 36:d10f368d037b 707 button_mute.fall(&mute_button_triggered);
deldering95 51:69087c44e8ac 708 button_mute.rise(&rise_mute);
ricardo_95 36:d10f368d037b 709 button_new_patient.fall(&trigger_new_patient); // New patient/calibration button rising event.
deldering95 43:d09814c177a0 710 button_new_patient.rise(&activate_new_patient_function); // Falling edge for calibration algorithm option.
ricardo_95 21:13e4824bc364 711
deldering95 48:aca02ef5cd01 712 __disable_irq();
deldering95 48:aca02ef5cd01 713 while(!pi_active) {
deldering95 48:aca02ef5cd01 714 Knight_Rider_Timer.reset();
deldering95 48:aca02ef5cd01 715 Knight_Rider_Timer.start();
deldering95 48:aca02ef5cd01 716 reposition_feedback_LED = control_LED_intensity;
deldering95 48:aca02ef5cd01 717 new_patient_feedback_LED = 0;
deldering95 48:aca02ef5cd01 718 while(Knight_Rider_Timer.read_ms()<(1*(total_knight_rider_cycle_time_ms/8))) {}
deldering95 48:aca02ef5cd01 719 new_patient_feedback_LED = control_LED_intensity;
deldering95 48:aca02ef5cd01 720 while(Knight_Rider_Timer.read_ms()<(2*(total_knight_rider_cycle_time_ms/8))) {}
deldering95 48:aca02ef5cd01 721 mute_feedback_LED = control_LED_intensity;
deldering95 48:aca02ef5cd01 722 reposition_feedback_LED = 0;
deldering95 48:aca02ef5cd01 723 while(Knight_Rider_Timer.read_ms()<(3*(total_knight_rider_cycle_time_ms/8))) {}
deldering95 48:aca02ef5cd01 724 lock_feedback_LED = control_LED_intensity;
deldering95 48:aca02ef5cd01 725 new_patient_feedback_LED = 0;
deldering95 48:aca02ef5cd01 726 while(Knight_Rider_Timer.read_ms()<(4*(total_knight_rider_cycle_time_ms/8))) {}
deldering95 48:aca02ef5cd01 727 mute_feedback_LED = 0;
deldering95 48:aca02ef5cd01 728 while(Knight_Rider_Timer.read_ms()<(5*(total_knight_rider_cycle_time_ms/8))) {}
deldering95 48:aca02ef5cd01 729 mute_feedback_LED = control_LED_intensity;
deldering95 48:aca02ef5cd01 730 while(Knight_Rider_Timer.read_ms()<(6*(total_knight_rider_cycle_time_ms/8))) {}
deldering95 48:aca02ef5cd01 731 new_patient_feedback_LED = control_LED_intensity;
deldering95 48:aca02ef5cd01 732 lock_feedback_LED = 0;
deldering95 48:aca02ef5cd01 733 while(Knight_Rider_Timer.read_ms()<(7*(total_knight_rider_cycle_time_ms/8))) {}
deldering95 48:aca02ef5cd01 734 reposition_feedback_LED = control_LED_intensity;
deldering95 48:aca02ef5cd01 735 mute_feedback_LED = 0;
ricardo_95 19:3b5999fa7b7e 736
deldering95 48:aca02ef5cd01 737 serial_read();
deldering95 48:aca02ef5cd01 738 colour_select_indicating_LED_wall(LED_colour);
deldering95 48:aca02ef5cd01 739 while(Knight_Rider_Timer.read_ms()<(8*(total_knight_rider_cycle_time_ms/8))) {}
deldering95 48:aca02ef5cd01 740
deldering95 48:aca02ef5cd01 741 }
deldering95 51:69087c44e8ac 742 __enable_irq();
deldering95 51:69087c44e8ac 743 delay_between_button_pressed.reset(); // Delaytimer reset en start.
deldering95 51:69087c44e8ac 744 delay_between_button_pressed.start();
deldering95 51:69087c44e8ac 745
deldering95 51:69087c44e8ac 746 reposition_feedback_LED = 0;
deldering95 51:69087c44e8ac 747 new_patient_feedback_LED = 0;
deldering95 51:69087c44e8ac 748 mute_feedback_LED = 0;
deldering95 51:69087c44e8ac 749 usb_serial.printf("Lock State: %d\n",lock_state);
deldering95 48:aca02ef5cd01 750 lock_feedback_LED = control_LED_intensity; // Lock LED initialization.
deldering95 51:69087c44e8ac 751
DEldering 0:c0e44c46c573 752 while (1) {
Ishy 42:673ddef4cfa4 753 piezo_electric_sample_timer.reset(); // Clock gebruiken o.i.d.?
Ishy 42:673ddef4cfa4 754 piezo_electric_sample_timer.start();
ricardo_95 46:a0e6e088a50a 755 connection_test_sensorplate = !testpin_sensorplate && pi_active;
deldering95 43:d09814c177a0 756
Ishy 42:673ddef4cfa4 757 if (test_mode == 1) {
Ishy 55:b74e7076d7a0 758 // usb_serial.printf("Connection test sensorplate = %d\n", connection_test_sensorplate);
Ishy 42:673ddef4cfa4 759 }
deldering95 43:d09814c177a0 760 if (test_mode == 1) {
Ishy 55:b74e7076d7a0 761 // usb_serial.printf("Loop time: %d ms\n",piezo_electric_sample_timer.read_ms());
deldering95 43:d09814c177a0 762 }
deldering95 43:d09814c177a0 763
Ishy 42:673ddef4cfa4 764 if (connection_test_sensorplate == 1) {
deldering95 58:8cfa736d8553 765 piezo_electric_array[0] = piezo_electric_adc.readADC_Differential_0_3(); // First PE readout.
deldering95 58:8cfa736d8553 766 piezo_electric_array[3] = piezo_electric_adc.readADC_Differential_1_3(); // First PE readout.
deldering95 58:8cfa736d8553 767
deldering95 48:aca02ef5cd01 768 for (uint8_t k = 0; k < 4; ++k) {
deldering95 48:aca02ef5cd01 769 piezo_resistive_array[k] = piezo_resistive_adc1.readADC_SingleEnded(k); // First 4 PR readout.
deldering95 48:aca02ef5cd01 770 }
deldering95 43:d09814c177a0 771 if (test_mode == 1) {
Ishy 55:b74e7076d7a0 772 // usb_serial.printf("Loop time: %d ms\n",piezo_electric_sample_timer.read_ms());
deldering95 43:d09814c177a0 773 }
deldering95 58:8cfa736d8553 774 while(piezo_electric_sample_timer.read_us()<(1*(total_readout_cycle_time_us/3))) {} // Wait untill 20% of cycle. Energy efficiency is not fine in this situation, correct if low energy is needed.
deldering95 58:8cfa736d8553 775 piezo_electric_array[1] = piezo_electric_adc.readADC_Differential_0_3(); // Second PE readout.
deldering95 58:8cfa736d8553 776 piezo_electric_array[4] = piezo_electric_adc.readADC_Differential_1_3(); // First PE readout.
deldering95 43:d09814c177a0 777
deldering95 48:aca02ef5cd01 778 for (uint8_t k = 0; k < 4; ++k) {
deldering95 48:aca02ef5cd01 779 piezo_resistive_array[k+4] = piezo_resistive_adc2.readADC_SingleEnded(k); // Last 4 PR readout.
deldering95 48:aca02ef5cd01 780 }
deldering95 43:d09814c177a0 781 if (test_mode == 1) {
Ishy 55:b74e7076d7a0 782 // usb_serial.printf("Loop time: %d ms\n",piezo_electric_sample_timer.read_ms());
deldering95 43:d09814c177a0 783 }
deldering95 58:8cfa736d8553 784 while(piezo_electric_sample_timer.read_us()<(2*(total_readout_cycle_time_us/3))) {} // Wait untill 40% of cycle. Energy efficiency is not fine in this situation, correct if low energy is needed.
deldering95 58:8cfa736d8553 785 piezo_electric_array[2] = piezo_electric_adc.readADC_Differential_0_3(); // Third PE readout.
deldering95 58:8cfa736d8553 786 piezo_electric_array[5] = piezo_electric_adc.readADC_Differential_1_3(); // First PE readout.
deldering95 43:d09814c177a0 787
deldering95 48:aca02ef5cd01 788 angle_device_sensorplate.getAccelero(accelerometer_sensorplate); // Get accelerometer data.
deldering95 48:aca02ef5cd01 789 angle = accelerometer_sensorplate[2]*100;
deldering95 48:aca02ef5cd01 790 if(angle == 0) {
deldering95 51:69087c44e8ac 791 MPU6050_belt angle_device_sensorplate(PB_9, PB_8);
deldering95 53:54c882995514 792 angle_device_sensorplate.getAccelero(accelerometer_sensorplate);
deldering95 48:aca02ef5cd01 793 angle = accelerometer_sensorplate[2]*100;
deldering95 48:aca02ef5cd01 794 }
deldering95 53:54c882995514 795 if((abs(accelerometer_sensorplate[0])+abs(accelerometer_sensorplate[1])+abs(accelerometer_sensorplate[2]))<= 6) {
deldering95 53:54c882995514 796 for(uint8_t k = 0; k < 3; ++k) {
deldering95 53:54c882995514 797 accelerometer_sensorplate[k]=accelerometer_sensorplate[k]*2;
deldering95 53:54c882995514 798 }
deldering95 53:54c882995514 799 }
deldering95 48:aca02ef5cd01 800 angle_device_sensorplate.getGyro(gyroscope_sensorplate); // Get gyroscope data.
deldering95 43:d09814c177a0 801 if (test_mode == 1) {
Ishy 55:b74e7076d7a0 802 // usb_serial.printf("Loop time: %d ms\n",piezo_electric_sample_timer.read_ms());
deldering95 43:d09814c177a0 803 }
deldering95 48:aca02ef5cd01 804 if (test_belt == 1) {
deldering95 48:aca02ef5cd01 805 angle_device_reference_belt.getGyro(gyroscope_reference_belt); // Get gyroscope data from Belt.
deldering95 48:aca02ef5cd01 806 angle_device_reference_belt.getAccelero(accelerometer_reference_belt); // Get accelerometer data from belt.
deldering95 48:aca02ef5cd01 807 }
deldering95 43:d09814c177a0 808
deldering95 48:aca02ef5cd01 809 if (connection_test_sensorplate == 1) {
deldering95 48:aca02ef5cd01 810 if (test_belt == 0) { // If statement for sending serial information sensorplate data when connection test is active.
deldering95 48:aca02ef5cd01 811 pi_serial.printf("?,%f,%f,%f,%f,%f,%f,0,0,0,0,0,0,\n", accelerometer_sensorplate[0], accelerometer_sensorplate[1], accelerometer_sensorplate[2], gyroscope_sensorplate[0], gyroscope_sensorplate[1], gyroscope_sensorplate[2]);
deldering95 53:54c882995514 812 } else {
deldering95 53:54c882995514 813 // Receiving order sensor information: 3 accelero sensors & 3 gyroscope sensors from sensorplate; 3 accelero sensors & 3 gyroscope sensors from belt. Is splitted in two parts - part 2/2.
deldering95 53:54c882995514 814 pi_serial.printf("?,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,\n", accelerometer_sensorplate[0], accelerometer_sensorplate[1], accelerometer_sensorplate[2], gyroscope_sensorplate[0], gyroscope_sensorplate[1], gyroscope_sensorplate[2], accelerometer_reference_belt[0], accelerometer_reference_belt[1], accelerometer_reference_belt[2], gyroscope_reference_belt[0], gyroscope_reference_belt[1], gyroscope_reference_belt[2]);
deldering95 48:aca02ef5cd01 815 }
deldering95 48:aca02ef5cd01 816 } // binair print and convert in pi
deldering95 53:54c882995514 817 else {
deldering95 53:54c882995514 818 pi_serial.printf("?,%f,%f,%f,%f,%f,%f,0,0,0,0,0,0,\n",0,0,0,0,0,0);
deldering95 53:54c882995514 819 }
Ishy 42:673ddef4cfa4 820 }
deldering95 43:d09814c177a0 821 if (test_mode == 1) {
Ishy 55:b74e7076d7a0 822 // usb_serial.printf("Loop time: %d ms\n",piezo_electric_sample_timer.read_ms());
deldering95 43:d09814c177a0 823 }
Ishy 42:673ddef4cfa4 824 timer_functions();
deldering95 43:d09814c177a0 825 if (test_mode == 1) {
Ishy 55:b74e7076d7a0 826 // usb_serial.printf("Loop time after timer_functions: %d ms\n",piezo_electric_sample_timer.read_ms());
deldering95 43:d09814c177a0 827 }
deldering95 43:d09814c177a0 828
deldering95 43:d09814c177a0 829 colour_select_indicating_LED_wall(LED_colour); // Function to select colour.
Ishy 42:673ddef4cfa4 830 set_userinterface_LED(); // Set LED's of user interface (LED's above buttons).
deldering95 43:d09814c177a0 831
deldering95 43:d09814c177a0 832 if (test_mode == 1) { // If statement for test purposal.
Ishy 55:b74e7076d7a0 833 // usb_serial.printf("Angle device sensorplate = %d\n",angle_device_sensorplate.testConnection());
Ishy 42:673ddef4cfa4 834 }
deldering95 43:d09814c177a0 835
Ishy 42:673ddef4cfa4 836 if (connection_test_sensorplate == 1) {
deldering95 58:8cfa736d8553 837 piezo_electric_array[4] = piezo_electric_adc.readADC_Differential_0_3(); // Fifth PE readout.
Ishy 42:673ddef4cfa4 838 }
deldering95 43:d09814c177a0 839
Ishy 42:673ddef4cfa4 840 while(piezo_electric_sample_timer.read_us()<(4.25*(total_readout_cycle_time_us/5))) {} // Wait untill 85% of cycle. Energy efficiency is not fine in this situation, correct if low energy is needed.
Ishy 42:673ddef4cfa4 841
deldering95 43:d09814c177a0 842 if (test_mode == 1) {
Ishy 55:b74e7076d7a0 843 // usb_serial.printf("Loop time: %d ms\n",piezo_electric_sample_timer.read_ms());
deldering95 43:d09814c177a0 844 }
deldering95 43:d09814c177a0 845
deldering95 43:d09814c177a0 846 if (test_mode == 0) { // If statements for test purposal (untill * mark).
Ishy 55:b74e7076d7a0 847 // usb_serial.printf("Loop time pre serial: %d ms\n",piezo_electric_sample_timer.read_ms());
deldering95 43:d09814c177a0 848 }
deldering95 43:d09814c177a0 849 serial_read(); // Call function for reading information from PI by serial connection.
deldering95 43:d09814c177a0 850 serial_log(); // Call function for logging information to PI by serial connection.
deldering95 43:d09814c177a0 851
deldering95 43:d09814c177a0 852 if (test_mode == 0) { // If statements for test purposal (untill * mark).
Ishy 42:673ddef4cfa4 853 usb_serial.printf("Loop time: %d ms\n",piezo_electric_sample_timer.read_ms());
Ishy 42:673ddef4cfa4 854 }
deldering95 48:aca02ef5cd01 855
deldering95 47:80cfc181f8b3 856 while(piezo_electric_sample_timer.read_us()<(total_readout_cycle_time_us)) {} // Wait untill 100% of cycle. Energy efficiency is not fine in this situation, correct if low energy is needed.
Ishy 42:673ddef4cfa4 857 //if (test_pin == 1) {
Ishy 42:673ddef4cfa4 858 // test_mode = 1;
Ishy 42:673ddef4cfa4 859 // usb_serial.printf("%d\n",test_mode);
Ishy 42:673ddef4cfa4 860 // }
Ishy 42:673ddef4cfa4 861 // if (test_pin == 0) {
Ishy 42:673ddef4cfa4 862 // test_mode = 0;
Ishy 42:673ddef4cfa4 863 // usb_serial.printf("%d\n",test_mode);
Ishy 42:673ddef4cfa4 864 // }
DEldering 0:c0e44c46c573 865 }
ricardo_95 12:7b3a5940f911 866 }