Buffer working with LCD, Serial and SD Card
Dependencies: BMP280
Fork of Thread_Communication by
main.h@7:f017a37bcf1b, 2017-12-28 (annotated)
- Committer:
- dnonoo
- Date:
- Thu Dec 28 19:32:22 2017 +0000
- Revision:
- 7:f017a37bcf1b
- Parent:
- 0:cb3a5c15b01e
- Child:
- 8:ab6322afa341
Mostly Georges buffer code using one mail queue and global variables with mutex locks.;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
benparkes | 0:cb3a5c15b01e | 1 | #include "LCD.h" |
benparkes | 0:cb3a5c15b01e | 2 | #include "BMP280.h" |
benparkes | 0:cb3a5c15b01e | 3 | |
dnonoo | 7:f017a37bcf1b | 4 | #define ENTER_KEY 1 |
dnonoo | 7:f017a37bcf1b | 5 | #define MAX_SAMPLES 120 |
dnonoo | 7:f017a37bcf1b | 6 | #define SENSOR_UPDATE 1 |
dnonoo | 7:f017a37bcf1b | 7 | #define DATA_READY 1 |
dnonoo | 7:f017a37bcf1b | 8 | #define SAMPLING_PERIOD 10 |
dnonoo | 7:f017a37bcf1b | 9 | #define ON 1 |
dnonoo | 7:f017a37bcf1b | 10 | #define OFF 0 |
dnonoo | 7:f017a37bcf1b | 11 | |
benparkes | 0:cb3a5c15b01e | 12 | extern LCD lcd; |
benparkes | 0:cb3a5c15b01e | 13 | extern BMP280 sensor; |
benparkes | 0:cb3a5c15b01e | 14 | |
benparkes | 0:cb3a5c15b01e | 15 | /* External LEDs as Open Drain */ |
dnonoo | 7:f017a37bcf1b | 16 | extern DigitalOut Red_ext (PE_15); |
dnonoo | 7:f017a37bcf1b | 17 | extern DigitalOut Yellow_ext (PB_10); |
dnonoo | 7:f017a37bcf1b | 18 | extern DigitalOut Green_ext (PB_11); |
benparkes | 0:cb3a5c15b01e | 19 | |
benparkes | 0:cb3a5c15b01e | 20 | /* Configure On-board LEDS */ |
dnonoo | 7:f017a37bcf1b | 21 | extern DigitalOut Green_int (LED1); |
dnonoo | 7:f017a37bcf1b | 22 | extern DigitalOut Blue_int (LED2); |
dnonoo | 7:f017a37bcf1b | 23 | extern DigitalOut Red_int (LED3); |
benparkes | 0:cb3a5c15b01e | 24 | |
benparkes | 0:cb3a5c15b01e | 25 | /* Configure Digital In Switches */ |
dnonoo | 7:f017a37bcf1b | 26 | extern DigitalIn SW_L (PE_12); |
dnonoo | 7:f017a37bcf1b | 27 | extern DigitalIn SW_R (PE_14); |
dnonoo | 7:f017a37bcf1b | 28 | extern DigitalIn SW_B (USER_BUTTON); |
benparkes | 0:cb3a5c15b01e | 29 | /* Configure Analogue Pins */ |
benparkes | 0:cb3a5c15b01e | 30 | /* Analogue IN */ |
dnonoo | 7:f017a37bcf1b | 31 | extern AnalogIn LDR_In (PA_0); |
benparkes | 0:cb3a5c15b01e | 32 | |
benparkes | 0:cb3a5c15b01e | 33 | /* Congfigure Serial interface */ |
dnonoo | 7:f017a37bcf1b | 34 | Serial pc(USBTX, USBRX); |
dnonoo | 7:f017a37bcf1b | 35 | |
dnonoo | 7:f017a37bcf1b | 36 | /* Mail */ |
dnonoo | 7:f017a37bcf1b | 37 | typedef struct { |
dnonoo | 7:f017a37bcf1b | 38 | float LDR_Value; |
dnonoo | 7:f017a37bcf1b | 39 | float temp_Value; |
dnonoo | 7:f017a37bcf1b | 40 | float press_Value; |
dnonoo | 7:f017a37bcf1b | 41 | } mail_t; |
dnonoo | 7:f017a37bcf1b | 42 | |
dnonoo | 7:f017a37bcf1b | 43 | Mail<mail_t, 16> mail_box; |
dnonoo | 7:f017a37bcf1b | 44 | |
dnonoo | 7:f017a37bcf1b | 45 | //data FIFO buffer |
dnonoo | 7:f017a37bcf1b | 46 | char data_buffer[MAX_SAMPLES][64]; |
dnonoo | 7:f017a37bcf1b | 47 | int sample_h = 0; |
dnonoo | 7:f017a37bcf1b | 48 | int sample_t = 0; |
dnonoo | 7:f017a37bcf1b | 49 | int data_h = 0; |
dnonoo | 7:f017a37bcf1b | 50 | int data_t = 0; |
dnonoo | 7:f017a37bcf1b | 51 | struct tm * sample_epoch; |
dnonoo | 7:f017a37bcf1b | 52 | |
dnonoo | 7:f017a37bcf1b | 53 | |
dnonoo | 7:f017a37bcf1b | 54 | //Serial_CMD |
dnonoo | 7:f017a37bcf1b | 55 | volatile int rx_in=0; |
dnonoo | 7:f017a37bcf1b | 56 | char rx_buffer[32]; |
dnonoo | 7:f017a37bcf1b | 57 | time_t raw_time = time(NULL); |
dnonoo | 7:f017a37bcf1b | 58 | char serial_buffer[80]; |
dnonoo | 7:f017a37bcf1b | 59 | |
dnonoo | 7:f017a37bcf1b | 60 | extern void POST(); |