Exemplo n.º 1
0
def Sunset():
    global LampBusy, StartTime, Index, Status, GlobalSleep
    GlobalSleep = 0
    if(SunsetStart == 1 and LampBusy == 0):
        LampBusy = 1
        StartTime = lampio.getTimeMillis()
        Index = 0
        Status = 0
        Color[0] = 255
        Color[1] = 255
        Color[2] = 255
        lampio.setLamp(Color)
    if(SunsetStart == 1 and LampBusy == 1 and lampio.getTimeDifferenceMillis(StartTime) >= (int(SunsetDuration) * 60000)):
        lampio.writeFile("sunset_start", "0")
        lampio.writeFile("mode", "0")
        LampBusy = 0
        StartTime = 0
        time.sleep(1)
    if(SunsetStart == 1 and LampBusy == 1 and Status <= 760):
        Index = int(2 - math.floor(Status/255))
        Color[Index] = 250 - Status%255
        lampio.setLamp(Color)
        Status += 5
        GlobalSleep = float(SunsetDuration)*60/154
Exemplo n.º 2
0
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
    if(lampio.getTimeDifferenceMillis(ElapsedRetrieveDataTime) >= 150):
        ElapsedRetrieveDataTime = lampio.getTimeMillis()
Exemplo n.º 3
0
def buttonPressed(button):
    lampio.writeFile("mode", lampio.readFile("buttons")[button])