1
- # MicroPython package template
1
+ # MicroPython I2C LCD
2
2
3
- [ ![ Downloads] ( https://pepy.tech/badge/micropython-package-template )] ( https://pepy.tech/project/micropython-package-template )
4
- ![ Release] ( https://img.shields.io/github/v/release/brainelectronics/micropython-package-template ?include_prereleases&color=success )
3
+ [ ![ Downloads] ( https://pepy.tech/badge/micropython-i2c-lcd )] ( https://pepy.tech/project/micropython-i2c-lcd )
4
+ ![ Release] ( https://img.shields.io/github/v/release/brainelectronics/micropython-i2c-lcd ?include_prereleases&color=success )
5
5
![ MicroPython] ( https://img.shields.io/badge/micropython-Ok-green.svg )
6
6
[ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-yellow.svg )] ( https://opensource.org/licenses/MIT )
7
- [ ![ codecov] ( https://codecov.io/github/brainelectronics/micropython-package-template /branch/main/graph/badge.svg )] ( https://app.codecov.io/github/brainelectronics/micropython-package-template )
8
- [ ![ CI] ( https://github.com/brainelectronics/micropython-package-template /actions/workflows/release.yml/badge.svg )] ( https://github.com/brainelectronics/micropython-package-template /actions/workflows/release.yml )
7
+ [ ![ codecov] ( https://codecov.io/github/brainelectronics/micropython-i2c-lcd /branch/main/graph/badge.svg )] ( https://app.codecov.io/github/brainelectronics/micropython-i2c-lcd )
8
+ [ ![ CI] ( https://github.com/brainelectronics/micropython-i2c-lcd /actions/workflows/release.yml/badge.svg )] ( https://github.com/brainelectronics/micropython-i2c-lcd /actions/workflows/release.yml )
9
9
10
- MicroPython PyPi package template project with auto deploy
10
+ Micropython package to control HD44780 LCD displays 1602 and 2004 via I2C
11
11
12
12
---------------
13
13
14
14
## General
15
15
16
- MicroPython PyPi package template with GitHub Action based testing and deploy
16
+ Micropython package to control HD44780 LCD displays 1602 and 2004 via I2C
17
+
18
+ 📚 The latest documentation is available at
19
+ [ MicroPython I2C LCD ReadTheDocs] [ ref-rtd-micropython-i2c-lcd ] 📚
17
20
18
21
<!-- MarkdownTOC -->
19
22
@@ -27,12 +30,6 @@ MicroPython PyPi package template with GitHub Action based testing and deploy
27
30
- [Manually](#manually)
28
31
- [Upload files to board](#upload-files-to-board)
29
32
- [ Usage] ( #usage )
30
- - [ Create a PyPi \( micropython\) package] ( #create-a-pypi-micropython-package )
31
- - [Setup](#setup-1)
32
- - [Create a distribution](#create-a-distribution)
33
- - [Upload to PyPi](#upload-to-pypi)
34
- - [ Contributing] ( #contributing )
35
- - [Unittests](#unittests)
36
33
- [ Credits] ( #credits )
37
34
38
35
<!-- /MarkdownTOC -->
@@ -78,7 +75,7 @@ Install the latest package version of this lib on the MicroPython device
78
75
79
76
``` python
80
77
import upip
81
- upip.install(' micropython-package-template ' )
78
+ upip.install(' micropython-i2c-lcd ' )
82
79
```
83
80
84
81
#### Specific version
@@ -87,7 +84,7 @@ Install a specific, fixed package version of this lib on the MicroPython device
87
84
88
85
``` python
89
86
import upip
90
- upip.install(' micropython-package-template ==0.1.1 ' )
87
+ upip.install(' micropython-i2c-lcd ==0.1.0 ' )
91
88
```
92
89
93
90
#### Test version
@@ -101,12 +98,9 @@ will be used.
101
98
import upip
102
99
# overwrite index_urls to only take artifacts from test.pypi.org
103
100
upip.index_urls = [' https://test.pypi.org/pypi' ]
104
- upip.install(' micropython-package-template ==0.2 .0rc1.dev6 ' )
101
+ upip.install(' micropython-i2c-lcd ==0.1 .0rc1.dev2 ' )
105
102
```
106
103
107
- See also [ brainelectronics Test PyPi Server in Docker] [ ref-brainelectronics-test-pypiserver ]
108
- for a test PyPi server running on Docker.
109
-
110
104
### Manually
111
105
112
106
#### Upload files to board
@@ -126,9 +120,9 @@ folders to the device
126
120
127
121
``` bash
128
122
mkdir /pyboard/lib
129
- mkdir /pyboard/lib/be_upy_blink
123
+ mkdir /pyboard/lib/lcd_i2c
130
124
131
- cp be_upy_blink /* /pyboard/lib/be_upy_blink
125
+ cp lcd_i2c /* /pyboard/lib/lcd_i2c
132
126
133
127
cp examples/main.py /pyboard
134
128
cp examples/boot.py /pyboard
@@ -137,93 +131,32 @@ cp examples/boot.py /pyboard
137
131
## Usage
138
132
139
133
``` python
140
- from be_upy_blink import flash_led
141
- from machine import Pin
142
-
143
- led_pin = Pin(4 , Pin.OUT )
144
-
145
- flash_led(pin = led_pin, amount = 3 )
146
- # flash_led(pin=led_pin, amount=3, on_time=1, off_time=3)
147
- ```
148
-
149
- ## Create a PyPi (micropython) package
150
-
151
- ### Setup
152
-
153
- Install the required python package with the following command in a virtual
154
- environment to avoid any conflicts with other packages installed on your local
155
- system.
156
-
157
- ``` bash
158
- python3 -m venv .venv
159
- source .venv/bin/activate
160
-
161
- pip install twine
162
- ```
163
-
164
- ### Create a distribution
165
-
166
- This module overrides distutils (also compatible with setuptools) ` sdist `
167
- command to perform pre- and post-processing as required for MicroPython's
168
- upip package manager. This script is taken from
169
- [ pfalcon's picoweb] [ ref-pfalcon-picoweb-sdist-upip ] and updated to be PEP8
170
- conform.
171
-
172
- ``` bash
173
- python setup.py sdist
174
- ```
175
-
176
- A new folder ` dist ` will be created. The [ ` sdist_upip ` ] ( sdist_upip.py ) will be
177
- used to create everything necessary.
178
-
179
- ### Upload to PyPi
180
-
181
- ** Be aware: [ pypi.org] [ ref-pypi ] and [ test.pypi.org] [ ref-test-pypi ] are different**
134
+ from lcd_i2c import LCD
135
+ from machine import I2C , Pin
182
136
183
- You can ** NOT** login to [ test.pypi.org] [ ref-test-pypi ] with the
184
- [ pypi.org] [ ref-pypi ] account unless you created the same on the other. See
185
- [ invalid auth help page of ** test** pypi] [ ref-invalid-auth-test-pypi ]
186
-
187
- For testing purposes add ` --repository testpypi ` to
188
- upload it to [ test.pypi.org] [ ref-test-pypi ]
189
-
190
- ``` bash
191
- twine upload dist/micropython-package-template-* .tar.gz -u PYPI_USERNAME -p PYPI_PASSWORD
192
- ```
137
+ I2C_ADDR = 0x 27
138
+ NUM_ROWS = 2
139
+ NUM_COLS = 16
193
140
194
- ## Contributing
141
+ # define custom I2C interface, default is 'I2C(0)'
142
+ # check the docs of your device for further details and pin infos
143
+ i2c = I2C(1 , scl = Pin(3 ), sda = Pin(2 ), freq = 800_000 )
144
+ lcd = LCD(addr = I2C_ADDR , cols = NUM_COLS , rows = NUM_ROWS , i2c = i2c)
195
145
196
- ### Unittests
197
-
198
- Run the unittests locally with the following command after installing this
199
- package in a virtual environment
200
-
201
- ``` bash
202
- # run all tests
203
- nose2 --config tests/unittest.cfg
204
-
205
- # run only one specific tests
206
- nose2 tests.test_blink.TestBlink.test_flash_led
207
- ```
208
-
209
- Generate the coverage files with
210
-
211
- ``` bash
212
- python create_report_dirs.py
213
- coverage html
146
+ lcd.begin()
147
+ lcd.print(" Hello World" )
214
148
```
215
149
216
- The coverage report is placed at ` reports/coverage/html/index.html `
150
+ For further examples check the ` examples ` folder or the Example chapter in the
151
+ docs.
217
152
218
153
## Credits
219
154
220
- Based on the [ PyPa sample project ] [ ref-pypa-sample ] .
155
+ Based on [ Frank de Brabanders Arduino LiquidCrystal I2C Library ] [ ref-arduino-lcd-i2c-library ] .
221
156
222
157
<!-- Links -->
158
+ [ ref-rtd-micropython-i2c-lcd ] : https://micropython-i2c-lcd.readthedocs.io/en/latest/
223
159
[ ref-remote-upy-shell ] : https://github.com/dhylands/rshell
224
- [ ref-brainelectronics-test-pypiserver ] : https://github.com/brainelectronics/test-pypiserver
225
- [ ref-pypa-sample ] : https://github.com/pypa/sampleproject
226
- [ ref-pfalcon-picoweb-sdist-upip ] : https://github.com/pfalcon/picoweb/blob/b74428ebdde97ed1795338c13a3bdf05d71366a0/sdist_upip.py
160
+ [ ref-arduino-lcd-i2c-library ] : https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library
227
161
[ ref-test-pypi ] : https://test.pypi.org/
228
162
[ ref-pypi ] : https://pypi.org/
229
- [ ref-invalid-auth-test-pypi ] : https://test.pypi.org/help/#invalid-auth
0 commit comments