Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jposada202020 committed Jun 29, 2023
1 parent 1f6868c commit 19a8ee3
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions micropython_tcs3430/tcs3430.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
from micropython import const
from micropython_tcs3430.i2c_helpers import CBits, RegisterStruct

try:
from typing import Tuple
except ImportError:
pass


__version__ = "0.0.0+auto.0"
__repo__ = "https://github.com/jposada202020/MicroPython_TCS3430.git"

Expand Down Expand Up @@ -87,8 +81,7 @@ class TCS3430:
_als_gain = CBits(2, _CFG1, 0)
_raw_data = RegisterStruct(_DATA, ">HHHH")


_waiting_times = {0:2.78, 1:33.4}
_waiting_times = {0: 2.78, 1: 33.4}

def __init__(self, i2c, address: int = 0x39) -> None:
self._i2c = i2c
Expand All @@ -100,7 +93,6 @@ def __init__(self, i2c, address: int = 0x39) -> None:
self._operation_mode = ENABLED
print(self._integration_time)


@property
def operation_mode(self) -> str:
"""
Expand Down Expand Up @@ -137,7 +129,7 @@ def integration_time(self) -> float:

@integration_time.setter
def integration_time(self, value: float) -> None:
if value>711 or value<2.78:
if value > 711 or value < 2.78:
raise ValueError("Value must be a valid integration_time setting")
self._integration_time = int(value / 2.78)

Expand All @@ -150,7 +142,7 @@ def als_wait_time(self) -> float:
forth; By asserting wlong, in register 0x8D the wait time is given
in multiples of 33.4ms (12x)
"""
return self._als_wait_time * _waiting_times[self._wait_long]
return self._als_wait_time * self._waiting_times[self._wait_long]

@als_wait_time.setter
def als_wait_time(self, value: float) -> None:
Expand All @@ -160,7 +152,7 @@ def als_wait_time(self, value: float) -> None:
else:
if value > 23747 or value < 33.4:
raise ValueError("Value must be a valid als_wait_time setting")
self._als_wait_time = int(value / _waiting_times[self._wait_long])
self._als_wait_time = int(value / self._waiting_times[self._wait_long])

@property
def als_gain(self) -> str:
Expand Down Expand Up @@ -190,5 +182,8 @@ def als_gain(self, value: int) -> None:

@property
def measurements(self):
"""
Return ALS values
"""
als_z, als_y, ir1_value, als_x = self._raw_data
return als_z, als_y, als_x, ir1_value

0 comments on commit 19a8ee3

Please sign in to comment.