|
12 | 12 | from adafruit_ht16k33.ht16k33 import HT16K33 |
13 | 13 |
|
14 | 14 | try: |
15 | | - from typing import Union, List, Tuple |
| 15 | + from typing import Union, List, Tuple, Optional, Dict |
16 | 16 | from busio import I2C |
17 | 17 | except ImportError: |
18 | 18 | pass |
@@ -335,10 +335,17 @@ class Seg7x4(Seg14x4): |
335 | 335 |
|
336 | 336 | POSITIONS = (0, 2, 6, 8) # The positions of characters. |
337 | 337 |
|
338 | | - def __init__(self, i2c: I2C, address: int = 0x70, auto_write: bool = True) -> None: |
| 338 | + def __init__( |
| 339 | + self, |
| 340 | + i2c: I2C, |
| 341 | + address: int = 0x70, |
| 342 | + auto_write: bool = True, |
| 343 | + char_dict: Optional[Dict[str, int]] = None, |
| 344 | + ) -> None: |
339 | 345 | super().__init__(i2c, address, auto_write) |
340 | 346 | # Use colon for controling two-dots indicator at the center (index 0) |
341 | 347 | self._colon = Colon(self) |
| 348 | + self._chardict = char_dict |
342 | 349 |
|
343 | 350 | def scroll(self, count: int = 1) -> None: |
344 | 351 | """Scroll the display by specified number of places. |
@@ -370,8 +377,11 @@ def _put(self, char: str, index: int = 0) -> None: |
370 | 377 | # pylint: disable=too-many-return-statements |
371 | 378 | if not 0 <= index <= 3: |
372 | 379 | return |
373 | | - char = char.lower() |
374 | 380 | index = self.POSITIONS[index] |
| 381 | + if self._chardict and char in self._chardict: |
| 382 | + self._set_buffer(index, self._chardict[char]) |
| 383 | + return |
| 384 | + char = char.lower() |
375 | 385 | if char == ".": |
376 | 386 | self._set_buffer(index, self._get_buffer(index) | 0b10000000) |
377 | 387 | return |
@@ -438,11 +448,18 @@ class BigSeg7x4(Seg7x4): |
438 | 448 | `show` must be called explicitly. |
439 | 449 | """ |
440 | 450 |
|
441 | | - def __init__(self, i2c: I2C, address: int = 0x70, auto_write: bool = True) -> None: |
| 451 | + def __init__( |
| 452 | + self, |
| 453 | + i2c: I2C, |
| 454 | + address: int = 0x70, |
| 455 | + auto_write: bool = True, |
| 456 | + char_dict: Optional[Dict[str, int]] = None, |
| 457 | + ) -> None: |
442 | 458 | super().__init__(i2c, address, auto_write) |
443 | 459 | # Use colon for controling two-dots indicator at the center (index 0) |
444 | 460 | # or the two-dots indicators at the left (index 1) |
445 | 461 | self.colon = Colon(self, 2) |
| 462 | + self._chardict = char_dict |
446 | 463 |
|
447 | 464 | def _setindicator(self, index: int, value: bool) -> None: |
448 | 465 | """Set side LEDs (dots) |
|
0 commit comments