예제 #1
0
    def start_print_service(self):
        print "Starting lcd print service"
        if (self.lcd_module == "pcf8574_1602"):
            self.myLCD = pcf8574_1602(self.lcd_i2c_add,self.lcd_i2c_port)
        elif (self.lcd_module == "mcp23017_1602"):
            self.myLCD = mcp23017_1602(self.lcd_i2c_add,self.lcd_i2c_port)
        else:
            self.myLCD = None

        if (self.myLCD == None):
            sys.exit(0)
        
        self.myLCD.lcd1602.backlight(1)
        self.myLCD.lcd1602.clear_display()
        self.myLCD.lcd1602.return_home()   
        self.myLCD.lcd1602.write_string(0,0,"Starting") 
        self.myLCD.lcd1602.write_string(1,0,"LCD Service") 
        
        while 1:
            myTime = datetime.now()
            myRTC = myTime.strftime('%y:%m:%d:%H:%M:%S:%w').split(":")
#            print "current time is " + myTime.strftime('%y:%m:%d:%H:%M:%S')
            self.myLCD.lcd1602.write_string(0,0,"Current Time") 
            self.myLCD.lcd1602.write_string(1,0,myTime.strftime('%m:%d %H:%M:%S')) 
            if (self.stop_print_service_flag == True):
                break;
            time.sleep(0.5)        
예제 #2
0
    def thread_1(self):
        print "Starting lcd print service"
        if (self.lcd_module == "pcf8574_1602"):
            self.myLCD = pcf8574_1602(self.lcd_i2c_add,self.lcd_i2c_port)
        elif (self.lcd_module == "mcp23017_1602"):
            self.myLCD = mcp23017_1602(self.lcd_i2c_add,self.lcd_i2c_port)
        else:
            self.myLCD = None

        if (self.myLCD == None):
            sys.exit(0)
        
        self.myLCD.lcd1602.backlight(1)
        self.myLCD.lcd1602.clear_display()
        self.myLCD.lcd1602.return_home()   
        self.myLCD.lcd1602.write_string(0,0,"Starting") 
        self.myLCD.lcd1602.write_string(1,0,"LCD Service") 
        while 1:
            myTime = datetime.now()
            myRTC = myTime.strftime('%y:%m:%d:%H:%M:%S:%w').split(":")
#            print myTime.strftime('%m:%d %H:%M:%S')
            while not self.lcd_msg_q.empty():
                lcd_msg = self.lcd_msg_q.get()
                lcd_msg += "\\n\\n"
                lcd_msgs = lcd_msg.split("\\n")
#               print "lcd display "  , lcd_msg , lcd_msgs
                self.myLCD.lcd1602.write_string(0,0,lcd_msgs[0]+"              ") 
                self.myLCD.lcd1602.write_string(1,0,lcd_msgs[1]+"              ")
                time.sleep(5)
                
            self.myLCD.lcd1602.write_string(0,0,"Current Time " + str(self.mqtt_msg_cnt)) 
            self.myLCD.lcd1602.write_string(1,0,myTime.strftime('%m:%d %H:%M:%S'))             
            if (self.stop_flag == True):
                break;
            time.sleep(1)
        print "Exiting thread_1"