circuitpython-sevenseg 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- circuitpython_sevenseg-1.0.0/LICENSE +20 -0
- circuitpython_sevenseg-1.0.0/PKG-INFO +193 -0
- circuitpython_sevenseg-1.0.0/README.md +178 -0
- circuitpython_sevenseg-1.0.0/circuitpython_sevenseg/__init__.py +8 -0
- circuitpython_sevenseg-1.0.0/circuitpython_sevenseg/sevenseg.py +117 -0
- circuitpython_sevenseg-1.0.0/circuitpython_sevenseg.egg-info/PKG-INFO +193 -0
- circuitpython_sevenseg-1.0.0/circuitpython_sevenseg.egg-info/SOURCES.txt +9 -0
- circuitpython_sevenseg-1.0.0/circuitpython_sevenseg.egg-info/dependency_links.txt +1 -0
- circuitpython_sevenseg-1.0.0/circuitpython_sevenseg.egg-info/top_level.txt +2 -0
- circuitpython_sevenseg-1.0.0/pyproject.toml +27 -0
- circuitpython_sevenseg-1.0.0/setup.cfg +4 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kritish Mohapatra
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
9
|
+
of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
16
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
17
|
+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
18
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: circuitpython-sevenseg
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A lightweight CircuitPython library for controlling single-digit 7-segment displays
|
|
5
|
+
Author-email: Kritish Mohapatra <kritishmohapatra06norisk@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/kritishmohapatra/circuitpython-sevenseg
|
|
7
|
+
Keywords: circuitpython,seven-segment,7-segment,display,iot,embedded,pico,esp32
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: System :: Hardware
|
|
13
|
+
Requires-Python: >=3.0
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# circuitpython-sevenseg
|
|
17
|
+
|
|
18
|
+
A lightweight CircuitPython library for controlling single digit 7 segment displays (common cathode or common anode).
|
|
19
|
+
|
|
20
|
+
Supports **digits, uppercase & lowercase letters, and symbols** works on Raspberry Pi Pico, Adafruit Feather, Seeed XIAO ESP32-S3, and any CircuitPython-supported board.
|
|
21
|
+
|
|
22
|
+
> CircuitPython port of [micropython-sevenseg](https://github.com/kritishmohapatra/micropython-sevenseg)
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
Copy the `circuitpython_sevenseg/` folder to the `lib/` directory on your `CIRCUITPY` drive:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
CIRCUITPY/
|
|
32
|
+
└── lib/
|
|
33
|
+
└── circuitpython_sevenseg/
|
|
34
|
+
├── __init__.py
|
|
35
|
+
└── sevenseg.py
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Pin Diagram
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
---a---
|
|
44
|
+
| |
|
|
45
|
+
f b
|
|
46
|
+
| |
|
|
47
|
+
---g---
|
|
48
|
+
| |
|
|
49
|
+
e c
|
|
50
|
+
| |
|
|
51
|
+
---d--- ● dp
|
|
52
|
+
|
|
53
|
+
Pin order: [a, b, c, d, e, f, g, dp]
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Quick Start
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
import board
|
|
62
|
+
import time
|
|
63
|
+
from circuitpython_sevenseg import SevenSeg
|
|
64
|
+
|
|
65
|
+
seg = SevenSeg(
|
|
66
|
+
pins=[board.GP2, board.GP3, board.GP4, board.GP5,
|
|
67
|
+
board.GP6, board.GP7, board.GP8, board.GP9],
|
|
68
|
+
common_anode=False
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# Show a digit
|
|
72
|
+
seg.show(5)
|
|
73
|
+
|
|
74
|
+
# Show a letter
|
|
75
|
+
seg.show('A')
|
|
76
|
+
|
|
77
|
+
# Show with decimal point
|
|
78
|
+
seg.show(3, dp=True)
|
|
79
|
+
|
|
80
|
+
# Turn on decimal point only
|
|
81
|
+
seg.dot(True)
|
|
82
|
+
|
|
83
|
+
# Clear display
|
|
84
|
+
seg.clear()
|
|
85
|
+
|
|
86
|
+
# Release pins
|
|
87
|
+
seg.deinit()
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## API Reference
|
|
93
|
+
|
|
94
|
+
### `SevenSeg(pins, common_anode=False)`
|
|
95
|
+
|
|
96
|
+
Initializes the display.
|
|
97
|
+
|
|
98
|
+
| Parameter | Type | Description |
|
|
99
|
+
|---|---|---|
|
|
100
|
+
| `pins` | list | 8 pin objects in order `[a, b, c, d, e, f, g, dp]` |
|
|
101
|
+
| `common_anode` | bool | `True` for common anode, `False` for common cathode (default) |
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
### `show(char, dp=False)`
|
|
106
|
+
|
|
107
|
+
Displays a character on the 7-segment display.
|
|
108
|
+
|
|
109
|
+
| Parameter | Type | Description |
|
|
110
|
+
|---|---|---|
|
|
111
|
+
| `char` | int or str | Digit `0–9` or supported character (see table below) |
|
|
112
|
+
| `dp` | bool | Also turn on decimal point (default `False`) |
|
|
113
|
+
|
|
114
|
+
Raises `ValueError` if character is not supported.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
### `clear()`
|
|
119
|
+
|
|
120
|
+
Turns off all segments including the decimal point.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
### `dot(on=True)`
|
|
125
|
+
|
|
126
|
+
Toggles the decimal point without affecting other segments.
|
|
127
|
+
|
|
128
|
+
| Parameter | Type | Description |
|
|
129
|
+
|---|---|---|
|
|
130
|
+
| `on` | bool | `True` = on, `False` = off (default `True`) |
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
### `deinit()`
|
|
135
|
+
|
|
136
|
+
Releases all GPIO pins. Call when done to free resources.
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Supported Characters
|
|
141
|
+
|
|
142
|
+
### Digits
|
|
143
|
+
`0 1 2 3 4 5 6 7 8 9`
|
|
144
|
+
|
|
145
|
+
### Uppercase Letters
|
|
146
|
+
`A B C D E F G H I J L N O P Q R S T U Y Z`
|
|
147
|
+
|
|
148
|
+
> K, M, V, W, X not supported — physically impossible on 7-segment display.
|
|
149
|
+
|
|
150
|
+
### Lowercase Letters
|
|
151
|
+
`a b c d e f g h i j l n o p q r s t u y`
|
|
152
|
+
|
|
153
|
+
### Symbols
|
|
154
|
+
`- _ . ! ? ' " [ ] = + ^ (space)`
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Wiring Example — Raspberry Pi Pico / Pico 2W
|
|
159
|
+
|
|
160
|
+
| Segment | Pico Pin |
|
|
161
|
+
|---------|----------|
|
|
162
|
+
| a | GP2 |
|
|
163
|
+
| b | GP3 |
|
|
164
|
+
| c | GP4 |
|
|
165
|
+
| d | GP5 |
|
|
166
|
+
| e | GP6 |
|
|
167
|
+
| f | GP7 |
|
|
168
|
+
| g | GP8 |
|
|
169
|
+
| dp | GP9 |
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Examples
|
|
174
|
+
|
|
175
|
+
| File | Description |
|
|
176
|
+
|------|-------------|
|
|
177
|
+
| `sevenseg_simpletest.py` | Basic 0–9 counter |
|
|
178
|
+
| `sevenseg_all_chars.py` | All supported characters |
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## License
|
|
184
|
+
|
|
185
|
+
MIT License © 2026 Kritish Mohapatra
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Author
|
|
190
|
+
|
|
191
|
+
**Kritish Mohapatra**
|
|
192
|
+
- GitHub: [@kritishmohapatra](https://github.com/kritishmohapatra)
|
|
193
|
+
- MicroPython version: [micropython-sevenseg](https://github.com/kritishmohapatra/micropython-sevenseg)
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# circuitpython-sevenseg
|
|
2
|
+
|
|
3
|
+
A lightweight CircuitPython library for controlling single digit 7 segment displays (common cathode or common anode).
|
|
4
|
+
|
|
5
|
+
Supports **digits, uppercase & lowercase letters, and symbols** works on Raspberry Pi Pico, Adafruit Feather, Seeed XIAO ESP32-S3, and any CircuitPython-supported board.
|
|
6
|
+
|
|
7
|
+
> CircuitPython port of [micropython-sevenseg](https://github.com/kritishmohapatra/micropython-sevenseg)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
Copy the `circuitpython_sevenseg/` folder to the `lib/` directory on your `CIRCUITPY` drive:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
CIRCUITPY/
|
|
17
|
+
└── lib/
|
|
18
|
+
└── circuitpython_sevenseg/
|
|
19
|
+
├── __init__.py
|
|
20
|
+
└── sevenseg.py
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Pin Diagram
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
---a---
|
|
29
|
+
| |
|
|
30
|
+
f b
|
|
31
|
+
| |
|
|
32
|
+
---g---
|
|
33
|
+
| |
|
|
34
|
+
e c
|
|
35
|
+
| |
|
|
36
|
+
---d--- ● dp
|
|
37
|
+
|
|
38
|
+
Pin order: [a, b, c, d, e, f, g, dp]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Quick Start
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
import board
|
|
47
|
+
import time
|
|
48
|
+
from circuitpython_sevenseg import SevenSeg
|
|
49
|
+
|
|
50
|
+
seg = SevenSeg(
|
|
51
|
+
pins=[board.GP2, board.GP3, board.GP4, board.GP5,
|
|
52
|
+
board.GP6, board.GP7, board.GP8, board.GP9],
|
|
53
|
+
common_anode=False
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
# Show a digit
|
|
57
|
+
seg.show(5)
|
|
58
|
+
|
|
59
|
+
# Show a letter
|
|
60
|
+
seg.show('A')
|
|
61
|
+
|
|
62
|
+
# Show with decimal point
|
|
63
|
+
seg.show(3, dp=True)
|
|
64
|
+
|
|
65
|
+
# Turn on decimal point only
|
|
66
|
+
seg.dot(True)
|
|
67
|
+
|
|
68
|
+
# Clear display
|
|
69
|
+
seg.clear()
|
|
70
|
+
|
|
71
|
+
# Release pins
|
|
72
|
+
seg.deinit()
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## API Reference
|
|
78
|
+
|
|
79
|
+
### `SevenSeg(pins, common_anode=False)`
|
|
80
|
+
|
|
81
|
+
Initializes the display.
|
|
82
|
+
|
|
83
|
+
| Parameter | Type | Description |
|
|
84
|
+
|---|---|---|
|
|
85
|
+
| `pins` | list | 8 pin objects in order `[a, b, c, d, e, f, g, dp]` |
|
|
86
|
+
| `common_anode` | bool | `True` for common anode, `False` for common cathode (default) |
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
### `show(char, dp=False)`
|
|
91
|
+
|
|
92
|
+
Displays a character on the 7-segment display.
|
|
93
|
+
|
|
94
|
+
| Parameter | Type | Description |
|
|
95
|
+
|---|---|---|
|
|
96
|
+
| `char` | int or str | Digit `0–9` or supported character (see table below) |
|
|
97
|
+
| `dp` | bool | Also turn on decimal point (default `False`) |
|
|
98
|
+
|
|
99
|
+
Raises `ValueError` if character is not supported.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
### `clear()`
|
|
104
|
+
|
|
105
|
+
Turns off all segments including the decimal point.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
### `dot(on=True)`
|
|
110
|
+
|
|
111
|
+
Toggles the decimal point without affecting other segments.
|
|
112
|
+
|
|
113
|
+
| Parameter | Type | Description |
|
|
114
|
+
|---|---|---|
|
|
115
|
+
| `on` | bool | `True` = on, `False` = off (default `True`) |
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
### `deinit()`
|
|
120
|
+
|
|
121
|
+
Releases all GPIO pins. Call when done to free resources.
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Supported Characters
|
|
126
|
+
|
|
127
|
+
### Digits
|
|
128
|
+
`0 1 2 3 4 5 6 7 8 9`
|
|
129
|
+
|
|
130
|
+
### Uppercase Letters
|
|
131
|
+
`A B C D E F G H I J L N O P Q R S T U Y Z`
|
|
132
|
+
|
|
133
|
+
> K, M, V, W, X not supported — physically impossible on 7-segment display.
|
|
134
|
+
|
|
135
|
+
### Lowercase Letters
|
|
136
|
+
`a b c d e f g h i j l n o p q r s t u y`
|
|
137
|
+
|
|
138
|
+
### Symbols
|
|
139
|
+
`- _ . ! ? ' " [ ] = + ^ (space)`
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Wiring Example — Raspberry Pi Pico / Pico 2W
|
|
144
|
+
|
|
145
|
+
| Segment | Pico Pin |
|
|
146
|
+
|---------|----------|
|
|
147
|
+
| a | GP2 |
|
|
148
|
+
| b | GP3 |
|
|
149
|
+
| c | GP4 |
|
|
150
|
+
| d | GP5 |
|
|
151
|
+
| e | GP6 |
|
|
152
|
+
| f | GP7 |
|
|
153
|
+
| g | GP8 |
|
|
154
|
+
| dp | GP9 |
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Examples
|
|
159
|
+
|
|
160
|
+
| File | Description |
|
|
161
|
+
|------|-------------|
|
|
162
|
+
| `sevenseg_simpletest.py` | Basic 0–9 counter |
|
|
163
|
+
| `sevenseg_all_chars.py` | All supported characters |
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## License
|
|
169
|
+
|
|
170
|
+
MIT License © 2026 Kritish Mohapatra
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Author
|
|
175
|
+
|
|
176
|
+
**Kritish Mohapatra**
|
|
177
|
+
- GitHub: [@kritishmohapatra](https://github.com/kritishmohapatra)
|
|
178
|
+
- MicroPython version: [micropython-sevenseg](https://github.com/kritishmohapatra/micropython-sevenseg)
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Kritish Mohapatra
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
"""CircuitPython library for controlling single-digit 7-segment displays."""
|
|
5
|
+
|
|
6
|
+
import digitalio
|
|
7
|
+
_DIGITS = {
|
|
8
|
+
0: (1, 1, 1, 1, 1, 1, 0),
|
|
9
|
+
1: (0, 1, 1, 0, 0, 0, 0),
|
|
10
|
+
2: (1, 1, 0, 1, 1, 0, 1),
|
|
11
|
+
3: (1, 1, 1, 1, 0, 0, 1),
|
|
12
|
+
4: (0, 1, 1, 0, 0, 1, 1),
|
|
13
|
+
5: (1, 0, 1, 1, 0, 1, 1),
|
|
14
|
+
6: (1, 0, 1, 1, 1, 1, 1),
|
|
15
|
+
7: (1, 1, 1, 0, 0, 0, 0),
|
|
16
|
+
8: (1, 1, 1, 1, 1, 1, 1),
|
|
17
|
+
9: (1, 1, 1, 1, 0, 1, 1),
|
|
18
|
+
'A': (1, 1, 1, 0, 1, 1, 1),
|
|
19
|
+
'B': (0, 0, 1, 1, 1, 1, 1),
|
|
20
|
+
'C': (1, 0, 0, 1, 1, 1, 0),
|
|
21
|
+
'D': (0, 1, 1, 1, 1, 0, 1),
|
|
22
|
+
'E': (1, 0, 0, 1, 1, 1, 1),
|
|
23
|
+
'F': (1, 0, 0, 0, 1, 1, 1),
|
|
24
|
+
'G': (1, 0, 1, 1, 1, 1, 1),
|
|
25
|
+
'H': (0, 1, 1, 0, 1, 1, 1),
|
|
26
|
+
'I': (0, 0, 0, 0, 1, 1, 0),
|
|
27
|
+
'J': (0, 1, 1, 1, 1, 0, 0),
|
|
28
|
+
'L': (0, 0, 0, 1, 1, 1, 0),
|
|
29
|
+
'N': (1, 1, 1, 0, 1, 1, 0),
|
|
30
|
+
'O': (1, 1, 1, 1, 1, 1, 0),
|
|
31
|
+
'P': (1, 1, 0, 0, 1, 1, 1),
|
|
32
|
+
'Q': (1, 1, 1, 0, 0, 1, 1),
|
|
33
|
+
'R': (1, 0, 0, 0, 1, 1, 0),
|
|
34
|
+
'S': (1, 0, 1, 1, 0, 1, 1),
|
|
35
|
+
'T': (0, 0, 0, 1, 1, 1, 1),
|
|
36
|
+
'U': (0, 1, 1, 1, 1, 1, 0),
|
|
37
|
+
'Y': (0, 1, 1, 1, 0, 1, 1),
|
|
38
|
+
'Z': (1, 1, 0, 1, 1, 0, 1),
|
|
39
|
+
'a': (1, 1, 1, 1, 1, 0, 1),
|
|
40
|
+
'b': (0, 0, 1, 1, 1, 1, 1),
|
|
41
|
+
'c': (0, 0, 0, 1, 1, 0, 1),
|
|
42
|
+
'd': (0, 1, 1, 1, 1, 0, 1),
|
|
43
|
+
'e': (1, 1, 0, 1, 1, 1, 1),
|
|
44
|
+
'f': (1, 0, 0, 0, 1, 1, 1),
|
|
45
|
+
'g': (1, 1, 1, 1, 0, 1, 1),
|
|
46
|
+
'h': (0, 0, 1, 0, 1, 1, 1),
|
|
47
|
+
'i': (0, 0, 1, 0, 0, 0, 0),
|
|
48
|
+
'j': (0, 1, 1, 1, 0, 0, 0),
|
|
49
|
+
'l': (0, 0, 0, 1, 1, 1, 0),
|
|
50
|
+
'n': (0, 0, 1, 0, 1, 0, 1),
|
|
51
|
+
'o': (0, 0, 1, 1, 1, 0, 1),
|
|
52
|
+
'p': (1, 1, 0, 0, 1, 1, 1),
|
|
53
|
+
'q': (1, 1, 1, 0, 0, 1, 1),
|
|
54
|
+
'r': (0, 0, 0, 0, 1, 0, 1),
|
|
55
|
+
's': (1, 0, 1, 1, 0, 1, 1),
|
|
56
|
+
't': (0, 0, 0, 1, 1, 1, 1),
|
|
57
|
+
'u': (0, 0, 1, 1, 1, 0, 0),
|
|
58
|
+
'y': (0, 1, 1, 1, 0, 1, 1),
|
|
59
|
+
# ── Symbols ──────────────────────────────
|
|
60
|
+
'-': (0, 0, 0, 0, 0, 0, 1),
|
|
61
|
+
'_': (0, 0, 0, 1, 0, 0, 0),
|
|
62
|
+
'.': (0, 0, 0, 0, 0, 0, 0), # dp only — use dp=True
|
|
63
|
+
'!': (0, 1, 1, 0, 0, 0, 0), # like 1, dp=True for !
|
|
64
|
+
'?': (1, 1, 0, 0, 1, 0, 1),
|
|
65
|
+
"'": (0, 0, 0, 0, 0, 1, 0),
|
|
66
|
+
'"': (0, 1, 0, 0, 0, 1, 0),
|
|
67
|
+
'[': (1, 0, 0, 1, 1, 1, 0),
|
|
68
|
+
']': (1, 1, 1, 1, 0, 0, 0),
|
|
69
|
+
'=': (0, 0, 0, 1, 0, 0, 1),
|
|
70
|
+
'+': (0, 0, 1, 0, 1, 0, 1),
|
|
71
|
+
'^': (1, 1, 0, 0, 0, 1, 0),
|
|
72
|
+
' ': (0, 0, 0, 0, 0, 0, 0),
|
|
73
|
+
}
|
|
74
|
+
class SevenSeg:
|
|
75
|
+
def __init__(self, pins, common_anode=False):
|
|
76
|
+
if len(pins)!=8:
|
|
77
|
+
raise ValueError("Exactly 8 pins required: [a, b, c, d, e, f, g, dp]")
|
|
78
|
+
self.common_anode=common_anode
|
|
79
|
+
self._pins=[]
|
|
80
|
+
for pin in pins:
|
|
81
|
+
p = digitalio.DigitalInOut(pin)
|
|
82
|
+
p.direction = digitalio.Direction.OUTPUT
|
|
83
|
+
p.value = False
|
|
84
|
+
self._pins.append(p)
|
|
85
|
+
self.clear()
|
|
86
|
+
def _write(self, segments, dp=False):
|
|
87
|
+
for i, val in enumerate(segments):
|
|
88
|
+
if self.common_anode:
|
|
89
|
+
self._pins[i].value=not bool(val)
|
|
90
|
+
else:
|
|
91
|
+
self._pins[i].value=bool(val)
|
|
92
|
+
if self.common_anode:
|
|
93
|
+
self._pins[7].value=not bool(dp)
|
|
94
|
+
else:
|
|
95
|
+
self._pins[7].value=bool(dp)
|
|
96
|
+
def show(self, char, dp=False):
|
|
97
|
+
if isinstance(char, str) and len(char)==1 and char.isdigit():
|
|
98
|
+
char=int(char)
|
|
99
|
+
if char not in _DIGITS:
|
|
100
|
+
raise ValueError(f"Unsupported character: {char!r}")
|
|
101
|
+
segments=_DIGITS[char]
|
|
102
|
+
self._write(segments, dp)
|
|
103
|
+
def clear(self):
|
|
104
|
+
off=1 if self.common_anode else 0
|
|
105
|
+
for p in self._pins:
|
|
106
|
+
p.value=bool(off)
|
|
107
|
+
def dot(self, on=True):
|
|
108
|
+
if self.common_anode:
|
|
109
|
+
self._pins[7].value=not bool(on)
|
|
110
|
+
else:
|
|
111
|
+
self._pins[7].value=bool(on)
|
|
112
|
+
def deinit(self):
|
|
113
|
+
self.clear()
|
|
114
|
+
for pin in self._pins:
|
|
115
|
+
pin.deinit()
|
|
116
|
+
|
|
117
|
+
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: circuitpython-sevenseg
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A lightweight CircuitPython library for controlling single-digit 7-segment displays
|
|
5
|
+
Author-email: Kritish Mohapatra <kritishmohapatra06norisk@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/kritishmohapatra/circuitpython-sevenseg
|
|
7
|
+
Keywords: circuitpython,seven-segment,7-segment,display,iot,embedded,pico,esp32
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: System :: Hardware
|
|
13
|
+
Requires-Python: >=3.0
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# circuitpython-sevenseg
|
|
17
|
+
|
|
18
|
+
A lightweight CircuitPython library for controlling single digit 7 segment displays (common cathode or common anode).
|
|
19
|
+
|
|
20
|
+
Supports **digits, uppercase & lowercase letters, and symbols** works on Raspberry Pi Pico, Adafruit Feather, Seeed XIAO ESP32-S3, and any CircuitPython-supported board.
|
|
21
|
+
|
|
22
|
+
> CircuitPython port of [micropython-sevenseg](https://github.com/kritishmohapatra/micropython-sevenseg)
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
Copy the `circuitpython_sevenseg/` folder to the `lib/` directory on your `CIRCUITPY` drive:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
CIRCUITPY/
|
|
32
|
+
└── lib/
|
|
33
|
+
└── circuitpython_sevenseg/
|
|
34
|
+
├── __init__.py
|
|
35
|
+
└── sevenseg.py
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Pin Diagram
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
---a---
|
|
44
|
+
| |
|
|
45
|
+
f b
|
|
46
|
+
| |
|
|
47
|
+
---g---
|
|
48
|
+
| |
|
|
49
|
+
e c
|
|
50
|
+
| |
|
|
51
|
+
---d--- ● dp
|
|
52
|
+
|
|
53
|
+
Pin order: [a, b, c, d, e, f, g, dp]
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Quick Start
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
import board
|
|
62
|
+
import time
|
|
63
|
+
from circuitpython_sevenseg import SevenSeg
|
|
64
|
+
|
|
65
|
+
seg = SevenSeg(
|
|
66
|
+
pins=[board.GP2, board.GP3, board.GP4, board.GP5,
|
|
67
|
+
board.GP6, board.GP7, board.GP8, board.GP9],
|
|
68
|
+
common_anode=False
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# Show a digit
|
|
72
|
+
seg.show(5)
|
|
73
|
+
|
|
74
|
+
# Show a letter
|
|
75
|
+
seg.show('A')
|
|
76
|
+
|
|
77
|
+
# Show with decimal point
|
|
78
|
+
seg.show(3, dp=True)
|
|
79
|
+
|
|
80
|
+
# Turn on decimal point only
|
|
81
|
+
seg.dot(True)
|
|
82
|
+
|
|
83
|
+
# Clear display
|
|
84
|
+
seg.clear()
|
|
85
|
+
|
|
86
|
+
# Release pins
|
|
87
|
+
seg.deinit()
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## API Reference
|
|
93
|
+
|
|
94
|
+
### `SevenSeg(pins, common_anode=False)`
|
|
95
|
+
|
|
96
|
+
Initializes the display.
|
|
97
|
+
|
|
98
|
+
| Parameter | Type | Description |
|
|
99
|
+
|---|---|---|
|
|
100
|
+
| `pins` | list | 8 pin objects in order `[a, b, c, d, e, f, g, dp]` |
|
|
101
|
+
| `common_anode` | bool | `True` for common anode, `False` for common cathode (default) |
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
### `show(char, dp=False)`
|
|
106
|
+
|
|
107
|
+
Displays a character on the 7-segment display.
|
|
108
|
+
|
|
109
|
+
| Parameter | Type | Description |
|
|
110
|
+
|---|---|---|
|
|
111
|
+
| `char` | int or str | Digit `0–9` or supported character (see table below) |
|
|
112
|
+
| `dp` | bool | Also turn on decimal point (default `False`) |
|
|
113
|
+
|
|
114
|
+
Raises `ValueError` if character is not supported.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
### `clear()`
|
|
119
|
+
|
|
120
|
+
Turns off all segments including the decimal point.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
### `dot(on=True)`
|
|
125
|
+
|
|
126
|
+
Toggles the decimal point without affecting other segments.
|
|
127
|
+
|
|
128
|
+
| Parameter | Type | Description |
|
|
129
|
+
|---|---|---|
|
|
130
|
+
| `on` | bool | `True` = on, `False` = off (default `True`) |
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
### `deinit()`
|
|
135
|
+
|
|
136
|
+
Releases all GPIO pins. Call when done to free resources.
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Supported Characters
|
|
141
|
+
|
|
142
|
+
### Digits
|
|
143
|
+
`0 1 2 3 4 5 6 7 8 9`
|
|
144
|
+
|
|
145
|
+
### Uppercase Letters
|
|
146
|
+
`A B C D E F G H I J L N O P Q R S T U Y Z`
|
|
147
|
+
|
|
148
|
+
> K, M, V, W, X not supported — physically impossible on 7-segment display.
|
|
149
|
+
|
|
150
|
+
### Lowercase Letters
|
|
151
|
+
`a b c d e f g h i j l n o p q r s t u y`
|
|
152
|
+
|
|
153
|
+
### Symbols
|
|
154
|
+
`- _ . ! ? ' " [ ] = + ^ (space)`
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Wiring Example — Raspberry Pi Pico / Pico 2W
|
|
159
|
+
|
|
160
|
+
| Segment | Pico Pin |
|
|
161
|
+
|---------|----------|
|
|
162
|
+
| a | GP2 |
|
|
163
|
+
| b | GP3 |
|
|
164
|
+
| c | GP4 |
|
|
165
|
+
| d | GP5 |
|
|
166
|
+
| e | GP6 |
|
|
167
|
+
| f | GP7 |
|
|
168
|
+
| g | GP8 |
|
|
169
|
+
| dp | GP9 |
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Examples
|
|
174
|
+
|
|
175
|
+
| File | Description |
|
|
176
|
+
|------|-------------|
|
|
177
|
+
| `sevenseg_simpletest.py` | Basic 0–9 counter |
|
|
178
|
+
| `sevenseg_all_chars.py` | All supported characters |
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## License
|
|
184
|
+
|
|
185
|
+
MIT License © 2026 Kritish Mohapatra
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Author
|
|
190
|
+
|
|
191
|
+
**Kritish Mohapatra**
|
|
192
|
+
- GitHub: [@kritishmohapatra](https://github.com/kritishmohapatra)
|
|
193
|
+
- MicroPython version: [micropython-sevenseg](https://github.com/kritishmohapatra/micropython-sevenseg)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
circuitpython_sevenseg/__init__.py
|
|
5
|
+
circuitpython_sevenseg/sevenseg.py
|
|
6
|
+
circuitpython_sevenseg.egg-info/PKG-INFO
|
|
7
|
+
circuitpython_sevenseg.egg-info/SOURCES.txt
|
|
8
|
+
circuitpython_sevenseg.egg-info/dependency_links.txt
|
|
9
|
+
circuitpython_sevenseg.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "circuitpython-sevenseg"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "A lightweight CircuitPython library for controlling single-digit 7-segment displays"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [{name = "Kritish Mohapatra", email = "kritishmohapatra06norisk@gmail.com"}]
|
|
11
|
+
requires-python = ">=3.0"
|
|
12
|
+
keywords = ["circuitpython", "seven-segment", "7-segment", "display", "iot", "embedded", "pico", "esp32"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 5 - Production/Stable",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Topic :: System :: Hardware",
|
|
19
|
+
]
|
|
20
|
+
[project.urls]
|
|
21
|
+
Homepage = "https://github.com/kritishmohapatra/circuitpython-sevenseg"
|
|
22
|
+
|
|
23
|
+
[tool.setuptools.packages.find]
|
|
24
|
+
exclude = ["examples*", "tests*"]
|
|
25
|
+
|
|
26
|
+
[tool.setuptools]
|
|
27
|
+
license-files = []
|