Problem with LCD over UART after firmware update

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
Posts: 32
Joined: Fri Aug 22, 2014 5:42 pm

Problem with LCD over UART after firmware update

Post by riklaunim » Sun Oct 23, 2016 8:19 pm

I was using a LCD display with an UART interface some time ago. Few days ago I've updated the firmware to latest and I've notices that the UART doesn't have .send() method any more, only .write()

I had a code like:

Code: Select all

x.send(chr(1)+"some text"+chr(0xFF))
now with write I can't make it to work - LCD doesn't display anything. Are there any other UART changes?

My LCD class:

Code: Select all

import pyb

class LCD(object):
    END = chr(0xFF)

    def __init__(self, device, rows, columns):
        self.commands = {
            'display_string': chr(1),
            'set_cursor_position': chr(2),
            'clear_line': chr(3),
            'clear': chr(4),
            'set_lcd_type': chr(5),
            'backlight': chr(7)
        self.device = device
        self.rows = rows
        self.columns = columns
        self.connection = None

    def configure(self):
        self.connection = pyb.UART(self.device, 9600)
        self.execute_command('set_lcd_type', chr(self.rows) + chr(self.columns))

    def clear(self):
        self.execute_command('clear', '')

    def clear_line(self, line):
        self.execute_command('clear_line', chr(line))

    def set_backlight(self, brightness):
        self.execute_command('backlight', chr(brightness))

    def set_cursor_position(self, row, column):
        self.execute_command('set_cursor_position', chr(row) + chr(column))

    def display_string(self, string):
        self.execute_command('display_string', string)

    def close(self):

    def execute_command(self, command, payload):
        self.connection.send(self.commands[command] + payload + self.END)

Code: Select all

def do_serial_demo():
    lcd = LCD(3, rows=4, columns=20)
    accel = pyb.Accel()

    while True:
        lcd.set_cursor_position(1, 1)
        lcd.set_cursor_position(2, 1)

Post Reply