MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / write_line

Method write_line

resources/waveshare_epd/lcd1602.py:111–125  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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."""

Callers 1

_run_lcd1602Method · 0.95

Calls 5

initMethod · 0.95
_set_cursorMethod · 0.95
_send_dataMethod · 0.95
decodeMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected