Skip to content

change color property to use scaled color_raw values #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions adafruit_tcs34725.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,11 @@ def color(self):
Examples: Red = 16711680 (0xff0000), Green = 65280 (0x00ff00),
Blue = 255 (0x0000ff), SlateGray = 7372944 (0x708090)
"""
r, g, b = self.color_rgb_bytes
return (r << 16) | (g << 8) | b
r, g, b, _c = self.color_raw
scaled_r = r * 255 // 1024
scaled_g = g * 255 // 1024
scaled_b = b * 255 // 1024
return (scaled_r << 16) | (scaled_g << 8) | scaled_b

@property
def active(self):
Expand Down