mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-09-19 16:46:11 -04:00
0.3.0 BH1750FVT_RT
This commit is contained in:
parent
e358d8dc85
commit
451f956326
@ -1,39 +1,34 @@
|
||||
//
|
||||
// FILE: BH1750FVI.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.2.10
|
||||
// VERSION: 0.3.0
|
||||
// PURPOSE: library for BH1750FVI lux sensor Arduino
|
||||
// URL: https://github.com/RobTillaart/BH1750FVI
|
||||
//
|
||||
// HISTORY: see changelog.md
|
||||
|
||||
|
||||
#include "BH1750FVI.h"
|
||||
|
||||
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
BH1750FVI::BH1750FVI(const uint8_t address, const uint8_t dataPin, const uint8_t clockPin)
|
||||
{
|
||||
_address = address;
|
||||
_wire = &Wire;
|
||||
|
||||
if ((dataPin < 255) && (clockPin < 255))
|
||||
{
|
||||
_wire->begin(dataPin, clockPin);
|
||||
} else {
|
||||
_wire->begin();
|
||||
}
|
||||
begin();
|
||||
}
|
||||
#endif
|
||||
// COMMANDS P5
|
||||
#define BH1750FVI_POWER_ON 0x00
|
||||
#define BH1750FVI_POWER_OFF 0x01
|
||||
#define BH1750FVI_RESET 0x07
|
||||
#define BH1750FVI_CONT_HIGH 0x10
|
||||
#define BH1750FVI_CONT_HIGH2 0x11
|
||||
#define BH1750FVI_CONT_LOW 0x13
|
||||
#define BH1750FVI_ONCE_HIGH 0x20
|
||||
#define BH1750FVI_ONCE_HIGH2 0x21
|
||||
#define BH1750FVI_ONCE_LOW 0x23
|
||||
|
||||
|
||||
BH1750FVI::BH1750FVI(const uint8_t address, TwoWire *wire)
|
||||
{
|
||||
_address = address;
|
||||
_wire = wire;
|
||||
_wire->begin();
|
||||
begin();
|
||||
_data = 0;
|
||||
_error = BH1750FVI_OK;
|
||||
_sensitivityFactor = BH1750FVI_REFERENCE_TIME;
|
||||
_mode = BH1750FVI_MODE_HIGH;
|
||||
}
|
||||
|
||||
|
||||
@ -115,6 +110,24 @@ int BH1750FVI::getError()
|
||||
}
|
||||
|
||||
|
||||
void BH1750FVI::powerOn()
|
||||
{
|
||||
command(BH1750FVI_POWER_ON);
|
||||
}
|
||||
|
||||
|
||||
void BH1750FVI::powerOff()
|
||||
{
|
||||
command(BH1750FVI_POWER_OFF);
|
||||
}
|
||||
|
||||
|
||||
void BH1750FVI::reset()
|
||||
{
|
||||
command(BH1750FVI_RESET);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////
|
||||
//
|
||||
// operational mode
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// FILE: BH1750FVI.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.2.10
|
||||
// VERSION: 0.3.0
|
||||
// PURPOSE: Arduino library for BH1750FVI (GY-30) lux sensor
|
||||
// HISTORY: see changelog.md
|
||||
//
|
||||
@ -28,24 +28,12 @@
|
||||
#include "Arduino.h"
|
||||
|
||||
|
||||
#define BH1750FVI_LIB_VERSION (F("0.2.10"))
|
||||
#define BH1750FVI_LIB_VERSION (F("0.3.0"))
|
||||
|
||||
|
||||
#define BH1750FVI_DEFAULT_ADDRESS 0x23
|
||||
#define BH1750FVI_ALT_ADDRESS 0x5C
|
||||
|
||||
|
||||
// COMMANDS P5
|
||||
#define BH1750FVI_POWER_ON 0x00
|
||||
#define BH1750FVI_POWER_OFF 0x01
|
||||
#define BH1750FVI_RESET 0x07
|
||||
#define BH1750FVI_CONT_HIGH 0x10
|
||||
#define BH1750FVI_CONT_HIGH2 0x11
|
||||
#define BH1750FVI_CONT_LOW 0x13
|
||||
#define BH1750FVI_ONCE_HIGH 0x20
|
||||
#define BH1750FVI_ONCE_HIGH2 0x21
|
||||
#define BH1750FVI_ONCE_LOW 0x23
|
||||
|
||||
#define BH1750FVI_REFERENCE_TIME 0x45 // 69 = default
|
||||
|
||||
#define BH1750FVI_MODE_LOW 0x00
|
||||
@ -62,15 +50,9 @@ class BH1750FVI
|
||||
{
|
||||
public:
|
||||
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
// dataPin and clockPin can be used for ESP8266
|
||||
BH1750FVI(const uint8_t address , const uint8_t dataPin, const uint8_t clockPin);
|
||||
#endif
|
||||
|
||||
BH1750FVI(const uint8_t address, TwoWire *wire = &Wire);
|
||||
// returns true if isConnected()
|
||||
bool begin(); // resets to constructor defaults. (use with care)
|
||||
|
||||
bool isConnected(); // returns true if address is on I2C bus
|
||||
|
||||
|
||||
@ -79,16 +61,16 @@ public:
|
||||
int getError();
|
||||
|
||||
|
||||
void powerOn() { command(BH1750FVI_POWER_ON); };
|
||||
void powerOff() { command(BH1750FVI_POWER_OFF); };
|
||||
void reset() { command(BH1750FVI_RESET); };
|
||||
void powerOn();
|
||||
void powerOff();
|
||||
void reset();
|
||||
|
||||
|
||||
// MODE TIME RESOLUTION
|
||||
// 2 HIGH2 120 ms 0.5 lux // recommended max * 1.5 = 180 ms
|
||||
// 1 HIGH 120 ms 1.0 lux
|
||||
// 0 LOW 16 ms 4.0 lux
|
||||
uint8_t getMode() { return _mode; };
|
||||
uint8_t getMode() { return _mode; };
|
||||
|
||||
|
||||
void setContHighRes();
|
||||
@ -106,8 +88,8 @@ public:
|
||||
// to be used for very high and very low brightness
|
||||
// or to correct for e.g. transparency
|
||||
void changeTiming(uint8_t time = BH1750FVI_REFERENCE_TIME); // 69 is default
|
||||
|
||||
|
||||
|
||||
|
||||
// returns changeTiming() parameter
|
||||
uint8_t setCorrectionFactor(float factor = 1); // 0.45 .. 3.68
|
||||
// returns percentage set.
|
||||
@ -130,7 +112,7 @@ public:
|
||||
|
||||
|
||||
// datasheet Page 3 figure 1 (experimental correction)
|
||||
// Effect of wavelength can be substantial,
|
||||
// Effect of wavelength can be substantial,
|
||||
// correction is calculated by multiple linear approximations.
|
||||
// wavelength of 580 ==> correction == 1
|
||||
// returns the wavelength correction factor
|
||||
@ -160,5 +142,5 @@ private:
|
||||
};
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -6,12 +6,21 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
##[0.3.0] - 2023-10-18
|
||||
- simplify constructor / begin()
|
||||
- update examples
|
||||
- add Wire1 specific example
|
||||
- moved code from .h to .cpp
|
||||
- update readme.md
|
||||
- update keywords.txt
|
||||
|
||||
----
|
||||
|
||||
## [0.2.10] - 2022-10-28
|
||||
- Add RP2040 support to build-CI.
|
||||
- Add CHANGELOG.md
|
||||
- update unit test
|
||||
|
||||
|
||||
##[0.2.9] - 2021-12-14
|
||||
- update library.json
|
||||
- update license
|
||||
|
@ -2,8 +2,11 @@
|
||||
[![Arduino CI](https://github.com/RobTillaart/BH1750FVI_RT/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
|
||||
[![Arduino-lint](https://github.com/RobTillaart/BH1750FVI_RT/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/BH1750FVI_RT/actions/workflows/arduino-lint.yml)
|
||||
[![JSON check](https://github.com/RobTillaart/BH1750FVI_RT/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/BH1750FVI_RT/actions/workflows/jsoncheck.yml)
|
||||
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/BH1750FVI_RT.svg)](https://github.com/RobTillaart/BH1750FVI_RT/issues)
|
||||
|
||||
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/BH1750FVI_RT/blob/master/LICENSE)
|
||||
[![GitHub release](https://img.shields.io/github/release/RobTillaart/BH1750FVI_RT.svg?maxAge=3600)](https://github.com/RobTillaart/BH1750FVI_RT/releases)
|
||||
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/BH1750FVI_RT.svg)](https://registry.platformio.org/libraries/robtillaart/BH1750FVI_RT)
|
||||
|
||||
|
||||
# BH1750FVI_RT
|
||||
@ -60,6 +63,10 @@ Note: the breakout board was 5 volt tolerant.
|
||||
|
||||
## Interface
|
||||
|
||||
```cpp
|
||||
#include "BH1750FVI.h"
|
||||
```
|
||||
|
||||
### Constructor
|
||||
|
||||
- **BH1750FVI(uint8_t address, uint8_t dataPin, uint8_t clockPin)** ESP constructor with I2C parameters.
|
||||
@ -178,6 +185,12 @@ See samples...
|
||||
|
||||
## Future
|
||||
|
||||
#### Must
|
||||
|
||||
#### Should
|
||||
|
||||
#### Could
|
||||
|
||||
- **Intelligent isReady()**
|
||||
After a **getLux()** call one can clean the data register explicitly with
|
||||
**reset()**. Then a call to **isReady()** fetches data and as long as
|
||||
@ -185,3 +198,14 @@ data equals zero the sensor is not ready.
|
||||
- **DVI interface**
|
||||
To investigate, sort of external reset?
|
||||
- move code to .cpp
|
||||
|
||||
#### Wont
|
||||
|
||||
## Support
|
||||
|
||||
If you appreciate my libraries, you can support the development and maintenance.
|
||||
Improve the quality of the libraries by providing issues and Pull Requests, or
|
||||
donate through PayPal or GitHub sponsors.
|
||||
|
||||
Thank you,
|
||||
|
||||
|
@ -58,6 +58,7 @@ void setup()
|
||||
Serial.println();
|
||||
|
||||
Wire.begin();
|
||||
|
||||
myLux.powerOn();
|
||||
myLux.setContHighRes();
|
||||
|
||||
@ -93,5 +94,4 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
// -- END OF FILE --
|
||||
|
@ -1,17 +1,15 @@
|
||||
//
|
||||
// FILE: BH1750FVI_async.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: demo of BH1750FVI lux scanner library
|
||||
// DATE: 2020-08-20
|
||||
//
|
||||
|
||||
|
||||
#include "BH1750FVI.h"
|
||||
|
||||
BH1750FVI myLux(0x23);
|
||||
|
||||
float correctionFactor = 0.45; // min value see datasheet
|
||||
float correctionFactor = 0.45; // min value see datasheet
|
||||
uint32_t count = 0;
|
||||
|
||||
|
||||
@ -50,7 +48,7 @@ void loop()
|
||||
Serial.print("\t");
|
||||
Serial.println(val / myLux.getCorrectionFactor(), 1);
|
||||
|
||||
// note correction factor are steps of 1/69 internally, see datasheet
|
||||
// note correction factor are steps of 1/69 internally, see datasheet
|
||||
correctionFactor += 0.05;
|
||||
if (correctionFactor > 3.68) // 0.45 - 3.68 = 45 steps of 0.05
|
||||
{
|
||||
@ -62,9 +60,8 @@ void loop()
|
||||
count++;
|
||||
}
|
||||
delay(1000);
|
||||
// do other things here
|
||||
// do other things here
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
// -- END OF FILE --
|
||||
|
@ -1,13 +1,12 @@
|
||||
//
|
||||
// FILE: BH1750FVI_cont_high_res.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: demo of BH1750FVI lux scanner library
|
||||
// DATE: 2020-02-02
|
||||
//
|
||||
// This is a minimal version, which can be optimized by
|
||||
// using mylux.getRaw() instead of myLux.getLux(); line38
|
||||
// gain on UNO: ~350 bytes smaller
|
||||
// This is a minimal version, which can be optimized by
|
||||
// using mylux.getRaw() instead of myLux.getLux(); line 38
|
||||
// gain on UNO: ~350 bytes smaller
|
||||
|
||||
|
||||
#include "BH1750FVI.h"
|
||||
@ -44,4 +43,4 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
@ -0,0 +1,28 @@
|
||||
platforms:
|
||||
rpipico:
|
||||
board: rp2040:rp2040:rpipico
|
||||
package: rp2040:rp2040
|
||||
gcc:
|
||||
features:
|
||||
defines:
|
||||
- ARDUINO_ARCH_RP2040
|
||||
warnings:
|
||||
flags:
|
||||
|
||||
packages:
|
||||
rp2040:rp2040:
|
||||
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
|
||||
|
||||
compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
# - uno
|
||||
# - due
|
||||
# - zero
|
||||
# - leonardo
|
||||
# - m4
|
||||
- esp32
|
||||
# - esp8266
|
||||
# - mega2560
|
||||
- rpipico
|
||||
|
@ -0,0 +1,44 @@
|
||||
//
|
||||
// FILE: BH1750FVI_cont_high_res_Wire1.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: demo of BH1750FVI lux scanner library
|
||||
// DATE: 2023-10-18
|
||||
//
|
||||
// This sketch only works on platforms with a Wire1
|
||||
// e.g. ESP32 and RPIpico
|
||||
|
||||
|
||||
#include "BH1750FVI.h"
|
||||
|
||||
BH1750FVI myLux(0x23, &Wire1); // explicit I2C bus.
|
||||
|
||||
uint32_t lastUpdate = 0;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.print(__FILE__);
|
||||
Serial.println();
|
||||
|
||||
Wire.begin();
|
||||
|
||||
myLux.powerOn();
|
||||
myLux.setContHighRes();
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
uint16_t interval = 100;
|
||||
if (millis() - lastUpdate >= interval)
|
||||
{
|
||||
lastUpdate += interval;
|
||||
float val = myLux.getLux();
|
||||
Serial.println(val, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
@ -1,10 +1,8 @@
|
||||
//
|
||||
// FILE: BH1750FVI_cont_low_res.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.1
|
||||
// PURPOSE: demo of BH1750FVI lux scanner library
|
||||
// DATE: 2020-02-02
|
||||
//
|
||||
|
||||
|
||||
#include "BH1750FVI.h"
|
||||
@ -37,9 +35,7 @@ void loop()
|
||||
float val = myLux.getLux();
|
||||
Serial.println(val, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
// -- END OF FILE --
|
||||
|
@ -1,10 +1,8 @@
|
||||
//
|
||||
// FILE: BH1750FVI_setAngle.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: demo of BH1750FVI lux scanner library
|
||||
// DATE: 2020-08-31
|
||||
//
|
||||
|
||||
|
||||
#include "BH1750FVI.h"
|
||||
@ -44,5 +42,4 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
// -- END OF FILE --
|
||||
|
@ -1,10 +1,8 @@
|
||||
//
|
||||
// FILE: setCorrectionFactor.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.1
|
||||
// PURPOSE: demo of BH1750FVI lux scanner library
|
||||
// DATE: 2020-02-02
|
||||
//
|
||||
|
||||
|
||||
#include "BH1750FVI.h"
|
||||
@ -13,7 +11,7 @@ BH1750FVI myLux(0x23);
|
||||
|
||||
uint32_t lastUpdate = 0;
|
||||
|
||||
float correctionFactor = 0.45; // min value see datasheet
|
||||
float correctionFactor = 0.45; // min value see datasheet
|
||||
|
||||
|
||||
void setup()
|
||||
@ -32,7 +30,7 @@ void setup()
|
||||
|
||||
void loop()
|
||||
{
|
||||
uint16_t interval = 180; // max time see datasheet P2
|
||||
uint16_t interval = 180; // max time see datasheet P2
|
||||
if (millis() - lastUpdate >= interval)
|
||||
{
|
||||
lastUpdate += interval;
|
||||
@ -44,10 +42,10 @@ void loop()
|
||||
Serial.print("\t");
|
||||
Serial.println(val / myLux.getCorrectionFactor(), 1);
|
||||
|
||||
// note correctionfactor are steps of 1/69 internally, see datasheet
|
||||
myLux.setCorrectionFactor(correctionFactor); // 0.45 .. 3.68
|
||||
// note correctionfactor are steps of 1/69 internally, see datasheet
|
||||
myLux.setCorrectionFactor(correctionFactor); // 0.45 .. 3.68
|
||||
correctionFactor += 0.05;
|
||||
if (correctionFactor > 3.68)
|
||||
if (correctionFactor > 3.68)
|
||||
{
|
||||
correctionFactor = 0.45;
|
||||
Serial.println();
|
||||
@ -56,5 +54,4 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
// -- END OF FILE --
|
||||
|
@ -1,10 +1,8 @@
|
||||
//
|
||||
// FILE: BH1750FVI_setTemperature.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: demo of BH1750FVI lux scanner library
|
||||
// DATE: 2020-09-04
|
||||
//
|
||||
|
||||
|
||||
#include "BH1750FVI.h"
|
||||
@ -45,5 +43,5 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -1,10 +1,8 @@
|
||||
//
|
||||
// FILE: BH1750FVI_setWaveLength.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: demo of BH1750FVI lux scanner library
|
||||
// DATE: 2020-09-04
|
||||
//
|
||||
|
||||
|
||||
#include "BH1750FVI.h"
|
||||
@ -43,9 +41,7 @@ void setup()
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
// -- END OF FILE --
|
||||
|
@ -1,10 +1,8 @@
|
||||
//
|
||||
// FILE: BH1750FVI_single_shot_3_res.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: demo of BH1750FVI lux scanner library
|
||||
// DATE: 2020-08-20
|
||||
//
|
||||
|
||||
|
||||
#include "BH1750FVI.h"
|
||||
@ -65,5 +63,4 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
// -- END OF FILE --
|
||||
|
@ -40,9 +40,16 @@ getWaveLength KEYWORD2
|
||||
|
||||
# Constants (LITERAL1)
|
||||
BH1750FVI_LIB_VERSION LITERAL1
|
||||
|
||||
BH1750FVI_DEFAULT_ADDRESS LITERAL1
|
||||
BH1750FVI_ALT_ADDRESS LITERAL1
|
||||
|
||||
BH1750FVI_REFERENCE_TIME LITERAL1
|
||||
|
||||
BH1750FVI_MODE_LOW LITERAL1
|
||||
BH1750FVI_MODE_HIGH LITERAL1
|
||||
BH1750FVI_MODE_HIGH2 LITERAL1
|
||||
|
||||
BH1750FVI_OK LITERAL1
|
||||
BH1750FVI_ERROR_WIRE_REQUEST LITERAL1
|
||||
|
||||
|
@ -15,9 +15,9 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/BH1750FVI_RT.git"
|
||||
},
|
||||
"version": "0.2.10",
|
||||
"version": "0.3.0",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"frameworks": "*",
|
||||
"platforms": "*",
|
||||
"headers": "BH1750FVI.h"
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=BH1750FVI_RT
|
||||
version=0.2.10
|
||||
version=0.3.0
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library for BH1750FVI (GY-30) lux sensor
|
||||
|
@ -50,6 +50,9 @@ unittest(test_constructor)
|
||||
{
|
||||
BH1750FVI myLux(0x23);
|
||||
|
||||
Wire.begin();
|
||||
myLux.begin();
|
||||
|
||||
myLux.setContHigh2Res();
|
||||
assertEqual(2, myLux.getMode());
|
||||
myLux.setContHighRes();
|
||||
@ -75,16 +78,6 @@ unittest(test_constants)
|
||||
assertEqual(0x23, BH1750FVI_DEFAULT_ADDRESS);
|
||||
assertEqual(0x5C, BH1750FVI_ALT_ADDRESS);
|
||||
|
||||
assertEqual(0x00, BH1750FVI_POWER_ON);
|
||||
assertEqual(0x01, BH1750FVI_POWER_OFF);
|
||||
assertEqual(0x07, BH1750FVI_RESET);
|
||||
assertEqual(0x10, BH1750FVI_CONT_HIGH);
|
||||
assertEqual(0x11, BH1750FVI_CONT_HIGH2);
|
||||
assertEqual(0x13, BH1750FVI_CONT_LOW);
|
||||
assertEqual(0x20, BH1750FVI_ONCE_HIGH);
|
||||
assertEqual(0x21, BH1750FVI_ONCE_HIGH2);
|
||||
assertEqual(0x23, BH1750FVI_ONCE_LOW);
|
||||
|
||||
assertEqual(0x45, BH1750FVI_REFERENCE_TIME);
|
||||
|
||||
assertEqual(0x00, BH1750FVI_MODE_LOW);
|
||||
@ -100,6 +93,9 @@ unittest(test_read)
|
||||
{
|
||||
BH1750FVI myLux(0x23);
|
||||
|
||||
Wire.begin();
|
||||
myLux.begin();
|
||||
|
||||
assertEqual(0, myLux.getError());
|
||||
assertEqual(0, myLux.getRaw());
|
||||
assertEqual(0, myLux.getLux());
|
||||
@ -110,6 +106,9 @@ unittest(test_parameters)
|
||||
{
|
||||
BH1750FVI myLux(0x23);
|
||||
|
||||
Wire.begin();
|
||||
myLux.begin();
|
||||
|
||||
// 0.45 .. 3.68
|
||||
myLux.setCorrectionFactor(3.14);
|
||||
assertEqualFloat(3.14, myLux.getCorrectionFactor(), 0.01);
|
||||
@ -132,6 +131,9 @@ unittest(test_correctionFactor)
|
||||
{
|
||||
BH1750FVI myLux(0x23);
|
||||
|
||||
Wire.begin();
|
||||
myLux.begin();
|
||||
|
||||
// 0.45 .. 3.68
|
||||
assertEqual( 31, myLux.setCorrectionFactor(0.00) );
|
||||
assertEqual( 31, myLux.setCorrectionFactor(0.44) );
|
||||
@ -146,6 +148,9 @@ unittest(test_angleFactor)
|
||||
{
|
||||
BH1750FVI myLux(0x23);
|
||||
|
||||
Wire.begin();
|
||||
myLux.begin();
|
||||
|
||||
// -89 ..89
|
||||
assertEqualFloat(57.2987, myLux.setAngle(-90), 0.0001);
|
||||
assertEqualFloat(57.2987, myLux.setAngle(-89), 0.0001);
|
||||
@ -165,6 +170,9 @@ unittest(test_temperatureFactor)
|
||||
{
|
||||
BH1750FVI myLux(0x23);
|
||||
|
||||
Wire.begin();
|
||||
myLux.begin();
|
||||
|
||||
// -20 .. 100
|
||||
assertEqualFloat(1.020, myLux.setTemperature(-20), 0.001);
|
||||
assertEqualFloat(1.015, myLux.setTemperature(-10), 0.001);
|
||||
@ -186,6 +194,9 @@ unittest(test_wavelengthFactor)
|
||||
{
|
||||
BH1750FVI myLux(0x23);
|
||||
|
||||
Wire.begin();
|
||||
myLux.begin();
|
||||
|
||||
// 400 - 715
|
||||
assertEqualFloat(100.000, myLux.setWaveLength(300), 0.001);
|
||||
assertEqualFloat(100.000, myLux.setWaveLength(400), 0.001);
|
||||
@ -204,4 +215,5 @@ unittest(test_wavelengthFactor)
|
||||
|
||||
unittest_main()
|
||||
|
||||
// --------
|
||||
|
||||
// -- END OF FILE --
|
||||
|
Loading…
Reference in New Issue
Block a user