def updatelcd(self): self.getlcddata() if self.lcddata != self.old_lcddata: lcd = Lcd((self.unit['lcd'][0]['addr'][0:6]), (self.unit['lcd'][0]['addr'][6:8])) for index, item in enumerate(self.lcddata): if index < 4: lcd.setCursor(0, index) lcd.printString(item) else: print 'To many rows to print, max 4' if ( (not self.unit['pir']) and (not self.unit['lcd'][0]['backlightState']) ): self.pwmLcdBacklight(250) self.old_lcddata = self.lcddata elif ( (not self.unit['pir']) and (self.unit['lcd'][0]['backlightState']) ): self.pwmLcdBacklight(0)
else: pass self.__data = raw def getCelsius(self): if self.__fetchAddress(): self.__fetchData() return self.__data / 16.0 def getFahrenheit(self): if self.__fetchAddress(): self.__fetchData() return self.getCelsius() * 1.8 + 32.0 from nanpy import Lcd if __name__ == "__main__": lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) lcd.printString("Loc. London") temp_int = FakeDallasTemperature(6) temp_ext = FakeDallasTemperature(5) while(1): lcd.setCursor(0, 1) lcd.printString("Ex.%0.0f\xDFC In.%0.0f\xDFC" % (temp_int.getCelsius(), temp_ext.getCelsius()))