fuck this

Dependencies:   BMP280

main.cpp

Committer:
Swaggie
Date:
2018-01-09
Revision:
20:25939e03b803
Parent:
19:40c721f01ed2
Child:
21:6e733076f49c

File content as of revision 20:25939e03b803:

#include "mbed.h"
#include "WebUI.h"
#include "Serial.h"
#include "Sampling.h"
#include "LCD.h"
#include "SDCard.h"
#include "SDBlockDevice.h"
#include "Logging.h"

//Hardware setup
BMP280 sensor(D14, D15);    //enviromental sensor
AnalogIn LDRSensor(A0);     //LDR sensor
DigitalOut SamplingLED(PB_10);//LED to indicate sampling
//SD Card devices
InterruptIn SD_WP(PE_10);
InterruptIn UserButton(USER_BUTTON);
SDBlockDevice sd(PB_5, D12, D13, D10);
DigitalOut GreenLED(PB_11);

Serial PC(USBTX, USBRX);    //Serial interface
//SD Card Object
ENVDISPLAY lcd(D9, D8, D7, D6, D4, D2,PE_12, PE_14);    //LCD pins and two timeset buttons

int main()
{
    //Initialise devices
    firstSample = true; //Set only at start of program
    logging = true;
    //Hardware Self Test

    //Initialise interrupts and times
    SerialStart();  //Start serial comms
    lcd.Start();    //Start LCD functionality
    SDCardInit();   //Start SDCard functionality
    WebUISetup();   //Start Web Interface
    ConfigThreadsAndIR(); //Start sampling


    //Run
    while (true) {
        if (NewEnvSample && NewLDRSample) {
            //New samples have been captured and are in the register
            IncrementIndex();
            NewEnvSample = false;   //Reset sampling threads
            NewLDRSample = false;

            //push latest samples to LCD.
            lcd.UpdateData(tempReadings[currentIndex],presReadings[currentIndex],LDRReadings[currentIndex],timeReadings[currentIndex]);
            LogEvent(Log_IndexInc);   //Log position
        }
        if (logging) {
            string QueueData = CheckLoggingQueue(); //Get the data from queue
            char char_array[QueueData.length()+1];  //Char array for message
            strcpy(char_array, QueueData.c_str());  //String must be converted to char array for printf
            PC.printf("%s\n\r",char_array);
        }
    }
}