File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -673,6 +673,8 @@ def color(self):
673
673
674
674
The following example turns the LCD red and displays, "Hello, world!".
675
675
676
+ The property returns a list, but can be set as an int in the format ``0xRRGGBB``, as output by `rainbowio.colorwheel` for example.
677
+
676
678
.. code-block:: python
677
679
678
680
import time
@@ -691,6 +693,14 @@ def color(self):
691
693
692
694
@color .setter
693
695
def color (self , color ):
696
+ if isinstance (color , int ):
697
+ if color >> 24 :
698
+ raise ValueError ("Integer color value must be positive and 24 bits max" )
699
+ # NOTE: convert to 0-100
700
+ r = (value >> 16 ) / 2.55
701
+ g = ((value >> 8 ) & 0xFF ) / 2.55
702
+ b = (value & 0xFF ) / 2.55
703
+ color = [r , g , b ]
694
704
self ._color = color
695
705
for number , pin in enumerate (self .rgb_led ):
696
706
if hasattr (pin , "duty_cycle" ):
You can’t perform that action at this time.
0 commit comments