Skip to content

Commit dad37b7

Browse files
committed
Prep for v0.0.3
1 parent ee7bb9a commit dad37b7

7 files changed

Lines changed: 163 additions & 154 deletions

File tree

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ python-readme: library/README.rst
4141
python-license: library/LICENSE.txt
4242

4343
library/README.rst: README.md library/CHANGELOG.txt
44-
pandoc --from=markdown --to=rst -o library/README.rst README.md
45-
echo "" >> library/README.rst
46-
cat library/CHANGELOG.txt >> library/README.rst
44+
cp README.md library/README.md
45+
echo "" >> library/README.md
46+
cat library/CHANGELOG.txt >> library/README.md
4747

4848
library/LICENSE.txt: LICENSE
4949
cp LICENSE library/LICENSE.txt

library/CHANGELOG.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1+
0.0.3
2+
-----
3+
4+
* Fix: lower polling frequency and make customisable, for PR #6
5+
16
0.0.2
7+
-----
28

39
* Fix: Fix error on exit
410

library/MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
include CHANGELOG.txt
22
include LICENSE.txt
3-
include README.rst
3+
include README.md
44
include setup.py
55
recursive-include fanshim *.py

library/README.md

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# Fan Shim for Raspberry Pi
2+
3+
[![Build Status](https://travis-ci.com/pimoroni/fanshim-python.svg?branch=master)](https://travis-ci.com/pimoroni/fanshim-python)
4+
[![Coverage Status](https://coveralls.io/repos/github/pimoroni/fanshim-python/badge.svg?branch=master)](https://coveralls.io/github/pimoroni/fanshim-python?branch=master)
5+
[![PyPi Package](https://img.shields.io/pypi/v/fanshim.svg)](https://pypi.python.org/pypi/fanshim)
6+
[![Python Versions](https://img.shields.io/pypi/pyversions/fanshim.svg)](https://pypi.python.org/pypi/fanshim)
7+
8+
# Installing
9+
10+
Stable library from PyPi:
11+
12+
* Just run `sudo pip install fanshim`
13+
14+
Latest/development library from GitHub:
15+
16+
* `git clone https://github.com/pimoroni/fanshim-python`
17+
* `cd fanshim-python`
18+
* `sudo ./install.sh`
19+
20+
# Reference
21+
22+
You should first set up an instance of the `FANShim` class, eg:
23+
24+
```python
25+
from fanshim import FanShim
26+
fanshim = FanShim()
27+
```
28+
29+
## Fan
30+
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+
```
42+
43+
You can also toggle the fan with:
44+
45+
```python
46+
fanshim.toggle_fan()
47+
```
48+
49+
You can check the status of the fan with:
50+
51+
```python
52+
fanshim.get_fan() # returns 1 for 'on', 0 for 'off'
53+
```
54+
55+
## LED
56+
57+
Fan Shim includes one RGB APA-102 LED.
58+
59+
Set it to any colour with:
60+
61+
```python
62+
fanshim.set_light(r, g, b)
63+
```
64+
65+
Arguments r, g and b should be numbers between 0 and 255 that describe the colour you want.
66+
67+
For example, full red:
68+
69+
```
70+
fanshim.set_light(255, 0, 0)
71+
```
72+
73+
## Button
74+
75+
Fan Shim includes a button, you can bind actions to press, release and hold events.
76+
77+
Do something when the button is pressed:
78+
79+
```python
80+
@fanshim.on_press()
81+
def button_pressed():
82+
print("The button has been pressed!")
83+
```
84+
85+
Or when it has been released:
86+
87+
```python
88+
@fanshim.on_release()
89+
def button_released(was_held):
90+
print("The button has been pressed!")
91+
```
92+
93+
Or when it's been pressed long enough to trigger a hold:
94+
95+
```python
96+
fanshim.set_hold_time(2.0)
97+
98+
@fanshim.on_hold()
99+
def button_held():
100+
print("The button was held for 2 seconds")
101+
```
102+
103+
The function you bind to `on_release()` is passed a `was_held` parameter,
104+
this lets you know if the button was held down for longer than the configured
105+
hold time. If you want to bind an action to "press" and another to "hold" you
106+
should check this flag and perform your action in the `on_release()` handler:
107+
108+
```python
109+
@fanshim.on_release()
110+
def button_released(was_held):
111+
if was_held:
112+
print("Long press!")
113+
else:
114+
print("Short press!")
115+
```
116+
117+
To configure the amount of time the button should be held (in seconds), use:
118+
119+
```python
120+
fanshim.set_hold_time(number_of_seconds)
121+
```
122+
123+
If you need to stop Fan Shim from polling the button, use:
124+
125+
```python
126+
fanshim.stop_polling()
127+
```
128+
129+
You can start it again with:
130+
131+
```python
132+
fanshim.start_polling()
133+
```
134+
135+
136+
0.0.3
137+
-----
138+
139+
* Fix: lower polling frequency and make customisable, for PR #6
140+
141+
0.0.2
142+
-----
143+
144+
* Fix: Fix error on exit
145+
146+
0.0.1
147+
-----
148+
149+
* Initial Release

library/README.rst

Lines changed: 0 additions & 147 deletions
This file was deleted.

library/fanshim/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import atexit
55
from threading import Thread
66

7-
__version__ = '0.0.2'
7+
__version__ = '0.0.3'
88

99

1010
class FanShim():

library/setup.cfg

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
[metadata]
22
name = fanshim
3-
version = 0.0.2
3+
version = 0.0.3
44
author = Philip Howard
55
author_email = phil@pimoroni.com
66
description = Python library for the Pimoroni Fan Shim for Raspberry Pi
7-
long_description = file: README.rst
7+
long_description = file: README.md
8+
long_description_content_type = text/markdown
89
keywords = Raspberry Pi
910
url = https://www.pimoroni.com
1011
project_urls =

0 commit comments

Comments
 (0)