Beispiel #1
0
    def state_now(self):
        cur_time = convert.current_time()
        st = self.loc_lut[self.cur_state_index()]
        nxt_st = self.next_state()

        inf('currently in state:        ' + str(st.name))
        inf('current state start time:  ' + str(st.start))
        inf('cur_time:                  ' + str(cur_time))
        inf('next state:                ' + str(nxt_st.name))
        inf('next state start time:     ' + str(nxt_st.start))

        # calculate how far we are into the current state
        time_in = cur_time - st.start
        dbg('abs time in to this state: ' + str(time_in))

        # calculate what percentage we are into the current state
        frac_in = time_in / (nxt_st.start - st.start)
        dbg('frac in:                   ' + str(frac_in))

        cur_hue = convert.interp(st.hue, nxt_st.hue, frac_in)
        dbg('cur_hue:                   ' + str(cur_hue))

        cur_sat = convert.interp(st.sat, nxt_st.sat, frac_in)
        dbg('cur_sat:                   ' + str(cur_sat))

        cur_bright = convert.interp(st.bright, nxt_st.bright, frac_in)
        dbg('cur_bright:                ' + str(cur_bright))

        cur_kelvin = int(convert.interp(st.kelvin, nxt_st.kelvin, frac_in))
        dbg('cur_kelvin:                ' + str(cur_kelvin))

        cur_st = LightState(st.name, cur_bright, st.start, cur_hue, cur_sat,
                            cur_kelvin)
        return cur_st
Beispiel #2
0
    def state_now(self):
        cur_time = convert.current_time()
        st = self.loc_lut[self.cur_state_index()]
        nxt_st = self.next_state()

        inf('currently in state:        ' + str(st.name))
        inf('current state start time:  ' + str(st.start))
        inf('cur_time:                  ' + str(cur_time))
        inf('next state:                ' + str(nxt_st.name))
        inf('next state start time:     ' + str(nxt_st.start))

        # calculate how far we are into the current state
        time_in = cur_time - st.start
        dbg('abs time in to this state: ' + str(time_in))

        # calculate what percentage we are into the current state
        frac_in = time_in / (nxt_st.start - st.start)
        dbg('frac in:                   ' + str(frac_in))

        cur_hue = convert.interp(st.hue, nxt_st.hue, frac_in)
        dbg('cur_hue:                   ' + str(cur_hue))

        cur_sat = convert.interp(st.sat, nxt_st.sat, frac_in)
        dbg('cur_sat:                   '+str(cur_sat))

        cur_bright = convert.interp(st.bright, nxt_st.bright, frac_in)
        dbg('cur_bright:                '+str(cur_bright))

        cur_kelvin = int(convert.interp(st.kelvin, nxt_st.kelvin, frac_in))
        dbg('cur_kelvin:                '+str(cur_kelvin))

        cur_st = LightState(st.name, cur_bright, st.start,
                            cur_hue, cur_sat, cur_kelvin)
        return cur_st
Beispiel #3
0
 def secs_to_next_state(self):
     cur_time = convert.current_time()
     nxt_st = self.next_state()
     # calculate remaining duration in current state
     if nxt_st.start < cur_time:
         # this would be in the event that we're in the last scene of the lut
         dur = (1 - cur_time) + nxt_st.start
     else:
         dur = nxt_st.start - cur_time
     t = convert.day_frac_to_secs(dur)
     dbg('secs to next state:        ' + str(t))
     return t
Beispiel #4
0
 def secs_to_next_state(self):
     cur_time = convert.current_time()
     nxt_st = self.next_state()
     # calculate remaining duration in current state
     if nxt_st.start < cur_time:
         # this would be in the event that we're in the last scene of the lut
         dur = (1 - cur_time) + nxt_st.start
     else:
         dur = nxt_st.start - cur_time
     t = convert.day_frac_to_secs(dur)
     dbg('secs to next state:        ' + str(t))
     return t
Beispiel #5
0
 def cur_state_index(self):
     cur_time = convert.current_time()
     for i, st in enumerate(self.loc_lut):
         if st.start > cur_time:
             return self.wrap_index(self.loc_lut, i - 1)
     return len(self.loc_lut) - 1
Beispiel #6
0
 def cur_state_index(self):
     cur_time = convert.current_time()
     for i, st in enumerate(self.loc_lut):
         if st.start > cur_time:
             return self.wrap_index(self.loc_lut, i - 1)
     return len(self.loc_lut) - 1