Nucleo-transfer
Dependencies: ADS1015 MPU6050 PixelArray PixelArray-Nucleo mbed WS2813
Fork of Nucleo-transfer by
Diff: Sensorplate/main.cpp
- Revision:
- 45:7ebe860702b4
- Parent:
- 44:dcbde3175a37
- Child:
- 46:a0e6e088a50a
--- a/Sensorplate/main.cpp Fri Dec 01 16:09:08 2017 +0000 +++ b/Sensorplate/main.cpp Mon Jan 08 10:15:58 2018 +0000 @@ -4,12 +4,11 @@ co-authors: Menno Gravemaker (c) Copyright by Momo Medical BV. -Current version name: 2.1.3 -Date of modification: 18-10-2017 +Current version name: 2.1.4 +Date of modification: 8-1-2018 Purpose of this file: Code for LPC1768 microcontroller for controlling buttons, LED's and communicate to PI -Update ‘what’s new in this version?’: New structure added. - Readability improved. - Code optimized (variables and functions). +Update ‘what’s new in this version?’: Sensorplate connection test changed from software to hardware check. + ADC readout for accu deleted. Todo: -> Fix LED issue (yellow and red flashes at random moments); -> Optimize functions / improve readability; -> Split functions in seperate files?; @@ -36,7 +35,7 @@ #define WS2812_BUF 3 #define NUM_COLORS 5 #define NUM_LEDS_PER_COLOR 3 -#define NUMBER_LED_FRONT (3) // declaren waarvoor dient +#define NUMBER_LED_FRONT (3) #define ONE_COLOR InterruptIn button_lock(PC_0); // Input on intterupt base decleration. @@ -77,13 +76,13 @@ -> For detailed information/questions about this item, please read the technical manual or contact: Ricardo Molenaar | ricardo.molenaar@gmail.com */ I2C i2c_sensorplate_adc(PB_9, PB_8); // I2C for sensorplate. -I2C i2c_power_adc(PB_11, PB_10); // I2C for accupack. +//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_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. Adafruit_ADS1115 piezo_electric_adc(&i2c_sensorplate_adc, 0x4B); // i2c pins, i2c address. -Adafruit_ADS1115 adsAccu(&i2c_power_adc, 0x48); // i2c pins, i2c address. +//Adafruit_ADS1115 adsAccu(&i2c_power_adc, 0x48); // i2c pins, i2c address. Serial usb_serial(SERIAL_TX, SERIAL_RX); // tx, rx Serial pi_serial(PC_10, PC_11); // tx, rx Ticker total_readout_cycle; // Polling cycle. @@ -114,11 +113,11 @@ int speaker_active_ms = 750; // Time to iterate speaker on and off when alarm occurs. int alarm_voltage = 2400; // Needed voltage for alarm expressed as a digital 15 bit value (= 20% of max battery voltage). int LED_red_intensity = 0, LED_blue_intensity = 0, LED_green_intensity = 0; // Variables to set LED intensity. -short batteryvoltage_current = 0, batteryvoltage_last = 0, powervoltage_current, powervoltage_last; // Variables to manage batteryvoltage. Maybe change current to other? -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 +//short batteryvoltage_current = 0, batteryvoltage_last = 0, powervoltage_current, powervoltage_last; // Variables to manage batteryvoltage. Maybe change current to other? +//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 ********************************/ @@ -612,7 +611,7 @@ } } -void read_voltage() // Function for reading voltages from power and battery. +/*void read_voltage() // Function for reading voltages from power and battery. { if (power_plug_state == 1) { // If supplyvoltage (readed from input) is greater then the setted alarmvoltage. alarm = 0; // Alarm is off. @@ -650,14 +649,14 @@ } else { power_plug_state = 1; } -} +}*/ void read_adc() { return; piezo_electric_sample_timer.reset(); // Clock gebruiken o.i.d.? piezo_electric_sample_timer.start(); - connection_test_sensorplate = angle_device_sensorplate.testConnection(); + connection_test_sensorplate = ; if (test_mode == 1) { usb_serial.printf("Connection test sensorplate = %d\n", connection_test_sensorplate); @@ -800,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 = angle_device_sensorplate.testConnection(); + connection_test_sensorplate = sensorplate_connection_testpin; if (test_mode == 1) { usb_serial.printf("Connection test sensorplate = %d\n", connection_test_sensorplate);