def start(): logging.info("Starting...") global screens global curScreen global prevScreen screens["mainMenu"].setOptions(mainMenuOptions) screens["power"].setOptions(powerOptions) screens["print"].setOptions(printerFuntions) screens["printer"].setOptions(printerOptions) screens["outlet"].setOptions(outletOptions) logging.debug("Clearing LCD") Lcd.clear() logging.debug("Initing Hardware") Hardware.init() logging.debug("Starting checkPrinter thread") thread.start_new_thread(checkPrinter, ()) logging.info("Started") while(True): Hardware.update() if not curScreen == prevScreen: screens[curScreen].init() logging.info("Changing Screen to {}".format(curScreen)) prevScreen = curScreen screens[curScreen].update() screens[curScreen].draw() curScreen = screens[curScreen].nextScreen()
def start(): logging.info("Starting...") global screens global curScreen global prevScreen screens["mainMenu"].setOptions(mainMenuOptions) screens["power"].setOptions(powerOptions) screens["print"].setOptions(printerFuntions) screens["printer"].setOptions(printerOptions) screens["outlet"].setOptions(outletOptions) logging.debug("Clearing LCD") Lcd.clear() logging.debug("Initing Hardware") Hardware.init() logging.debug("Starting checkPrinter thread") thread.start_new_thread(checkPrinter, ()) logging.info("Started") while (True): Hardware.update() if not curScreen == prevScreen: screens[curScreen].init() logging.info("Changing Screen to {}".format(curScreen)) prevScreen = curScreen screens[curScreen].update() screens[curScreen].draw() curScreen = screens[curScreen].nextScreen()
def Mostra_lcd(temp_data_att, temp_int_att, temp_est_att, led_basso_att, led_alto_att, reg_min_att, reg_max_att): '''mostra i dati misurati su LCD''' riga_uno = temp_data_att riga_due = "Tint:" + str(temp_int_att) + " Test:" + str(temp_est_att) riga_tre = "Min:" + str(reg_min_att) + " Max:" + str(reg_max_att) riga_qua = "Nessun Allarme" if (led_basso_att == '1'): riga_qua = "Allarme BASSA!" if (led_alto_att == '1'): riga_qua = "Allarme ALTA!" Lcd.lcd_string(riga_uno, 1, 1) Lcd.lcd_string(riga_due, 2, 2) Lcd.lcd_string(riga_tre, 3, 2) Lcd.lcd_string(riga_qua, 4, 2)
def main(): board = Board() relay = Relay() lcd = Lcd() while (1): light = int(board.light()) lcd.display_string("Control: %d" % (board.control()), 1) lcd.display_string("Light: %d" % (light), 2) lcd.display_string("Temprature: %d" % (board.temperature()), 3) lcd.display_string("Custom: %d" % (board.custom()), 4) if light >= 175: relay.on(0) if light >= 200: relay.on(1) if light <= 125: relay.off(1) if light <= 50: relay.off(0) time.sleep(1)
def pumpswitchOn(request): #lcd = Lcd() #lcd.clear() #lcd.display_string("pump on",1) #relay = Relay() #relay.switch(3,1) lcd = Lcd() lcd.clear() pumpStatus = "ON" lcd.display_string("Water Pump %s" % pumpStatus, 1) moistureLevel = getLatestMoistureLevel() savedata(1, moistureLevel, pumpStatus) response_mesage = {"result": "pump is on"} return JsonResponse(response_mesage)
def mostra_cambi(K=1): ''' pubblica cambi temperature e stato limiti stampa enche per controlli K=0 solo in avvio''' global temp_data_att global temp_int global temp_est global temp_int_att global temp_est_att global reg_min global reg_max global reg_min_att global reg_max_att global led_basso_att global led_alto_att if (K == 1): temp_data_att = leggi_data_att() test_alarm(float(temp_int_att)) mqttc.publish('Temp/data', temp_data_att) mqttc.publish('Temp/interna', temp_int_att) mqttc.publish('Temp/esterna', temp_est_att) mqttc.publish('Led/bassa', led_basso_att, 1) mqttc.publish('Led/alta', led_alto_att) mqttc.publish('Temp/min', reg_min_att) mqttc.publish('Temp/max', reg_max_att) mqttc.publish('Temp/run', "ON") time.sleep(0.2) # mostra su LCD Lcd.lcd_init(LCD_RS, LCD_E, LCD_D4, LCD_D5, LCD_D6, LCD_D7, LCD_Back) Lcd.lcd_backlight(True) Lcd.lcd_clear() Mostra_lcd(temp_data_att, temp_int_att, temp_est_att, led_basso_att, led_alto_att, reg_min_att, reg_max_att) # fine LCD if (Test): print if (K == 0): # interviene solo dopo la lettura iniziale del file di stato temp_int = temp_int_att temp_est = temp_est_att reg_min = reg_min_att reg_max = reg_max_att if (Test): print
def main(): board = Board() lcd = Lcd() while (1): lcd.clear() lcd.display_string("Control: %d" % (board.control()), 1) lcd.display_string("Light: %d" % (board.light()), 2) lcd.display_string("Temprature: %d" % (board.temperature()), 3) lcd.display_string("Custom: %d" % (board.custom()), 4) time.sleep(3)
def callback(channel): if GPIO.input(channel): print "LED off" lcd = Lcd() lcd.clear() lcd.display_string(message_need_water, 1) savedata(1, "Need water") else: print "LED on" lcd = Lcd() lcd.clear() lcd.display_string(message_noneed_water, 1) savedata(1, "No need water")
def Avvio_LCD(): # Initialise display Lcd.lcd_init(LCD_RS, LCD_E, LCD_D4, LCD_D5, LCD_D6, LCD_D7, LCD_Back) # Accensione backlight Lcd.lcd_backlight(True) time.sleep(0.5) # Send some centred test Lcd.lcd_string("--------------------", 1, 2) Lcd.lcd_string("C.H.I.P. computer", 2, 2) Lcd.lcd_string("Works", 3, 2) Lcd.lcd_string("--------------------", 4, 2) time.sleep(5)
if __name__ == '__main__': try: tempture = TEMP() os.system('clear') if (Test): print "... tentativo di avvio ..." init_mqtt() mqttc.on_connect = on_connect mqttc.on_message = on_message # inizializza LCD Avvio_LCD() main() except KeyboardInterrupt: # salva stato su file in calso di Ctrl C salva_stato() pass finally: # spegne gli Switch di allarme mqttc.publish("Led/bassa", 0) mqttc.publish("Led/alta", 0) mqttc.publish("Temp/run", "OFF") # chiude LCD Lcd.lcd_clear() Lcd.lcd_string("Programma interrotto", 2, 2) Lcd.lcd_string("Goodbye!", 3, 2) time.sleep(1) Lcd.lcd_stop() # disconnetti mqtt mqttc.disconnect() os.system('clear') print "Programma interrotto\nGoodbye!"
def main(): lcd = Lcd() lcd.clear() for i in range(1,len(sys.argv)): lcd.display_string(sys.argv[i], i)
def __init__(self): self.lcd = Lcd.__init__() self.green = Led.__init__() self.red = Led.__init__()
def draw(self): for line in range(0, Lcd.height): Lcd.setCur(0, line) Lcd.write("".join(self.lines[line]))
def init(self): Lcd.clear()
def main(self): logging.info("Incubator started... " + self.start_time.strftime('%Y-%m-%d %H:%M:%S')) self.send_notification("Incubator started") self.ssr.set_point(self.config.get_temp()) # Start roller self.roller.set_day(self.config.get_day()) self.roller.start() web = Web.Web(self) web.start() lcd = Lcd() temp_sensor = Resource.create_temp_sensor() htu21d = Resource.create_humidity_sensor() # Start SSR service self.ssr.set_value(0) self.ssr.start() # Start buttons and relays # self.io_handler.start() i = 0 state = State() state.set_day(self.get_days_from_start()) http_sender = HttpSender.HttpSender() while self._running: state.update_ts() state.set_temp1(temp_sensor.read_temp()) pid = self.ssr.update(state.get_temp1()) state.set_pid(pid) #if state.temp1 > 38.5: # self.send_notification("High temp alert, {} gr".format(state.temp1)) if i % 10 == 0: # Read humidity and temp each 10 seconds try: state.set_temp2(htu21d.read_temperature()) state.set_humidity(htu21d.read_humidity()) except: self.send_notification("Failed to read htu21d") self.ventilation.set_state(state) state.set_humidity_level(self.ventilation.get_output_level()) http_sender.send("A123", state) if i >= 30: # Set new temp from config file self.config.reload() self.ssr.set_point(self.config.get_temp()) self.ssr.set_k(self.config.get_k()) self.ssr.set_i(self.config.get_i()) self.ventilation.set_point(self.get_humidity()) state.set_day(self.get_days_from_start()) if self.config.get_day() != state.get_day(): self.config.set_day(state.get_day()) self.config.save() self.roller.set_day(state.get_day()) self.log_incubator_state(self.config, state) # update web page web.update(state, self.config) i = 0 lcd.update(state, self.roller.get_minutes_from_last_roll()) sys.stdout.flush() time.sleep(1) i += 1 self.shutdown()
import os import time import Lcd as LCD import RPi.GPIO as GPIO # Lines LINE_1 = 0x80 # LCD RAM address for the 1st line LINE_2 = 0xC0 # LCD RAM address for the 2nd line LINE_3 = 0x94 # LCD RAM address for the 3rd line LINE_4 = 0xD4 # LCD RAM address for the 4th line # Intialize pygame pygame.init() # Intialize LCD Monitor LCD.init() # Setup GPIO for wired button detection GPIO.setmode(GPIO.BCM) GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP) # The state of the last wired button press lastInput = True # Main loop will continue until done is True done = False # When true music will be played playingMusic = False # When true amazon dash or wire button has been detected detectedButton = False # Index of current song being played (or that was just played)