mirror of
https://github.com/adafruit/Adafruit_TSL2561.git
synced 2026-08-03 20:24:05 +02:00
Merge pull request #30 from ladyada-piclaw/fix-clang-format-ci
Fix clang-format CI
This commit is contained in:
@@ -0,0 +1,13 @@
|
|||||||
|
Language: Cpp
|
||||||
|
BasedOnStyle: Google
|
||||||
|
IndentWidth: 2
|
||||||
|
ColumnLimit: 80
|
||||||
|
AllowShortFunctionsOnASingleLine: Empty
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
BinPackArguments: true
|
||||||
|
BinPackParameters: true
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
PointerAlignment: Left
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
@@ -3,7 +3,27 @@ name: Arduino Library CI
|
|||||||
on: [pull_request, push, repository_dispatch]
|
on: [pull_request, push, repository_dispatch]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
clang-format:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: '3.x'
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
repository: adafruit/ci-arduino
|
||||||
|
path: ci
|
||||||
|
|
||||||
|
- name: pre-install
|
||||||
|
run: bash ci/actions_install.sh
|
||||||
|
|
||||||
|
- name: clang
|
||||||
|
run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r .
|
||||||
|
|
||||||
build:
|
build:
|
||||||
|
needs: clang-format
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
+45
-45
@@ -88,7 +88,7 @@ boolean Adafruit_TSL2561_Unified::begin() {
|
|||||||
@returns True if sensor is found and initialized, false otherwise.
|
@returns True if sensor is found and initialized, false otherwise.
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
boolean Adafruit_TSL2561_Unified::begin(TwoWire *theWire) {
|
boolean Adafruit_TSL2561_Unified::begin(TwoWire* theWire) {
|
||||||
_i2c = theWire;
|
_i2c = theWire;
|
||||||
_i2c->begin();
|
_i2c->begin();
|
||||||
return init();
|
return init();
|
||||||
@@ -191,8 +191,8 @@ void Adafruit_TSL2561_Unified::setGain(tsl2561Gain_t gain) {
|
|||||||
IR-only light diode.
|
IR-only light diode.
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
void Adafruit_TSL2561_Unified::getLuminosity(uint16_t *broadband,
|
void Adafruit_TSL2561_Unified::getLuminosity(uint16_t* broadband,
|
||||||
uint16_t *ir) {
|
uint16_t* ir) {
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
|
|
||||||
if (!_tsl2561Initialised)
|
if (!_tsl2561Initialised)
|
||||||
@@ -213,18 +213,18 @@ void Adafruit_TSL2561_Unified::getLuminosity(uint16_t *broadband,
|
|||||||
|
|
||||||
/* Get the hi/low threshold for the current integration time */
|
/* Get the hi/low threshold for the current integration time */
|
||||||
switch (_it) {
|
switch (_it) {
|
||||||
case TSL2561_INTEGRATIONTIME_13MS:
|
case TSL2561_INTEGRATIONTIME_13MS:
|
||||||
_hi = TSL2561_AGC_THI_13MS;
|
_hi = TSL2561_AGC_THI_13MS;
|
||||||
_lo = TSL2561_AGC_TLO_13MS;
|
_lo = TSL2561_AGC_TLO_13MS;
|
||||||
break;
|
break;
|
||||||
case TSL2561_INTEGRATIONTIME_101MS:
|
case TSL2561_INTEGRATIONTIME_101MS:
|
||||||
_hi = TSL2561_AGC_THI_101MS;
|
_hi = TSL2561_AGC_THI_101MS;
|
||||||
_lo = TSL2561_AGC_TLO_101MS;
|
_lo = TSL2561_AGC_TLO_101MS;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
_hi = TSL2561_AGC_THI_402MS;
|
_hi = TSL2561_AGC_THI_402MS;
|
||||||
_lo = TSL2561_AGC_TLO_402MS;
|
_lo = TSL2561_AGC_TLO_402MS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
getData(&_b, &_ir);
|
getData(&_b, &_ir);
|
||||||
@@ -290,21 +290,21 @@ void Adafruit_TSL2561_Unified::disable(void) {
|
|||||||
Private function to read luminosity on both channels
|
Private function to read luminosity on both channels
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
void Adafruit_TSL2561_Unified::getData(uint16_t *broadband, uint16_t *ir) {
|
void Adafruit_TSL2561_Unified::getData(uint16_t* broadband, uint16_t* ir) {
|
||||||
/* Enable the device by setting the control bit to 0x03 */
|
/* Enable the device by setting the control bit to 0x03 */
|
||||||
enable();
|
enable();
|
||||||
|
|
||||||
/* Wait x ms for ADC to complete */
|
/* Wait x ms for ADC to complete */
|
||||||
switch (_tsl2561IntegrationTime) {
|
switch (_tsl2561IntegrationTime) {
|
||||||
case TSL2561_INTEGRATIONTIME_13MS:
|
case TSL2561_INTEGRATIONTIME_13MS:
|
||||||
delay(TSL2561_DELAY_INTTIME_13MS); // KTOWN: Was 14ms
|
delay(TSL2561_DELAY_INTTIME_13MS); // KTOWN: Was 14ms
|
||||||
break;
|
break;
|
||||||
case TSL2561_INTEGRATIONTIME_101MS:
|
case TSL2561_INTEGRATIONTIME_101MS:
|
||||||
delay(TSL2561_DELAY_INTTIME_101MS); // KTOWN: Was 102ms
|
delay(TSL2561_DELAY_INTTIME_101MS); // KTOWN: Was 102ms
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
delay(TSL2561_DELAY_INTTIME_402MS); // KTOWN: Was 403ms
|
delay(TSL2561_DELAY_INTTIME_402MS); // KTOWN: Was 403ms
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reads a two byte value from channel 0 (visible + infrared) */
|
/* Reads a two byte value from channel 0 (visible + infrared) */
|
||||||
@@ -344,15 +344,15 @@ uint32_t Adafruit_TSL2561_Unified::calculateLux(uint16_t broadband,
|
|||||||
/* Make sure the sensor isn't saturated! */
|
/* Make sure the sensor isn't saturated! */
|
||||||
uint16_t clipThreshold;
|
uint16_t clipThreshold;
|
||||||
switch (_tsl2561IntegrationTime) {
|
switch (_tsl2561IntegrationTime) {
|
||||||
case TSL2561_INTEGRATIONTIME_13MS:
|
case TSL2561_INTEGRATIONTIME_13MS:
|
||||||
clipThreshold = TSL2561_CLIPPING_13MS;
|
clipThreshold = TSL2561_CLIPPING_13MS;
|
||||||
break;
|
break;
|
||||||
case TSL2561_INTEGRATIONTIME_101MS:
|
case TSL2561_INTEGRATIONTIME_101MS:
|
||||||
clipThreshold = TSL2561_CLIPPING_101MS;
|
clipThreshold = TSL2561_CLIPPING_101MS;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
clipThreshold = TSL2561_CLIPPING_402MS;
|
clipThreshold = TSL2561_CLIPPING_402MS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return 65536 lux if the sensor is saturated */
|
/* Return 65536 lux if the sensor is saturated */
|
||||||
@@ -362,15 +362,15 @@ uint32_t Adafruit_TSL2561_Unified::calculateLux(uint16_t broadband,
|
|||||||
|
|
||||||
/* Get the correct scale depending on the intergration time */
|
/* Get the correct scale depending on the intergration time */
|
||||||
switch (_tsl2561IntegrationTime) {
|
switch (_tsl2561IntegrationTime) {
|
||||||
case TSL2561_INTEGRATIONTIME_13MS:
|
case TSL2561_INTEGRATIONTIME_13MS:
|
||||||
chScale = TSL2561_LUX_CHSCALE_TINT0;
|
chScale = TSL2561_LUX_CHSCALE_TINT0;
|
||||||
break;
|
break;
|
||||||
case TSL2561_INTEGRATIONTIME_101MS:
|
case TSL2561_INTEGRATIONTIME_101MS:
|
||||||
chScale = TSL2561_LUX_CHSCALE_TINT1;
|
chScale = TSL2561_LUX_CHSCALE_TINT1;
|
||||||
break;
|
break;
|
||||||
default: /* No scaling ... integration time = 402ms */
|
default: /* No scaling ... integration time = 402ms */
|
||||||
chScale = (1 << TSL2561_LUX_CHSCALE);
|
chScale = (1 << TSL2561_LUX_CHSCALE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Scale for gain (1x or 16x) */
|
/* Scale for gain (1x or 16x) */
|
||||||
@@ -473,7 +473,7 @@ uint32_t Adafruit_TSL2561_Unified::calculateLux(uint16_t broadband,
|
|||||||
false if sensor is saturated
|
false if sensor is saturated
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
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 */
|
||||||
@@ -501,7 +501,7 @@ bool Adafruit_TSL2561_Unified::getEvent(sensors_event_t *event) {
|
|||||||
details about the TSL2561 and its capabilities
|
details about the TSL2561 and its capabilities
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
void Adafruit_TSL2561_Unified::getSensor(sensor_t *sensor) {
|
void Adafruit_TSL2561_Unified::getSensor(sensor_t* sensor) {
|
||||||
/* Clear the sensor_t object */
|
/* Clear the sensor_t object */
|
||||||
memset(sensor, 0, sizeof(sensor_t));
|
memset(sensor, 0, sizeof(sensor_t));
|
||||||
|
|
||||||
|
|||||||
+14
-14
@@ -35,17 +35,17 @@
|
|||||||
#define TSL2561_ADDR_HIGH (0x49) ///< Default address (pin pulled high)
|
#define TSL2561_ADDR_HIGH (0x49) ///< Default address (pin pulled high)
|
||||||
|
|
||||||
// Lux calculations differ slightly for CS package
|
// Lux calculations differ slightly for CS package
|
||||||
//#define TSL2561_PACKAGE_CS ///< Chip scale package
|
// #define TSL2561_PACKAGE_CS ///< Chip scale package
|
||||||
#define TSL2561_PACKAGE_T_FN_CL ///< Dual Flat No-Lead package
|
#define TSL2561_PACKAGE_T_FN_CL ///< Dual Flat No-Lead package
|
||||||
|
|
||||||
#define TSL2561_COMMAND_BIT (0x80) ///< Must be 1
|
#define TSL2561_COMMAND_BIT (0x80) ///< Must be 1
|
||||||
#define TSL2561_CLEAR_BIT \
|
#define TSL2561_CLEAR_BIT \
|
||||||
(0x40) ///< Clears any pending interrupt (write 1 to clear)
|
(0x40) ///< Clears any pending interrupt (write 1 to clear)
|
||||||
#define TSL2561_WORD_BIT (0x20) ///< 1 = read/write word (rather than byte)
|
#define TSL2561_WORD_BIT (0x20) ///< 1 = read/write word (rather than byte)
|
||||||
#define TSL2561_BLOCK_BIT (0x10) ///< 1 = using block read/write
|
#define TSL2561_BLOCK_BIT (0x10) ///< 1 = using block read/write
|
||||||
|
|
||||||
#define TSL2561_CONTROL_POWERON (0x03) ///< Control register setting to turn on
|
#define TSL2561_CONTROL_POWERON (0x03) ///< Control register setting to turn on
|
||||||
#define TSL2561_CONTROL_POWEROFF \
|
#define TSL2561_CONTROL_POWEROFF \
|
||||||
(0x00) ///< Control register setting to turn off
|
(0x00) ///< Control register setting to turn off
|
||||||
|
|
||||||
#define TSL2561_LUX_LUXSCALE (14) ///< Scale by 2^14
|
#define TSL2561_LUX_LUXSCALE (14) ///< Scale by 2^14
|
||||||
@@ -115,11 +115,11 @@
|
|||||||
#define TSL2561_AGC_TLO_402MS (500) ///< Min value at Ti 402ms = 500
|
#define TSL2561_AGC_TLO_402MS (500) ///< Min value at Ti 402ms = 500
|
||||||
|
|
||||||
// Clipping thresholds
|
// Clipping thresholds
|
||||||
#define TSL2561_CLIPPING_13MS \
|
#define TSL2561_CLIPPING_13MS \
|
||||||
(4900) ///< # Counts that trigger a change in gain/integration
|
(4900) ///< # Counts that trigger a change in gain/integration
|
||||||
#define TSL2561_CLIPPING_101MS \
|
#define TSL2561_CLIPPING_101MS \
|
||||||
(37000) ///< # Counts that trigger a change in gain/integration
|
(37000) ///< # Counts that trigger a change in gain/integration
|
||||||
#define TSL2561_CLIPPING_402MS \
|
#define TSL2561_CLIPPING_402MS \
|
||||||
(65000) ///< # Counts that trigger a change in gain/integration
|
(65000) ///< # Counts that trigger a change in gain/integration
|
||||||
|
|
||||||
// Delay for integration times
|
// Delay for integration times
|
||||||
@@ -165,25 +165,25 @@ typedef enum {
|
|||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
class Adafruit_TSL2561_Unified : public Adafruit_Sensor {
|
class Adafruit_TSL2561_Unified : public Adafruit_Sensor {
|
||||||
public:
|
public:
|
||||||
Adafruit_TSL2561_Unified(uint8_t addr, int32_t sensorID = -1);
|
Adafruit_TSL2561_Unified(uint8_t addr, int32_t sensorID = -1);
|
||||||
boolean begin(void);
|
boolean begin(void);
|
||||||
boolean begin(TwoWire *theWire);
|
boolean begin(TwoWire* theWire);
|
||||||
boolean init();
|
boolean init();
|
||||||
|
|
||||||
/* TSL2561 Functions */
|
/* TSL2561 Functions */
|
||||||
void enableAutoRange(bool enable);
|
void enableAutoRange(bool enable);
|
||||||
void setIntegrationTime(tsl2561IntegrationTime_t time);
|
void setIntegrationTime(tsl2561IntegrationTime_t time);
|
||||||
void setGain(tsl2561Gain_t gain);
|
void setGain(tsl2561Gain_t gain);
|
||||||
void getLuminosity(uint16_t *broadband, uint16_t *ir);
|
void getLuminosity(uint16_t* broadband, uint16_t* ir);
|
||||||
uint32_t calculateLux(uint16_t broadband, uint16_t ir);
|
uint32_t calculateLux(uint16_t broadband, uint16_t ir);
|
||||||
|
|
||||||
/* Unified Sensor API Functions */
|
/* Unified Sensor API Functions */
|
||||||
bool getEvent(sensors_event_t *);
|
bool getEvent(sensors_event_t*);
|
||||||
void getSensor(sensor_t *);
|
void getSensor(sensor_t*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TwoWire *_i2c;
|
TwoWire* _i2c;
|
||||||
|
|
||||||
int8_t _addr;
|
int8_t _addr;
|
||||||
boolean _tsl2561Initialised;
|
boolean _tsl2561Initialised;
|
||||||
@@ -197,7 +197,7 @@ private:
|
|||||||
void write8(uint8_t reg, uint8_t value);
|
void write8(uint8_t reg, uint8_t value);
|
||||||
uint8_t read8(uint8_t reg);
|
uint8_t read8(uint8_t reg);
|
||||||
uint16_t read16(uint8_t reg);
|
uint16_t read16(uint8_t reg);
|
||||||
void getData(uint16_t *broadband, uint16_t *ir);
|
void getData(uint16_t* broadband, uint16_t* ir);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ADAFRUIT_TSL2561_H
|
#endif // ADAFRUIT_TSL2561_H
|
||||||
|
|||||||
Reference in New Issue
Block a user