@@ -21,52 +21,72 @@ Latest/development library from GitHub:
2121
2222You should first set up an instance of the ` FANShim ` class, eg:
2323
24- ```
24+ ``` python
2525from fanshim import FanShim
2626fanshim = FanShim()
2727```
2828
2929## Fan
3030
31- Turn the fan on with: ` fanshim.set_fan(True) `
31+ Turn the fan on with:
32+
33+ ``` python
34+ fanshim.set_fan(True )
35+ ```
36+
37+ Turn it off with:
38+
39+ ``` python
40+ fanshim.set_fan(False )
41+ ```
3242
33- Turn it off with: ` fanshim.set_fan(False) `
43+ You can also toggle the fan with:
3444
35- You can also toggle the fan with: ` fanshim.toggle_fan() `
45+ ``` python
46+ fanshim.toggle_fan()
47+ ```
3648
3749## LED
3850
3951Fan Shim includes one RGB APA-102 LED.
4052
41- Set it to any colour with: ` fanshim.set_light(r, g, b) `
53+ Set it to any colour with:
54+
55+ ``` python
56+ fanshim.set_light(r, g, b)
57+ ```
4258
4359Arguments r, g and b should be numbers between 0 and 255 that describe the colour you want.
4460
45- For example, full red: ` fanshim.set_light(255, 0, 0) `
61+ For example, full red:
62+
63+ ```
64+ fanshim.set_light(255, 0, 0)
65+ ```
4666
4767## Button
4868
4969Fan Shim includes a button, you can bind actions to press, release and hold events.
5070
5171Do something when the button is pressed:
5272
53- ```
73+ ``` python
5474@fanshim.on_press ()
5575def button_pressed ():
5676 print (" The button has been pressed!" )
5777```
5878
5979Or when it has been released:
6080
61- ```
81+ ``` python
6282@fanshim.on_release ()
6383def button_released (was_held ):
6484 print (" The button has been pressed!" )
6585```
6686
6787Or when it's been pressed long enough to trigger a hold:
6888
69- ```
89+ ``` python
7090fanshim.set_hold_time(2.0 )
7191
7292@fanshim.on_hold ()
@@ -79,7 +99,7 @@ this lets you know if the button was held down for longer than the configured
7999hold time. If you want to bind an action to "press" and another to "hold" you
80100should check this flag and perform your action in the ` on_release() ` handler:
81101
82- ```
102+ ``` python
83103@fanshim.on_release ()
84104def button_released (was_held ):
85105 if was_held:
@@ -90,19 +110,19 @@ def button_released(was_held):
90110
91111To configure the amount of time the button should be held (in seconds), use:
92112
93- ```
113+ ``` python
94114fanshim.set_hold_time(number_of_seconds)
95115```
96116
97117If you need to stop Fan Shim from polling the button, use:
98118
99- ```
119+ ``` python
100120fanshim.stop_polling()
101121```
102122
103123You can start it again with:
104124
105- ```
125+ ``` python
106126fanshim.start_polling()
107127```
108128
0 commit comments