diajzifsajoifajsoifaj

Dependencies:   BMP280 LGLCD

Fork of ELEC350-CWTEMPLATE-2017 by University of Plymouth - Stages 1, 2 and 3

Committer:
liam_grazier
Date:
Fri Jan 05 17:56:59 2018 +0000
Revision:
6:f0601ebd2423
Parent:
5:9b4844128e09
Child:
7:dd303488e55d
working screen

Who changed what in which revision?

UserRevisionLine numberNew contents of line
liam_grazier 5:9b4844128e09 1 #include "components.hpp"
liam_grazier 5:9b4844128e09 2 #include "SDBlockDevice.h"
liam_grazier 5:9b4844128e09 3 #include "FATFileSystem.h"
liam_grazier 5:9b4844128e09 4 //#include "Networkbits.hpp"
liam_grazier 5:9b4844128e09 5 #include "mbed.h"
liam_grazier 5:9b4844128e09 6 #include "lglcd.h"
liam_grazier 5:9b4844128e09 7 #include "stdio.h"
noutram 3:a88838ff33e7 8 // This is a very short demo that demonstrates all the hardware used in the coursework.
noutram 3:a88838ff33e7 9 // You will need a network connection set up (covered elsewhere). The host PC should have the address 10.0.0.1
noutram 0:36e89e3ed7c4 10
noutram 3:a88838ff33e7 11 //Threads
noutram 3:a88838ff33e7 12 Thread nwrkThread;
liam_grazier 5:9b4844128e09 13 int main(){
liam_grazier 5:9b4844128e09 14 lglcd mylcd(D7,D6,D5,D4,D3,D2);
liam_grazier 5:9b4844128e09 15 mylcd.clear();
liam_grazier 5:9b4844128e09 16 while(true){
liam_grazier 5:9b4844128e09 17 double temp = sensor.getTemperature();
liam_grazier 6:f0601ebd2423 18 double pressure = sensor.getPressure();
liam_grazier 6:f0601ebd2423 19 double lightin = adcIn;
liam_grazier 5:9b4844128e09 20 char TEM[6];
liam_grazier 5:9b4844128e09 21 char PRE[5];
liam_grazier 5:9b4844128e09 22 sprintf(TEM,"%.2f", temp);
liam_grazier 5:9b4844128e09 23 sprintf(PRE,"%.2f", pressure);
liam_grazier 5:9b4844128e09 24 printf(TEM);
liam_grazier 5:9b4844128e09 25 printf(PRE);
liam_grazier 6:f0601ebd2423 26 mylcd.setline(1,1);
liam_grazier 6:f0601ebd2423 27 mylcd.write("P:");
liam_grazier 5:9b4844128e09 28 mylcd.write(PRE);
liam_grazier 6:f0601ebd2423 29 mylcd.setline(1,10);
liam_grazier 6:f0601ebd2423 30 mylcd.write("T:");
liam_grazier 5:9b4844128e09 31 mylcd.write(TEM);
liam_grazier 6:f0601ebd2423 32 mylcd.setline(2,1);
liam_grazier 6:f0601ebd2423 33 mylcd.write("L:");
liam_grazier 6:f0601ebd2423 34 if(lightin > 0.8 && lightin < 0.9)
liam_grazier 6:f0601ebd2423 35 {
liam_grazier 6:f0601ebd2423 36 mylcd.setline(2,4);
liam_grazier 6:f0601ebd2423 37 mylcd.write(" ");
liam_grazier 6:f0601ebd2423 38 mylcd.setline(2,4);
liam_grazier 6:f0601ebd2423 39 mylcd.write("|||||||||");
liam_grazier 6:f0601ebd2423 40 }
liam_grazier 6:f0601ebd2423 41 else if(lightin > 0.51 && lightin < 0.9)
liam_grazier 6:f0601ebd2423 42 {
liam_grazier 6:f0601ebd2423 43 mylcd.setline(2,4);
liam_grazier 6:f0601ebd2423 44 mylcd.write(" ");
liam_grazier 6:f0601ebd2423 45 mylcd.setline(2,4);
liam_grazier 6:f0601ebd2423 46 mylcd.write("|||||");
liam_grazier 6:f0601ebd2423 47 }
liam_grazier 6:f0601ebd2423 48 else if(lightin > 0.4 && lightin < 0.5)
liam_grazier 6:f0601ebd2423 49 {
liam_grazier 6:f0601ebd2423 50 mylcd.setline(2,4);
liam_grazier 6:f0601ebd2423 51 mylcd.write(" ");
liam_grazier 6:f0601ebd2423 52 mylcd.setline(2,4);
liam_grazier 6:f0601ebd2423 53 mylcd.write("|||");
liam_grazier 6:f0601ebd2423 54 }
liam_grazier 6:f0601ebd2423 55 else if(lightin > 0.2 && lightin < 0.39)
liam_grazier 6:f0601ebd2423 56 {
liam_grazier 6:f0601ebd2423 57 mylcd.setline(2,4);
liam_grazier 6:f0601ebd2423 58 mylcd.write(" ");
liam_grazier 6:f0601ebd2423 59 mylcd.setline(2,4);
liam_grazier 6:f0601ebd2423 60 mylcd.write("LOW");
liam_grazier 6:f0601ebd2423 61 }
liam_grazier 6:f0601ebd2423 62 else if(lightin < 0.19)
liam_grazier 6:f0601ebd2423 63 {
liam_grazier 6:f0601ebd2423 64 mylcd.setline(2,4);
liam_grazier 6:f0601ebd2423 65 mylcd.write(" ");
liam_grazier 6:f0601ebd2423 66 mylcd.setline(2,4);
liam_grazier 6:f0601ebd2423 67 mylcd.write("disconnected");
liam_grazier 6:f0601ebd2423 68 }
liam_grazier 6:f0601ebd2423 69
liam_grazier 6:f0601ebd2423 70 //mylcd.write(light);
liam_grazier 6:f0601ebd2423 71 //printf(adcIn);
liam_grazier 6:f0601ebd2423 72 wait(0.4);
liam_grazier 5:9b4844128e09 73
noutram 1:e1cf7663f5ff 74 }
noutram 3:a88838ff33e7 75
noutram 1:e1cf7663f5ff 76 //Flash to indicate goodness
liam_grazier 5:9b4844128e09 77
noutram 0:36e89e3ed7c4 78 }
noutram 0:36e89e3ed7c4 79
noutram 1:e1cf7663f5ff 80
noutram 1:e1cf7663f5ff 81