Exemple #1
0
def main():
    sensor = Sensor(sensor_type, sensor_channel)
    lcd = CharLCD("PCF8574", 0x27)

    # add custom chars
    lcd.create_char(0, degrees)

    menu = {
        1: sensor_data(sensor, lcd),
        2: clock(),
        3: ip()
    }

    for i in menu.keys():
        show(lcd, menu[i])
        time.sleep(3)
        lcd.clear()
Exemple #2
0
    def _init_lcd(self):
        lcd = CharLCD(i2c_expander='PCF8574',
                      address=self._rsc.lcd_address,
                      port=1,
                      cols=20,
                      rows=4,
                      dotsize=8,
                      charmap='A00',
                      auto_linebreaks=True,
                      backlight_enabled=False)
        #self._lcd.backlight_enabled = False
        lcd.cursor_mode = "hide"
        wifi_char = (0b00000, 0b11111, 0b00000, 0b01110, 0b00000, 0b00100,
                     0b00100, 0b00000)
        backspace_char = (0b00000, 0b00000, 0b00111, 0b01001, 0b10001, 0b01001,
                          0b00111, 0b00000)
        enter_char = (0b00000, 0b00001, 0b00101, 0b01001, 0b11111, 0b01000,
                      0b00100, 0b00000)

        lcd.create_char(0, wifi_char)
        lcd.create_char(1, backspace_char)
        lcd.create_char(2, enter_char)
        return lcd
Exemple #3
0
    from RPi import GPIO
    lcd = CharLCD(cols=cols,
                  rows=rows,
                  charmap=charmap,
                  numbering_mode=GPIO.BOARD,
                  pin_rs=pin_rs,
                  pin_rw=pin_rw,
                  pin_e=pin_e,
                  pins_data=pins_data,
                  auto_linebreaks=False)

off = 0b00000
on = 0b11111
b = [(off, off, off, off, off, off, off, on),
     (off, off, off, off, off, off, on, on),
     (off, off, off, off, off, on, on, on),
     (off, off, off, off, on, on, on, on), (off, off, off, on, on, on, on, on),
     (off, off, on, on, on, on, on, on), (off, on, on, on, on, on, on, on),
     (on, on, on, on, on, on, on, on)]
for i in range(8):
    lcd.create_char(i, b[i - 1])
ib = ['', '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07']
# cava.conf: framerate = 4, ascii_max_range = 8
for line in iter(sys.stdin.readline, b''):
    val = line[:-2].split(';')
    str = ''
    for i in val:
        str = str + ib[int(i)]
    lcd.clear()
    lcd.write_string(str)
class ScreenManager:
    """Manages Screens

    Creates the arborescence needed for a LedPanel and manages it

    Please call cleanup() once you have finished.
    """
    def __init__(self, panel):
        self.panel = panel

        self.lcd_lock = threading.RLock()
        self.gpio_lock = threading.Lock()

        home = StartScreen('HOME', 'LedPanel 289', self,
                           'Made by N.V.Zuijlen')
        main_menu = MenuScreen('MAIN_MENU', 'Menu', self)
        manual_menu = MenuScreen('MANUAL_MENU', 'Manuel', self)
        universe_selector = ValueScreen('UNIVERSE_SELECTOR', 'Choix Univers', self,
                                        self.panel.start_universe, 0, math.inf)
        channel_selector = ValueScreen('CHANNEL_SELECTOR', 'Choix Adresse', self,
                                       self.panel.start_channel+1, 1, DMX_UNIVERSE_SIZE)
        blackout = ToggleScreen('BLACKOUT', 'Blackout', self)
        test_pattern = MacroScreen('TEST_PATTERN', 'Test leds', self,
                                   macros.TestPixels(panel.columns, panel.rows))
        ip_info = InformationScreen('IP_INFO', 'Adresse IP', self, get_ip_address())

        universe_selector.setCallback(lambda uni: self.panel.setAddress(universe=uni))
        channel_selector.setCallback(lambda chan: self.panel.setAddress(channel=chan))
        blackout.setCallback(lambda off: self.panel.setOnOff(not off))

        home.addChild(main_menu)

        main_menu.addChild(universe_selector)
        main_menu.addChild(channel_selector)
        main_menu.addChild(manual_menu)
        main_menu.addChild(ip_info)

        manual_menu.addChild(blackout)
        manual_menu.addChild(test_pattern)

        self.current = home

        with self.lcd_lock:
            self.lcd = CharLCD(i2c_expander='PCF8574', address=0x3F, cols=20, rows=4,
                               auto_linebreaks=False, backlight_enabled=False)

            self.lcd.cursor_mode = 'hide'

            # UP/DOWN arrow. Use as char \x00
            self.lcd.create_char(0, (
                0b00100,
                0b01110,
                0b11111,
                0b00000,
                0b00000,
                0b11111,
                0b01110,
                0b00100
                ))

            self.updateScreen()
            #self.backlightOn()

    def listenToGPIO(self):
        for pin in [UP_BUTTON, DOWN_BUTTON, OK_BUTTON, BACK_BUTTON]:
            GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
            GPIO.add_event_detect(
                pin, GPIO.RISING,
                callback=self.getGPIOCallback(),
                bouncetime=200
                )

    def getGPIOCallback(self):
        def GPIOCallback(channel):
            with self.gpio_lock:
                GPIO.output(STATUS_LED, GPIO.HIGH)
                #self.backlightOn()

                if channel == UP_BUTTON:
                    print("UP", channel)
                    self.current.onUp()
                elif channel == DOWN_BUTTON:
                    print("DOWN", channel)
                    self.current.onDown()
                elif channel == OK_BUTTON:
                    print("OK", channel)
                    self.current.onOK()
                elif channel == BACK_BUTTON:
                    print("BACK", channel)
                    self.current.onBack()
                self.updateScreen()

                GPIO.output(STATUS_LED, GPIO.LOW)
        return GPIOCallback

    def backlightOn(self):
        self.on_time = datetime.now()
        with self.lcd_lock:
            self.lcd.backlight_enabled = True
        self.panel.threadSafeSchedule(
            11*1000,
            self.turn_off_backlight_if_inactivity
            )

    def turn_off_backlight_if_inactivity(self):
        if datetime.now() - self.on_time >= timedelta(seconds=10):
            with self.lcd_lock:
                self.lcd.backlight_enabled = False

    def updateScreen(self):
        self.current.computeDisplay()

        with self.lcd_lock:
            self.lcd.clear()
            self.lcd.write_string(self.current.first_line)
            self.lcd.crlf()
            self.lcd.write_string(self.current.second_line)

    def cleanup(self):
        GPIO.cleanup()
        with self.lcd_lock:
            self.lcd.close(clear=True)
Exemple #5
0
    0b01110,
    0b10110,
    0b11010,
    0b11100,
)
dot = (
    0b00000,
    0b00000,
    0b00000,
    0b00110,
    0b00110,
    0b00000,
    0b00000,
    0b00000,
)
lcd.create_char(0, pause)
lcd.create_char(1, play)
lcd.create_char(2, stop)
lcd.create_char(3, logol)
lcd.create_char(4, logor)
lcd.create_char(5, dot)

ipause = '\x00 '
iplay = '\x01 '
istop = '\x02 '
irr = '\x03\x04'
idots = ' \x05  \x05  \x05'
rn = '\r\n'

if len(sys.argv) == 2:  # rr - splash or single argument string (^ = linebreak)
    if argv1 == 'rr':
Exemple #6
0
class LCDScreen(object):
    def __init__(self,
                 welcome_text,
                 i2c_bus=1,
                 i2c_addr=0x27,
                 lcd_width=16,
                 lcd_rows=2):

        self.lcd = CharLCD(i2c_expander='PCF8574',
                           address=i2c_addr,
                           port=i2c_bus,
                           cols=lcd_width,
                           rows=lcd_rows,
                           dotsize=8,
                           charmap='A02',
                           auto_linebreaks=True,
                           backlight_enabled=True)

        self._lcd_width = lcd_width

        self.prevStr = ''

        # Create some custom characters
        self.lcd.create_char(0, (0, 0, 0, 0, 0, 0, 0, 0))
        self.lcd.create_char(1, (16, 24, 24, 24, 24, 24, 24, 16))
        self.lcd.create_char(2, (1, 3, 3, 3, 3, 3, 3, 1))
        self.lcd.create_char(3, (17, 27, 27, 27, 27, 27, 27, 17))
        self.lcd.create_char(4, (31, 31, 0, 0, 0, 0, 0, 0))
        self.lcd.create_char(5, (0, 0, 0, 0, 0, 0, 31, 31))
        self.lcd.create_char(6, (31, 31, 0, 0, 0, 0, 0, 31))
        self.lcd.create_char(7, (31, 0, 0, 0, 0, 0, 31, 31))

        self.lcd.backlight_enabled = True
        self.lcd.clear()
        self.print_line(welcome_text, 0, align='CENTER')
        self.print_line(__version__, 1, align='CENTER')
        self.lcd.home()

    def print_line(self, text, line=0, align='LEFT'):
        """Checks the string, if different than last call, update screen.

        :param text:
        :param line:
        :param align:
        :return:
        """

        if isinstance(text, float):
            text = str(text)

        text = text.encode('utf-8')

        if self.prevStr != text:  # Oh what a shitty way around actually learning the ins and outs of encoding chars...
            # Display string has changed, update LCD
            #self.lcd.clear()

            text_length = len(text)
            if text_length < self._lcd_width:
                blank_space = self._lcd_width - text_length
                if align == 'LEFT':
                    text = text + b' ' * blank_space
                elif align == 'RIGHT':
                    text = b' ' * blank_space + text
                else:
                    text = b' ' * (blank_space // 2) + text + b' ' * (
                        blank_space - blank_space // 2)
            else:
                text = text[:self._lcd_width]

            self.lcd.cursor_pos = (line, 0)

            self.lcd.write_string(text.decode('utf-8'))
            # Save so we can test if screen changed between calls, don't update if not needed to reduce LCD flicker
            self.prevStr = text
Exemple #7
0
    def cleanup(self):
        self.logger.debug("PlayingState cleaned up")
        self._random_msg_display.stop()
        self._name_display.stop()
        self._title_display.stop()


if __name__ == "__main__":
    # Resourcecs initialization
    rsc = Resources("/home/pi/python/webradio/conf.txt")
    # lcd initialization
    lcd = CharLCD(i2c_expander='PCF8574',
                  address=0x3f,
                  port=1,
                  cols=20,
                  rows=4,
                  dotsize=8,
                  charmap='A02',
                  auto_linebreaks=True,
                  backlight_enabled=True)
    lcd.backlight_enabled = True
    wifi = (0b00000, 0b11111, 0b00000, 0b01110, 0b00000, 0b00100, 0b00100,
            0b00000)
    lcd.create_char(0, wifi)

    state = PlayingState(lcd, rsc)
    state.enter_state()

    input("Entree pour quitter...")
    lcd.backlight_enabled = False
Exemple #8
0
class LCD:
    # Guard critical sections with shared class-lock
    LOCK = Lock()
    AXIS = 'XYZABC'

    POST_DECIMAL_PLACE = 1
    PRE_DECIMAL_PLACE = 3
    # Sign + Decimal Point + Digits before + Digits after
    WIDTH = 1 + 1 * (PRE_DECIMAL_PLACE >
                     0) + PRE_DECIMAL_PLACE + POST_DECIMAL_PLACE
    STATUS_LEN = 18

    SW_I2C_PORT = 11
    SW_I2C_SDA = 23
    SW_I2C_SCL = 24

    CONNECTED_CHAR = 0
    DISCONNECTED_CHAR = 1

    CONNECTED_SYMBOL = (
        0b01110,
        0b10001,
        0b10001,
        0b10001,
        0b11111,
        0b11011,
        0b11011,
        0b11111,
    )

    DISCONNECTED_SYMBOL = (
        0b01110,
        0b10000,
        0b10000,
        0b10000,
        0b11111,
        0b11011,
        0b11011,
        0b11111,
    )

    def __init__(self):
        # Adress and port expander type are fixed
        # Hide the specific implementation used
        try:
            self._lcd = CharLCD('PCF8574', 0x26, port=self.SW_I2C_PORT)
        except Exception:
            self.connected = False
        else:
            self.connected = True
            self._lcd.create_char(self.CONNECTED_CHAR, self.CONNECTED_SYMBOL)
            self._lcd.create_char(self.DISCONNECTED_CHAR,
                                  self.DISCONNECTED_SYMBOL)

    def print_pose(self, pose: List[float]):
        """
        Prints a pose on the lower three rows of the display
        """
        if self.connected:
            rows = 3 * ['']

            for i, (ax, val) in enumerate(zip(self.AXIS, pose)):
                if i >= 3:
                    space = ' '
                    unit = chr(223)
                    val = math.degrees(val)
                else:
                    space = ''
                    unit = ' mm'

                rows[
                    i %
                    3] += f'{ax}{val:+0{self.WIDTH}.{self.POST_DECIMAL_PLACE}f}{unit}{space}'

            display_str = '\r\n'.join(rows)

            # Critical section
            with self.LOCK:
                # Set cursor to start of second row and write positions
                self._lcd.cursor_pos = (1, 0)
                self._lcd.write_string(display_str)

    def print_connection(self, is_connected: bool):
        if self.connected:
            # Critical section
            with self.LOCK:
                # Move cursor to upper right corner
                self._lcd.cursor_pos = (0, self.STATUS_LEN + 1)

                if is_connected:
                    self._lcd.write_string(chr(self.CONNECTED_CHAR))
                else:
                    self._lcd.write_string(chr(self.DISCONNECTED_CHAR))

    def print_status(self, status: str):
        if self.connected:
            # Critical section
            with self.LOCK:
                self._lcd.home()

            if len(status) > self.STATUS_LEN:
                status = status[:self.STATUS_LEN + 1]
            else:
                status += ' ' * (self.STATUS_LEN - len(status))

            # Critical section
            with self.LOCK:
                self._lcd.write_string(status)

    def __del__(self):
        if self.connected:
            # Critical section
            with self.LOCK:
                self._lcd.close()
Exemple #9
0
def main():

    try:
        
        thread_one_wire = One_Wire()
        thread_one_wire.start()

        thread_stop_watch = Stop_Watch()
        thread_stop_watch.start()
        
        lcd = CharLCD('PCF8574', 0x27)
        degree = (0b00010, 0b00101, 0b00101, 0b00010, 0b00000, 0b00000, 0b00000, 0b00000)
        lcd.create_char(0, degree)
        
        sandclock = (0b00000, 0b11111, 0b01010, 0b00100, 0b00100, 0b01010, 0b11111, 0b00000)
        lcd.create_char(1, sandclock)
        
        lcd.cursor_pos = (0, 0)
        lcd.write_string('Temp 1: 00.0\x00C')
        lcd.cursor_pos = (1, 0)
        lcd.write_string('Temp 2: 00.0\x00C')
        lcd.cursor_pos = (2, 0)
        lcd.write_string('Temp 3: 00.0\x00C')
        lcd.cursor_pos = (3, 0)
        lcd.write_string('Timer : 00:00:00')

        Display_ref = ['0','02','03']

        print("End program with CRLT+C !!")

        while(True):
            for i in range(3):
                lcd.cursor_pos = (i, 8)
                lcd.write_string(thread_one_wire.Device_Temp[i])

          
            if Display_ref[0] != thread_stop_watch.Display_value[0]:
                lcd.cursor_pos = (3, 9)
                Display_ref[0] = thread_stop_watch.Display_value[0]
                lcd.write_string(thread_stop_watch.Display_value[0])
                #print("treffer hour")
            
            
            if Display_ref[1] != thread_stop_watch.Display_value[1]:
                lcd.cursor_pos = (3, 11)
                Display_ref[1] = thread_stop_watch.Display_value[1]
                #print("treffer min")
                if len(thread_stop_watch.Display_value[1]) > 1:
                    lcd.write_string(thread_stop_watch.Display_value[1])
                else:
                    lcd.write_string("0" + thread_stop_watch.Display_value[1])
            
            if Display_ref[2] != thread_stop_watch.Display_value[2]:
                lcd.cursor_pos = (3, 14)
                Display_ref[2] = thread_stop_watch.Display_value[2]
                #print("treffer sec")
                if len(thread_stop_watch.Display_value[2]) > 1:
                    lcd.write_string(thread_stop_watch.Display_value[2])
                else:
                    lcd.write_string("0" + thread_stop_watch.Display_value[2])
            
            if thread_stop_watch.Timer_running == True: 
                lcd.cursor_pos = (3, 18)
                lcd.write_string('\x01')
            else:
                lcd.cursor_pos = (3, 18)
                lcd.write_string(' ')

            time.sleep(.5)

    except Exception as err:
        print(err)
Exemple #10
0
            0b01000,
            0b10001,
        )
        sunR = (
            0b01001,
            0b00010,
            0b10000,
            0b11000,
            0b11011,
            0b10000,
            0b00010,
            0b01001,
        )
        plug = (
            0b01010,
            0b01010,
            0b01010,
            0b11111,
            0b11111,
            0b01110,
            0b01110,
            0b00100,
        )
        device2.create_char(0, degree)
        device2.create_char(1, sunL)
        device2.create_char(2, sunR)
        device2.create_char(3, plug)
        main()
    except KeyboardInterrupt:
        pass
Exemple #11
0
from RPLCD.i2c import CharLCD

lcd = CharLCD('PCF8574', 0x3f)
lcd.clear();

i = (
	0b00000,
	0b00000,
	0b00010,
	0b11011,
	0b11010,
	0b00010,
	0b00000,
	0b00000
)
lcd.create_char(0, i)

e = (
	0b00000,
	0b00000,
	0b00010,
	0b11010,
	0b11010,
	0b00010,
	0b00000,
	0b00000
)
lcd.create_char(1, e)

t = (
	0b00001,
Exemple #12
0
    0b11111,
    0b10001,
    0b01110,
    0b00000,
)
waiting = (
    0b00000,
    0b01010,
    0b00000,
    0b00000,
    0b00000,
    0b11111,
    0b00000,
    0b00000,
)
lcd.create_char(0, smiley)
lcd.create_char(1, smiley_open)
lcd.create_char(2, waiting)

# Make sure that the LCD will be cleared on exit


def close_lcd():
    lcd.close(clear=True)


atexit.register(close_lcd)


def write_to_lcd(string):
    lcd.clear()
Exemple #13
0
class StompBox():
    def __init__(self):

        # initialize LCD
        if I2C:
            self.LCD = CharLCD(i2c_expander=I2CEXPANDER,
                               address=I2CADDR,
                               port=1,
                               cols=COLS,
                               rows=ROWS,
                               dotsize=8,
                               charmap='A02',
                               auto_linebreaks=True,
                               backlight_enabled=True)
        else:
            self.LCD = RPLCD.CharLCD(
                pin_rs=LCD_RS,
                pin_e=LCD_EN,
                pin_rw=None,
                pins_data=[LCD_D4, LCD_D5, LCD_D6, LCD_D7],
                numbering_mode=GPIO.BCM,
                cols=COLS,
                rows=ROWS,
                compat_mode=True)
        self.LCD.create_char(CHR_BSP, [0, 3, 5, 9, 5, 3, 0, 0])
        self.LCD.create_char(CHR_ENT, [0, 1, 5, 9, 31, 8, 4, 0])
        self.lcd_clear()

        # set up buttons
        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BCM)
        for button in BUTTONS:
            if ACTIVE_HIGH:
                GPIO.setup(BUTTONS[button],
                           GPIO.IN,
                           pull_up_down=GPIO.PUD_DOWN)
            else:
                GPIO.setup(BUTTONS[button], GPIO.IN, pull_up_down=GPIO.PUD_UP)
        self.state = {button: UP for button in BUTTONS}
        self.timer = {button: 0 for button in BUTTONS}

    def button(self, button):
        return self.state[button]

    def buttons(self):
        return self.state.values()

    def update(self):
        time.sleep(POLL_TIME)

        t = time.time()
        for button in BUTTONS:
            if GPIO.input(BUTTONS[button]) != ACTIVE:
                self.timer[button] = t
                if self.state[button] == DOWN:
                    self.state[button] = TAP
                else:
                    self.state[button] = UP
            else:
                if self.state[button] == UP:
                    self.state[button] = DOWN
                    self.timer[button] = t
                elif self.state[button] == DOWN:
                    if (t - self.timer[button]) >= HOLD_TIME:
                        self.state[button] = HOLD
                elif self.state[button] == HOLD:
                    self.state[button] = HELD
                elif self.state[button] == HELD:
                    if (t - self.timer[button]) >= LONG_TIME:
                        self.state[button] = LONG
                elif self.state[button] == LONG:
                    self.state[button] = LONGER

        if self.scrollmsg:
            if (t - self.lastscroll) >= SCROLL_TIME:
                self.lastscroll = t
                self.scrollpos += 1
                self.lcd_write(self.scrollmsg, self.scrollrow)

    def waitforrelease(self, tmin=0):
        # wait for all buttons to be released and at least :tmin seconds
        tmin = time.time() + tmin
        while True:
            self.update()
            if time.time() >= tmin:
                if all(s == UP for s in self.state.values()):
                    break

    def waitfortap(self, t):
        # wait :t seconds or until a button is tapped
        # return True if tapped, False if not
        tstop = time.time() + t
        while time.time() < tstop:
            self.update()
            if TAP in self.state.values():
                return True
        return False

    def lcd_clear(self):
        self.LCD.clear()
        self.scrollmsg = ''

    def lcd_write(self, text, row=0, col=0):
        if len(text) > COLS:
            if self.scrollmsg:
                self.LCD.cursor_pos = (row, 0)
                if self.scrollpos < 0:
                    self.LCD.write_string(LINESTR % self.scrollmsg[:COLS])
                elif self.scrollpos < (len(self.scrollmsg) - COLS):
                    self.LCD.write_string(
                        LINESTR %
                        self.scrollmsg[self.scrollpos:self.scrollpos + COLS])
                elif self.scrollpos < (len(self.scrollmsg) - (COLS - 2)):
                    self.LCD.write_string(LINESTR % self.scrollmsg[-COLS:])
                else:
                    self.scrollpos = -4
            else:
                self.scrollmsg = text
                self.scrollrow = row
                self.scrollpos = -4
                self.lastscroll = time.time()
                self.LCD.cursor_pos = (row, 0)
                self.LCD.write_string(LINESTR % text[:COLS])
        else:
            if self.scrollmsg and row == self.scrollrow:
                self.scrollmsg = ''
            self.LCD.cursor_pos = (row, col)
            self.LCD.write_string(text + ' ' * (COLS - len(text)))

    def lcd_blink(self, text, row=0, n=3):
        while n != 0:
            self.lcd_write(' ' * COLS, row)
            time.sleep(BLINK_TIME)
            self.lcd_write(LINESTR % text, row)
            time.sleep(BLINK_TIME)
            n -= 1

    def choose_opt(self, opts, row=0, timeout=MENU_TIMEOUT, passlong=False):
        """
        has the user choose from a list of choices in :opts
        returns the index of the choice
        or -1 if the user backed out or time expired
        passlong: pass LONG through to calling loop
        """
        i = 0
        while True:
            self.lcd_write(' ' * COLS, row)
            self.lcd_write(opts[i], row)
            if ROWS == 4:
                if COLS == 20:
                    self.lcd_write('Prev            Next', 2)
                    self.lcd_write('Back---Long---Select', 3)
                else:
                    self.lcd_write('Prev        Next', 2)
                    self.lcd_write('Back-Long-Select', 3)
            tstop = time.time() + timeout
            while True:
                if timeout and time.time() > tstop:
                    self.lcd_write(' ' * COLS, row)
                    return -1
                self.update()
                if sum(self.state.values()) == UP:
                    continue
                elif self.state['right'] == TAP:
                    i = (i + 1) % len(opts)
                    break
                elif self.state['left'] == TAP:
                    i = (i - 1) % len(opts)
                    break
                elif self.state['right'] == HOLD:
                    self.lcd_blink(opts[i], row)
                    return i
                elif self.state['left'] == HOLD:
                    self.lcd_write(' ' * COLS, row)
                    return -1
                elif LONG in self.state.values() and passlong:
                    for b in self.state:
                        if self.state[b] == LONG:
                            self.state[b] = HELD
                    return -1

    def choose_val(self, val, inc, minval, maxval, format=LINESTR):
        """
        lets the user change a numeric parameter
        returns the user's choice on timeout
        """
        while True:
            self.lcd_write(LINESTR % (format % val), 1)
            tstop = time.time() + MENU_TIMEOUT
            while time.time() < tstop:
                self.update()
                if sum(self.state.values()) == UP:
                    continue
                if self.state['right'] > DOWN:
                    val = min(val + inc, maxval)
                elif self.state['left'] > DOWN:
                    val = max(val - inc, minval)
                break
            else:
                return val

    def char_input(self,
                   text='',
                   row=1,
                   timeout=MENU_TIMEOUT,
                   charset=INPCHARS):
        """
        a way of letting the user enter a text string with two buttons
        text: the initial value of the text
        user taps buttons to choose character, holds buttons to move
         cursor right or left
        when cursor is at end of input, user can tap to
         delete or newline character
        newline returns text
        timeout returns empty string
        """
        i = len(text)
        char = len(charset) - 1
        self.LCD.cursor_mode = 'blink'
        while True:
            if i < len(text):
                char = charset.find(text[i])
            lpos = max(i - (COLS - 1), 0)
            self.lcd_write(LINESTR % text[lpos:lpos + COLS], row)
            if char > -1:
                self.lcd_write(charset[char], row, min(i, COLS - 1))
            self.LCD.cursor_pos = (row, min(i, COLS - 1))
            tstop = time.time() + timeout
            while time.time() < tstop:
                self.update()
                if sum(self.state.values()) == UP:
                    continue
                elif TAP in self.state.values():
                    if i == len(text):
                        if self.state['right'] == TAP:
                            char = (char + 1) % len(charset)
                        else:
                            char = (char - 1) % len(charset)
                    else:
                        if self.state['right'] == TAP:
                            char = (char + 1) % (len(charset) - 2)
                        else:
                            char = (char - 1) % (len(charset) - 2)
                    if char < (len(charset) - 2):
                        text = text[0:i] + charset[char] + text[i + 1:]
                    break
                elif self.state['right'] >= HOLD:
                    if self.state['right'] == HELD:
                        continue
                    if char == (len(charset) - 1):
                        if self.state['right'] != HOLD:
                            continue
                        self.LCD.cursor_mode = 'hide'
                        self.lcd_blink(text.strip()[0:COLS], row)
                        return text.strip()
                    if self.state['right'] > HELD:
                        time.sleep(BLINK_TIME)
                    i = min(i + 1, len(text))
                    if i == len(text):
                        char = len(charset) - 1
                    break
                elif self.state['left'] >= HOLD:
                    if self.state['left'] == HELD:
                        continue
                    if char == (len(charset) - 2):
                        text = text[0:max(0, i - 1)] + text[i:]
                    if self.state['left'] > HELD: time.sleep(BLINK_TIME)
                    i = max(i - 1, 0)
                    break
            else:
                self.LCD.cursor_mode = 'hide'
                return ''
Exemple #14
0
class LCD1602Plugin(octoprint.plugin.StartupPlugin,
                    octoprint.plugin.EventHandlerPlugin,
                    octoprint.plugin.ProgressPlugin):

  def __init__(self):
    if (os.getenv('LCD1602_DOCKER')):
      print('We are running in test environnement, no i2c device attached.')
      try:
        print('Loading fake_rpi instead of smbus2')
        sys.modules['smbus2'] = fake_rpi.smbus
        self.mylcd = fake_rpi.smbus.SMBus(1)
      except:
        print('Cannot load fake_rpi !')
    else:
      self.mylcd = CharLCD(i2c_expander='PCF8574', address=0x27, cols=16, rows=2, backlight_enabled=True, charmap='A00')
      
      # create block for progress bar
      self.block = bytearray(b'\xFF\xFF\xFF\xFF\xFF\xFF\xFF')
      self.block.append(255)
      self.mylcd.create_char(1,self.block)
    
    # init vars
    self.start_date = 0

    # create block for progress bar
    #self.mylcd.create_char(1,self.block)

  def JobIsDone(self,lcd):

    # create final anim
    self.birdy = [ '^_-' , '^_^', '-_^' , '^_^', '0_0', '-_-', '^_-', '^_^','@_@','*_*','$_$','<_<','>_>']

    for pos in range(0,13):
      lcd.cursor_pos = (1,pos)
      lcd.write_string(self.birdy[pos])
      time.sleep(0.5)
      lcd.clear()
    lcd.write_string('Job is Done    \,,/(^_^)\,,/')

      
  def on_after_startup(self):
    mylcd = self.mylcd
    self._logger.info("plugin initialized !")

  
  def on_print_progress(self,storage,path,progress):
    mylcd = self.mylcd
    percent = int(progress/6.25)+1
    completed = '\x01'*percent
    mylcd.clear()
    mylcd.write_string('Completed: '+str(progress)+'%')
    mylcd.cursor_pos = (1,0)
    mylcd.write_string(completed)

    if progress==1 :
      self.start_date=time.time()
  
    if progress>10 and progress<100:
      now=time.time()
      elapsed=now-self.start_date
      average=elapsed/(progress-1)
      remaining=int((100-progress)*average)
      remaining=str(datetime.timedelta(seconds=remaining))
      mylcd.cursor_pos = (1,3)
      mylcd.write_string(remaining)

    if progress==100 :
      self.JobIsDone(mylcd)



  def on_event(self,event,payload):
    mylcd = self.mylcd
      
    if event in "Connected":
      mylcd.clear()
      mylcd.write_string('Connected to:')
      mylcd.cursor_pos = (1,0)
      mylcd.write_string(payload["port"])

    if event in "Shutdown":
      mylcd.clear()
      mylcd.write_string('Bye bye ^_^')
      time.sleep(1)
      mylcd._set_backlight_enabled(False)
      mylcd.close()
    
    
    if event in "PrinterStateChanged":
      
      if payload["state_string"] in "Offline":
        mylcd.clear()
        mylcd.write_string('Octoprint is not connected')
        time.sleep(2)
        mylcd.clear()
        mylcd.write_string('saving a polar bear, eco mode ON')
        time.sleep(5)
        mylcd._set_backlight_enabled(False)
      
      if payload["state_string"] in "Operational":
        mylcd._set_backlight_enabled(True)
        mylcd.clear()
        mylcd.write_string('Printer is       Operational')
      
      if payload["state_string"] in "Cancelling":
        mylcd.clear()
        mylcd.write_string('Printer  is Cancelling job') 
        time.sleep(0.2)
      
      if payload["state_string"] in "PrintCancelled":
        mylcd.clear()
        time.sleep(0.5)
        mylcd.write_string(' Job has been Cancelled (0_0) ' ) 
        time.sleep(2)
      
      if payload["state_string"] in "Paused":
        mylcd.clear()
        time.sleep(0.5)
        mylcd.write_string('Printer is  Paused') 

      if payload["state_string"] in "Resuming":
        mylcd.clear()
        mylcd.write_string('Printer is Resuming its job') 
        time.sleep(0.2)

  def get_update_information(self):
      return dict(
          LCD1602Plugin=dict(
              displayName="LCD1602 display",
              displayVersion=self._plugin_version,

              type="github_release",
              current=self._plugin_version,
              user="******",
              repo="OctoPrint-Lcd1602",

              pip="https://github.com/n3bojs4/octoprint-LCD1602/archive/{target}.zip"
          )
      )
Exemple #15
0
lcd.clear()
lcd.write_string('This is a long string that will wrap across multiple lines!')
input('Text should nicely wrap around lines. ')

lcd.clear()
lcd.cursor_mode = CursorMode.hide
lcd.write_string('Paris: 21{deg}C\n\rZ{uuml}rich: 18{deg}C'.format(deg=unichr(176), uuml=unichr(129)))
print('Text should now show "Paris: 21°C, Zürich: 18°C" without any encoding issues.', end='')
input()

# Test custom chars
lcd.clear()
happy = (0b00000, 0b01010, 0b01010, 0b00000, 0b10001, 0b10001, 0b01110, 0b00000)
sad = (0b00000, 0b01010, 0b01010, 0b00000, 0b01110, 0b10001, 0b10001, 0b00000)
lcd.create_char(0, sad)
lcd.write_string(unichr(0))
lcd.create_char(1, happy)
lcd.write_string(unichr(1))
input('You should now see a sad and a happy face next to each other. ')
lcd.create_char(0, happy)
lcd.home()
lcd.write_string(unichr(0))
input('Now both faces should be happy. ')

lcd.clear()
lcd.write_string('12345678901234567890\r\n2nd line')
input('The first line should be filled with numbers, the second line should show "2nd line"')

lcd.clear()
lcd.write_string('999456..............\n\r\n\n\n123')
Exemple #16
0
class TwolineDisplay:

	__lcd = None
	__animIdx = -1
	__animChars = []
	__screenMode = ""
	__port = 1
	__logger = None

	def __init__(self, logger):
		self.__logger = logger
		return None

	def open(self):
		addr = self.__find_device(self.__port)
		if (addr < 1):
			raise exception
		self.__lcd = CharLCD(i2c_expander='PCF8574', address=addr, port=self.__port,
				  cols=16, rows=2, dotsize=8,
				  #charmap='A02',
				  auto_linebreaks=True,
				  backlight_enabled=True)
		self.__lcd.clear()
		self.__create_custom_chars()
		return True

	def close(self):
		self.__lcd.clear()
		self.__lcd.close()
		self.__lcd = None
		return True

	def __find_device(self,port):
		bus = smbus.SMBus(port) # 1 indicates /dev/i2c-1
		for device in range(128):
			try:
				bus.read_byte(device)
				#print(hex(device))
				return device
			except: # exception if read_byte fails
				pass
		return -1

	def clear(self):
		self.__lcd.clear()
		self.__screenMode = ""

	def show_centered(self,line,text):
		self.__setScreenModeToText()
		self.__logger.debug("Display: " + text)
		self.__lcd.cursor_pos = (line, 0)
		self.__lcd.write_string(text.center(16))

	def show_centered(self,line0,line1):
		self.__setScreenModeToText()
		self.__logger.debug("Display: " + (line0 if line0 is not None else "") + " || " + (line1 if line1 is not None else ""))
		if (line0 is not None):
			self.__lcd.cursor_pos = (0, 0)
			self.__lcd.write_string(line0.center(16))
		if (line1 is not None):
			self.__lcd.cursor_pos = (1, 0)
			self.__lcd.write_string(line1.center(16))

	def update_value_time_trend(self,value,mins,trend):
		self.__setScreenModeToEgv()
		valStr = "--"
		trendChars = "  "
		if (value > 0):
			valStr = str(value)
			trendChars = self.__get_trend_chars(trend)
	
		print(valStr + "   " + str(mins))

		valStr = valStr.replace("0","O")
		valStr = valStr.rjust(6)
		self.__lcd.cursor_pos = (0, 0)
		self.__lcd.write_string(valStr)

		self.__lcd.cursor_pos = (1, 4)
		self.__lcd.write_string(trendChars)

		ageStr = self.update_age(mins)		
		

	def update_age(self, mins):
		self.__setScreenModeToEgv()
		ageStr = "now"
		if (mins > 50):
			ageStr = "50+"
		elif (mins > 0):
			ageStr = str(mins) + "m"

		ageStr = ageStr.replace("0","O")
		ageStr = ageStr.rjust(3)
		
		self.__lcd.cursor_pos = (1, 13)
		self.__lcd.write_string(ageStr)
		

	def updateAnimation(self):
		self.__setScreenModeToEgv()
		self.__animIdx += 1
		if (self.__animIdx >= len(self.__animChars)):
			self.__animIdx = 0
		char = self.__animChars[self.__animIdx]
		self.__lcd.cursor_pos = (0, 15)
		self.__lcd.write_string(char)
		
	def __setScreenModeToEgv(self):
		if (not self.__screenMode == "egv"):
			self.__logger.debug("Display mode EGV")
			self.__screenMode = "egv"
			self.__lcd.clear()
			
	def __setScreenModeToText(self):
		if (not self.__screenMode == "text"):
			self.__logger.debug("Display mode Text")
			self.__screenMode = "text"
			self.__lcd.clear()
		
	def __get_trend_chars(self,trend):
		if(trend == Trend.NONE):
			return "**"
		if(trend == Trend.DoubleUp):
			return "\x01\x01"
		if(trend == Trend.SingleUp):
			return "\x01 "
		if(trend == Trend.FortyFiveUp):
			return "\x02 "
		if(trend == Trend.Flat):
			return "-\x7e"
		if(trend == Trend.FortyFiveDown):
			return "\x03 "
		if(trend == Trend.SingleDown):
			return "\x04 "
		if(trend == Trend.DoubleDown):
			return "\x04\x04"
		if(trend == Trend.NotComputable):
			return "NC"
		if(trend == Trend.RateOutOfRange):
			return "HI"
		return "??"
		#self.__lcd.write_string('\x02\x02 \x02 \x03 -\x7e \x05 \x06 \x06\x06')

	def __create_custom_chars(self):
		upArrow = (
			 0b00000,
			 0b00100,
			 0b01110,
			 0b10101,
			 0b00100,
			 0b00100,
			 0b00100,
			 0b00100
		)
		self.__lcd.create_char(1, upArrow)

		upSlight = (
			 0b00000,
			 0b00000,
			 0b00111,
			 0b00011,
			 0b00101,
			 0b01000,
			 0b10000,
			 0b00000
		)
		self.__lcd.create_char(2, upSlight)

		dnSlight = (
			 0b00000,
			 0b00000,
			 0b10000,
			 0b01000,
			 0b00101,
			 0b00011,
			 0b00111,
			 0b00000
		)
		self.__lcd.create_char(3, dnSlight)

		dnArrow = (
			 0b00000,
			 0b00100,
			 0b00100,
			 0b00100,
			 0b00100,
			 0b10101,
			 0b01110,
			 0b00100
		)
		self.__lcd.create_char(4, dnArrow)

		
		self.__animChars = [ '\x05', '\x06', '\x07' ]

		anim1 = (
			 0b00000,
			 0b00000,
			 0b00000,
			 0b00000,
			 0b00000,
			 0b00000,
			 0b00010,
			 0b00000
		)
		self.__lcd.create_char(5, anim1)
		
		anim2 = (
			 0b00000,
			 0b00000,
			 0b00000,
			 0b00100,
			 0b01010,
			 0b00100,
			 0b00000,
			 0b00000
		)
		self.__lcd.create_char(6, anim2)
		
		anim3 = (
			 0b01100,
			 0b10010,
			 0b10010,
			 0b01100,
			 0b00000,
			 0b00000,
			 0b00000,
			 0b00000
		)
		self.__lcd.create_char(7, anim3)
Exemple #17
0
class OctoPrintLcd1604(octoprint.plugin.StartupPlugin,
                       octoprint.plugin.EventHandlerPlugin,
                       octoprint.plugin.ProgressPlugin):
    def __init__(self):

        # init vars
        self.start_date = 0

        self.block = bytearray(b'\xFF\xFF\xFF\xFF\xFF\xFF\xFF')
        self.block.append(255)

        self.cols = 20
        self.rows = 4

        # init lcd
        self.lcd = CharLCD(i2c_expander='PCF8574',
                           address=0x27,
                           port=1,
                           cols=self.cols,
                           rows=self.rows,
                           dotsize=8,
                           charmap='A00',
                           auto_linebreaks=True,
                           backlight_enabled=True)

        # create block for progress bar
        self.lcd.create_char(1, self.block)

    def on_after_startup(self):
        lcd = self.lcd
        lcd.clear()
        self._logger.info("plugin initialized!")

    def on_print_progress(self, storage, path, progress):

        lcd = self.lcd
        lcd.clear()

        cols = self.cols
        rows = self.rows

        if progress == 0:
            self.start_date = time.time()
            self.start_time = time.strftime("%H:%M:%S")

        # progress
        str_progress = str(str(progress) + '%')

        lcd.cursor_pos = (0, 0)
        lcd.write_string('Progress:')

        lcd.cursor_pos = (0, int(cols - len(str_progress)))
        lcd.write_string(str_progress)

        # duration
        duration = int(time.time() - self.start_date)
        duration = str(datetime.timedelta(seconds=duration))

        lcd.cursor_pos = (1, 0)
        lcd.write_string('Duration:')

        lcd.cursor_pos = (1, int(cols - len(duration)))
        lcd.write_string(duration)

        # estimate
        lcd.cursor_pos = (2, 0)
        lcd.write_string('Estimate:')

        if progress > 5 and progress < 100:
            elapsed = time.time() - self.start_date
            average = elapsed / (progress - 1)
            remaining = int((100 - progress) * average)
            remaining = str(datetime.timedelta(seconds=remaining))
        else:
            remaining = str(datetime.timedelta(seconds=0))

        lcd.cursor_pos = (2, int(cols - len(remaining)))
        lcd.write_string(remaining)

        # progress bar
        percent = int(progress / (101 / cols))
        completed = '\x01' * percent

        lcd.cursor_pos = (3, 0)
        lcd.write_string(completed)

    def get_update_information(self):
        return dict(OctoPrintLcd1604=dict(
            displayName="OctoPrint LCD1604",
            displayVersion=self._plugin_version,
            type="github_release",
            current=self._plugin_version,
            user="******",
            repo="octoprint-lcd1604",
            pip=
            "https://github.com/tivrobo/octoprint-lcd1604/archive/{target}.zip"
        ))
Exemple #18
0
class lcd_mgr():

    lcd = None
    framebuffer = ['', '']
    num_cols = 16
    #threads = []
    t = None

    def __init__(self):

        self.lcd = CharLCD(i2c_expander='PCF8574',
                           address=0x27,
                           port=1,
                           cols=16,
                           rows=2,
                           dotsize=8,
                           charmap='A00',
                           auto_linebreaks=True,
                           backlight_enabled=True)

        self.framebuffer[0] = '                '
        self.framebuffer[1] = '                '
        self.lcd.clear()
        self.charset()

    def write_to_lcd(self):
        """Write the framebuffer out to the specified LCD."""
        self.lcd.home()
        for row in self.framebuffer:
            self.lcd.write_string(row.ljust(self.num_cols)[:self.num_cols])
            self.lcd.write_string('\r\n')

    def set_fb_str(self, row, col, txt):
        self.framebuffer[row] = self.framebuffer[
            row][:col] + txt + self.framebuffer[row][col + len(txt):]

    def lcd_text(self, txt):
        self.set_fb_str(0, 0, txt)
        self.write_to_lcd()

    def lcd_play(self, artist, track, filename, tracknumber, tracktotal):
        #self.lcd_text( '{1}{2}/{3}'.format('\x00',tracknumber,tracktotal) )
        self.set_fb_str(1, 0, '{0}{1}/{2}'.format('\x00', tracknumber,
                                                  tracktotal))

        # Various display modes:
        # 1) Artist - Trackname
        if not artist == None and not track == None:
            testtxt = '{0} - {1}'.format(artist, track)
        else:
            testtxt = filename

        self.lcd_text(testtxt)

        #not the right place to stop... stop at every display change... hmm, write_to_lcd??
        #threads[0].stop()
        #self.t.stop() 			THREADS CAN'T BE STOPPED IN PYTHON!!! ---- multiprocessing ? asyncio ?

        if len(testtxt) > 16:
            #todo run under separate thread! (or atleast async..)
            self.loop_string(testtxt, 0, delay=0)
            time.sleep(2)
            self.lcd_text(testtxt)
            #self.t = threading.Thread(target=self.worker, args=(testtxt,))
            #threads.append(t)
            #self.t.start()
            #self.worker( testtxt, 0, delay=0 )

    def lcd_ding(self, bla):

        if bla == 'src_usb':
            self.set_fb_str(1, 1, 'USB')
            self.write_to_lcd()
        elif bla == 'update_on':
            self.set_fb_str(1, 5, 'UPD')
            self.write_to_lcd()
        elif bla == 'random_on':
            self.set_fb_str(1, 9, 'RND')
            self.write_to_lcd()
        elif bla == 'att_on':
            self.set_fb_str(1, 13, 'ATT')
            self.write_to_lcd()

    def worker(self, string):
        while True:
            self.loop_string(string, 0, delay=0)
            time.sleep(2)
            self.lcd_text(string)
            time.sleep(2)

    def loop_string(self, string, row, postfix='', delay=0.3):
        padding = ' ' * self.num_cols
        s = string
        for i in range(len(s) - self.num_cols + 1 + len(postfix)):
            self.framebuffer[row] = s[i:i + self.num_cols -
                                      len(postfix)] + postfix
            self.write_to_lcd()
            time.sleep(delay)

    def charset(self):
        """
		chr_play = (
				0b10000,
				0b11000,
				0b11100,
				0b11110,
				0b11100,
				0b11000,
				0b10000,
				0b00000
		)
		"""
        chr_play = (0b00000, 0b10000, 0b11000, 0b11100, 0b11000, 0b10000,
                    0b00000, 0b00000)
        chr_pause = (0b11011, 0b11011, 0b11011, 0b11011, 0b11011, 0b11011,
                     0b11011, 0b00000)
        chr_up = (0b00000, 0b00100, 0b01110, 0b11111, 0b00100, 0b00100,
                  0b00100, 0b00000)
        chr_down = (0b00000, 0b00100, 0b00100, 0b00100, 0b11111, 0b01110,
                    0b00100, 0b00000)

        chr_left = (0b00000, 0b00000, 0b00100, 0b01100, 0b11111, 0b01100,
                    0b00100, 0b00000)

        chr_right = (0b00000, 0b00000, 0b00100, 0b00110, 0b11111, 0b00110,
                     0b00100, 0b00000)

        self.lcd.create_char(0, chr_play)
        self.lcd.create_char(1, chr_pause)
        self.lcd.create_char(4, chr_up)
        self.lcd.create_char(5, chr_down)
        self.lcd.create_char(6, chr_left)
        self.lcd.create_char(7, chr_right)
class Display():
    def __init__(self):
        self.lcd = CharLCD(i2c_expander='PCF8574',
                           address=0x27,
                           port=1,
                           cols=20,
                           rows=4,
                           dotsize=8,
                           charmap='A00',
                           auto_linebreaks=True)

    def rus_test(self):
        line = 'БГДЖЗИЙЛПУФЦЧШЩЬЫЮЯ     '
        line1 = line[0:8]
        line2 = line[8:16]
        line3 = line[16:19]
        str_out = '\x00\x01\x02\x03\x04\x05\x06\x07'
        for l in [line1, line2, line3]:

            for char in enumerate(l):
                self.lcd.create_char(char[0], chars_dict[char[1]])
            self.lcd.write_string(str_out[:len(l)])
            sleep(2)
            self.lcd.clear()

        self.lcd.backlight_enabled = False

        self.lcd.close(clear=True)

    def clear(self):
        self.lcd.clear()

    def welcome_message(self):
        # Здравствуйте
        # Нажмите
        # одну из кнопок
        # ЗДУЙ
        # ЖИЮП
        for char in enumerate('ЗДУЙЖИДП'):
            self.lcd.create_char(char[0], chars_dict[char[1]])
        self.lcd.cursor_pos = (0, 4)
        self.lcd.write_string('\x00\x01PABCTB\x02\x03TE!')
        self.lcd.cursor_pos = (2, 6)
        self.lcd.write_string('HA\x04M\x05TE')
        self.lcd.cursor_pos = (3, 3)
        self.lcd.write_string('O\x06H\x02 \x05\x00 KHO\x07OK')

    def turn_off(self):
        self.lcd.clear()
        self.lcd.backlight_enabled = False
        self.lcd.close(clear=True)

    def print_rus_string(self, strings):
        """
        Печатает набор строк на экране LCD2004
        Подставляет русские символы, не более 8-ми
        :param strings: список вида [((row, col), string), ...]
        (row, col) - позиция начала строки
        string - содержание строки
        :return: True - строка выведена, False - строка не выведена
        """

        strings = list(strings)

        long_string = ''

        # начальное преобразование и проверка словаря строк для вывода
        for item in strings:
            row = item[0][0]
            col = item[0][1]
            string = item[1].upper()[:min(20, len(item[1]))]
            if row > 3 | col > 19:
                raise ValueError('Illegal position')

            # формирование одной длинной строки для проверки
            long_string += item[1]

            strings[strings.index(item)] = ((row, col), string)

        rus_letters = list(chars_dict.keys(
        ))  # строка русских символов (словарь индивидуальных символов)

        # выделение и проверка количества символов, требующих подстановки
        individual_chars = list(
            set([item for item in long_string.upper() if item in rus_letters]))
        if len(individual_chars) > 8:
            raise ValueError('Too many RUS symbols: {:d}'.format(
                len(individual_chars)))
        else:
            print('Total RUS characters: {:d}'.format(len(individual_chars)))

        # создание словаря escape - последовательностей
        for char in enumerate(individual_chars):
            self.lcd.create_char(char[0], chars_dict[char[1]])

        # создание словаря строк для печати (английские буквы + escape последовательности)
        strings_to_print = []
        for item in strings:
            row = item[0][0]
            col = item[0][1]
            string = item[1]
            string_to_print = ''
            for letter in list(string):
                if letter in individual_chars:
                    string_to_print += escapes[individual_chars.index(letter)]
                else:
                    string_to_print += eng_rus[letter]
            strings_to_print.append(((row, col), string_to_print))
        for item in strings_to_print:
            self.lcd.cursor_pos = item[0]
            self.lcd.write_string(item[1])