Skip to content

Commit 986cde0

Browse files
Merge pull request #1 from brainelectronics/feature/initial-implementation
Initial implementation
2 parents f77f59d + 5a0107c commit 986cde0

28 files changed

+1664
-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

+55-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 -->
@@ -76,18 +73,35 @@ station.isconnected()
7673

7774
Install 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
8084
import upip
81-
upip.install('micropython-package-template')
85+
upip.install('micropython-i2c-lcd')
8286
```
8387

8488
#### Specific version
8589

8690
Install 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
89103
import 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
97111
MicroPython device. If no specific version is set, the latest stable version
98112
will 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
101122
import upip
102123
# overwrite index_urls to only take artifacts from test.pypi.org
103124
upip.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
128146
mkdir /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

133151
cp examples/main.py /pyboard
134152
cp 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 = 0x27
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

be_upy_blink/blink.py

-34
This file was deleted.

0 commit comments

Comments
 (0)