forked from adafruit/Adafruit_TSL2561
Set min value to 1.0
This commit is contained in:
@@ -173,7 +173,7 @@ void Adafruit_TSL2561_Unified::getData (uint16_t *broadband, uint16_t *ir)
|
|||||||
Constructor
|
Constructor
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
Adafruit_TSL2561_Unified::Adafruit_TSL2561_Unified(uint8_t addr, int32_t sensorID)
|
Adafruit_TSL2561_Unified::Adafruit_TSL2561_Unified(uint8_t addr, int32_t sensorID)
|
||||||
{
|
{
|
||||||
_addr = addr;
|
_addr = addr;
|
||||||
_tsl2561Initialised = false;
|
_tsl2561Initialised = false;
|
||||||
@@ -193,14 +193,14 @@ Adafruit_TSL2561_Unified::Adafruit_TSL2561_Unified(uint8_t addr, int32_t sensorI
|
|||||||
doing anything else)
|
doing anything else)
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
boolean Adafruit_TSL2561_Unified::begin()
|
boolean Adafruit_TSL2561_Unified::begin()
|
||||||
{
|
{
|
||||||
wire = &Wire;
|
wire = &Wire;
|
||||||
wire -> begin();
|
wire -> begin();
|
||||||
return init();
|
return init();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean Adafruit_TSL2561_Unified::begin(TwoWire *theWire)
|
boolean Adafruit_TSL2561_Unified::begin(TwoWire *theWire)
|
||||||
{
|
{
|
||||||
wire = theWire;
|
wire = theWire;
|
||||||
wire -> begin();
|
wire -> begin();
|
||||||
@@ -226,7 +226,7 @@ boolean Adafruit_TSL2561_Unified::init()
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@brief Enables or disables the auto-gain settings when reading
|
@brief Enables or disables the auto-gain settings when reading
|
||||||
@@ -380,8 +380,8 @@ uint32_t Adafruit_TSL2561_Unified::calculateLux(uint16_t broadband, uint16_t ir)
|
|||||||
{
|
{
|
||||||
unsigned long chScale;
|
unsigned long chScale;
|
||||||
unsigned long channel1;
|
unsigned long channel1;
|
||||||
unsigned long channel0;
|
unsigned long channel0;
|
||||||
|
|
||||||
/* Make sure the sensor isn't saturated! */
|
/* Make sure the sensor isn't saturated! */
|
||||||
uint16_t clipThreshold;
|
uint16_t clipThreshold;
|
||||||
switch (_tsl2561IntegrationTime)
|
switch (_tsl2561IntegrationTime)
|
||||||
@@ -495,10 +495,10 @@ uint32_t Adafruit_TSL2561_Unified::calculateLux(uint16_t broadband, uint16_t ir)
|
|||||||
bool Adafruit_TSL2561_Unified::getEvent(sensors_event_t *event)
|
bool Adafruit_TSL2561_Unified::getEvent(sensors_event_t *event)
|
||||||
{
|
{
|
||||||
uint16_t broadband, ir;
|
uint16_t broadband, ir;
|
||||||
|
|
||||||
/* Clear the event */
|
/* Clear the event */
|
||||||
memset(event, 0, sizeof(sensors_event_t));
|
memset(event, 0, sizeof(sensors_event_t));
|
||||||
|
|
||||||
event->version = sizeof(sensors_event_t);
|
event->version = sizeof(sensors_event_t);
|
||||||
event->sensor_id = _tsl2561SensorID;
|
event->sensor_id = _tsl2561SensorID;
|
||||||
event->type = SENSOR_TYPE_LIGHT;
|
event->type = SENSOR_TYPE_LIGHT;
|
||||||
@@ -507,9 +507,9 @@ bool Adafruit_TSL2561_Unified::getEvent(sensors_event_t *event)
|
|||||||
/* Calculate the actual lux value */
|
/* Calculate the actual lux value */
|
||||||
getLuminosity(&broadband, &ir);
|
getLuminosity(&broadband, &ir);
|
||||||
event->light = calculateLux(broadband, ir);
|
event->light = calculateLux(broadband, ir);
|
||||||
|
|
||||||
if (event->light == 65536) {
|
if (event->light == 65536) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -532,6 +532,6 @@ void Adafruit_TSL2561_Unified::getSensor(sensor_t *sensor)
|
|||||||
sensor->type = SENSOR_TYPE_LIGHT;
|
sensor->type = SENSOR_TYPE_LIGHT;
|
||||||
sensor->min_delay = 0;
|
sensor->min_delay = 0;
|
||||||
sensor->max_value = 17000.0; /* Based on trial and error ... confirm! */
|
sensor->max_value = 17000.0; /* Based on trial and error ... confirm! */
|
||||||
sensor->min_value = 0.0;
|
sensor->min_value = 1.0;
|
||||||
sensor->resolution = 1.0;
|
sensor->resolution = 1.0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user