Skip to content

Commit 731c219

Browse files
authored
Merge pull request #378 from srobo/kch_updates
Update KCH interface
2 parents 39d25d1 + f3ba800 commit 731c219

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

programming/sr/leds/index.md

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,37 +22,41 @@ once set they will hold their value even if your code exits. This is potentially
2222
useful to understand the current state of your code as it runs or the final
2323
state of the code afterwards.
2424

25-
Each channel of each LED acts independently, so you can either set them separately:
25+
Each of the LEDs can be set to one of 8 colours:
2626

2727
~~~~~ python
28-
# Turn on the red channel of LED A
29-
R.kch.a.red = 1
28+
# Set LED A to red
29+
R.kch[UserLED.A] = Colour.RED
3030

31-
# Turn on the green channel of LED B
32-
R.kch.b.green = 1
31+
# Set LED B to cyan
32+
R.kch[UserLED.B] = Colour.CYAN
3333

34-
# Turn off the red channel of LED A
35-
R.kch.a.red = 0
34+
# Turn LED C off
35+
R.kch[UserLED.C] = Colour.OFF
3636
~~~~~
3737

38-
Alternatively you can set the red, green and blue channels for a given LED all together:
38+
The available colours are:
3939

4040
~~~~~ python
41-
# Set LED C to a yellow colour
42-
R.kch.c.rgb = (1, 1, 0)
43-
44-
# Set LED B to a light blue colour
45-
R.kch.b.rgb = (0, 1, 1)
41+
OFF
42+
RED
43+
YELLOW
44+
GREEN
45+
CYAN
46+
BLUE
47+
MAGENTA
48+
WHITE
4649
~~~~~
4750

48-
You can also access all the LEDs together:
51+
Alternatively you can set the red, green and blue channels for a given LED separately:
4952

5053
~~~~~ python
51-
# Turn on the blue channel of all the LEDs
52-
for led in R.kch.leds.values():
53-
led.blue = 1
54+
# Turn on the blue segment of LED A
55+
R.kch[UserLED.A].b = True
56+
57+
# Turn off the red segment of LED B
58+
R.kch[UserLED.B].r = False
5459

55-
# Set all LEDs to a purple colour
56-
for led in R.kch.leds.values():
57-
led.rgb = (1, 0, 1)
60+
# Turn on green segment of LED B
61+
R.kch[UserLED.B].g = True
5862
~~~~~

0 commit comments

Comments
 (0)