Write *text* to the given *row* (0 or 1), padded/truncated to 16 chars. Non-ASCII characters are replaced with '?' since the HD44780 ROM only covers ASCII + Japanese kana glyphs. This is the primary method used by the display loop.
(self, row: int, text: str)
| 109 | logger.debug("LCD1602 cleared") |
| 110 | |
| 111 | def write_line(self, row: int, text: str): |
| 112 | """Write *text* to the given *row* (0 or 1), padded/truncated to 16 chars. |
| 113 | |
| 114 | Non-ASCII characters are replaced with '?' since the HD44780 ROM only |
| 115 | covers ASCII + Japanese kana glyphs. This is the primary method used |
| 116 | by the display loop. |
| 117 | """ |
| 118 | if not self._initialized: |
| 119 | self.init() |
| 120 | row = max(0, min(row, LCD_HEIGHT - 1)) |
| 121 | text = text.encode("ascii", errors="replace").decode("ascii") |
| 122 | text = text.ljust(LCD_WIDTH)[:LCD_WIDTH] |
| 123 | self._set_cursor(row, 0) |
| 124 | for ch in text: |
| 125 | self._send_data(ord(ch)) |
| 126 | |
| 127 | def backlight(self, on: bool = True): |
| 128 | """Turn the backlight on or off.""" |
no test coverage detected