sampling hardware files

Dependents:   ELEC350_Project2

Committer:
Swabey89
Date:
Thu Jan 03 12:18:07 2019 +0000
Revision:
15:cb01650a4cfe
Parent:
14:84bd246f98f4
Updates

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