upm  1.3.0
Sensor/Actuator repository for libmraa (v1.7.0)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
bh1750.hpp
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2016 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 #pragma once
25 
26 #include <string>
27 #include <iostream>
28 
29 #include <stdlib.h>
30 #include <unistd.h>
31 #include <string.h>
32 
33 #include "bh1750.h"
34 
35 namespace upm {
60  class BH1750 {
61  public:
62 
72  BH1750(int bus=BH1750_DEFAULT_I2C_BUS, int addr=BH1750_DEFAULT_I2C_ADDR,
73  BH1750_OPMODES_T mode=BH1750_OPMODE_H2_ONCE);
74 
78  ~BH1750();
79 
86  void reset();
87 
93  float getLux();
94 
98  void powerUp();
99 
103  void powerDown();
104 
110  void setOpmode(BH1750_OPMODES_T mode);
111 
112  protected:
113  // bh1750 device context
114  bh1750_context m_bh1750;
115 
121  void sendCommand(uint8_t cmd);
122 
128  uint16_t readData();
129 
130  private:
131  /* Disable implicit copy and assignment operators */
132  BH1750(const BH1750&) = delete;
133  BH1750 &operator=(const BH1750&) = delete;
134  };
135 }
void powerUp()
Definition: bh1750.cxx:62
C API for the BH1750 Light Sensor.
void sendCommand(uint8_t cmd)
Definition: bh1750.cxx:83
float getLux()
Definition: bh1750.cxx:51
void setOpmode(BH1750_OPMODES_T mode)
Definition: bh1750.cxx:76
void reset()
Definition: bh1750.cxx:46
BH1750(int bus=BH1750_DEFAULT_I2C_BUS, int addr=BH1750_DEFAULT_I2C_ADDR, BH1750_OPMODES_T mode=BH1750_OPMODE_H2_ONCE)
Definition: bh1750.cxx:33
~BH1750()
Definition: bh1750.cxx:41
uint16_t readData()
Definition: bh1750.cxx:90
UPM C API for the DFRobot I2C BH1750 Light Sensor.
Definition: bh1750.hpp:60
void powerDown()
Definition: bh1750.cxx:69
Definition: bh1750.h:51