Skip to content

Commit 78c67f8

Browse files
Merge 27b3b72 into f77f59d
2 parents f77f59d + 27b3b72 commit 78c67f8

28 files changed

+1640
-351
lines changed

.coveragerc

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ omit =
1010
.tox/*,
1111
build/*,
1212
dist/*,
13-
version.py
13+
version.py,
14+
lcd_i2c/const.py,
15+
lcd_i2c/typing.py,
1416

1517
[report]
1618
# include = src/*
17-
include = be_upy_blink/*
19+
include = lcd_i2c/*
1820
# Regexes for lines to exclude from consideration
1921

2022
ignore_errors = True

.editorconfig

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ trim_trailing_whitespace = true
1515
[*.py]
1616
indent_size = 4
1717

18+
[*.json]
19+
indent_size = 4
20+
21+
# 2 space indentation
1822
[*.yml]
1923
indent_size = 2
2024

.flake8

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ exclude =
4545
libs_external
4646
sdist_upip.py
4747
setup.py
48-
update_version.py
4948

5049
# Provide a comma-separated list of glob patterns to add to the list of excluded ones.
5150
# extend-exclude =

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
run: |
3131
changelog2version \
3232
--changelog_file changelog.md \
33-
--version_file be_upy_blink/version.py \
33+
--version_file lcd_i2c/version.py \
3434
--version_file_type py \
3535
--debug
3636
python setup.py sdist

.github/workflows/test-release.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
run: |
2828
changelog2version \
2929
--changelog_file changelog.md \
30-
--version_file be_upy_blink/version.py \
30+
--version_file lcd_i2c/version.py \
3131
--version_file_type py \
3232
--additional_version_info="-rc${{ github.run_number }}.dev${{ github.event.number }}" \
3333
--debug

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
run: |
4545
changelog2version \
4646
--changelog_file changelog.md \
47-
--version_file be_upy_blink/version.py \
47+
--version_file lcd_i2c/version.py \
4848
--version_file_type py \
4949
--debug
5050
python setup.py sdist

LICENSE.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 brainelectronics and contributors
3+
Copyright (c) 2023 brainelectronics and contributors
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of
66
this software and associated documentation files (the "Software"), to deal in

README.md

+31-98
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
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 -->
@@ -78,7 +75,7 @@ Install the latest package version of this lib on the MicroPython device
7875

7976
```python
8077
import upip
81-
upip.install('micropython-package-template')
78+
upip.install('micropython-i2c-lcd')
8279
```
8380

8481
#### Specific version
@@ -87,7 +84,7 @@ Install a specific, fixed package version of this lib on the MicroPython device
8784

8885
```python
8986
import upip
90-
upip.install('micropython-package-template==0.1.1')
87+
upip.install('micropython-i2c-lcd==0.1.0')
9188
```
9289

9390
#### Test version
@@ -101,12 +98,9 @@ will be used.
10198
import upip
10299
# overwrite index_urls to only take artifacts from test.pypi.org
103100
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')
105102
```
106103

107-
See also [brainelectronics Test PyPi Server in Docker][ref-brainelectronics-test-pypiserver]
108-
for a test PyPi server running on Docker.
109-
110104
### Manually
111105

112106
#### Upload files to board
@@ -126,9 +120,9 @@ folders to the device
126120

127121
```bash
128122
mkdir /pyboard/lib
129-
mkdir /pyboard/lib/be_upy_blink
123+
mkdir /pyboard/lib/lcd_i2c
130124

131-
cp be_upy_blink/* /pyboard/lib/be_upy_blink
125+
cp lcd_i2c/* /pyboard/lib/lcd_i2c
132126

133127
cp examples/main.py /pyboard
134128
cp examples/boot.py /pyboard
@@ -137,93 +131,32 @@ cp examples/boot.py /pyboard
137131
## Usage
138132

139133
```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
182136

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 = 0x27
138+
NUM_ROWS = 2
139+
NUM_COLS = 16
193140

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)
195145

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")
214148
```
215149

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.
217152

218153
## Credits
219154

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].
221156

222157
<!-- Links -->
158+
[ref-rtd-micropython-i2c-lcd]: https://micropython-i2c-lcd.readthedocs.io/en/latest/
223159
[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
227161
[ref-test-pypi]: https://test.pypi.org/
228162
[ref-pypi]: https://pypi.org/
229-
[ref-invalid-auth-test-pypi]: https://test.pypi.org/help/#invalid-auth

be_upy_blink/blink.py

-34
This file was deleted.

0 commit comments

Comments
 (0)