コード例 #1
0
lcd.cursor_pos = (0, 5)
lcd.write_string('12345')
input('The string should have a left offset of 5 characters. ')

lcd.write_shift_mode = ShiftMode.display
lcd.cursor_pos = (1, 5)
lcd.write_string('12345')
input('Both strings should now be at column 0. ')

lcd.write_shift_mode = ShiftMode.cursor
lcd.cursor_pos = (1, 5)
lcd.write_string(lcd.write_shift_mode.name)
input('The string "cursor" should now be on the second row, column 0. ')

lcd.home()
input(
    'Cursor should now be at initial position. Everything should be shifted to the right by 5 characters. '
)

with cursor(lcd, 1, 15):
    lcd.write_string('X')
input('The last character on the LCD should now be an "X"')

lcd.display_enabled = False
input('Display should now be blank. ')

with cleared(lcd):
    lcd.write_string('Eggs, Ham\n\rand Spam')
lcd.display_enabled = True
input(
コード例 #2
0
# LCD Setup
lcd = CharLCD(numbering_mode=GPIO.BCM,
              pin_rs=0,
              pin_e=5,
              pins_data=[6, 13, 19, 26],
              cols=16,
              rows=2)
lcd.clear()

# Init values
temperature_path = glob.glob('/sys/bus/w1/devices/28-*')[0] + "/temperature"
previous_value_celcius = 0
count = 0

while (True):
    lcd.home()  # reset cursor to beginning
    # Read Temperature
    file = open(temperature_path)
    try:
        raw_temp = float(file.read())
    except:
        continue

    # Calculate Temperature
    value_celcius = round(raw_temp / 1000, 2)
    value_farenheit = round((value_celcius * (9.0 / 5.0)) + 32, 2)

    # Display Temperature
    lcd.write_string("Temperature")

    if (count % 2 == 0):