if len(args) > 0:
self.write_data(bytearray(args))
- def write_cmd_cpy(self, command, *args):
- """Write command to OLED (CircuitPython).
-
- Args:
- command (byte): ILI9341 command code.
- *args (optional bytes): Data to transmit.
- """
- self.dc.value = False
- self.cs.value = False
- # Confirm SPI locked before writing
- while not self.spi.try_lock():
- pass
- self.spi.write(bytearray([command]))
- self.spi.unlock()
- self.cs.value = True
- # Handle any passed data
- if len(args) > 0:
- self.write_data(bytearray(args))
-
def write_data_mpy(self, data):
"""Write data to OLED (MicroPython).
self.cs(0)
self.spi.write(data)
self.cs(1)
-
- def write_data_cpy(self, data):
- """Write data to OLED (CircuitPython).
-
- Args:
- data (bytes): Data to transmit.
- """
- self.dc.value = True
- self.cs.value = False
- # Confirm SPI locked before writing
- while not self.spi.try_lock():
- pass
- self.spi.write(data)
- self.spi.unlock()
- self.cs.value = True