forked from mitchgu/TAMProxy-pyHost
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolor_read.py
More file actions
27 lines (21 loc) · 905 Bytes
/
color_read.py
File metadata and controls
27 lines (21 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from tamproxy import Sketch, SyncedSketch, Timer
from tamproxy.devices import Color
# Prints RGB, clear(C), colorTemp, and lux values read and
# computed from the device. For more details, see the Adafruit_TCS34725
# Arduino library, from which the colorTemp and lux computations are
# used.
# Color sensor should be connected to the I2C ports (SDA and SCL)
class ColorRead(SyncedSketch):
def setup(self):
self.color = Color(self.tamp,
integrationTime=Color.INTEGRATION_TIME_101MS,
gain=Color.GAIN_1X)
self.timer = Timer()
def loop(self):
if self.timer.millis() > 100:
self.timer.reset()
print self.color.r, self.color.g, self.color.b, self.color.c
print self.color.colorTemp, self.color.lux
if __name__ == "__main__":
sketch = ColorRead(1, -0.00001, 100)
sketch.run()