Nathanaël Semhoun / Mbed OS mdot_commonsense

Dependencies:   libmDot-mbed5

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Sensors.h Source File

Sensors.h

00001 /* Copyright (c) 2015 Vertical M2M, MIT License
00002  *
00003  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 
00004  * and associated documentation files (the "Software"), to deal in the Software without restriction, 
00005  * including without limitation the rights to use, copy, modify, merge, publish, distribute, 
00006  * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 
00007  * furnished to do so, subject to the following conditions:
00008  *
00009  * The above copyright notice and this permission notice shall be included in all copies or 
00010  * substantial portions of the Software.
00011  *
00012  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 
00013  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
00014  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
00015  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
00016  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00017  */
00018 
00019 #ifndef __SENSORS__
00020 #define __SENSORS__
00021 
00022 #include "mbed.h"
00023 #include "DHT.h"
00024 
00025 #include <string>
00026 
00027 struct SensorsConfig_t
00028 {
00029     PinName dht;
00030     PinName motion;
00031     PinName light;
00032     PinName switch1;
00033     PinName switch2;
00034     
00035     time_t UpdatePeriod_s;
00036 };
00037 
00038 class Sensors {
00039 public:
00040     Sensors(SensorsConfig_t p_config);
00041     ~Sensors();
00042     
00043     void updateValues();
00044     
00045     float getTemp();
00046     float getHumidity();
00047     bool getMotion();
00048     float getLight();
00049     bool getSwitch1();
00050     bool getSwitch2();
00051     void setSwitch1(bool value);
00052     void setSwitch2(bool value);
00053     
00054 private:
00055     /**
00056      * Sensors
00057      */
00058     DHT m_sDht;
00059     DigitalIn m_sMotion;
00060     AnalogIn m_sLight;
00061     DigitalOut m_sSwitch1;
00062     DigitalOut m_sSwitch2;
00063     
00064     /**
00065      * Values
00066      */
00067     float m_temp;
00068     float m_humidity; 
00069     bool m_motion;
00070     float m_light;
00071     bool m_switch1;
00072     bool m_switch2;
00073     
00074     /**
00075      * Update configuration
00076      */
00077     time_t m_updatePeriod_s;
00078     time_t m_nextUpdate;
00079 };
00080 
00081 #endif