Esempio n. 1
0
def refresh(do_clear):
    # refresh the display
    if (do_clear):
        lcd.clear()
        lcd.home()
        global req_clear
        req_clear = False
    # version on row 0
    with cursor(lcd, row_version,row_version_indent):
        lcd.write_string(row_version_txt)
    if (row_msg_txt == ""):
        # no message, just display the Aquila on row 1
        with cursor(lcd, row_msg, 8):
            lcd.write_string(unichr(0))
            lcd.write_string(unichr(1))
            lcd.write_string(unichr(2))
            lcd.write_string(unichr(3))
    else:
        # we have a message, display that instead
        with cursor(lcd, row_msg, calc_indent(row_msg_txt)):
            lcd.write_string(row_msg_txt)
        
    # MET on row 2
    with cursor(lcd,row_met,row_met_indent):
        lcd.write_string('MET ' + format_met())
    # score on row 3
    with cursor(lcd,row_score,row_score_indent):
        lcd.write_string(format_score())

    # ensure cursor is in the right position
    position_cursor()
Esempio n. 2
0
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('Display should now show "Eggs, Ham and Spam" with a line break after "Ham". ')

lcd.shift_display(4)
input('Text should now be shifted to the right by 4 characters. ')
lcd.shift_display(-4)
input('Shift should now be undone. ')
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(
    'Display should now show "Eggs, Ham and Spam" with a line break after "Ham". '
)

lcd.shift_display(4)
input('Text should now be shifted to the right by 4 characters. ')
Esempio n. 4
0
def main():

    #   on lit les sondes

    #   point froid
    humidity, temperature = Adafruit_DHT.read_retry(Adafruit_DHT.DHT22, 22)
    #  point chaud
    humidityC, temperatureC = Adafruit_DHT.read_retry(Adafruit_DHT.DHT22, 27)

    # on arrondi a 2 chiffres
    humidity = round(humidity, 2)
    temperature = round(temperature, 2)
    humidityC = round(humidityC, 2)
    temperatureC = round(temperatureC, 2)

    lcd = CharLCD(cols=16,
                  rows=2,
                  pin_rw=None,
                  pin_rs=7,
                  pin_e=8,
                  pins_data=[25, 24, 23, 18],
                  pin_backlight=13,
                  backlight_enabled=True,
                  numbering_mode=GPIO.BCM)

    with cleared(lcd):
        lcd.create_char(2, tete)
        lcd.create_char(3, corpsbas)
        lcd.create_char(4, corpshaut)
        lcd.write_string(unichr(3))
        lcd.write_string(unichr(4))
        lcd.write_string(unichr(3))
        lcd.write_string(unichr(4))
        lcd.write_string(unichr(3))
        lcd.write_string(unichr(4))
        lcd.write_string(unichr(2))
        lcd.write_string(u'  ')
        lcd.write_string(unichr(2))
        lcd.write_string(unichr(4))
        lcd.write_string(unichr(3))
        lcd.write_string(unichr(4))
        lcd.write_string(unichr(3))
        lcd.write_string(unichr(4))
        lcd.write_string(unichr(3))

    with cursor(lcd, 1, 0):
        lcd.create_char(1, coeur)
        lcd.write_string(unichr(1))
        lcd.write_string(unichr(1))
        lcd.write_string(unichr(1))
        lcd.write_string(u'  Salut ! ')
        lcd.write_string(unichr(1))
        lcd.write_string(unichr(1))
        lcd.write_string(unichr(1))

    time.sleep(4)

    with cleared(lcd):
        lcd.write_string(u'Point chaud :')

    with cursor(lcd, 1, 0):
        lcd.write_string(u' Temp = %s ' % temperatureC)
        lcd.create_char(0, degres)
        lcd.write_string(unichr(0))
        lcd.write_string(u'C')

    time.sleep(5)

    with cleared(lcd):
        lcd.write_string(u'Point chaud :')

    with cursor(lcd, 1, 0):
        lcd.write_string(u' Humi = %s ' % humidityC)
        lcd.write_string(u'%')

    time.sleep(5)

    with cleared(lcd):
        lcd.write_string(u'Point froid :')

    with cursor(lcd, 1, 0):
        lcd.write_string(u' Temp = %s ' % temperature)
        lcd.create_char(0, degres)
        lcd.write_string(unichr(0))
        lcd.write_string(u'C')

    time.sleep(5)

    with cleared(lcd):
        lcd.write_string(u'Point froid :')

    with cursor(lcd, 1, 0):
        lcd.write_string(u' Humi = %s ' % humidity)
        lcd.write_string(u'%')

    time.sleep(5)

    with cleared(lcd):
        lcd.create_char(2, tete)
        lcd.create_char(3, corpsbas)
        lcd.create_char(4, corpshaut)
        lcd.write_string(unichr(3))
        lcd.write_string(unichr(4))
        lcd.write_string(unichr(3))
        lcd.write_string(unichr(4))
        lcd.write_string(unichr(3))
        lcd.write_string(unichr(4))
        lcd.write_string(unichr(2))
        lcd.write_string(u'  ')
        lcd.write_string(unichr(2))
        lcd.write_string(unichr(4))
        lcd.write_string(unichr(3))
        lcd.write_string(unichr(4))
        lcd.write_string(unichr(3))
        lcd.write_string(unichr(4))
        lcd.write_string(unichr(3))

    with cursor(lcd, 1, 0):
        lcd.create_char(1, coeur)
        lcd.write_string(unichr(1))
        lcd.write_string(unichr(1))
        lcd.write_string(unichr(1))
        lcd.write_string(u' Bye-bye ! ')
        lcd.write_string(unichr(1))
        lcd.write_string(unichr(1))
        lcd.write_string(unichr(1))

    time.sleep(4)

    lcd.close(clear=True)
Esempio n. 5
0
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 = (2, 5)
lcd.write_string(lcd.write_shift_mode.name)
input('The string "cursor" should now be on the third 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, 3, 19):
    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, Bacon\n\rand Spam')
lcd.display_enabled = True
input('Display should now show "Eggs, Ham, Bacon and Spam". ')

lcd.shift_display(4)
input('Text should now be shifted to the right by 4 characters. ')
lcd.shift_display(-4)
input('Shift should now be undone. ')
Esempio n. 6
0
 def _update_display(self):
     with cleared(self.lcd):
          self.lcd.write_string(self.line1)
     with cursor(self.lcd, 1, 0):
          self.lcd.write_string(self.line2)
Esempio n. 7
0
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 = (2, 5)
lcd.write_string(lcd.write_shift_mode.name)
input('The string "cursor" should now be on the third 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, 3, 19):
    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, Bacon\n\rand Spam')
lcd.display_enabled = True
input('Display should now show "Eggs, Ham, Bacon and Spam". ')

lcd.shift_display(4)
input('Text should now be shifted to the right by 4 characters. ')
lcd.shift_display(-4)
input('Shift should now be undone. ')
Esempio n. 8
0
# create the aquila characters
aquila0 = (0b01111,0b00011,0b00001,0b00000,0b00000,0b00000,0b00000,0b00000)
lcd.create_char(0,aquila0)
aquila1 = (0b11101,0b11000,0b11111,0b11111,0b01101,0b00001,0b00011,0b00010)
lcd.create_char(1,aquila1)
aquila2 = (0b01011,0b10001,0b11111,0b11111,0b11011,0b11000,0b11100,0b10100)
lcd.create_char(2,aquila2)
aquila3 = (0b11111,0b11100,0b11000,0b10000,0b00000,0b00000,0b00000,0b00000)
lcd.create_char(3,aquila3)

# prep the LCD
lcd.clear()
lcd.home()

with cursor(lcd, 0, 2):
    lcd.write_string('AUSPEX 410014.M2')
    # test github editor for spaces
    # OK it worked

# draw the aquila centred on line 2
with cursor(lcd, 1,8):
    lcd.write_string(unichr(0))
    lcd.write_string(unichr(1))
    lcd.write_string(unichr(2))
    lcd.write_string(unichr(3))

with cursor(lcd,2,4):
    lcd.write_string('MET: 1:22:45')

with cursor(lcd,3,2):