| 48 | # ------------------------------------------------------------------ |
| 49 | |
| 50 | def init(self): |
| 51 | if not _LUMA_AVAILABLE: |
| 52 | raise RuntimeError("luma.led_matrix is required for MAX7219. Install: pip3 install luma.led_matrix") |
| 53 | serial = _spi(port=self.spi_port, device=self.spi_device, gpio=_noop()) |
| 54 | self._device = _max7219_dev( |
| 55 | serial, |
| 56 | cascaded=self.cascaded, |
| 57 | block_orientation=self.block_orientation, |
| 58 | rotate=0, |
| 59 | blocks_arranged_in_reverse_order=False, |
| 60 | ) |
| 61 | # luma contrast is 0–255; map from 0–15 |
| 62 | self._device.contrast(self._brightness * 17) |
| 63 | # Force-clear the display — MAX7219 powers on with all pixels lit |
| 64 | self._device.clear() |
| 65 | logger.info(f"MAX7219 initialised ({self.width}×{self.height}) cascaded={self.cascaded} brightness={self._brightness}") |
| 66 | |
| 67 | def Clear(self): |
| 68 | if self._device: |