Skip to content

Commit f82f166

Browse files
authored
Merge pull request #13 from process1183/colorproperty
Add color property to the TCS34725 class (closes #8).
2 parents 9abe203 + a6f0930 commit f82f166

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

adafruit_tcs34725.py

+10
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,16 @@ def color_rgb_bytes(self):
242242
blue = int(pow((int((b/clear) * 256) / 255), 2.5) * 255)
243243
return (red, green, blue)
244244

245+
@property
246+
def color(self):
247+
"""Read the RGB color detected by the sensor. Returns an int with 8 bits per channel.
248+
249+
Examples: Red = 16711680 (0xff0000), Green = 65280 (0x00ff00),
250+
Blue = 255 (0x0000ff), SlateGray = 7372944 (0x708090)
251+
"""
252+
r, g, b = self.color_rgb_bytes
253+
return (r << 16) | (g << 8) | b
254+
245255

246256
@property
247257
def temperature(self):

0 commit comments

Comments
 (0)