Skip to content

Commit 6e9b682

Browse files
committed
Syntax highlight documentation
1 parent 42c196f commit 6e9b682

1 file changed

Lines changed: 33 additions & 13 deletions

File tree

README.md

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,52 +21,72 @@ Latest/development library from GitHub:
2121

2222
You should first set up an instance of the `FANShim` class, eg:
2323

24-
```
24+
```python
2525
from fanshim import FanShim
2626
fanshim = 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

3951
Fan 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

4359
Arguments 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

4969
Fan Shim includes a button, you can bind actions to press, release and hold events.
5070

5171
Do something when the button is pressed:
5272

53-
```
73+
```python
5474
@fanshim.on_press()
5575
def button_pressed():
5676
print("The button has been pressed!")
5777
```
5878

5979
Or when it has been released:
6080

61-
```
81+
```python
6282
@fanshim.on_release()
6383
def button_released(was_held):
6484
print("The button has been pressed!")
6585
```
6686

6787
Or when it's been pressed long enough to trigger a hold:
6888

69-
```
89+
```python
7090
fanshim.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
7999
hold time. If you want to bind an action to "press" and another to "hold" you
80100
should check this flag and perform your action in the `on_release()` handler:
81101

82-
```
102+
```python
83103
@fanshim.on_release()
84104
def button_released(was_held):
85105
if was_held:
@@ -90,19 +110,19 @@ def button_released(was_held):
90110

91111
To configure the amount of time the button should be held (in seconds), use:
92112

93-
```
113+
```python
94114
fanshim.set_hold_time(number_of_seconds)
95115
```
96116

97117
If you need to stop Fan Shim from polling the button, use:
98118

99-
```
119+
```python
100120
fanshim.stop_polling()
101121
```
102122

103123
You can start it again with:
104124

105-
```
125+
```python
106126
fanshim.start_polling()
107127
```
108128

0 commit comments

Comments
 (0)