def draw(self): if not self.redraw: return self.redraw = False if self.selected_index == 0: with cleared(Register.LCD): Register.LCD.write_string(" LAMPA 2\n\rPROCENT CH1 " + str(Register.LIGHT2_PERCENT[0]) + "%" + self.get_override()) if self.selected_index == 1: with cleared(Register.LCD): Register.LCD.write_string(" LAMPA 2\n\rPROCENT CH2 " + str(Register.LIGHT2_PERCENT[1]) + "%" + self.get_override()) if self.selected_index == 2: with cleared(Register.LCD): Register.LCD.write_string(" LAMPA 2\n\rPROCENT CH3 " + str(Register.LIGHT2_PERCENT[2]) + "%" + self.get_override()) if self.selected_index == 3: with cleared(Register.LCD): Register.LCD.write_string(" LAMPA 2\n\rPROCENT CH4 " + str(Register.LIGHT2_PERCENT[3]) + "%" + self.get_override()) if self.selected_index == 4: with cleared(Register.LCD): Register.LCD.write_string(" LAMPA 2\n\r RESET BLOKAD ") if self.selected_index == 5: with cleared(Register.LCD): Register.LCD.write_string(" LAMPA 2\n\r WYJSCIE")
def draw(self): if not self.redraw: return self.redraw = False if self.selected_index == 0: with cleared(Register.LCD): Register.LCD.write_string( " PRZELACZNIKI\n\rFILTR 1 " + Register.get_switch_state(Register.I2C_POWERMOD_FILTER1) + self.get_override(Register.I2C_POWERMOD_FILTER1)) if self.selected_index == 1: with cleared(Register.LCD): Register.LCD.write_string( " PRZELACZNIKI\n\rFILTR 2 " + Register.get_switch_state(Register.I2C_POWERMOD_FILTER2) + self.get_override(Register.I2C_POWERMOD_FILTER2)) if self.selected_index == 2: with cleared(Register.LCD): Register.LCD.write_string( " PRZELACZNIKI\n\rO2 " + Register.get_switch_state(Register.I2C_POWERMOD_O2) + self.get_override(Register.I2C_POWERMOD_O2)) if self.selected_index == 3: with cleared(Register.LCD): Register.LCD.write_string( " PRZELACZNIKI\n\rCO2 " + Register.get_switch_state(Register.I2C_POWERMOD_CO2) + self.get_override(Register.I2C_POWERMOD_CO2)) if self.selected_index == 4: with cleared(Register.LCD): Register.LCD.write_string( " PRZELACZNIKI\n\rGRZALKA " + Register.get_switch_state(Register.I2C_POWERMOD_HEATER) + self.get_override(Register.I2C_POWERMOD_HEATER)) if self.selected_index == 5: with cleared(Register.LCD): Register.LCD.write_string( " PRZELACZNIKI\n\rGRZALKA LED " + Register.get_switch_state(Register.I2C_POWERMOD_HEATER_LED) + self.get_override(Register.I2C_POWERMOD_HEATER_LED)) if self.selected_index == 6: with cleared(Register.LCD): Register.LCD.write_string(" PRZELACZNIKI\n\r RESET BLOKAD ") if self.selected_index == 7: with cleared(Register.LCD): Register.LCD.write_string(" PRZELACZNIKI\n\r WYJSCIE")
def draw(self): if not self.redraw: return self.redraw = False if self.selected_index == 0: with cleared(Register.LCD): Register.LCD.write_string(" PRZELACZNIKI\n\rFILTR 1 " + Register.get_switch_state(Register.I2C_POWERMOD_FILTER1) + self.get_override(Register.I2C_POWERMOD_FILTER1)) if self.selected_index == 1: with cleared(Register.LCD): Register.LCD.write_string(" PRZELACZNIKI\n\rFILTR 2 " + Register.get_switch_state(Register.I2C_POWERMOD_FILTER2) + self.get_override(Register.I2C_POWERMOD_FILTER2)) if self.selected_index == 2: with cleared(Register.LCD): Register.LCD.write_string(" PRZELACZNIKI\n\rO2 " + Register.get_switch_state(Register.I2C_POWERMOD_O2) + self.get_override(Register.I2C_POWERMOD_O2)) if self.selected_index == 3: with cleared(Register.LCD): Register.LCD.write_string(" PRZELACZNIKI\n\rCO2 " + Register.get_switch_state(Register.I2C_POWERMOD_CO2) + self.get_override(Register.I2C_POWERMOD_CO2)) if self.selected_index == 4: with cleared(Register.LCD): Register.LCD.write_string(" PRZELACZNIKI\n\rGRZALKA " + Register.get_switch_state(Register.I2C_POWERMOD_HEATER) + self.get_override(Register.I2C_POWERMOD_HEATER)) if self.selected_index == 5: with cleared(Register.LCD): Register.LCD.write_string(" PRZELACZNIKI\n\rGRZALKA LED " + Register.get_switch_state(Register.I2C_POWERMOD_HEATER_LED) + self.get_override(Register.I2C_POWERMOD_HEATER_LED)) if self.selected_index == 6: with cleared(Register.LCD): Register.LCD.write_string(" PRZELACZNIKI\n\r RESET BLOKAD ") if self.selected_index == 7: with cleared(Register.LCD): Register.LCD.write_string(" PRZELACZNIKI\n\r WYJSCIE")
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.text_align_mode = Alignment.right lcd.write_string(' Spam') input('The word "Spam" should now be inverted. ') lcd.text_align_mode = Alignment.left lcd.write_string(' Wurscht')
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.text_align_mode = Alignment.right lcd.write_string(' Spam') input('The word "Spam" should now be inverted. ')
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)
def draw(self): if 0 <= self.iter < 20: if self.i == 0: with cleared(self.lcd): self.lcd.write_string(" TEMP WODY\r\n " + str(Register.WATER_TEMP)) self.lcd.home() self.i += 1 if 20 <= self.iter < 40: if self.i == 1: with cleared(self.lcd): self.lcd.write_string(" TEMP LAMPY\r\n " + str(Register.LIGHT1_TEMP)) self.lcd.home() self.i += 1 if 40 <= self.iter < 60: if self.i == 2: with cleared(self.lcd): self.lcd.write_string(" TEMP OTOCZENIA\r\n " + str(Register.AIR_TEMP)) self.lcd.home() self.i += 1 if 60 <= self.iter < 80: if self.i == 3: with cleared(self.lcd): self.lcd.write_string(" pH WODY\r\n 6.5pH") self.lcd.home() self.i += 1 #STAN BUTELEK if 80 <= self.iter < 100: if self.i == 4: with cleared(self.lcd): self.lcd.write_string("STAN " +Register.BOTTLE_SETTINGS['1']['name'] + "\r\n " + str(Register.BOTTLE_SETTINGS['1']['percent']) + '%') self.lcd.home() self.i += 1 if 100 <= self.iter < 120: if self.i == 5: with cleared(self.lcd): self.lcd.write_string("STAN " + Register.BOTTLE_SETTINGS['2']['name'] + "\r\n " + str( Register.BOTTLE_SETTINGS['2']['percent']) + '%') self.lcd.home() self.i += 1 # ostatni przypisuje na zero if 120 <= self.iter < 140: if self.i == 6: with cleared(self.lcd): self.lcd.write_string("STAN " + Register.BOTTLE_SETTINGS['3']['name'] + "\r\n " + str( Register.BOTTLE_SETTINGS['3']['percent']) + '%') self.lcd.home() self.i += 1 # ostatni przypisuje na zero if 140 <= self.iter < 160: if self.i == 7: with cleared(self.lcd): self.lcd.write_string("STAN " + Register.BOTTLE_SETTINGS['4']['name'] + "\r\n " + str( Register.BOTTLE_SETTINGS['4']['percent']) + '%') self.lcd.home() self.i += 1 # ostatni przypisuje na zero if 160 <= self.iter < 180: if self.i == 8: with cleared(self.lcd): self.lcd.write_string("STAN " + Register.BOTTLE_SETTINGS['5']['name'] + "\r\n " + str( Register.BOTTLE_SETTINGS['5']['percent']) + '%') self.lcd.home() self.i += 1 # ostatni przypisuje na zero if 180 <= self.iter < 200: if self.i == 9: with cleared(self.lcd): self.lcd.write_string("STAN " + Register.BOTTLE_SETTINGS['6']['name'] + "\r\n " + str( Register.BOTTLE_SETTINGS['6']['percent']) + '%') self.lcd.home() self.i += 1 # ostatni przypisuje na zero # STAN WLACZNIKOW if 200 <= self.iter < 220: if self.i == 10: with cleared(self.lcd): self.lcd.write_string("STAN " + Register.POWERMOD_DATA[str(Register.I2C_POWERMOD_LIGHT1)]['name'] + "\r\n " + str(Register.POWERMOD_DATA[str(Register.I2C_POWERMOD_LIGHT1)]['on'])) self.lcd.home() self.i += 1 # ostatni przypisuje na zero if 220 <= self.iter < 240: if self.i == 11: with cleared(self.lcd): self.lcd.write_string("STAN " + Register.POWERMOD_DATA[str(Register.I2C_POWERMOD_LIGHT2)]['name'] + "\r\n " + str(Register.POWERMOD_DATA[str(Register.I2C_POWERMOD_LIGHT2)]['on'])) self.lcd.home() self.i += 1 # ostatni przypisuje na zero if 240 <= self.iter < 260: if self.i == 12: with cleared(self.lcd): self.lcd.write_string("STAN " + Register.POWERMOD_DATA[str(Register.I2C_POWERMOD_FILTER1)]['name'] + "\r\n " + str(Register.POWERMOD_DATA[str(Register.I2C_POWERMOD_FILTER1)]['on'])) self.lcd.home() self.i += 1 # ostatni przypisuje na zero if 260 <= self.iter < 280: if self.i == 13: with cleared(self.lcd): self.lcd.write_string("STAN " + Register.POWERMOD_DATA[str(Register.I2C_POWERMOD_FILTER2)]['name'] + "\r\n " + str(Register.POWERMOD_DATA[str(Register.I2C_POWERMOD_FILTER2)]['on'])) self.lcd.home() self.i += 1 # ostatni przypisuje na zero if 280 <= self.iter < 300: if self.i == 14: with cleared(self.lcd): self.lcd.write_string("STAN " + Register.POWERMOD_DATA[str(Register.I2C_POWERMOD_O2)]['name'] + "\r\n " + str(Register.POWERMOD_DATA[str(Register.I2C_POWERMOD_O2)]['on'])) self.lcd.home() self.i += 1 # ostatni przypisuje na zero if 300 <= self.iter < 320: if self.i == 15: with cleared(self.lcd): self.lcd.write_string("STAN " + Register.POWERMOD_DATA[str(Register.I2C_POWERMOD_CO2)]['name'] + "\r\n " + str(Register.POWERMOD_DATA[str(Register.I2C_POWERMOD_CO2)]['on'])) self.lcd.home() self.i += 1 # ostatni przypisuje na zero if 340 <= self.iter < 360: if self.i == 16: with cleared(self.lcd): self.lcd.write_string("STAN " + Register.POWERMOD_DATA[str(Register.I2C_POWERMOD_HEATER)]['name'] + "\r\n " + str(Register.POWERMOD_DATA[str(Register.I2C_POWERMOD_HEATER)]['on'])) self.lcd.home() self.i += 1 # ostatni przypisuje na zero if 360 <= self.iter < 380: if self.i == 17: with cleared(self.lcd): self.lcd.write_string("STAN " + Register.POWERMOD_DATA[str(Register.I2C_POWERMOD_HEATER_LED)]['name'] + "\r\n " + str(Register.POWERMOD_DATA[str(Register.I2C_POWERMOD_HEATER_LED)]['on'])) self.lcd.home() self.i = 0 # ostatni przypisuje na zero self.iter += 1 self.iter %= 380
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)
def update(self, *lines): with cleared(self.lcd): for i in range(0, len(lines)): self.lcd.cursor_pos = (i, 0) text = self.__replace_custom_chars(lines[i]) self.lcd.write_string(text)
def draw(self): if 0 <= self.iter < 20: if self.i == 0: with cleared(self.lcd): self.lcd.write_string(" TEMP WODY\r\n " + str(Register.WATER_TEMP)) self.lcd.home() self.i += 1 if 20 <= self.iter < 40: if self.i == 1: with cleared(self.lcd): self.lcd.write_string(" TEMP LAMPY\r\n " + str(Register.LIGHT1_TEMP)) self.lcd.home() self.i += 1 if 40 <= self.iter < 60: if self.i == 2: with cleared(self.lcd): self.lcd.write_string(" TEMP OTOCZENIA\r\n " + str(Register.AIR_TEMP)) self.lcd.home() self.i += 1 if 60 <= self.iter < 80: if self.i == 3: with cleared(self.lcd): self.lcd.write_string(" pH WODY\r\n 6.5pH") self.lcd.home() self.i += 1 #STAN BUTELEK if 80 <= self.iter < 100: if self.i == 4: with cleared(self.lcd): self.lcd.write_string( "STAN " + Register.BOTTLE_SETTINGS['1']['name'] + "\r\n " + str(Register.BOTTLE_SETTINGS['1']['percent']) + '%') self.lcd.home() self.i += 1 if 100 <= self.iter < 120: if self.i == 5: with cleared(self.lcd): self.lcd.write_string( "STAN " + Register.BOTTLE_SETTINGS['2']['name'] + "\r\n " + str(Register.BOTTLE_SETTINGS['2']['percent']) + '%') self.lcd.home() self.i += 1 # ostatni przypisuje na zero if 120 <= self.iter < 140: if self.i == 6: with cleared(self.lcd): self.lcd.write_string( "STAN " + Register.BOTTLE_SETTINGS['3']['name'] + "\r\n " + str(Register.BOTTLE_SETTINGS['3']['percent']) + '%') self.lcd.home() self.i += 1 # ostatni przypisuje na zero if 140 <= self.iter < 160: if self.i == 7: with cleared(self.lcd): self.lcd.write_string( "STAN " + Register.BOTTLE_SETTINGS['4']['name'] + "\r\n " + str(Register.BOTTLE_SETTINGS['4']['percent']) + '%') self.lcd.home() self.i += 1 # ostatni przypisuje na zero if 160 <= self.iter < 180: if self.i == 8: with cleared(self.lcd): self.lcd.write_string( "STAN " + Register.BOTTLE_SETTINGS['5']['name'] + "\r\n " + str(Register.BOTTLE_SETTINGS['5']['percent']) + '%') self.lcd.home() self.i += 1 # ostatni przypisuje na zero if 180 <= self.iter < 200: if self.i == 9: with cleared(self.lcd): self.lcd.write_string( "STAN " + Register.BOTTLE_SETTINGS['6']['name'] + "\r\n " + str(Register.BOTTLE_SETTINGS['6']['percent']) + '%') self.lcd.home() self.i += 1 # ostatni przypisuje na zero # STAN WLACZNIKOW if 200 <= self.iter < 220: if self.i == 10: with cleared(self.lcd): self.lcd.write_string( "STAN " + Register.POWERMOD_DATA[str( Register.I2C_POWERMOD_LIGHT1)]['name'] + "\r\n " + str(Register.POWERMOD_DATA[str( Register.I2C_POWERMOD_LIGHT1)]['on'])) self.lcd.home() self.i += 1 # ostatni przypisuje na zero if 220 <= self.iter < 240: if self.i == 11: with cleared(self.lcd): self.lcd.write_string( "STAN " + Register.POWERMOD_DATA[str( Register.I2C_POWERMOD_LIGHT2)]['name'] + "\r\n " + str(Register.POWERMOD_DATA[str( Register.I2C_POWERMOD_LIGHT2)]['on'])) self.lcd.home() self.i += 1 # ostatni przypisuje na zero if 240 <= self.iter < 260: if self.i == 12: with cleared(self.lcd): self.lcd.write_string( "STAN " + Register.POWERMOD_DATA[str( Register.I2C_POWERMOD_FILTER1)]['name'] + "\r\n " + str(Register.POWERMOD_DATA[str( Register.I2C_POWERMOD_FILTER1)]['on'])) self.lcd.home() self.i += 1 # ostatni przypisuje na zero if 260 <= self.iter < 280: if self.i == 13: with cleared(self.lcd): self.lcd.write_string( "STAN " + Register.POWERMOD_DATA[str( Register.I2C_POWERMOD_FILTER2)]['name'] + "\r\n " + str(Register.POWERMOD_DATA[str( Register.I2C_POWERMOD_FILTER2)]['on'])) self.lcd.home() self.i += 1 # ostatni przypisuje na zero if 280 <= self.iter < 300: if self.i == 14: with cleared(self.lcd): self.lcd.write_string( "STAN " + Register.POWERMOD_DATA[str( Register.I2C_POWERMOD_O2)]['name'] + "\r\n " + str(Register.POWERMOD_DATA[str( Register.I2C_POWERMOD_O2)]['on'])) self.lcd.home() self.i += 1 # ostatni przypisuje na zero if 300 <= self.iter < 320: if self.i == 15: with cleared(self.lcd): self.lcd.write_string( "STAN " + Register.POWERMOD_DATA[str( Register.I2C_POWERMOD_CO2)]['name'] + "\r\n " + str(Register.POWERMOD_DATA[str( Register.I2C_POWERMOD_CO2)]['on'])) self.lcd.home() self.i += 1 # ostatni przypisuje na zero if 340 <= self.iter < 360: if self.i == 16: with cleared(self.lcd): self.lcd.write_string( "STAN " + Register.POWERMOD_DATA[str( Register.I2C_POWERMOD_HEATER)]['name'] + "\r\n " + str(Register.POWERMOD_DATA[str( Register.I2C_POWERMOD_HEATER)]['on'])) self.lcd.home() self.i += 1 # ostatni przypisuje na zero if 360 <= self.iter < 380: if self.i == 17: with cleared(self.lcd): self.lcd.write_string( "STAN " + Register.POWERMOD_DATA[str( Register.I2C_POWERMOD_HEATER_LED)]['name'] + "\r\n " + str(Register.POWERMOD_DATA[str( Register.I2C_POWERMOD_HEATER_LED)]['on'])) self.lcd.home() self.i = 0 # ostatni przypisuje na zero self.iter += 1 self.iter %= 380