Example #1
0
    def gen_frames(self):
        '''Generates frames for a movie using the Bulb class object.'''
        fmax = self.fps * self.mov_len  # get number of frames for a movie of length in seconds
        if self.elip:  # if want to rotate bulb on a path
            self.path = self.elipse(
                pts=fmax)  # apply number of frames to camera path
        elif self.views:
            self.path = self.viewer(
                pts=fmax)  # apply number of frames to camera path
        else:
            # if you dont want a path, just use the observer position in each iteration
            x, y, z = self.obpos[0] * np.ones(fmax), self.obpos[1] * np.ones(
                fmax), self.obpos[2] * np.ones(fmax)
            self.path = np.vstack((x, y, z)).T

        degrees = np.linspace(self.deg_star, self.deg_end,
                              fmax)  # apply number of frames to degrees
        # make a new set of frames and dont overwrite frames you already have using offset
        bulb = Bulb(imsize=self.res)
        Parallel(n_jobs=mp.cpu_count())(
            delayed(bulb.bulb_image)(observer_position=np.array(self.path[i]),
                                     degree=degrees[i],
                                     counter=i + self.off)
            for i in tqdm(range(fmax), desc=' :: Generating Frames :: '))
        return (
            fmax, self.fps
        )  #return the max frame index and framerate for the movie (can be useful)
Example #2
0
    def run(self):
        top = tkinter.Tk()
        top.protocol("WM_DELETE_WINDOW", self.callback)
        top.geometry('80x240')

        self.red = Bulb(top, (0, 0), 'red', 'off')
        self.yellow = Bulb(top, (0, 80), 'yellow', 'off')
        self.green = Bulb(top, (0, 160), 'green', 'off')

        def animate(bulbs):
            for bulb in bulbs:
                bulb.update()

            top.after(120, animate, bulbs)

        top.after(100, animate, [self.red, self.yellow, self.green])
        self.root = top

        self.root.mainloop()
Example #3
0
#!/usr/bin/env python3
import os
import random
import sys
import threading
from time import sleep

from bulb import Bulb


b = Bulb(host='192.168.4.170')

reg_color = [0, 0, 0, 255]
reg_brightness = 100

threading.Thread(target=b.change_color,
                 args=(*reg_color, reg_brightness)).start()

while True:
    sleep(random.randint(4, 5))
    for i in range(random.randint(1, 7)):
        sleep(random.randint(0, 200) / 1000)
        threading.Thread(target=b.change_color,
                         args=(*reg_color, 0)).start()
        sleep(random.randint(100, 300) / 1000)
        threading.Thread(target=b.change_color,
                         args=(*reg_color, reg_brightness)).start()
Example #4
0
import time
from film import Cinematic
from bulb import Bulb
import os
import numpy as np

if __name__ == '__main__':
    #Choose a color scheme from bulb
    bulbo = Bulb()
    bulbo.colordict.keys()
    colors = bulbo.colordict.keys()
    string = ''
    for i in colors:
        string += str(i) + '\n'
    inputstring = '\n\nPlease specify what color scheme you would like to see on the object. \n\nYou can choose from:\n{} \n\nEnter color here: '.format(
        string)
    while True:
        a = input(inputstring)
        try:
            a = str(a)
            assert a in colors
            break
        except Exception:
            print(
                '\n\n :: Invalid color. Please choose from the given list. :: '
            )

    # Make single high res picture of Mandelbulb, with a given colormap, and with a specific degree from the mandelbulb set.
    # takes ~ 50 seconds
    print(' :: Demo Starting ::')
    frame_index = 10
 def __init__(self, maxDutyCycle):
     self.maxDutyCycle = maxDutyCycle
     self.dayBulb = Bulb(12, 80, 0.1, 10)
     self.nightBulb = Bulb(13, 80, 10, 0.1)
     self.dayBulb.change_duty_cycle(80)
     self.nightBulb.change_duty_cycle(0)
class DualBulb:
    def __init__(self, maxDutyCycle):
        self.maxDutyCycle = maxDutyCycle
        self.dayBulb = Bulb(12, 80, 0.1, 10)
        self.nightBulb = Bulb(13, 80, 10, 0.1)
        self.dayBulb.change_duty_cycle(80)
        self.nightBulb.change_duty_cycle(0)

    def morning_sequence(self):
        self.set_bulbs_on(0, 0)
        self.dayBulb.transition_on()

    def evening_sequence(self):
        for x in range(self.maxDutyCycle):
            self.dayBulb.change_duty_cycle(self.maxDutyCycle - x)
            self.nightBulb.change_duty_cycle(x)
            time.sleep(10)

    def turn_on(self):
        # set the bulbs to ON mode
        self.dayBulb.turn_on()
        self.nightBulb.turn_on()

    def turn_off(self):
        # set the bulbs to OFF mode
        self.dayBulb.turn_off()
        self.nightBulb.turn_off()

    def set_bulbs_on(self, morningDuty, nightDuty):
        # set the duty cycles for morning and night bulbs, then turn on
        self.dayBulb.set_on(morningDuty)
        self.nightBulb.set_on(nightDuty)

    def check_bulb_status(self):
        # returns true if any bulbs are on, false otherwise
        return (self.dayBulb.check_status() or self.nightBulb.check_status())
from bulb import Bulb
import time

testBulb = Bulb(12, 70)

testBulb.transition_on()
time.sleep(1)
testBulb.transition_off()