Nucleo-transfer
Dependencies: ADS1015 MPU6050 PixelArray PixelArray-Nucleo mbed WS2813
Fork of Nucleo-transfer by
Diff: Sensorplate/main.cpp
- Revision:
- 46:a0e6e088a50a
- Parent:
- 45:7ebe860702b4
- Child:
- 47:80cfc181f8b3
- Child:
- 54:a65b6fa447b0
diff -r 7ebe860702b4 -r a0e6e088a50a Sensorplate/main.cpp --- a/Sensorplate/main.cpp Mon Jan 08 10:15:58 2018 +0000 +++ b/Sensorplate/main.cpp Thu Jan 11 10:28:38 2018 +0000 @@ -38,14 +38,15 @@ #define NUMBER_LED_FRONT (3) #define ONE_COLOR -InterruptIn button_lock(PC_0); // Input on intterupt base decleration. -InterruptIn button_reposition(PC_1); +InterruptIn button_lock(PC_1); // Input on intterupt base decleration. +InterruptIn button_reposition(PC_3); InterruptIn button_mute(PC_2); -InterruptIn button_new_patient(PC_3); +InterruptIn button_new_patient(PC_0); DigitalIn intensity_code(PA_12); DigitalIn colour_code_1(PA_11); DigitalIn colour_code_0(PB_12); +DigitalIn testpin_sensorplate(PC_6); DigitalOut LED_on_dev_board1(LED1); // Decleration of digital outputs. DigitalOut LED_on_dev_board2(LED2); @@ -57,10 +58,10 @@ WS2812 ws(PA_7, WS2812_BUF, 3, 9, 9, 6); -PwmOut lock_feedback_LED(PB_13); // Declaration of pulse with modulation outputs. -PwmOut mute_feedback_LED(PB_1); +PwmOut lock_feedback_LED(PB_1); // Declaration of pulse with modulation outputs. +PwmOut mute_feedback_LED(PB_15); PwmOut new_patient_feedback_LED(PB_14); -PwmOut reposition_feedback_LED(PB_15); +PwmOut reposition_feedback_LED(PB_13); Timer button_lock_hold_timer; // Timer for time lock button should be pressed. Timer button_calibration_hold_timer; // Timer for calibration function (new patient holding 5 seconds). @@ -77,7 +78,7 @@ */ I2C i2c_sensorplate_adc(PB_9, PB_8); // I2C for sensorplate. //I2C i2c_power_adc(PB_11, PB_10); // I2C for accupack. -MPU6050 angle_device_sensorplate(PB_9, PB_8); // i2c pins // i2c address hardcoded 0x68. +MPU6050_belt angle_device_sensorplate(PB_9, PB_8); // i2c pins // i2c address hardcoded 0x68. MPU6050_belt angle_device_reference_belt(PB_9, PB_8); // i2c pins // i2c address hardcoded 0x69. Adafruit_ADS1115 piezo_resistive_adc1(&i2c_sensorplate_adc, 0x48); // i2c pins, i2c address. Adafruit_ADS1115 piezo_resistive_adc2(&i2c_sensorplate_adc, 0x49); // i2c pins, i2c address. @@ -117,7 +118,6 @@ //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 int intensity_day = 40, intensity_night = 10; // Intensity settings for LED's to wall. 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! -bool sensorplate_connection_testpin = true; // Variable to verify by a hardware connection if the sensorplate is connected. int colour_code = 0b00; bool pi_active = false; /*************************** TEST ********************************/ @@ -132,7 +132,7 @@ bool test_mode = 0; // Variable for connection test (should be changed): -int connection_test_sensorplate; +bool connection_test_sensorplate; /*************************** CODE ********************************/ @@ -224,7 +224,7 @@ reposition_flag = 0; } - if (batteryvoltage_current != batteryvoltage_last) { // If statement to control logging for batteryvoltage. + /*if (batteryvoltage_current != batteryvoltage_last) { // If statement to control logging for batteryvoltage. pi_serial.printf("%%" "%d\n", batteryvoltage_current); if (test_mode == 1) { // If statement for test purposal. @@ -232,7 +232,7 @@ } batteryvoltage_last = batteryvoltage_current; - } + }*/ if (LED_red_logged != LED_red_state) { // If statement to control logging for LED_red. if (LED_red_state == 1) { @@ -656,7 +656,7 @@ return; piezo_electric_sample_timer.reset(); // Clock gebruiken o.i.d.? piezo_electric_sample_timer.start(); - connection_test_sensorplate = ; + connection_test_sensorplate = !testpin_sensorplate; if (test_mode == 1) { usb_serial.printf("Connection test sensorplate = %d\n", connection_test_sensorplate); @@ -714,13 +714,13 @@ timer_functions(); - batteryvoltage_current = batteryvoltage_last; + /*batteryvoltage_current = batteryvoltage_last; powervoltage_current = powervoltage_last; - read_voltage(); // Read_voltage function to control alarm. + read_voltage();*/ // Read_voltage function to control alarm. - if (test_mode == 1) { + /*if (test_mode == 1) { usb_serial.printf("Voltage = %d , %d\n", batteryvoltage_current, powervoltage_current); - } + }*/ uint32_t val = 0; colour_select_indicating_LED_wall(LED_colour); // Function to select colour. @@ -764,13 +764,13 @@ { wait_ms(boot_delay_ms); // Wait to boot sensorplate first. i2c_sensorplate_adc.frequency(i2c__frequency); // Set frequency for i2c connection to sensorplate (variable is declared in config part). - i2c_power_adc.frequency(i2c__frequency); // Same as line 695, but now for ADC to read battery- en powervoltage. + //i2c_power_adc.frequency(i2c__frequency); // Same as line 695, but now for ADC to read battery- en powervoltage. usb_serial.baud(baud_rate); // Set serial USB connection baud rate (variable is declared in config part). pi_serial.baud(baud_rate); // Same as line 697, but now for serial PI connection. piezo_resistive_adc1.setGain(GAIN_TWOTHIRDS); // Set ranges of ADC to +/-6.144V (end is marked with #): piezo_resistive_adc2.setGain(GAIN_TWOTHIRDS); piezo_electric_adc.setGain(GAIN_TWOTHIRDS); - adsAccu.setGain(GAIN_TWOTHIRDS); // #) End of configuration ADC ranges. + //adsAccu.setGain(GAIN_TWOTHIRDS); // #) End of configuration ADC ranges. pi_serial.format(8, SerialBase::None, 1); // Set serial communication line with PI. button_lock.mode(PullUp); @@ -799,7 +799,7 @@ // wait_us(total_readout_cycle_time_us+1); // Wait indefinitely. piezo_electric_sample_timer.reset(); // Clock gebruiken o.i.d.? piezo_electric_sample_timer.start(); - connection_test_sensorplate = sensorplate_connection_testpin; + connection_test_sensorplate = !testpin_sensorplate && pi_active; if (test_mode == 1) { usb_serial.printf("Connection test sensorplate = %d\n", connection_test_sensorplate); @@ -874,15 +874,15 @@ if (test_mode == 1) { usb_serial.printf("Loop time after timer_functions: %d ms\n",piezo_electric_sample_timer.read_ms()); } - batteryvoltage_current = batteryvoltage_last; + /*batteryvoltage_current = batteryvoltage_last; powervoltage_current = powervoltage_last; - read_voltage(); // Read_voltage function to control alarm. + read_voltage();*/ // Read_voltage function to control alarm. if (test_mode == 1) { usb_serial.printf("Loop time after read_voltage: %d ms\n",piezo_electric_sample_timer.read_ms()); } - if (test_mode == 1) { + /*if (test_mode == 1) { usb_serial.printf("Voltage = %d , %d\n", batteryvoltage_current, powervoltage_current); - } + }*/ uint32_t val = 0; colour_select_indicating_LED_wall(LED_colour); // Function to select colour.