mirror of
https://github.com/cmur2/python-veml6070.git
synced 2024-10-05 05:02:17 +02:00
module: add estimated risk level calculation based on UVA light intensity
- thresholds from vendor, take with a grain of salt as these are estimations
This commit is contained in:
parent
4eda08a9c9
commit
1bdfe0e54a
@ -90,6 +90,17 @@ class TestVeml6070(snapshottest.TestCase):
|
||||
self.assertEqual(veml.get_uva_light_intensity(), 0x0106 * (0.1/0.1125) * 0.05 / 4)
|
||||
self.assertMatchSnapshot(mockbus._log)
|
||||
|
||||
def test_get_estimated_risk_level(self):
|
||||
mockbus = setup_mockbus(initial_read={
|
||||
0x38+1: [0x01, 0x04],
|
||||
0x38+0: [0x06, 0x01]
|
||||
})
|
||||
veml = veml6070.Veml6070()
|
||||
intensity = veml.get_uva_light_intensity()
|
||||
self.assertEqual(veml.get_estimated_risk_level(intensity), "low")
|
||||
intensity = veml.get_uva_light_intensity()
|
||||
self.assertEqual(veml.get_estimated_risk_level(intensity), "moderate")
|
||||
|
||||
def test_get_refresh_time(self):
|
||||
mockbus = setup_mockbus()
|
||||
veml = veml6070.Veml6070(rset=veml6070.RSET_240K)
|
||||
|
@ -102,3 +102,19 @@ class Veml6070(object):
|
||||
INTEGRATIONTIME_4T: 4
|
||||
}
|
||||
return self.rset * RSET_TO_REFRESHTIME_SCALE * case_refresh_it[self.integration_time]
|
||||
|
||||
@staticmethod
|
||||
def get_estimated_risk_level(intensity):
|
||||
"""
|
||||
returns estimated risk level from comparing UVA light intensity value
|
||||
in W/(m*m) as parameter, thresholds calculated from application notes
|
||||
"""
|
||||
if intensity < 24.888:
|
||||
return "low"
|
||||
if intensity < 49.800:
|
||||
return "moderate"
|
||||
if intensity < 66.400:
|
||||
return "high"
|
||||
if intensity < 91.288:
|
||||
return "very high"
|
||||
return "extreme"
|
||||
|
Loading…
Reference in New Issue
Block a user