Пример #1
0
    print('This tool shows the character map of your LCD on the display.')
    print('Press ctrl+c at any time to abort.\n')

    page = 0
    chars_per_page = rows * cols

    try:
        while True:
            page_start = page * chars_per_page
            page_end = page_start + chars_per_page
            if page_end > 256:
                page_end = 256
            lcd.clear()
            print('Displaying page %d (characters %d-%d).' %
                  (page, page_start, page_end - 1))
            for i in range(page_start, page_end):
                if i < 255:
                    lcd.write_string(unichr(i))
                else:
                    lcd.write_string(unichr(i))
                    safe_input('Press <ENTER> to exit.')
                    lcd.clear()
                    sys.exit(0)
            page += 1
            safe_input('Press <ENTER> to continue.')
    except KeyboardInterrupt:
        print('Aborting.')

    lcd.clear()
Пример #2
0
    print('This tool shows the character map of your LCD on the display.')
    print('Press ctrl+c at any time to abort.\n')

    page = 0
    chars_per_page = rows * cols

    try:
        while True:
            page_start = page * chars_per_page
            page_end = page_start + chars_per_page
            if page_end > 256:
                page_end = 256
            lcd.clear()
            print('Displaying page %d (characters %d-%d).' %
                       (page, page_start, page_end - 1))
            for i in range(page_start, page_end):
                if i < 255:
                    lcd.write_string(unichr(i))
                else:
                    lcd.write_string(unichr(i))
                    safe_input('Press <ENTER> to exit.')
                    lcd.clear()
                    sys.exit(0)
            page += 1
            safe_input('Press <ENTER> to continue.')
    except KeyboardInterrupt:
        print('Aborting.')

    lcd.clear()
Пример #3
0
try:
    unichr = unichr
except NameError:
    unichr = chr

lcd = CharLCD(address=0x38, port=1, cols=20, rows=4, dotsize=8)

input('Display should be blank. ')

lcd.cursor_mode = CursorMode.blink
input('The cursor should now blink. ')

lcd.cursor_mode = CursorMode.line
input('The cursor should now be a line. ')

lcd.write_string('Hello world!')
input('"Hello world!" should be on the LCD. ')

assert lcd.cursor_pos == (0, 12), 'cursor_pos should now be (0, 12)'

lcd.cursor_pos = (1, 0)
lcd.write_string('2')
lcd.cursor_pos = (2, 0)
lcd.write_string('3')
lcd.cursor_pos = (3, 0)
lcd.write_string('4')
assert lcd.cursor_pos == (3, 1), 'cursor_pos should now be (3, 1)'
input('Lines 2, 3 and 4 should now be labelled with the right numbers. ')

lcd.clear()
input('Display should now be clear, cursor should be at initial position. ')
Пример #4
0
    unichr = unichr
except NameError:
    unichr = chr


lcd = CharLCD(address=0x38, port=1, cols=20, rows=4, dotsize=8)

input('Display should be blank. ')

lcd.cursor_mode = CursorMode.blink
input('The cursor should now blink. ')

lcd.cursor_mode = CursorMode.line
input('The cursor should now be a line. ')

lcd.write_string('Hello world!')
input('"Hello world!" should be on the LCD. ')

assert lcd.cursor_pos == (0, 12), 'cursor_pos should now be (0, 12)'

lcd.cursor_pos = (1, 0)
lcd.write_string('2')
lcd.cursor_pos = (2, 0)
lcd.write_string('3')
lcd.cursor_pos = (3, 0)
lcd.write_string('4')
assert lcd.cursor_pos == (3, 1), 'cursor_pos should now be (3, 1)'
input('Lines 2, 3 and 4 should now be labelled with the right numbers. ')

lcd.clear()
input('Display should now be clear, cursor should be at initial position. ')
Пример #5
0
    unichr = unichr
except NameError:
    unichr = chr


lcd = CharLCD(address=0x3F, port=1, cols=16, rows=2, dotsize=8)

input('Display should be blank. ')

lcd.cursor_mode = CursorMode.blink
input('The cursor should now blink. ')

lcd.cursor_mode = CursorMode.line
input('The cursor should now be a line. ')

lcd.write_string('Hello world!')
input('"Hello world!" should be on the LCD. ')

assert lcd.cursor_pos == (0, 12), 'cursor_pos should now be (0, 12)'

lcd.cursor_pos = (1, 0)
lcd.write_string('2')
assert lcd.cursor_pos == (1, 1), 'cursor_pos should now be (2, 1)'
input('Lines 2, should now be labelled with the right number. ')

lcd.clear()
input('Display should now be clear, cursor should be at initial position. ')

lcd.cursor_pos = (0, 5)
lcd.write_string('12345')
input('The string should have a left offset of 5 characters. ')