|
1 | | -# PyLetMeCreate |
| 1 | + |
2 | 2 |
|
3 | | -This is the python binding of the LetMeCreate library. It requires Python 3. See [LetMeCreate](https://github.com/francois-berder/LetMeCreate) for the complete list of interface and click board supported. |
4 | 3 |
|
5 | | -## Integration in Openwrt |
| 4 | +# PyLetMeCreate |
6 | 5 |
|
7 | | -Before reading any further, make sure that you installed the LetMeCreate library as shown on its github page. |
| 6 | +This is the python binding of the LetMeCreate library. It requires Python 3. See [LetMeCreate](https://github.com/francois-berder/LetMeCreate) for the complete list of interface and click board supported. |
| 7 | +PyLetMeCreate relies on LetMeCreate, hence it is important that both versions match. |
8 | 8 |
|
| 9 | +Examples are installed in /usr/bin/pyletmecreate_examples. |
9 | 10 |
|
10 | | -### Installation steps |
| 11 | +## Integration in Openwrt |
11 | 12 |
|
12 | | -Clone the library and openwrt somewhere on you computer: |
| 13 | +PyLetMeCreate is already part of Imagination Technologies' OpenWrt. |
| 14 | +To compile the library (only possible once you built Openwrt once): |
13 | 15 |
|
14 | 16 | ```sh |
15 | | -$ mkdir ci-40 |
16 | | -$ cd ci-40 |
17 | | -$ git clone https://github.com/CreatorDev/openwrt.git |
18 | | -$ mkdir -p custom/pyletmecreate |
19 | | -$ cd custom/pyletmecreate |
| 17 | +$ make package/pyletmecreate/{clean,compile} -j1 V=s |
20 | 18 | ``` |
21 | | -#### Stable release |
22 | 19 |
|
23 | | -If you are only interested in getting the latest release of LetMeCreate library, then download a copy of Makefile.stable located in miscellaneous folder. Copy this file inside the pyletmecreate folder you have just created and rename it to Makefile. |
24 | | - |
25 | | -#### Development configuration |
| 20 | +### Installation steps |
26 | 21 |
|
27 | | -If you are interested in modifying the library, getting the latest changes, then clone it in custom/pyletmecreate folder you just created: |
| 22 | +You can install PyLetMeCreate package on OpenWRT executing: |
28 | 23 |
|
29 | 24 | ```sh |
30 | | -$ git clone https://github.com/francois-berder/PyLetMeCreate.git |
| 25 | +$ opkg install pyletmecreate |
31 | 26 | ``` |
32 | 27 |
|
33 | | -Copy the Makefile to the right location: |
34 | | -```sh |
35 | | -$ cp PyLetMeCreate/miscellaneous/Makefile.devel Makefile |
36 | | -``` |
| 28 | +Each release has the ipk as an attachment. You can download the ipk, copy it to your Ci40 and install with opkg: |
37 | 29 |
|
38 | | -This project uses two branches. The dev branch contains all the latest changes and should not be considered stable. The dev branch is sometimes merged to master once new features are considered stable. |
39 | | - |
40 | | -#### Register PyLetMeCreate in Openwrt |
41 | | - |
42 | | -To register the feed in openwrt, go back in openwrt folder and open feeds.conf.default. |
43 | | -Add this line: |
44 | | -``` |
45 | | -src-link custom /change/this/path/to/the/location/of/ci-40/custom/directory/ |
46 | | -``` |
47 | | - |
48 | | -Update and install all feeds: |
49 | 30 | ```sh |
50 | | -$ ./scripts/feeds update -a |
51 | | -$ ./scripts/feeds install -a |
| 31 | +$ opkg install path-to-the-ipk |
52 | 32 | ``` |
53 | | -Select python3-letmecreate in make menuconfig. It will automatically select python3 and letmecreate. Then, compile Openwrt: |
54 | 33 |
|
55 | | -```sh |
56 | | -$ make -j1 V=s |
57 | | -``` |
58 | | -To create an ipk, run this command (only possible once you built Openwrt once): |
59 | | - |
60 | | -```sh |
61 | | -$ make package/pyletmecreate/{clean,compile} -j1 V=s |
62 | | -``` |
| 34 | +### Usage example |
63 | 35 |
|
64 | | -### Installation of PyLetMeCreate on Ci40 |
65 | 36 |
|
66 | | -#### Install PyLetMeCreate using ipk |
| 37 | +```python |
| 38 | +#!/usr/bin/env python3 |
| 39 | +"""This example shows how to read the temperature using a Thermo3 Click |
| 40 | +on Mikrobus 1. |
| 41 | +""" |
67 | 42 |
|
68 | | -In openwrt folder, the ipk is located in bin/pistachio/packages/custom. Transfer it to your Ci40 using scp: |
69 | | -```sh |
70 | | -$ scp bin/pistachio/packages/custom/python3-letmecreate_1.0.1_pistachio.ipk root@<ip-of-your-ci40>:/tmp |
71 | | -``` |
| 43 | +from letmecreate.core import i2c |
| 44 | +from letmecreate.core.common import MIKROBUS_1 |
| 45 | +from letmecreate.click import thermo3 |
72 | 46 |
|
73 | | -On you Ci40: |
74 | | -```sh |
75 | | -$ opkg install /tmp/python3-letmecreate_1.0.1_pistachio.ipk |
76 | | -``` |
77 | 47 |
|
78 | | -#### Install PyLetMeCreate by copying letmecreate folder |
| 48 | +# Initialise I2C on Mikrobus 1 |
| 49 | +i2c.init() |
| 50 | +i2c.select_bus(MIKROBUS_1) |
79 | 51 |
|
| 52 | +# Read temperature |
| 53 | +thermo3.enable(0) |
| 54 | +print('{} degrees celsius'.format(thermo3.get_temperature())) |
| 55 | +thermo3.disable() |
80 | 56 |
|
81 | | -In your PyLetMeCreate folder, transfer the files to: |
82 | | -```sh |
83 | | -$ scp letmecreate root@<ip-of-your-Ci40>:/usr/lib/python3.5/site-packages |
| 57 | +# Release I2C |
| 58 | +i2c.release() |
84 | 59 | ``` |
85 | | - |
86 | | -This will only work if python3.5 is already installed on your Ci40. You might need to change the directory path if you have a different version of Python installed. |
0 commit comments