Some refactoring
This commit is contained in:
parent
78317d6c4f
commit
1273bcae49
11 changed files with 182 additions and 234 deletions
|
|
@ -1,17 +1,3 @@
|
|||
/*
|
||||
|
||||
This is a library for the BH1750FVI Digital Light Sensor
|
||||
breakout board.
|
||||
|
||||
The board uses I2C for communication. 2 pins are required to
|
||||
interface to the device.
|
||||
|
||||
Datasheet:
|
||||
http://rohmfs.rohm.com/en/products/databook/datasheet/ic/sensor/light/bh1750fvi-e.pdf
|
||||
|
||||
based on Christopher Laws, March, 2013 code.
|
||||
|
||||
*/
|
||||
#ifndef SensorBH1750_H
|
||||
#define SensorBH1750_H
|
||||
|
||||
|
|
@ -19,52 +5,16 @@ based on Christopher Laws, March, 2013 code.
|
|||
#include "HalInterfaces.h"
|
||||
|
||||
|
||||
#define BH1750_DEBUG 0
|
||||
|
||||
#define BH1750_I2CADDR 0x23
|
||||
|
||||
// No active state
|
||||
#define BH1750_POWER_DOWN 0x00
|
||||
|
||||
// Waiting for measurement command
|
||||
#define BH1750_POWER_ON 0x01
|
||||
|
||||
// Reset data register value - not accepted in POWER_DOWN mode
|
||||
#define BH1750_RESET 0x07
|
||||
|
||||
// Start measurement at 1lx resolution. Measurement time is approx 120ms.
|
||||
#define BH1750_CONTINUOUS_HIGH_RES_MODE 0x10
|
||||
|
||||
// Start measurement at 0.5lx resolution. Measurement time is approx 120ms.
|
||||
#define BH1750_CONTINUOUS_HIGH_RES_MODE_2 0x11
|
||||
|
||||
// Start measurement at 4lx resolution. Measurement time is approx 16ms.
|
||||
#define BH1750_CONTINUOUS_LOW_RES_MODE 0x13
|
||||
|
||||
// Start measurement at 1lx resolution. Measurement time is approx 120ms.
|
||||
// Device is automatically set to Power Down after measurement.
|
||||
#define BH1750_ONE_TIME_HIGH_RES_MODE 0x20
|
||||
|
||||
// Start measurement at 0.5lx resolution. Measurement time is approx 120ms.
|
||||
// Device is automatically set to Power Down after measurement.
|
||||
#define BH1750_ONE_TIME_HIGH_RES_MODE_2 0x21
|
||||
|
||||
// Start measurement at 1lx resolution. Measurement time is approx 120ms.
|
||||
// Device is automatically set to Power Down after measurement.
|
||||
#define BH1750_ONE_TIME_LOW_RES_MODE 0x23
|
||||
|
||||
|
||||
class SensorBH1750 : public SensorPowerConsumption, public SensorLight{
|
||||
public:
|
||||
virtual void setup();
|
||||
virtual unsigned int getLuminosity();
|
||||
virtual unsigned int getConsumption();
|
||||
virtual void reset();
|
||||
virtual void read(PowerData& data);
|
||||
virtual void read(LightData& data);
|
||||
|
||||
void configure(uint8_t mode);
|
||||
private:
|
||||
unsigned int pulses;
|
||||
void write8(uint8_t data);
|
||||
|
||||
void configure(uint8_t mode);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue