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