From e457f2c1b703daf5a0f929e4fae57ee9bc042f04 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Wed, 27 Jul 2022 00:34:16 -0400 Subject: [PATCH 1/4] Add adafruit_register as dependency --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index a45c547..e429efc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ Adafruit-Blinka adafruit-circuitpython-busdevice +adafruit-circuitpython-register From 5bcc11fbaf18ad0999dae6c26ded242df924afd0 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Wed, 27 Jul 2022 00:34:48 -0400 Subject: [PATCH 2/4] Add UV index, refactor to adafruit_register --- adafruit_si1145.py | 55 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/adafruit_si1145.py b/adafruit_si1145.py index 2b96c64..a2cae5a 100644 --- a/adafruit_si1145.py +++ b/adafruit_si1145.py @@ -27,9 +27,9 @@ """ import time -import struct from micropython import const from adafruit_bus_device import i2c_device +from adafruit_register.i2c_struct import Struct __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_SI1145.git" @@ -38,10 +38,15 @@ SI1145_DEFAULT_ADDRESS = const(0x60) SI1145_PART_ID = const(0x00) SI1145_HW_KEY = const(0x07) +_COEFF_0 = const(0x13) +_COEFF_1 = const(0x14) +_COEFF_2 = const(0x15) +_COEFF_3 = const(0x16) SI1145_PARAM_WR = const(0x17) SI1145_COMMAND = const(0x18) SI1145_RESPONSE = const(0x20) SI1145_ALS_VIS_DATA0 = const(0x22) +SI1145_UV_INDEX_DATA0 = const(0x2C) SI1145_PARAM_RD = const(0x2E) # Commands (for COMMAND register) @@ -58,20 +63,30 @@ class SI1145: """Driver for the SI1145 UV, IR, Visible Light Sensor.""" + _device_info = Struct(SI1145_PART_ID, " Date: Wed, 27 Jul 2022 00:42:00 -0400 Subject: [PATCH 3/4] Remove TODO --- adafruit_si1145.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_si1145.py b/adafruit_si1145.py index a2cae5a..adea964 100644 --- a/adafruit_si1145.py +++ b/adafruit_si1145.py @@ -64,7 +64,7 @@ class SI1145: """Driver for the SI1145 UV, IR, Visible Light Sensor.""" _device_info = Struct(SI1145_PART_ID, " Date: Tue, 9 Aug 2022 23:20:29 -0400 Subject: [PATCH 4/4] Simplify const() variable names --- adafruit_si1145.py | 72 +++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/adafruit_si1145.py b/adafruit_si1145.py index adea964..0ed3068 100644 --- a/adafruit_si1145.py +++ b/adafruit_si1145.py @@ -35,49 +35,49 @@ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_SI1145.git" # Registers -SI1145_DEFAULT_ADDRESS = const(0x60) -SI1145_PART_ID = const(0x00) -SI1145_HW_KEY = const(0x07) +_DEFAULT_ADDRESS = const(0x60) +_PART_ID = const(0x00) +_HW_KEY = const(0x07) _COEFF_0 = const(0x13) _COEFF_1 = const(0x14) _COEFF_2 = const(0x15) _COEFF_3 = const(0x16) -SI1145_PARAM_WR = const(0x17) -SI1145_COMMAND = const(0x18) -SI1145_RESPONSE = const(0x20) -SI1145_ALS_VIS_DATA0 = const(0x22) -SI1145_UV_INDEX_DATA0 = const(0x2C) -SI1145_PARAM_RD = const(0x2E) +_PARAM_WR = const(0x17) +_COMMAND = const(0x18) +_RESPONSE = const(0x20) +_ALS_VIS_DATA0 = const(0x22) +_UV_INDEX_DATA0 = const(0x2C) +_PARAM_RD = const(0x2E) # Commands (for COMMAND register) -SI1145_CMD_PARAM_QUERY = const(0b10000000) -SI1145_CMD_PARAM_SET = const(0b10100000) -SI1145_CMD_NOP = const(0b00000000) -SI1145_CMD_RESET = const(0b00000001) -SI1145_CMD_ALS_FORCE = const(0b00000110) +_CMD_PARAM_QUERY = const(0b10000000) +_CMD_PARAM_SET = const(0b10100000) +_CMD_NOP = const(0b00000000) +_CMD_RESET = const(0b00000001) +_CMD_ALS_FORCE = const(0b00000110) # RAM Parameter Offsets (use with PARAM_QUERY / PARAM_SET) -SI1145_RAM_CHLIST = const(0x01) +_RAM_CHLIST = const(0x01) class SI1145: """Driver for the SI1145 UV, IR, Visible Light Sensor.""" - _device_info = Struct(SI1145_PART_ID, "