From dad37b7e656b3a9d652eb783f4278192a8a5180b Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Wed, 6 Nov 2019 12:59:13 +0000 Subject: [PATCH] Prep for v0.0.3 --- Makefile | 6 +- library/CHANGELOG.txt | 6 ++ library/MANIFEST.in | 2 +- library/README.md | 149 ++++++++++++++++++++++++++++++++++++ library/README.rst | 147 ----------------------------------- library/fanshim/__init__.py | 2 +- library/setup.cfg | 5 +- 7 files changed, 163 insertions(+), 154 deletions(-) create mode 100644 library/README.md delete mode 100644 library/README.rst diff --git a/Makefile b/Makefile index d1d3cd7..9497831 100644 --- a/Makefile +++ b/Makefile @@ -41,9 +41,9 @@ python-readme: library/README.rst python-license: library/LICENSE.txt library/README.rst: README.md library/CHANGELOG.txt - pandoc --from=markdown --to=rst -o library/README.rst README.md - echo "" >> library/README.rst - cat library/CHANGELOG.txt >> library/README.rst + cp README.md library/README.md + echo "" >> library/README.md + cat library/CHANGELOG.txt >> library/README.md library/LICENSE.txt: LICENSE cp LICENSE library/LICENSE.txt diff --git a/library/CHANGELOG.txt b/library/CHANGELOG.txt index dd49ea8..0c81946 100644 --- a/library/CHANGELOG.txt +++ b/library/CHANGELOG.txt @@ -1,4 +1,10 @@ +0.0.3 +----- + +* Fix: lower polling frequency and make customisable, for PR #6 + 0.0.2 +----- * Fix: Fix error on exit diff --git a/library/MANIFEST.in b/library/MANIFEST.in index 2a3ae94..4310b98 100644 --- a/library/MANIFEST.in +++ b/library/MANIFEST.in @@ -1,5 +1,5 @@ include CHANGELOG.txt include LICENSE.txt -include README.rst +include README.md include setup.py recursive-include fanshim *.py diff --git a/library/README.md b/library/README.md new file mode 100644 index 0000000..b289cfc --- /dev/null +++ b/library/README.md @@ -0,0 +1,149 @@ +# Fan Shim for Raspberry Pi + +[![Build Status](https://travis-ci.com/pimoroni/fanshim-python.svg?branch=master)](https://travis-ci.com/pimoroni/fanshim-python) +[![Coverage Status](https://coveralls.io/repos/github/pimoroni/fanshim-python/badge.svg?branch=master)](https://coveralls.io/github/pimoroni/fanshim-python?branch=master) +[![PyPi Package](https://img.shields.io/pypi/v/fanshim.svg)](https://pypi.python.org/pypi/fanshim) +[![Python Versions](https://img.shields.io/pypi/pyversions/fanshim.svg)](https://pypi.python.org/pypi/fanshim) + +# Installing + +Stable library from PyPi: + +* Just run `sudo pip install fanshim` + +Latest/development library from GitHub: + +* `git clone https://github.com/pimoroni/fanshim-python` +* `cd fanshim-python` +* `sudo ./install.sh` + +# Reference + +You should first set up an instance of the `FANShim` class, eg: + +```python +from fanshim import FanShim +fanshim = FanShim() +``` + +## Fan + +Turn the fan on with: + +```python +fanshim.set_fan(True) +``` + +Turn it off with: + +```python +fanshim.set_fan(False) +``` + +You can also toggle the fan with: + +```python +fanshim.toggle_fan() +``` + +You can check the status of the fan with: + +```python +fanshim.get_fan() # returns 1 for 'on', 0 for 'off' +``` + +## LED + +Fan Shim includes one RGB APA-102 LED. + +Set it to any colour with: + +```python +fanshim.set_light(r, g, b) +``` + +Arguments r, g and b should be numbers between 0 and 255 that describe the colour you want. + +For example, full red: + +``` +fanshim.set_light(255, 0, 0) +``` + +## Button + +Fan Shim includes a button, you can bind actions to press, release and hold events. + +Do something when the button is pressed: + +```python +@fanshim.on_press() +def button_pressed(): + print("The button has been pressed!") +``` + +Or when it has been released: + +```python +@fanshim.on_release() +def button_released(was_held): + print("The button has been pressed!") +``` + +Or when it's been pressed long enough to trigger a hold: + +```python +fanshim.set_hold_time(2.0) + +@fanshim.on_hold() +def button_held(): + print("The button was held for 2 seconds") +``` + +The function you bind to `on_release()` is passed a `was_held` parameter, +this lets you know if the button was held down for longer than the configured +hold time. If you want to bind an action to "press" and another to "hold" you +should check this flag and perform your action in the `on_release()` handler: + +```python +@fanshim.on_release() +def button_released(was_held): + if was_held: + print("Long press!") + else: + print("Short press!") +``` + +To configure the amount of time the button should be held (in seconds), use: + +```python +fanshim.set_hold_time(number_of_seconds) +``` + +If you need to stop Fan Shim from polling the button, use: + +```python +fanshim.stop_polling() +``` + +You can start it again with: + +```python +fanshim.start_polling() +``` + + +0.0.3 +----- + +* Fix: lower polling frequency and make customisable, for PR #6 + +0.0.2 +----- + +* Fix: Fix error on exit + +0.0.1 +----- + +* Initial Release diff --git a/library/README.rst b/library/README.rst deleted file mode 100644 index f5a6de7..0000000 --- a/library/README.rst +++ /dev/null @@ -1,147 +0,0 @@ -Fan Shim for Raspberry Pi -========================= - -`Build Status `__ -`Coverage -Status `__ -`PyPi Package `__ `Python -Versions `__ - -Installing -========== - -Stable library from PyPi: - -- Just run ``sudo pip install fanshim`` - -Latest/development library from GitHub: - -- ``git clone https://github.com/pimoroni/fanshim-python`` -- ``cd fanshim-python`` -- ``sudo ./install.sh`` - -Reference -========= - -You should first set up an instance of the ``FANShim`` class, eg: - -.. code:: python - - from fanshim import FanShim - fanshim = FanShim() - -Fan ---- - -Turn the fan on with: - -.. code:: python - - fanshim.set_fan(True) - -Turn it off with: - -.. code:: python - - fanshim.set_fan(False) - -You can also toggle the fan with: - -.. code:: python - - fanshim.toggle_fan() - -LED ---- - -Fan Shim includes one RGB APA-102 LED. - -Set it to any colour with: - -.. code:: python - - fanshim.set_light(r, g, b) - -Arguments r, g and b should be numbers between 0 and 255 that describe -the colour you want. - -For example, full red: - -:: - - fanshim.set_light(255, 0, 0) - -Button ------- - -Fan Shim includes a button, you can bind actions to press, release and -hold events. - -Do something when the button is pressed: - -.. code:: python - - @fanshim.on_press() - def button_pressed(): - print("The button has been pressed!") - -Or when it has been released: - -.. code:: python - - @fanshim.on_release() - def button_released(was_held): - print("The button has been pressed!") - -Or when it’s been pressed long enough to trigger a hold: - -.. code:: python - - fanshim.set_hold_time(2.0) - - @fanshim.on_hold() - def button_held(): - print("The button was held for 2 seconds") - -The function you bind to ``on_release()`` is passed a ``was_held`` -parameter, this lets you know if the button was held down for longer -than the configured hold time. If you want to bind an action to “press” -and another to “hold” you should check this flag and perform your action -in the ``on_release()`` handler: - -.. code:: python - - @fanshim.on_release() - def button_released(was_held): - if was_held: - print("Long press!") - else: - print("Short press!") - -To configure the amount of time the button should be held (in seconds), -use: - -.. code:: python - - fanshim.set_hold_time(number_of_seconds) - -If you need to stop Fan Shim from polling the button, use: - -.. code:: python - - fanshim.stop_polling() - -You can start it again with: - -.. code:: python - - fanshim.start_polling() - -0.0.2 - -* Fix: Fix error on exit - -0.0.1 ------ - -* Initial Release diff --git a/library/fanshim/__init__.py b/library/fanshim/__init__.py index ccc8db1..c3fb454 100644 --- a/library/fanshim/__init__.py +++ b/library/fanshim/__init__.py @@ -4,7 +4,7 @@ import atexit from threading import Thread -__version__ = '0.0.2' +__version__ = '0.0.3' class FanShim(): diff --git a/library/setup.cfg b/library/setup.cfg index d5c24f2..47caca6 100644 --- a/library/setup.cfg +++ b/library/setup.cfg @@ -1,10 +1,11 @@ [metadata] name = fanshim -version = 0.0.2 +version = 0.0.3 author = Philip Howard author_email = phil@pimoroni.com description = Python library for the Pimoroni Fan Shim for Raspberry Pi -long_description = file: README.rst +long_description = file: README.md +long_description_content_type = text/markdown keywords = Raspberry Pi url = https://www.pimoroni.com project_urls =