1- # MicroPython package template
1+ # MicroPython I2C LCD
22
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 )
55![ MicroPython] ( https://img.shields.io/badge/micropython-Ok-green.svg )
66[ ![ 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 )
99
10- MicroPython PyPi package template project with auto deploy
10+ Micropython package to control HD44780 LCD displays 1602 and 2004 via I2C
1111
1212---------------
1313
1414## General
1515
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 ] 📚
1720
1821<!-- MarkdownTOC -->
1922
@@ -27,12 +30,6 @@ MicroPython PyPi package template with GitHub Action based testing and deploy
2730 - [Manually](#manually)
2831 - [Upload files to board](#upload-files-to-board)
2932- [ 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)
3633- [ Credits] ( #credits )
3734
3835<!-- /MarkdownTOC -->
@@ -76,18 +73,35 @@ station.isconnected()
7673
7774Install the latest package version of this lib on the MicroPython device
7875
76+ ``` python
77+ import mip
78+ mip.install(" github:brainelectronics/micropython-i2c-lcd" )
79+ ```
80+
81+ For MicroPython versions below 1.19.1 use the ` upip ` package instead of ` mip `
82+
7983``` python
8084import upip
81- upip.install(' micropython-package-template ' )
85+ upip.install(' micropython-i2c-lcd ' )
8286```
8387
8488#### Specific version
8589
8690Install a specific, fixed package version of this lib on the MicroPython device
8791
92+ ``` python
93+ import mip
94+ # install a verions of a specific branch
95+ mip.install(" github:brainelectronics/micropython-i2c-lcd" , version = " feature/initial-implementation" )
96+ # install a tag version
97+ mip.install(" github:brainelectronics/micropython-i2c-lcd" , version = " 0.1.0" )
98+ ```
99+
100+ For MicroPython versions below 1.19.1 use the ` upip ` package instead of ` mip `
101+
88102``` python
89103import upip
90- upip.install(' micropython-package-template ==0.1.1 ' )
104+ upip.install(' micropython-i2c-lcd ==0.1.0 ' )
91105```
92106
93107#### Test version
@@ -97,16 +111,20 @@ Install a specific release candidate version uploaded to
97111MicroPython device. If no specific version is set, the latest stable version
98112will be used.
99113
114+ ``` python
115+ import mip
116+ mip.install(" github:brainelectronics/micropython-i2c-lcd" , version = " 0.1.0-rc3.dev1" )
117+ ```
118+
119+ For MicroPython versions below 1.19.1 use the ` upip ` package instead of ` mip `
120+
100121``` python
101122import upip
102123# overwrite index_urls to only take artifacts from test.pypi.org
103124upip.index_urls = [' https://test.pypi.org/pypi' ]
104- upip.install(' micropython-package-template ==0.2.0rc1.dev6 ' )
125+ upip.install(' micropython-i2c-lcd ==0.1.0rc3.dev1 ' )
105126```
106127
107- See also [ brainelectronics Test PyPi Server in Docker] [ ref-brainelectronics-test-pypiserver ]
108- for a test PyPi server running on Docker.
109-
110128### Manually
111129
112130#### Upload files to board
@@ -126,9 +144,9 @@ folders to the device
126144
127145``` bash
128146mkdir /pyboard/lib
129- mkdir /pyboard/lib/be_upy_blink
147+ mkdir /pyboard/lib/lcd_i2c
130148
131- cp be_upy_blink /* /pyboard/lib/be_upy_blink
149+ cp lcd_i2c /* /pyboard/lib/lcd_i2c
132150
133151cp examples/main.py /pyboard
134152cp examples/boot.py /pyboard
@@ -137,93 +155,32 @@ cp examples/boot.py /pyboard
137155## Usage
138156
139157``` 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.
158+ from lcd_i2c import LCD
159+ from machine import I2C , Pin
178160
179- ### Upload to PyPi
161+ I2C_ADDR = 0x 27
162+ NUM_ROWS = 2
163+ NUM_COLS = 16
180164
181- ** Be aware: [ pypi.org] [ ref-pypi ] and [ test.pypi.org] [ ref-test-pypi ] are different**
165+ # define custom I2C interface, default is 'I2C(0)'
166+ # check the docs of your device for further details and pin infos
167+ i2c = I2C(1 , scl = Pin(3 ), sda = Pin(2 ), freq = 800_000 )
168+ lcd = LCD(addr = I2C_ADDR , cols = NUM_COLS , rows = NUM_ROWS , i2c = i2c)
182169
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- ```
193-
194- ## Contributing
195-
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
170+ lcd.begin()
171+ lcd.print(" Hello World" )
214172```
215173
216- The coverage report is placed at ` reports/coverage/html/index.html `
174+ For further examples check the ` examples ` folder or the Example chapter in the
175+ docs.
217176
218177## Credits
219178
220- Based on the [ PyPa sample project ] [ ref-pypa-sample ] .
179+ Based on [ Frank de Brabanders Arduino LiquidCrystal I2C Library ] [ ref-arduino-lcd-i2c-library ] .
221180
222181<!-- Links -->
182+ [ ref-rtd-micropython-i2c-lcd ] : https://micropython-i2c-lcd.readthedocs.io/en/latest/
223183[ 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
184+ [ ref-arduino-lcd-i2c-library ] : https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library
227185[ ref-test-pypi ] : https://test.pypi.org/
228186[ ref-pypi ] : https://pypi.org/
229- [ ref-invalid-auth-test-pypi ] : https://test.pypi.org/help/#invalid-auth
0 commit comments