fuck this
Dependencies: BMP280
main.cpp@21:6e733076f49c, 2018-01-09 (annotated)
- Committer:
- mwthewsey
- Date:
- Tue Jan 09 20:51:19 2018 +0000
- Revision:
- 21:6e733076f49c
- Parent:
- 20:25939e03b803
- Child:
- 24:7bf408dc491a
Everything working. Comments checked.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
noutram | 0:65ff7ad381e8 | 1 | #include "mbed.h" |
Swaggie | 2:5a38ae8459d5 | 2 | #include "WebUI.h" |
Swaggie | 2:5a38ae8459d5 | 3 | #include "Serial.h" |
Swaggie | 3:8fa1e77c8a5d | 4 | #include "Sampling.h" |
Swaggie | 3:8fa1e77c8a5d | 5 | #include "LCD.h" |
mwthewsey | 11:b538e73841ae | 6 | #include "SDCard.h" |
Swaggie | 5:bea93c8e50b7 | 7 | #include "SDBlockDevice.h" |
Swaggie | 20:25939e03b803 | 8 | #include "Logging.h" |
mwthewsey | 12:03589f1d5c30 | 9 | |
mwthewsey | 12:03589f1d5c30 | 10 | //Hardware setup |
mwthewsey | 21:6e733076f49c | 11 | BMP280 sensor(D14, D15); //Enviromental sensor |
mwthewsey | 21:6e733076f49c | 12 | AnalogIn LDRSensor(A0); //LDR sensor |
mwthewsey | 21:6e733076f49c | 13 | DigitalOut SamplingLED(PB_10); //LED to indicate sampling |
mwthewsey | 21:6e733076f49c | 14 | |
Swaggie | 19:40c721f01ed2 | 15 | //SD Card devices |
Swaggie | 19:40c721f01ed2 | 16 | InterruptIn SD_WP(PE_10); |
Swaggie | 19:40c721f01ed2 | 17 | InterruptIn UserButton(USER_BUTTON); |
Swaggie | 19:40c721f01ed2 | 18 | SDBlockDevice sd(PB_5, D12, D13, D10); |
Swaggie | 19:40c721f01ed2 | 19 | DigitalOut GreenLED(PB_11); |
mwthewsey | 12:03589f1d5c30 | 20 | |
mwthewsey | 21:6e733076f49c | 21 | //Serial interface |
mwthewsey | 21:6e733076f49c | 22 | Serial PC(USBTX, USBRX); |
mwthewsey | 21:6e733076f49c | 23 | |
mwthewsey | 21:6e733076f49c | 24 | //LCD card object. LCD pins and two timeset buttons |
mwthewsey | 21:6e733076f49c | 25 | ENVDISPLAY lcd(D9, D8, D7, D6, D4, D2,PE_12, PE_14); |
noutram | 0:65ff7ad381e8 | 26 | |
noutram | 0:65ff7ad381e8 | 27 | int main() |
noutram | 0:65ff7ad381e8 | 28 | { |
Swaggie | 2:5a38ae8459d5 | 29 | //Initialise devices |
Swaggie | 19:40c721f01ed2 | 30 | firstSample = true; //Set only at start of program |
mwthewsey | 21:6e733076f49c | 31 | logging = false; |
mwthewsey | 21:6e733076f49c | 32 | |
Swaggie | 2:5a38ae8459d5 | 33 | //Hardware Self Test |
mwthewsey | 21:6e733076f49c | 34 | |
mwthewsey | 12:03589f1d5c30 | 35 | |
Swaggie | 19:40c721f01ed2 | 36 | //Initialise interrupts and times |
mwthewsey | 21:6e733076f49c | 37 | SerialStart(); //Start serial comms |
mwthewsey | 21:6e733076f49c | 38 | lcd.Start(); //Start LCD functionality |
mwthewsey | 21:6e733076f49c | 39 | SDCardInit(); //Start SDCard functionality |
mwthewsey | 21:6e733076f49c | 40 | WebUISetup(); //Start Web Interface |
Swaggie | 19:40c721f01ed2 | 41 | ConfigThreadsAndIR(); //Start sampling |
Swaggie | 19:40c721f01ed2 | 42 | |
Swaggie | 19:40c721f01ed2 | 43 | |
Swaggie | 6:8e1795a5886b | 44 | //Run |
Swaggie | 19:40c721f01ed2 | 45 | while (true) { |
Swaggie | 19:40c721f01ed2 | 46 | if (NewEnvSample && NewLDRSample) { |
Swaggie | 7:bf9f92ff02e8 | 47 | //New samples have been captured and are in the register |
mwthewsey | 21:6e733076f49c | 48 | IncrementIndex(); //Index for buffers |
Swaggie | 19:40c721f01ed2 | 49 | NewEnvSample = false; //Reset sampling threads |
Swaggie | 6:8e1795a5886b | 50 | NewLDRSample = false; |
Swaggie | 19:40c721f01ed2 | 51 | |
mwthewsey | 21:6e733076f49c | 52 | //Push latest samples to LCD. |
mwthewsey | 11:b538e73841ae | 53 | lcd.UpdateData(tempReadings[currentIndex],presReadings[currentIndex],LDRReadings[currentIndex],timeReadings[currentIndex]); |
Swaggie | 20:25939e03b803 | 54 | LogEvent(Log_IndexInc); //Log position |
Swaggie | 6:8e1795a5886b | 55 | } |
Swaggie | 20:25939e03b803 | 56 | if (logging) { |
mwthewsey | 21:6e733076f49c | 57 | //Grab from mailbox and print to serial |
Swaggie | 20:25939e03b803 | 58 | string QueueData = CheckLoggingQueue(); //Get the data from queue |
Swaggie | 20:25939e03b803 | 59 | char char_array[QueueData.length()+1]; //Char array for message |
Swaggie | 20:25939e03b803 | 60 | strcpy(char_array, QueueData.c_str()); //String must be converted to char array for printf |
Swaggie | 20:25939e03b803 | 61 | PC.printf("%s\n\r",char_array); |
Swaggie | 20:25939e03b803 | 62 | } |
Swaggie | 19:40c721f01ed2 | 63 | } |
Swaggie | 7:bf9f92ff02e8 | 64 | } |