You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.5 KiB

#ifndef _BH1750_H_
#define _BH1750_H_
#include <iostream>
#include <array>
#include <string>
#include "../../communication/i2c/i2c.hpp"
//Start measurement at 4lx resolution. Time typically 16ms.
#define BH1750_CONTINUOUS_LOW_RES_MODE 0x13
//Start measurement at 1lx resolution. Time typically 120ms
#define BH1750_CONTINUOUS_HIGH_RES_MODE_1 0x10
//Start measurement at 0.5lx resolution. Time typically 120ms
#define BH1750_CONTINUOUS_HIGH_RES_MODE_2 0x11
//Start measurement at 1lx resolution. Time typically 120ms
//Device is automatically set to Power Down after measurement.
#define BH1750_ONE_TIME_HIGH_RES_MODE_1 0x20
//Start measurement at 0.5lx resolution. Time typically 120ms
//Device is automatically set to Power Down after measurement.
#define BH1750_ONE_TIME_HIGH_RES_MODE_2 0x21
//Start measurement at 1lx resolution. Time typically 120ms
//Device is automatically set to Power Down after measurement.
#define BH1750_ONE_TIME_LOW_RES_MODE 0x23
#define BH1750_POWER_DOWN 0x00 // No active state
#define BH1750_POWER_ON 0x01 // Power on
#define BH1750_RESET 0x07 // Reset data register value
#define BH1750_ADDR 0x23 // Device Adress
class Bh1750
{
public:
Bh1750(I2C *i2c);
uint8_t sleep(); // To be testes
uint8_t wake(); // To be tested
uint8_t reset(); // To be tested
float oneShot(uint8_t mode); // ok
float continious(uint8_t mode, uint8_t delayMs); // IMplment delay or make a delay class ???
private:
I2C* i2c_bh1750;
uint8_t high;
uint8_t low;
uint8_t currentMode;
uint8_t currentState;
};
#endif // _BH1750_H_