436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
|
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
|
+
+
+
+
+
+
+
+
+
|
return h
def _rgb_to_color(self, rgb):
r = (rgb >> 16) & 0xff
g = (rgb >> 8) & 0xff
b = rgb & 0xff
# If the value is really a shade of white
# encode the brightness as a negative value
# where 0 is -1, 1 is -2, etc
if r == g and g == b:
return (r * -1) - 1
# Compute the hue of the RGB value (ignore
# luminance and saturation)
h = self._rgb_to_hue(r, g, b)
# Convert the hue into a LimitlessLED value
# which is really just the position along the
# color strip, offset
color = ((h / 360.0) * 255.0) + 26
color = color % 256
color = int(color + 0.5)
self._debug("RGB = \x1b[38;2;%i;%i;%im%06x\x1b[0m; Hue = %s; Color = %i" % (r, g, b, rgb, str(h * 360), color))
return color
|