Writes a command to the LCD. Data is latched on the falling edge of E.
(self, cmd)
| 58 | self.i2c.writeto(self.i2c_addr, bytearray([0])) |
| 59 | |
| 60 | def hal_write_command(self, cmd): |
| 61 | """Writes a command to the LCD. |
| 62 | |
| 63 | Data is latched on the falling edge of E. |
| 64 | """ |
| 65 | byte = ((self.backlight << SHIFT_BACKLIGHT) | (((cmd >> 4) & 0x0f) << SHIFT_DATA)) |
| 66 | self.i2c.writeto(self.i2c_addr, bytearray([byte | MASK_E])) |
| 67 | self.i2c.writeto(self.i2c_addr, bytearray([byte])) |
| 68 | byte = ((self.backlight << SHIFT_BACKLIGHT) | ((cmd & 0x0f) << SHIFT_DATA)) |
| 69 | self.i2c.writeto(self.i2c_addr, bytearray([byte | MASK_E])) |
| 70 | self.i2c.writeto(self.i2c_addr, bytearray([byte])) |
| 71 | if cmd <= 3: |
| 72 | # The home and clear commands require a worst case delay of 4.1 msec |
| 73 | sleep(0.005) |
| 74 | |
| 75 | def hal_write_data(self, data): |
| 76 | """Write data to the LCD.""" |