mirror of
https://github.com/cmur2/python-veml6070.git
synced 2024-12-22 00:54:23 +01:00
module: calculate refresh time from any RSET without lookup table
This commit is contained in:
parent
6b2bde2dce
commit
df23b9905b
@ -101,4 +101,6 @@ class TestVeml6070(snapshottest.TestCase):
|
|||||||
veml3 = veml6070.Veml6070(rset=veml6070.RSET_600K)
|
veml3 = veml6070.Veml6070(rset=veml6070.RSET_600K)
|
||||||
veml3.set_integration_time(veml6070.INTEGRATIONTIME_2T)
|
veml3.set_integration_time(veml6070.INTEGRATIONTIME_2T)
|
||||||
self.assertEqual(veml3.get_refresh_time(), 0.5)
|
self.assertEqual(veml3.get_refresh_time(), 0.5)
|
||||||
|
veml4 = veml6070.Veml6070(rset=480000)
|
||||||
|
self.assertEqual(veml4.get_refresh_time(), 0.2)
|
||||||
# don't assert mockbus._log as we do not care
|
# don't assert mockbus._log as we do not care
|
||||||
|
@ -19,6 +19,10 @@ INTEGRATIONTIME_1T = 0x01
|
|||||||
INTEGRATIONTIME_2T = 0x02
|
INTEGRATIONTIME_2T = 0x02
|
||||||
INTEGRATIONTIME_4T = 0x03
|
INTEGRATIONTIME_4T = 0x03
|
||||||
|
|
||||||
|
# Scale factor in seconds / Ohm to determine refresh time for any RSET
|
||||||
|
# Note: 0.1 seconds (100 ms) are applicable for RSET_240K and INTEGRATIONTIME_1T
|
||||||
|
RSET_TO_REFRESHTIME_SCALE = 0.1 / RSET_240K
|
||||||
|
|
||||||
class Veml6070(object):
|
class Veml6070(object):
|
||||||
|
|
||||||
def __init__(self, i2c_bus=1, sensor_address=ADDR_L, rset=RSET_270K, integration_time=INTEGRATIONTIME_1T):
|
def __init__(self, i2c_bus=1, sensor_address=ADDR_L, rset=RSET_270K, integration_time=INTEGRATIONTIME_1T):
|
||||||
@ -72,19 +76,13 @@ class Veml6070(object):
|
|||||||
"""
|
"""
|
||||||
returns time needed to perform a complete measurement using current settings (in s)
|
returns time needed to perform a complete measurement using current settings (in s)
|
||||||
"""
|
"""
|
||||||
case_refresh_rset = {
|
|
||||||
RSET_240K: 0.1,
|
|
||||||
RSET_270K: 0.1125,
|
|
||||||
RSET_300K: 0.125,
|
|
||||||
RSET_600K: 0.25
|
|
||||||
}
|
|
||||||
case_refresh_it = {
|
case_refresh_it = {
|
||||||
INTEGRATIONTIME_1_2T: 0.5,
|
INTEGRATIONTIME_1_2T: 0.5,
|
||||||
INTEGRATIONTIME_1T: 1,
|
INTEGRATIONTIME_1T: 1,
|
||||||
INTEGRATIONTIME_2T: 2,
|
INTEGRATIONTIME_2T: 2,
|
||||||
INTEGRATIONTIME_4T: 4
|
INTEGRATIONTIME_4T: 4
|
||||||
}
|
}
|
||||||
return case_refresh_rset[self.rset] * case_refresh_it[self.integration_time]
|
return self.rset * RSET_TO_REFRESHTIME_SCALE * case_refresh_it[self.integration_time]
|
||||||
|
|
||||||
def get_uva_light_sensitivity(self):
|
def get_uva_light_sensitivity(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user