Exemplo n.º 1
0
from RPLCD_i2c import CharLCD
from RPLCD_i2c import Alignment, CursorMode, ShiftMode
from RPLCD_i2c import cursor, cleared

try:
    input = raw_input
except NameError:
    pass

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)
Exemplo n.º 2
0
    safe_input = input

try:
    unichr = unichr
except NameError:  # Python 3
    unichr = chr

if __name__ == '__main__':
    if len(sys.argv) != 3:
        print('Usage: %s <rows> <cols>' % sys.argv[0])
        sys.exit(1)

    rows, cols = int(sys.argv[1]), int(sys.argv[2])
    lcd = CharLCD(address=0x3F,
                  port=1,
                  cols=cols,
                  rows=rows,
                  dotsize=8,
                  ignore_special=True)

    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
Exemplo n.º 3
0
            cur_hour = int(tens_hour) * 10 + int(hour)
            # enable backlight by night
            lcd.set_backlight(cur_hour >= 19 or cur_hour < 9)

        # dots blink
        clock_dots()

        if counter == 15:
            counter = 0
            # date display
            clock_date(digits, month, day_name)
            # temperature display
            clock_temp()
            # temperature display
            clock_hour(digits)


if __name__ == '__main__':

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

    try:
        main()
    except KeyboardInterrupt:
        pass
    finally:
        lcd.clear()
        lcd.set_backlight(False)
        lcd.home()