Example #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(1)        
Example #2
0
def write_message(config):
    print "writting  message to LCD"
#    config = parse_config(config)
#    print config.lcd_module, format(config.lcd_i2c_add,'02X'), config.lcd_i2c_port, " > " + config.lcd_message
    myDevice = None
    if (config.lcd_module == "pcf8574_1602"):
        myDevice = pcf8574_1602(config.lcd_i2c_add,config.lcd_i2c_port)
    elif (config.lcd_module == "mcp23017_1602"):
       myDevice = mcp23017_1602(config.lcd_i2c_add,config.lcd_i2c_port)
    else:
       myDevice = None

    if (myDevice == None):
        sys.exit(0)
    
    myDevice.lcd1602.backlight(1)
    myDevice.lcd1602.clear_display()
    myDevice.lcd1602.return_home()    
    messages = config.lcd_message.split("\\n")
#    print messages
    line = 0
    for msg in messages:
        if (line <2):
            myDevice.lcd1602.write_string(line,0,msg)    
            print msg
        line = line + 1
    myDevice.lcd1602.set_cursor(0,100)
Example #3
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"