Exemplo n.º 1
0
TemperatureMeasured = 0	#Measured temperature
Scheduled = []	#Programmed Auto
Index = 0	#Index of colors
Status = 0  #Status of animation
GlobalSleep = 0.1 #Global sleep time

#    Main program

lampio.setLamp(Color)

while True:

    # Check Mode
    if(lampio.getTimeDifferenceMillis(ElapsedCheckModeTime) >= 1000):
        ElapsedCheckModeTime = lampio.getTimeMillis()
        TempRead = int(lampio.readFile("mode"))
        if(TempRead != Mode):
            lampio.writeFile("sunset_start", "0")
            Mode = TempRead
            LampBusy = 0
            StartTime = 0
            AutoDuration = 0
            Index = 0
            Status = 0
            Color = list(StartColor[Mode])
            lampio.setLamp(Color)
        #Check shutdown
        if(int(lampio.readFile("shutdown")) == 1):
            os.system("sudo shutdown -h now")

    # Retrieve data of the current Mode
Exemplo n.º 2
0
def buttonPressed(button):
    lampio.writeFile("mode", lampio.readFile("buttons")[button])