circuitpython-sevenseg 1.0.0__py3-none-any.whl

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.
@@ -0,0 +1,8 @@
1
+ # SPDX-FileCopyrightText: 2026 Kritish Mohapatra
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ from .sevenseg import SevenSeg, _DIGITS
5
+
6
+ __version__ = "1.0.0"
7
+ __author__ = "Kritish Mohapatra"
8
+ __license__ = "MIT"
@@ -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,6 @@
1
+ circuitpython_sevenseg/__init__.py,sha256=7twH2fxqbt8p9JYrYzzT9Dk9fqs64jVf7uuqOjUjyhU,203
2
+ circuitpython_sevenseg/sevenseg.py,sha256=7rYvwCQ3wn3FrcSdVSxeomm80JsyHQJcTUn4QGTlYWc,4143
3
+ circuitpython_sevenseg-1.0.0.dist-info/METADATA,sha256=o46Fm_y__ZJDzvPRCZomzrtxadCjU71HwYzHSKHwDyk,4126
4
+ circuitpython_sevenseg-1.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
5
+ circuitpython_sevenseg-1.0.0.dist-info/top_level.txt,sha256=YdPpWOGpYlyzu3SF2b03nG_1OvAqQyWl9puCcRASfEI,23
6
+ circuitpython_sevenseg-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ circuitpython_sevenseg