def __buttery(r_from, g_from, b_from, r_to, g_to, b_to): step_ms = 2 interval_sec = 0.3 if Data.DCACHE[3] == 0: # Turn from OFF to on (to colors) r_from, g_from, b_from = 0, 0, 0 Data.DCACHE[3] = 1 r_gen = transition(from_val=r_from, to_val=r_to, step_ms=step_ms, interval_sec=interval_sec) g_gen = transition(from_val=g_from, to_val=g_to, step_ms=step_ms, interval_sec=interval_sec) b_gen = transition(from_val=b_from, to_val=b_to, step_ms=step_ms, interval_sec=interval_sec) for _r in r_gen: _g = g_gen.__next__() _b = b_gen.__next__() for lcnt in range(0, __init_NEOPIXEL().n): Data.NEOPIXEL_OBJ[lcnt] = (_r, _g, _b) Data.NEOPIXEL_OBJ.write() sleep_ms(1)
def set_transition(r, g, b, sec): """ Set transition color change for long dimming periods < 30sec - creates the color dimming generators :param r: red value 0-255 :param g: green value 0-255 :param b: blue value 0-255 :param sec: transition length in sec :return: info msg string """ Data.DCACHE[3] = 1 timirqseq = cfgget('timirqseq') from_red = Data.DCACHE[0] from_green = Data.DCACHE[1] from_blue = Data.DCACHE[2] # Generate RGB color transition object (generator) Data.FADE_OBJ = (transition(from_val=from_red, to_val=r, step_ms=timirqseq, interval_sec=sec), transition(from_val=from_green, to_val=g, step_ms=timirqseq, interval_sec=sec), transition(from_val=from_blue, to_val=b, step_ms=timirqseq, interval_sec=sec)) return 'Settings was applied... wait for: run_transition'
def __buttery(ww_from, cw_from, ww_to, cw_to): step_ms = 2 interval_sec = 0.3 if Data.CWWW_CACHE[2] == 0: # Turn from OFF to on (to whites) ww_from, cw_from = 0, 0 Data.CWWW_CACHE[2] = 1 ww_gen = transition(from_val=ww_from, to_val=ww_to, step_ms=step_ms, interval_sec=interval_sec) cw_gen = transition(from_val=cw_from, to_val=cw_to, step_ms=step_ms, interval_sec=interval_sec) for _ww in ww_gen: Data.CWWW_OBJS[1].duty(_ww) Data.CWWW_OBJS[0].duty(cw_gen.__next__()) sleep_ms(step_ms)
def __buttery(x_from, y_from, x_to, y_to): x_diff = abs(x_from - x_to) y_diff = abs(y_from - y_to) max_diff = y_diff if x_diff < y_diff else x_diff step_ms = RoboArm.SPEED_MS # resolution interval_sec = float(RoboArm.SPEED_MS * 0.001 * max_diff) # calculate travel time in sec x = transition(from_val=x_from, to_val=x_to, step_ms=step_ms, interval_sec=interval_sec) y = transition(from_val=y_from, to_val=y_to, step_ms=step_ms, interval_sec=interval_sec) for _x in x: servo.sduty(_x) servo.s2duty(y.__next__()) sleep_ms(step_ms)
def set_transition(cw, ww, sec): """ Set transition white channel change for long dimming periods < 30sec - creates the 2 white dimming generators :param cw: cold white value 0-1000 :param ww: warm white value 0-1000 :param sec: transition length in sec :return: info msg string """ Data.CWWW_CACHE[2] = 1 timirqseq = cfgget('timirqseq') from_cw = Data.CWWW_CACHE[0] from_ww = Data.CWWW_CACHE[1] # Generate cold white + warm white transition object (generator) Data.FADE_OBJS = (transition(from_val=from_cw, to_val=cw, step_ms=timirqseq, interval_sec=sec), transition(from_val=from_ww, to_val=ww, step_ms=timirqseq, interval_sec=sec)) return 'Settings was applied... wait for: run_transition'
def __buttery(r_from, g_from, b_from, r_to, g_to, b_to): step_ms = 2 interval_sec = 0.3 if Data.RGB_CACHE[3] == 0: # Turn from OFF to on (to colors) r_from, g_from, b_from = 0, 0, 0 Data.RGB_CACHE[3] = 1 r_gen = transition(from_val=r_from, to_val=r_to, step_ms=step_ms, interval_sec=interval_sec) g_gen = transition(from_val=g_from, to_val=g_to, step_ms=step_ms, interval_sec=interval_sec) b_gen = transition(from_val=b_from, to_val=b_to, step_ms=step_ms, interval_sec=interval_sec) for _r in r_gen: Data.RGB_OBJS[0].duty(_r) Data.RGB_OBJS[1].duty(g_gen.__next__()) Data.RGB_OBJS[2].duty(b_gen.__next__()) sleep_ms(step_ms)