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

Method _init_sequence

resources/waveshare_epd/lcd1602.py:244–273  ·  view source on GitHub ↗

Run the HD44780 initialisation sequence for 4-bit operation.

(self)

Source from the content-addressed store, hash-verified

242 # ------------------------------------------------------------------
243
244 def _init_sequence(self):
245 """Run the HD44780 initialisation sequence for 4-bit operation."""
246 time.sleep(0.05) # wait >40 ms after VCC rises to 2.7 V
247
248 # Three wake-up writes in 8-bit mode (before switching to 4-bit)
249 for _ in range(3):
250 self._send_nibble(0x30, 0)
251 time.sleep(0.005)
252
253 # Switch to 4-bit mode
254 self._send_nibble(0x20, 0)
255 time.sleep(0.001)
256
257 # Function set: 4-bit, 2 lines, 5×8 font
258 self._send_cmd(_CMD_FUNCTIONSET | _FLAG_FUNCTION_2LINE | _FLAG_FUNCTION_5X8)
259 time.sleep(0.001)
260
261 # Display control: display ON, cursor OFF, blink OFF
262 self._send_cmd(_CMD_DISPLAYCONTROL | _FLAG_DISPLAY_ON)
263 time.sleep(0.001)
264
265 # Clear display
266 self._send_cmd(_CMD_CLEARDISPLAY)
267 time.sleep(0.002)
268
269 # Entry mode: increment cursor, no display shift
270 self._send_cmd(_CMD_ENTRYMODESET | _FLAG_ENTRY_INCREMENT)
271 time.sleep(0.001)
272
273 logger.debug("LCD1602 init sequence complete")

Callers 1

initMethod · 0.95

Calls 5

_send_nibbleMethod · 0.95
_send_cmdMethod · 0.95
rangeFunction · 0.85
debugMethod · 0.80
sleepMethod · 0.45

Tested by

no test coverage detected