sampling hardware files

Dependents:   ELEC350_Project2

Committer:
Swabey89
Date:
Fri Dec 28 10:04:11 2018 +0000
Revision:
12:06637a2bfa41
Parent:
11:26736781b336
Child:
13:2b8889547764
Updated

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Swabey89 0:6d337c4ac714 1 #ifndef __sample_hardware__
Swabey89 0:6d337c4ac714 2 #define __sample_hardware__
Swabey89 0:6d337c4ac714 3
Swabey89 0:6d337c4ac714 4 //#define BME
Swabey89 0:6d337c4ac714 5 #ifdef BME
Swabey89 0:6d337c4ac714 6 #include "BME280.h"
Swabey89 0:6d337c4ac714 7 #else
Swabey89 0:6d337c4ac714 8 #include "BMP280.h"
Swabey89 0:6d337c4ac714 9 #endif
Swabey89 0:6d337c4ac714 10 #include "TextLCD.h"
Swabey89 0:6d337c4ac714 11 #include "SDBlockDevice.h"
Swabey89 0:6d337c4ac714 12 #include "FATFileSystem.h"
Swabey89 7:4945b875c6fc 13 #include <string>
Swabey89 7:4945b875c6fc 14
Swabey89 7:4945b875c6fc 15 #define BUFFERSIZE 120
Swabey89 7:4945b875c6fc 16
Swabey89 9:9283082c0f0f 17 //TEST FOR SD CARD
Swabey89 9:9283082c0f0f 18 #define SIGNAL_SD 3
Swabey89 9:9283082c0f0f 19
Swabey89 12:06637a2bfa41 20 #define TOUT_TIME 2
Swabey89 12:06637a2bfa41 21
Swabey89 11:26736781b336 22 extern Mutex timeLock;
Swabey89 11:26736781b336 23
Swabey89 7:4945b875c6fc 24 class sensorData
Swabey89 7:4945b875c6fc 25 {
Swabey89 7:4945b875c6fc 26 private:
Swabey89 7:4945b875c6fc 27 double temperature;
Swabey89 7:4945b875c6fc 28 double pressure;
Swabey89 8:92f3e4a99651 29 float lightlevel;
Swabey89 11:26736781b336 30 //struct tm* timeData;
Swabey89 7:4945b875c6fc 31 string time_str;
Swabey89 7:4945b875c6fc 32 public:
Swabey89 7:4945b875c6fc 33 sensorData(void)
Swabey89 7:4945b875c6fc 34 {
Swabey89 7:4945b875c6fc 35 this->temperature = 0;
Swabey89 7:4945b875c6fc 36 this->pressure = 0;
Swabey89 7:4945b875c6fc 37 this->lightlevel = 0;
Swabey89 8:92f3e4a99651 38 this->time_str = "";
Swabey89 7:4945b875c6fc 39 }
Swabey89 7:4945b875c6fc 40
Swabey89 7:4945b875c6fc 41 void updatetemp(double t)
Swabey89 7:4945b875c6fc 42 {
Swabey89 7:4945b875c6fc 43 this->temperature = t;
Swabey89 7:4945b875c6fc 44 };
Swabey89 7:4945b875c6fc 45
Swabey89 7:4945b875c6fc 46 void updatepress(double p)
Swabey89 7:4945b875c6fc 47 {
Swabey89 7:4945b875c6fc 48 this->pressure = p;
Swabey89 7:4945b875c6fc 49 };
Swabey89 7:4945b875c6fc 50
Swabey89 7:4945b875c6fc 51 void updatelight(float l)
Swabey89 7:4945b875c6fc 52 {
Swabey89 7:4945b875c6fc 53 this->lightlevel = l;
Swabey89 7:4945b875c6fc 54 };
Swabey89 7:4945b875c6fc 55
Swabey89 7:4945b875c6fc 56 void updateTime()
Swabey89 7:4945b875c6fc 57 {
Swabey89 8:92f3e4a99651 58 string t;
Swabey89 7:4945b875c6fc 59 time_t seconds;
Swabey89 11:26736781b336 60 timeLock.lock();
Swabey89 11:26736781b336 61 seconds = time(NULL);
Swabey89 8:92f3e4a99651 62 t = ctime(&seconds);
Swabey89 11:26736781b336 63 timeLock.unlock();
Swabey89 8:92f3e4a99651 64 t = t.substr(0,t.length()-1);
Swabey89 8:92f3e4a99651 65 this->time_str = t;
Swabey89 11:26736781b336 66
Swabey89 7:4945b875c6fc 67 }
Swabey89 7:4945b875c6fc 68
Swabey89 7:4945b875c6fc 69 double gettemp(void)
Swabey89 7:4945b875c6fc 70 {
Swabey89 7:4945b875c6fc 71 return this->temperature;
Swabey89 7:4945b875c6fc 72 };
Swabey89 7:4945b875c6fc 73
Swabey89 7:4945b875c6fc 74 double getpress(void)
Swabey89 7:4945b875c6fc 75 {
Swabey89 7:4945b875c6fc 76 return this->pressure;
Swabey89 7:4945b875c6fc 77 };
Swabey89 7:4945b875c6fc 78
Swabey89 7:4945b875c6fc 79 float getlight(void)
Swabey89 7:4945b875c6fc 80 {
Swabey89 7:4945b875c6fc 81 return this->lightlevel;
Swabey89 7:4945b875c6fc 82 };
Swabey89 7:4945b875c6fc 83
Swabey89 7:4945b875c6fc 84 string getTime(void)
Swabey89 7:4945b875c6fc 85 {
Swabey89 7:4945b875c6fc 86 return this->time_str;
Swabey89 7:4945b875c6fc 87 }
Swabey89 7:4945b875c6fc 88 };
Swabey89 0:6d337c4ac714 89
Swabey89 0:6d337c4ac714 90 enum ELEC350_ERROR_CODE {OK, FATAL};
Swabey89 0:6d337c4ac714 91
Swabey89 3:703870c099d6 92
Swabey89 3:703870c099d6 93 extern RawSerial* pc;
Swabey89 0:6d337c4ac714 94 extern DigitalOut onBoardLED;
Swabey89 0:6d337c4ac714 95 extern DigitalOut redLED;
Swabey89 0:6d337c4ac714 96 extern DigitalOut yellowLED;
Swabey89 0:6d337c4ac714 97 extern DigitalOut greenLED;
Swabey89 0:6d337c4ac714 98
Swabey89 0:6d337c4ac714 99 extern DigitalIn onBoardSwitch;
Swabey89 0:6d337c4ac714 100 extern DigitalIn SW1;
Swabey89 0:6d337c4ac714 101 extern DigitalIn SW2;
Swabey89 0:6d337c4ac714 102 //extern Serial pc;
Swabey89 0:6d337c4ac714 103 extern AnalogIn adcIn;
Swabey89 0:6d337c4ac714 104
Swabey89 0:6d337c4ac714 105 #ifdef BME
Swabey89 0:6d337c4ac714 106 extern BME280 sensor;
Swabey89 0:6d337c4ac714 107 #else
Swabey89 0:6d337c4ac714 108 extern BMP280 sensor;
Swabey89 0:6d337c4ac714 109 #endif
Swabey89 0:6d337c4ac714 110
Swabey89 0:6d337c4ac714 111 extern TextLCD lcd;
Swabey89 0:6d337c4ac714 112 extern SDBlockDevice sd;
Swabey89 0:6d337c4ac714 113
Swabey89 11:26736781b336 114
Swabey89 11:26736781b336 115
Swabey89 0:6d337c4ac714 116 extern void post();
Swabey89 0:6d337c4ac714 117 extern void errorCode(ELEC350_ERROR_CODE err);
Swabey89 0:6d337c4ac714 118
Swabey89 0:6d337c4ac714 119 #endif