]> vault307.fbx.one Git - RPI-PICO-I2C-LCD.git/blobdiff - pico_i2c_lcd.py
Update pico_i2c_lcd_test.py
[RPI-PICO-I2C-LCD.git] / pico_i2c_lcd.py
index d7941d881d951118523d5f298a662ad2a52d5fad..d81ee852331fb0b46997591386c17e77beff28fc 100644 (file)
@@ -18,7 +18,7 @@ class I2cLcd(LcdApi):
     def __init__(self, i2c, i2c_addr, num_lines, num_columns):
         self.i2c = i2c
         self.i2c_addr = i2c_addr
     def __init__(self, i2c, i2c_addr, num_lines, num_columns):
         self.i2c = i2c
         self.i2c_addr = i2c_addr
-        self.i2c.writeto(self.i2c_addr, bytearray([0]))
+        self.i2c.writeto(self.i2c_addr, bytes([0]))
         utime.sleep_ms(20)   # Allow LCD time to powerup
         # Send reset 3 times
         self.hal_write_init_nibble(self.LCD_FUNCTION_RESET)
         utime.sleep_ms(20)   # Allow LCD time to powerup
         # Send reset 3 times
         self.hal_write_init_nibble(self.LCD_FUNCTION_RESET)
@@ -40,27 +40,27 @@ class I2cLcd(LcdApi):
         # Writes an initialization nibble to the LCD.
         # This particular function is only used during initialization.
         byte = ((nibble >> 4) & 0x0f) << SHIFT_DATA
         # Writes an initialization nibble to the LCD.
         # This particular function is only used during initialization.
         byte = ((nibble >> 4) & 0x0f) << SHIFT_DATA
-        self.i2c.writeto(self.i2c_addr, bytearray([byte | MASK_E]))
-        self.i2c.writeto(self.i2c_addr, bytearray([byte]))
+        self.i2c.writeto(self.i2c_addr, bytes([byte | MASK_E]))
+        self.i2c.writeto(self.i2c_addr, bytes([byte]))
         
     def hal_backlight_on(self):
         # Allows the hal layer to turn the backlight on
         
     def hal_backlight_on(self):
         # Allows the hal layer to turn the backlight on
-        self.i2c.writeto(self.i2c_addr, bytearray([1 << SHIFT_BACKLIGHT]))
+        self.i2c.writeto(self.i2c_addr, bytes([1 << SHIFT_BACKLIGHT]))
         
     def hal_backlight_off(self):
         #Allows the hal layer to turn the backlight off
         
     def hal_backlight_off(self):
         #Allows the hal layer to turn the backlight off
-        self.i2c.writeto(self.i2c_addr, bytearray([0]))
+        self.i2c.writeto(self.i2c_addr, bytes([0]))
         
     def hal_write_command(self, cmd):
         # Write a command to the LCD. Data is latched on the falling edge of E.
         byte = ((self.backlight << SHIFT_BACKLIGHT) |
                 (((cmd >> 4) & 0x0f) << SHIFT_DATA))
         
     def hal_write_command(self, cmd):
         # Write a command to the LCD. Data is latched on the falling edge of E.
         byte = ((self.backlight << SHIFT_BACKLIGHT) |
                 (((cmd >> 4) & 0x0f) << SHIFT_DATA))
-        self.i2c.writeto(self.i2c_addr, bytearray([byte | MASK_E]))
-        self.i2c.writeto(self.i2c_addr, bytearray([byte]))
+        self.i2c.writeto(self.i2c_addr, bytes([byte | MASK_E]))
+        self.i2c.writeto(self.i2c_addr, bytes([byte]))
         byte = ((self.backlight << SHIFT_BACKLIGHT) |
                 ((cmd & 0x0f) << SHIFT_DATA))
         byte = ((self.backlight << SHIFT_BACKLIGHT) |
                 ((cmd & 0x0f) << SHIFT_DATA))
-        self.i2c.writeto(self.i2c_addr, bytearray([byte | MASK_E]))
-        self.i2c.writeto(self.i2c_addr, bytearray([byte]))
+        self.i2c.writeto(self.i2c_addr, bytes([byte | MASK_E]))
+        self.i2c.writeto(self.i2c_addr, bytes([byte]))
         if cmd <= 3:
             # The home and clear commands require a worst case delay of 4.1 msec
             utime.sleep_ms(5)
         if cmd <= 3:
             # The home and clear commands require a worst case delay of 4.1 msec
             utime.sleep_ms(5)
@@ -70,10 +70,10 @@ class I2cLcd(LcdApi):
         byte = (MASK_RS |
                 (self.backlight << SHIFT_BACKLIGHT) |
                 (((data >> 4) & 0x0f) << SHIFT_DATA))
         byte = (MASK_RS |
                 (self.backlight << SHIFT_BACKLIGHT) |
                 (((data >> 4) & 0x0f) << SHIFT_DATA))
-        self.i2c.writeto(self.i2c_addr, bytearray([byte | MASK_E]))
-        self.i2c.writeto(self.i2c_addr, bytearray([byte]))
+        self.i2c.writeto(self.i2c_addr, bytes([byte | MASK_E]))
+        self.i2c.writeto(self.i2c_addr, bytes([byte]))
         byte = (MASK_RS |
                 (self.backlight << SHIFT_BACKLIGHT) |
                 ((data & 0x0f) << SHIFT_DATA))      
         byte = (MASK_RS |
                 (self.backlight << SHIFT_BACKLIGHT) |
                 ((data & 0x0f) << SHIFT_DATA))      
-        self.i2c.writeto(self.i2c_addr, bytearray([byte | MASK_E]))
-        self.i2c.writeto(self.i2c_addr, bytearray([byte]))
+        self.i2c.writeto(self.i2c_addr, bytes([byte | MASK_E]))
+        self.i2c.writeto(self.i2c_addr, bytes([byte]))