actionified, formatted and doxy'd
This commit is contained in:
parent
5391bd9977
commit
5e10ee8980
9 changed files with 369 additions and 154 deletions
32
.github/workflows/githubci.yml
vendored
Normal file
32
.github/workflows/githubci.yml
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
name: Arduino Library CI
|
||||
|
||||
on: [pull_request, push, repository_dispatch]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
repository: adafruit/ci-arduino
|
||||
path: ci
|
||||
|
||||
- name: pre-install
|
||||
run: bash ci/actions_install.sh
|
||||
|
||||
- name: test platforms
|
||||
run: python3 ci/build_platform.py main_platforms
|
||||
|
||||
- name: clang
|
||||
run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r .
|
||||
|
||||
- name: doxygen
|
||||
env:
|
||||
GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }}
|
||||
PRETTYNAME : "Adafruit SI1145 Arduino Library"
|
||||
run: bash ci/doxy_gen_and_deploy.sh
|
||||
|
|
@ -1,43 +1,54 @@
|
|||
/***************************************************
|
||||
/***************************************************
|
||||
This is a library for the Si1145 UV/IR/Visible Light Sensor
|
||||
|
||||
Designed specifically to work with the Si1145 sensor in the
|
||||
adafruit shop
|
||||
----> https://www.adafruit.com/products/1777
|
||||
|
||||
These sensors use I2C to communicate, 2 pins are required to
|
||||
These sensors use I2C to communicate, 2 pins are required to
|
||||
interface
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, all text above must be included in any redistribution
|
||||
****************************************************/
|
||||
|
||||
#include "Adafruit_SI1145.h"
|
||||
|
||||
Adafruit_SI1145::Adafruit_SI1145()
|
||||
: m_pBus(&Wire)
|
||||
, _addr(SI1145_ADDR)
|
||||
{
|
||||
/**
|
||||
* @brief Construct a new Adafruit_SI1145::Adafruit_SI1145 object
|
||||
*
|
||||
*/
|
||||
Adafruit_SI1145::Adafruit_SI1145() : m_pBus(&Wire), _addr(SI1145_ADDR) {}
|
||||
/**
|
||||
* @brief Initize the driver, specifying the `TwoWire` bus to use
|
||||
*
|
||||
* @param pBus Pointer to the `TwoWire` I2C bus to use
|
||||
* @return boolean true: success false: failure to initialize the sensor
|
||||
*/
|
||||
boolean Adafruit_SI1145::begin(TwoWire *pBus) {
|
||||
return begin(SI1145_ADDR, pBus);
|
||||
}
|
||||
boolean Adafruit_SI1145::begin(TwoWire* pBus){
|
||||
return begin(SI1145_ADDR,pBus);
|
||||
}
|
||||
|
||||
boolean Adafruit_SI1145::begin(uint8_t addr,TwoWire* pBus) {
|
||||
/**
|
||||
* @brief Initize the driver, supplying both a `TwoWire` bus and I2C address
|
||||
*
|
||||
* @param addr The I2C address of the Sensor
|
||||
* @param pBus Pointer to the `TwoWire` instance to use
|
||||
* @return boolean true: success false: failure to initize the sensor
|
||||
*/
|
||||
boolean Adafruit_SI1145::begin(uint8_t addr, TwoWire *pBus) {
|
||||
|
||||
_addr = addr;
|
||||
m_pBus = pBus;
|
||||
m_pBus->begin();
|
||||
uint8_t id = read8(SI1145_REG_PARTID);
|
||||
if (id != 0x45) return false; // look for SI1145
|
||||
|
||||
reset();
|
||||
|
||||
if (id != 0x45)
|
||||
return false; // look for SI1145
|
||||
|
||||
/***********************************/
|
||||
reset();
|
||||
|
||||
/***********************************/
|
||||
// enable UVindex measurement coefficients!
|
||||
write8(SI1145_REG_UCOEFF0, 0x29);
|
||||
write8(SI1145_REG_UCOEFF1, 0x89);
|
||||
|
|
@ -45,14 +56,14 @@ boolean Adafruit_SI1145::begin(uint8_t addr,TwoWire* pBus) {
|
|||
write8(SI1145_REG_UCOEFF3, 0x00);
|
||||
|
||||
// enable UV sensor
|
||||
writeParam(SI1145_PARAM_CHLIST, SI1145_PARAM_CHLIST_ENUV |
|
||||
SI1145_PARAM_CHLIST_ENALSIR | SI1145_PARAM_CHLIST_ENALSVIS |
|
||||
SI1145_PARAM_CHLIST_ENPS1);
|
||||
writeParam(SI1145_PARAM_CHLIST,
|
||||
SI1145_PARAM_CHLIST_ENUV | SI1145_PARAM_CHLIST_ENALSIR |
|
||||
SI1145_PARAM_CHLIST_ENALSVIS | SI1145_PARAM_CHLIST_ENPS1);
|
||||
// enable interrupt on every sample
|
||||
write8(SI1145_REG_INTCFG, SI1145_REG_INTCFG_INTOE);
|
||||
write8(SI1145_REG_IRQEN, SI1145_REG_IRQEN_ALSEVERYSAMPLE);
|
||||
write8(SI1145_REG_INTCFG, SI1145_REG_INTCFG_INTOE);
|
||||
write8(SI1145_REG_IRQEN, SI1145_REG_IRQEN_ALSEVERYSAMPLE);
|
||||
|
||||
/****************************** Prox Sense 1 */
|
||||
/****************************** Prox Sense 1 */
|
||||
|
||||
// program LED current
|
||||
write8(SI1145_REG_PSLED21, 0x03); // 20mA for LED 1 only
|
||||
|
|
@ -64,10 +75,10 @@ boolean Adafruit_SI1145::begin(uint8_t addr,TwoWire* pBus) {
|
|||
// take 511 clocks to measure
|
||||
writeParam(SI1145_PARAM_PSADCOUNTER, SI1145_PARAM_ADCCOUNTER_511CLK);
|
||||
// in prox mode, high range
|
||||
writeParam(SI1145_PARAM_PSADCMISC, SI1145_PARAM_PSADCMISC_RANGE|
|
||||
SI1145_PARAM_PSADCMISC_PSMODE);
|
||||
writeParam(SI1145_PARAM_PSADCMISC,
|
||||
SI1145_PARAM_PSADCMISC_RANGE | SI1145_PARAM_PSADCMISC_PSMODE);
|
||||
|
||||
writeParam(SI1145_PARAM_ALSIRADCMUX, SI1145_PARAM_ADCMUX_SMALLIR);
|
||||
writeParam(SI1145_PARAM_ALSIRADCMUX, SI1145_PARAM_ADCMUX_SMALLIR);
|
||||
// fastest clocks, clock div 1
|
||||
writeParam(SI1145_PARAM_ALSIRADCGAIN, 0);
|
||||
// take 511 clocks to measure
|
||||
|
|
@ -75,8 +86,6 @@ boolean Adafruit_SI1145::begin(uint8_t addr,TwoWire* pBus) {
|
|||
// in high range mode
|
||||
writeParam(SI1145_PARAM_ALSIRADCMISC, SI1145_PARAM_ALSIRADCMISC_RANGE);
|
||||
|
||||
|
||||
|
||||
// fastest clocks, clock div 1
|
||||
writeParam(SI1145_PARAM_ALSVISADCGAIN, 0);
|
||||
// take 511 clocks to measure
|
||||
|
|
@ -84,18 +93,20 @@ boolean Adafruit_SI1145::begin(uint8_t addr,TwoWire* pBus) {
|
|||
// in high range mode (not normal signal)
|
||||
writeParam(SI1145_PARAM_ALSVISADCMISC, SI1145_PARAM_ALSVISADCMISC_VISRANGE);
|
||||
|
||||
|
||||
/************************/
|
||||
/************************/
|
||||
|
||||
// measurement rate for auto
|
||||
write8(SI1145_REG_MEASRATE0, 0xFF); // 255 * 31.25uS = 8ms
|
||||
|
||||
|
||||
// auto run
|
||||
write8(SI1145_REG_COMMAND, SI1145_PSALS_AUTO);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reset the sensor's registers to an initial state
|
||||
*
|
||||
*/
|
||||
void Adafruit_SI1145::reset() {
|
||||
write8(SI1145_REG_MEASRATE0, 0);
|
||||
write8(SI1145_REG_MEASRATE1, 0);
|
||||
|
|
@ -108,39 +119,48 @@ void Adafruit_SI1145::reset() {
|
|||
write8(SI1145_REG_COMMAND, SI1145_RESET);
|
||||
delay(10);
|
||||
write8(SI1145_REG_HWKEY, 0x17);
|
||||
|
||||
|
||||
delay(10);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
// returns the UV index * 100 (divide by 100 to get the index)
|
||||
uint16_t Adafruit_SI1145::readUV(void) {
|
||||
return read16(0x2C);
|
||||
}
|
||||
/**
|
||||
* @brief Get the current UV reading
|
||||
*
|
||||
* @return uint16_t The the UV index * 100 (divide by 100 to get the index)
|
||||
*/
|
||||
uint16_t Adafruit_SI1145::readUV(void) { return read16(0x2C); }
|
||||
|
||||
// returns visible+IR light levels
|
||||
uint16_t Adafruit_SI1145::readVisible(void) {
|
||||
return read16(0x22);
|
||||
}
|
||||
/**
|
||||
* @brief Get the Visible & IR light levels
|
||||
*
|
||||
* @return uint16_t The Visible & IR light levels
|
||||
*/
|
||||
uint16_t Adafruit_SI1145::readVisible(void) { return read16(0x22); }
|
||||
|
||||
// returns IR light levels
|
||||
uint16_t Adafruit_SI1145::readIR(void) {
|
||||
return read16(0x24);
|
||||
}
|
||||
/**
|
||||
* @brief Get the Infrared light level
|
||||
*
|
||||
* @return uint16_t The Infrared light level
|
||||
*/
|
||||
uint16_t Adafruit_SI1145::readIR(void) { return read16(0x24); }
|
||||
|
||||
// returns "Proximity" - assumes an IR LED is attached to LED
|
||||
uint16_t Adafruit_SI1145::readProx(void) {
|
||||
return read16(0x26);
|
||||
}
|
||||
/**
|
||||
* @brief Gets the Proximity measurement - **Requires an attached IR LED**
|
||||
*
|
||||
* @return uint16_t The proximity measurement
|
||||
*/
|
||||
uint16_t Adafruit_SI1145::readProx(void) { return read16(0x26); }
|
||||
|
||||
/*********************************************************************/
|
||||
|
||||
uint8_t Adafruit_SI1145::writeParam(uint8_t p, uint8_t v) {
|
||||
//Serial.print("Param 0x"); Serial.print(p, HEX);
|
||||
//Serial.print(" = 0x"); Serial.println(v, HEX);
|
||||
|
||||
// Serial.print("Param 0x"); Serial.print(p, HEX);
|
||||
// Serial.print(" = 0x"); Serial.println(v, HEX);
|
||||
|
||||
write8(SI1145_REG_PARAMWR, v);
|
||||
write8(SI1145_REG_COMMAND, p | SI1145_PARAM_SET);
|
||||
return read8(SI1145_REG_PARAMRD);
|
||||
|
|
@ -153,33 +173,33 @@ uint8_t Adafruit_SI1145::readParam(uint8_t p) {
|
|||
|
||||
/*********************************************************************/
|
||||
|
||||
uint8_t Adafruit_SI1145::read8(uint8_t reg) {
|
||||
m_pBus->beginTransmission(_addr);
|
||||
m_pBus->write((uint8_t)reg);
|
||||
m_pBus->endTransmission();
|
||||
uint8_t Adafruit_SI1145::read8(uint8_t reg) {
|
||||
m_pBus->beginTransmission(_addr);
|
||||
m_pBus->write((uint8_t)reg);
|
||||
m_pBus->endTransmission();
|
||||
|
||||
m_pBus->requestFrom((uint8_t)_addr, (uint8_t)1);
|
||||
return m_pBus->read();
|
||||
m_pBus->requestFrom((uint8_t)_addr, (uint8_t)1);
|
||||
return m_pBus->read();
|
||||
}
|
||||
|
||||
uint16_t Adafruit_SI1145::read16(uint8_t a) {
|
||||
uint16_t ret;
|
||||
|
||||
m_pBus->beginTransmission(_addr); // start transmission to device
|
||||
m_pBus->write(a); // sends register address to read from
|
||||
m_pBus->endTransmission(); // end transmission
|
||||
|
||||
m_pBus->requestFrom(_addr, (uint8_t)2);// send data n-bytes read
|
||||
ret = m_pBus->read(); // receive DATA
|
||||
ret |= (uint16_t)m_pBus->read() << 8; // receive DATA
|
||||
m_pBus->beginTransmission(_addr); // start transmission to device
|
||||
m_pBus->write(a); // sends register address to read from
|
||||
m_pBus->endTransmission(); // end transmission
|
||||
|
||||
m_pBus->requestFrom(_addr, (uint8_t)2); // send data n-bytes read
|
||||
ret = m_pBus->read(); // receive DATA
|
||||
ret |= (uint16_t)m_pBus->read() << 8; // receive DATA
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Adafruit_SI1145::write8(uint8_t reg, uint8_t val) {
|
||||
|
||||
m_pBus->beginTransmission(_addr); // start transmission to device
|
||||
m_pBus->write(reg); // sends register address to write
|
||||
m_pBus->write(val); // sends value
|
||||
m_pBus->endTransmission(); // end transmission
|
||||
m_pBus->beginTransmission(_addr); // start transmission to device
|
||||
m_pBus->write(reg); // sends register address to write
|
||||
m_pBus->write(val); // sends value
|
||||
m_pBus->endTransmission(); // end transmission
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +1,26 @@
|
|||
/***************************************************
|
||||
/***************************************************
|
||||
This is a library for the Si1145 UV/IR/Visible Light Sensor
|
||||
|
||||
Designed specifically to work with the Si1145 sensor in the
|
||||
adafruit shop
|
||||
----> https://www.adafruit.com/products/1777
|
||||
|
||||
These sensors use I2C to communicate, 2 pins are required to
|
||||
These sensors use I2C to communicate, 2 pins are required to
|
||||
interface
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, all text above must be included in any redistribution
|
||||
****************************************************/
|
||||
#ifndef _SI1145_H_
|
||||
#define _SI1145_H_
|
||||
|
||||
|
||||
#if (ARDUINO >= 100)
|
||||
#include "Arduino.h"
|
||||
#include "Arduino.h"
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
#include <Wire.h>
|
||||
|
||||
|
|
@ -29,22 +28,22 @@
|
|||
#define SI1145_PARAM_QUERY 0x80
|
||||
#define SI1145_PARAM_SET 0xA0
|
||||
#define SI1145_NOP 0x0
|
||||
#define SI1145_RESET 0x01
|
||||
#define SI1145_BUSADDR 0x02
|
||||
#define SI1145_PS_FORCE 0x05
|
||||
#define SI1145_ALS_FORCE 0x06
|
||||
#define SI1145_PSALS_FORCE 0x07
|
||||
#define SI1145_PS_PAUSE 0x09
|
||||
#define SI1145_ALS_PAUSE 0x0A
|
||||
#define SI1145_PSALS_PAUSE 0xB
|
||||
#define SI1145_PS_AUTO 0x0D
|
||||
#define SI1145_ALS_AUTO 0x0E
|
||||
#define SI1145_RESET 0x01
|
||||
#define SI1145_BUSADDR 0x02
|
||||
#define SI1145_PS_FORCE 0x05
|
||||
#define SI1145_ALS_FORCE 0x06
|
||||
#define SI1145_PSALS_FORCE 0x07
|
||||
#define SI1145_PS_PAUSE 0x09
|
||||
#define SI1145_ALS_PAUSE 0x0A
|
||||
#define SI1145_PSALS_PAUSE 0xB
|
||||
#define SI1145_PS_AUTO 0x0D
|
||||
#define SI1145_ALS_AUTO 0x0E
|
||||
#define SI1145_PSALS_AUTO 0x0F
|
||||
#define SI1145_GET_CAL 0x12
|
||||
#define SI1145_GET_CAL 0x12
|
||||
|
||||
/* Parameters */
|
||||
#define SI1145_PARAM_I2CADDR 0x00
|
||||
#define SI1145_PARAM_CHLIST 0x01
|
||||
#define SI1145_PARAM_CHLIST 0x01
|
||||
#define SI1145_PARAM_CHLIST_ENUV 0x80
|
||||
#define SI1145_PARAM_CHLIST_ENAUX 0x40
|
||||
#define SI1145_PARAM_CHLIST_ENALSIR 0x20
|
||||
|
|
@ -53,7 +52,7 @@
|
|||
#define SI1145_PARAM_CHLIST_ENPS2 0x02
|
||||
#define SI1145_PARAM_CHLIST_ENPS3 0x04
|
||||
|
||||
#define SI1145_PARAM_PSLED12SEL 0x02
|
||||
#define SI1145_PARAM_PSLED12SEL 0x02
|
||||
#define SI1145_PARAM_PSLED12SEL_PS2NONE 0x00
|
||||
#define SI1145_PARAM_PSLED12SEL_PS2LED1 0x10
|
||||
#define SI1145_PARAM_PSLED12SEL_PS2LED2 0x20
|
||||
|
|
@ -63,73 +62,70 @@
|
|||
#define SI1145_PARAM_PSLED12SEL_PS1LED2 0x02
|
||||
#define SI1145_PARAM_PSLED12SEL_PS1LED3 0x04
|
||||
|
||||
#define SI1145_PARAM_PSLED3SEL 0x03
|
||||
#define SI1145_PARAM_PSENCODE 0x05
|
||||
#define SI1145_PARAM_ALSENCODE 0x06
|
||||
#define SI1145_PARAM_PSLED3SEL 0x03
|
||||
#define SI1145_PARAM_PSENCODE 0x05
|
||||
#define SI1145_PARAM_ALSENCODE 0x06
|
||||
|
||||
#define SI1145_PARAM_PS1ADCMUX 0x07
|
||||
#define SI1145_PARAM_PS2ADCMUX 0x08
|
||||
#define SI1145_PARAM_PS3ADCMUX 0x09
|
||||
#define SI1145_PARAM_PSADCOUNTER 0x0A
|
||||
#define SI1145_PARAM_PS1ADCMUX 0x07
|
||||
#define SI1145_PARAM_PS2ADCMUX 0x08
|
||||
#define SI1145_PARAM_PS3ADCMUX 0x09
|
||||
#define SI1145_PARAM_PSADCOUNTER 0x0A
|
||||
#define SI1145_PARAM_PSADCGAIN 0x0B
|
||||
#define SI1145_PARAM_PSADCMISC 0x0C
|
||||
#define SI1145_PARAM_PSADCMISC_RANGE 0x20
|
||||
#define SI1145_PARAM_PSADCMISC_PSMODE 0x04
|
||||
|
||||
#define SI1145_PARAM_ALSIRADCMUX 0x0E
|
||||
#define SI1145_PARAM_AUXADCMUX 0x0F
|
||||
#define SI1145_PARAM_ALSIRADCMUX 0x0E
|
||||
#define SI1145_PARAM_AUXADCMUX 0x0F
|
||||
|
||||
#define SI1145_PARAM_ALSVISADCOUNTER 0x10
|
||||
#define SI1145_PARAM_ALSVISADCOUNTER 0x10
|
||||
#define SI1145_PARAM_ALSVISADCGAIN 0x11
|
||||
#define SI1145_PARAM_ALSVISADCMISC 0x12
|
||||
#define SI1145_PARAM_ALSVISADCMISC_VISRANGE 0x20
|
||||
|
||||
#define SI1145_PARAM_ALSIRADCOUNTER 0x1D
|
||||
#define SI1145_PARAM_ALSIRADCOUNTER 0x1D
|
||||
#define SI1145_PARAM_ALSIRADCGAIN 0x1E
|
||||
#define SI1145_PARAM_ALSIRADCMISC 0x1F
|
||||
#define SI1145_PARAM_ALSIRADCMISC_RANGE 0x20
|
||||
|
||||
#define SI1145_PARAM_ADCCOUNTER_511CLK 0x70
|
||||
|
||||
#define SI1145_PARAM_ADCMUX_SMALLIR 0x00
|
||||
#define SI1145_PARAM_ADCMUX_LARGEIR 0x03
|
||||
|
||||
|
||||
#define SI1145_PARAM_ADCMUX_SMALLIR 0x00
|
||||
#define SI1145_PARAM_ADCMUX_LARGEIR 0x03
|
||||
|
||||
/* REGISTERS */
|
||||
#define SI1145_REG_PARTID 0x00
|
||||
#define SI1145_REG_REVID 0x01
|
||||
#define SI1145_REG_SEQID 0x02
|
||||
#define SI1145_REG_PARTID 0x00
|
||||
#define SI1145_REG_REVID 0x01
|
||||
#define SI1145_REG_SEQID 0x02
|
||||
|
||||
#define SI1145_REG_INTCFG 0x03
|
||||
#define SI1145_REG_INTCFG 0x03
|
||||
#define SI1145_REG_INTCFG_INTOE 0x01
|
||||
#define SI1145_REG_INTCFG_INTMODE 0x02
|
||||
|
||||
#define SI1145_REG_IRQEN 0x04
|
||||
#define SI1145_REG_IRQEN 0x04
|
||||
#define SI1145_REG_IRQEN_ALSEVERYSAMPLE 0x01
|
||||
#define SI1145_REG_IRQEN_PS1EVERYSAMPLE 0x04
|
||||
#define SI1145_REG_IRQEN_PS2EVERYSAMPLE 0x08
|
||||
#define SI1145_REG_IRQEN_PS3EVERYSAMPLE 0x10
|
||||
|
||||
|
||||
#define SI1145_REG_IRQMODE1 0x05
|
||||
#define SI1145_REG_IRQMODE2 0x06
|
||||
|
||||
#define SI1145_REG_HWKEY 0x07
|
||||
#define SI1145_REG_HWKEY 0x07
|
||||
#define SI1145_REG_MEASRATE0 0x08
|
||||
#define SI1145_REG_MEASRATE1 0x09
|
||||
#define SI1145_REG_PSRATE 0x0A
|
||||
#define SI1145_REG_PSLED21 0x0F
|
||||
#define SI1145_REG_PSLED3 0x10
|
||||
#define SI1145_REG_UCOEFF0 0x13
|
||||
#define SI1145_REG_UCOEFF1 0x14
|
||||
#define SI1145_REG_UCOEFF2 0x15
|
||||
#define SI1145_REG_UCOEFF3 0x16
|
||||
#define SI1145_REG_PARAMWR 0x17
|
||||
#define SI1145_REG_COMMAND 0x18
|
||||
#define SI1145_REG_RESPONSE 0x20
|
||||
#define SI1145_REG_IRQSTAT 0x21
|
||||
#define SI1145_REG_IRQSTAT_ALS 0x01
|
||||
#define SI1145_REG_MEASRATE1 0x09
|
||||
#define SI1145_REG_PSRATE 0x0A
|
||||
#define SI1145_REG_PSLED21 0x0F
|
||||
#define SI1145_REG_PSLED3 0x10
|
||||
#define SI1145_REG_UCOEFF0 0x13
|
||||
#define SI1145_REG_UCOEFF1 0x14
|
||||
#define SI1145_REG_UCOEFF2 0x15
|
||||
#define SI1145_REG_UCOEFF3 0x16
|
||||
#define SI1145_REG_PARAMWR 0x17
|
||||
#define SI1145_REG_COMMAND 0x18
|
||||
#define SI1145_REG_RESPONSE 0x20
|
||||
#define SI1145_REG_IRQSTAT 0x21
|
||||
#define SI1145_REG_IRQSTAT_ALS 0x01
|
||||
|
||||
#define SI1145_REG_ALSVISDATA0 0x22
|
||||
#define SI1145_REG_ALSVISDATA1 0x23
|
||||
|
|
@ -147,12 +143,15 @@
|
|||
#define SI1145_REG_CHIPSTAT 0x30
|
||||
|
||||
#define SI1145_ADDR 0x60
|
||||
|
||||
class Adafruit_SI1145 {
|
||||
public:
|
||||
/**
|
||||
* @brief Library for using the Si1145 UV/IR/Visible Light Sensor
|
||||
*
|
||||
*/
|
||||
class Adafruit_SI1145 {
|
||||
public:
|
||||
Adafruit_SI1145(void);
|
||||
boolean begin(uint8_t addr = SI1145_ADDR,TwoWire* pBus = &Wire);
|
||||
boolean begin(TwoWire* pBus);
|
||||
boolean begin(uint8_t addr = SI1145_ADDR, TwoWire *pBus = &Wire);
|
||||
boolean begin(TwoWire *pBus);
|
||||
void reset();
|
||||
|
||||
uint16_t readUV();
|
||||
|
|
@ -160,13 +159,13 @@ class Adafruit_SI1145 {
|
|||
uint16_t readVisible();
|
||||
uint16_t readProx();
|
||||
|
||||
private:
|
||||
private:
|
||||
uint16_t read16(uint8_t addr);
|
||||
uint8_t read8(uint8_t addr);
|
||||
void write8(uint8_t reg, uint8_t val);
|
||||
uint8_t readParam(uint8_t p);
|
||||
uint8_t writeParam(uint8_t p, uint8_t v);
|
||||
TwoWire* m_pBus;
|
||||
TwoWire *m_pBus;
|
||||
uint8_t _addr;
|
||||
};
|
||||
#endif
|
||||
|
|
|
|||
30
README.md
Normal file
30
README.md
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# Adafruit SI1145 Library [](https://github.com/adafruit/Adafruit_SI1145_Library/actions)
|
||||
|
||||
This is the Adafruit Arduino library for the Si1145 UV/IR/Visible Light Sensor
|
||||
|
||||
Tested and works great with the Adafruit SI1145 Breakout Board
|
||||
[<img src="assets/board.jpg?raw=true" width="500px">](https://www.adafruit.com/products/1777)
|
||||
|
||||
These sensors use I2C to communicate, 2 pins are required to interface
|
||||
|
||||
Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!
|
||||
|
||||
# Contributing
|
||||
|
||||
Contributions are welcome! Please read our [Code of Conduct](https://github.com/adafruit/Adafruit_SI1145_Library/blob/master/CODE_OF_CONDUCT.md>)
|
||||
before contributing to help this project stay welcoming.
|
||||
|
||||
## Documentation and doxygen
|
||||
Documentation is produced by doxygen. Contributions should include documentation for any new code added.
|
||||
|
||||
Some examples of how to use doxygen can be found in these guide pages:
|
||||
|
||||
https://learn.adafruit.com/the-well-automated-arduino-library/doxygen
|
||||
|
||||
https://learn.adafruit.com/the-well-automated-arduino-library/doxygen-tips
|
||||
|
||||
Written by Limor Fried for Adafruit Industries.
|
||||
BSD license, check license.txt for more information
|
||||
All text above must be included in any redistribution
|
||||
|
||||
To install, use the Arduino Library Manager and search for "Adafruit SI1145 Library" and install the library.
|
||||
19
README.txt
19
README.txt
|
|
@ -1,19 +0,0 @@
|
|||
This is a library for the Si1145 UV/IR/Visible Light Sensor
|
||||
|
||||
Designed specifically to work with the Si1145 sensor in the adafruit shop
|
||||
----> https://www.adafruit.com/products/1777
|
||||
|
||||
These sensors use I2C to communicate, 2 pins are required to
|
||||
interface
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Check out the links above for our tutorials and wiring diagrams
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, all text above must be included in any redistribution
|
||||
|
||||
To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_SI1145. Check that the Adafruit_SI1145 folder contains Adafruit_SI1145.cpp and Adafruit_SI1145.h
|
||||
|
||||
Place the Adafruit_SI1145 library folder your arduinosketchfolder/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE.
|
||||
BIN
assets/board.jpg
Normal file
BIN
assets/board.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 272 KiB |
127
code-of-conduct.md
Normal file
127
code-of-conduct.md
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
# Adafruit Community Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and leaders pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, gender identity and expression, level or type of
|
||||
experience, education, socio-economic status, nationality, personal appearance,
|
||||
race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
We are committed to providing a friendly, safe and welcoming environment for
|
||||
all.
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Be kind and courteous to others
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Collaborating with other community members
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and sexual attention or advances
|
||||
* The use of inappropriate images, including in a community member's avatar
|
||||
* The use of inappropriate language, including in a community member's nickname
|
||||
* Any spamming, flaming, baiting or other attention-stealing behavior
|
||||
* Excessive or unwelcome helping; answering outside the scope of the question
|
||||
asked
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate
|
||||
|
||||
The goal of the standards and moderation guidelines outlined here is to build
|
||||
and maintain a respectful community. We ask that you don’t just aim to be
|
||||
"technically unimpeachable", but rather try to be your best self.
|
||||
|
||||
We value many things beyond technical expertise, including collaboration and
|
||||
supporting others within our community. Providing a positive experience for
|
||||
other community members can have a much more significant impact than simply
|
||||
providing the correct answer.
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project leaders are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project leaders have the right and responsibility to remove, edit, or
|
||||
reject messages, comments, commits, code, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any community member for other behaviors that they deem
|
||||
inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Moderation
|
||||
|
||||
Instances of behaviors that violate the Adafruit Community Code of Conduct
|
||||
may be reported by any member of the community. Community members are
|
||||
encouraged to report these situations, including situations they witness
|
||||
involving other community members.
|
||||
|
||||
You may report in the following ways:
|
||||
|
||||
In any situation, you may send an email to <support@adafruit.com>.
|
||||
|
||||
On the Adafruit Discord, you may send an open message from any channel
|
||||
to all Community Helpers by tagging @community helpers. You may also send an
|
||||
open message from any channel, or a direct message to @kattni#1507,
|
||||
@tannewt#4653, @Dan Halbert#1614, @cater#2442, @sommersoft#0222, or
|
||||
@Andon#8175.
|
||||
|
||||
Email and direct message reports will be kept confidential.
|
||||
|
||||
In situations on Discord where the issue is particularly egregious, possibly
|
||||
illegal, requires immediate action, or violates the Discord terms of service,
|
||||
you should also report the message directly to Discord.
|
||||
|
||||
These are the steps for upholding our community’s standards of conduct.
|
||||
|
||||
1. Any member of the community may report any situation that violates the
|
||||
Adafruit Community Code of Conduct. All reports will be reviewed and
|
||||
investigated.
|
||||
2. If the behavior is an egregious violation, the community member who
|
||||
committed the violation may be banned immediately, without warning.
|
||||
3. Otherwise, moderators will first respond to such behavior with a warning.
|
||||
4. Moderators follow a soft "three strikes" policy - the community member may
|
||||
be given another chance, if they are receptive to the warning and change their
|
||||
behavior.
|
||||
5. If the community member is unreceptive or unreasonable when warned by a
|
||||
moderator, or the warning goes unheeded, they may be banned for a first or
|
||||
second offense. Repeated offenses will result in the community member being
|
||||
banned.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct and the enforcement policies listed above apply to all
|
||||
Adafruit Community venues. This includes but is not limited to any community
|
||||
spaces (both public and private), the entire Adafruit Discord server, and
|
||||
Adafruit GitHub repositories. Examples of Adafruit Community spaces include
|
||||
but are not limited to meet-ups, audio chats on the Adafruit Discord, or
|
||||
interaction at a conference.
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. As a community
|
||||
member, you are representing our community, and are expected to behave
|
||||
accordingly.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 1.4, available at
|
||||
<https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>,
|
||||
and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html).
|
||||
|
||||
For other projects adopting the Adafruit Community Code of
|
||||
Conduct, please contact the maintainers of those projects for enforcement.
|
||||
If you wish to use this code of conduct for your own project, consider
|
||||
explicitly mentioning your moderation policy or making a copy with your
|
||||
own moderation policy so as to avoid confusion.
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
name=Adafruit SI1145 Library
|
||||
version=1.1.0
|
||||
version=1.1.1
|
||||
author=Adafruit
|
||||
maintainer=Adafruit <info@adafruit.com>
|
||||
sentence=Arduino library for the SI1145 sensors in the Adafruit shop
|
||||
|
|
|
|||
26
license.txt
Normal file
26
license.txt
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
Software License Agreement (BSD License)
|
||||
|
||||
Copyright (c) 2019 Limor Fried for Adafruit Industries
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holders nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
Loading…
Reference in a new issue