w mx / Mbed 2 deprecated sensors

Dependencies:   mbed

Fork of sensors by BieWang

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sensors.h Source File

sensors.h

00001 #ifndef SENSORS_H
00002 #define SENSORS_H
00003 
00004 #include "mbed.h"
00005 //+++++++++++++++++++++BH1750+++++++++++++++++++++++++++++
00006 #define BH1750_I2CADDR 0x46
00007 #define BH1750_POWER_DOWN 0x00                  // No active state
00008 #define BH1750_POWER_ON 0x01                    // Wating for measurment command
00009 #define BH1750_RESET 0x07                       // Reset data register value - not accepted in POWER_DOWN mode
00010 #define BH1750_CONTINUOUS_HIGH_RES_MODE  0x10   // Start measurement at 1lx resolution. Measurement time is approx 120ms.
00011 #define BH1750_CONTINUOUS_HIGH_RES_MODE_2  0x11 // Start measurement at 0.5lx resolution. Measurement time is approx 120ms.
00012 #define BH1750_CONTINUOUS_LOW_RES_MODE  0x13    // Start measurement at 4lx resolution. Measurement time is approx 16ms.
00013 
00014 // Start measurement at 1lx resolution. Measurement time is approx 120ms.
00015 // Device is automatically set to Power Down after measurement.
00016 #define BH1750_ONE_TIME_HIGH_RES_MODE  0x20
00017 
00018 // Start measurement at 0.5lx resolution. Measurement time is approx 120ms.
00019 // Device is automatically set to Power Down after measurement.
00020 #define BH1750_ONE_TIME_HIGH_RES_MODE_2  0x21
00021 
00022 // Start measurement at 1lx resolution. Measurement time is approx 120ms.
00023 // Device is automatically set to Power Down after measurement.
00024 #define BH1750_ONE_TIME_LOW_RES_MODE  0x23
00025 //++++++++++++++++++++++++++++++++++++++++
00026 
00027 
00028 class sr501
00029 {
00030 /*****
00031  * 红外热释电对象
00032  * 感应输出高电平
00033 *****/
00034   private:
00035 //    DigitalIn signal;
00036     bool status;
00037     InterruptIn signal1;
00038     DigitalIn signal2;
00039     void triggered();
00040   public:
00041     sr501(PinName pSignal);
00042     bool operator==(const bool &target);
00043     void reset();
00044     int read();
00045 };
00046 //=========================================
00047 class BH1750
00048 {
00049     
00050 /*****
00051 
00052 *****/
00053   private:
00054     I2C link;
00055     char rawdata[2];
00056     bool status;
00057   public:
00058     BH1750(PinName sda,PinName scl);
00059     BH1750(PinName sda,PinName scl,char mode[]);
00060     float getlightdata();
00061 };
00062 #endif