Пример #1
0
    def run(self):
        """Run the thing"""
        self.terminate = False
        self.holiday = HolidaySecretAPI(addr=self.ip)
        self.pulses = []
        while True:
            if self.terminate:
                return
            for p in self.pulses:
                p.move()            
            self.pulses = [p for p in self.pulses if p.active]

            for i in range(self.holiday.NUM_GLOBES):
                r = 0
                b = 0
                g = 0
                for p in self.pulses:
                    ( r1, g1, b1 ) = p.colours(i)
                    r += r1
                    g += g1
                    b += b1
                self.holiday.setglobe(i, toholiday(r), toholiday(g), toholiday(b))
            self.holiday.render() 

            if not self.queue.empty():
                p = self.queue.get()
                self.pulses.append(p)

            time.sleep(self.wait)
Пример #2
0
    def __init__(self, addr, config, grad):
        self.DECAY = config['decay']
        self.WAVELET = 10
        self.WAVEMULT = 100 // self.WAVELET
        self.holiday = HolidaySecretAPI(addr=addr)
        self.levels = [0.0] * 50
        self.buffer = [(0, 0, 0)] * 50
        self.mode = config['mode']
        self.gradient = grad
        self.ngrad = len(self.gradient)

        maps = config['maps']
        if 'map' not in config:
            self.map = range(50)
        else:
            self.makemap(maps[config['map']])

        if self.mode == 'wave':
            self.render = self.render_wave
        else:
            self.render = self.render_spectrum
            if self.mode == 'levels':
                self.f_col = self.f_col_levels
            else:
                self.f_col = self.f_col_spectrum
Пример #3
0
 def run(self):
     """Go"""
     global addr
     self.terminate = False
     self.holiday = HolidaySecretAPI(addr=addr)
     self.s = 0
     self.sorters = [Bubblesorter, Insertsorter, Mergesorter, Quicksorter]
     while True:
         if self.terminate:
             return
         self.runsort()
         time.sleep(SLEEP_BETWEEN)
Пример #4
0
 def run(self):
     """Run an CellularAutomaton"""
     global addr
     self.terminate = False
     self.holiday = HolidaySecretAPI(addr=addr)
     self.ca.start(self.holiday.NUM_GLOBES)
     while True:
         if self.terminate:
             return
         self.ca.step()
         for i in range(self.holiday.NUM_GLOBES):
             self.holiday.setglobe(i, *self.ca.cell(i))
         self.holiday.render()
         time.sleep(SLEEP)
Пример #5
0
 def run(self):
     """Go"""
     global addr
     self.terminate = False
     self.holiday = HolidaySecretAPI(addr=addr)
     self.tick = 0
     self.n = len(pattern)
     while True:
         if self.terminate:
             return
         for i in range(self.holiday.NUM_GLOBES):
             k = (i + self.tick) % self.n
             ( r, g, b ) = pattern[k]
             self.holiday.setglobe(i, r, g, b)
         self.tick += 1
         self.holiday.render()  
         time.sleep(.3)       
Пример #6
0
 def run(self):
     """Go"""
     global addr
     self.terminate = False
     self.holiday = HolidaySecretAPI(addr=addr)
     self.values = []
     for i in range(self.holiday.NUM_GLOBES):
         self.values.append((0, 0, 0))
     self.render()
     while True:
         if self.terminate:
             return
         nt = datetime.datetime.now()
         col = timecolour(nt)
         self.values.append(col)
         del (self.values[0])
         self.render()  # Send the colours out
         time.sleep(1)  # And finally, wait.
Пример #7
0
 def run(self):
     """Run the thang"""
     global addr
     self.terminate = False
     self.holiday = HolidaySecretAPI(addr=addr)
     self.reset()
     while True:
         if self.terminate:
             return
         for i in range(self.holiday.NUM_GLOBES):
             col = self.wheel[self.values[i] % self.mod]
             self.holiday.setglobe(i, *col)
             if i == 0:
                 self.values[i] = 1
             else:
                 self.values[i] = self.values[i] + self.values[i - 1]
         self.holiday.render()  # Send the colours out
         time.sleep(SLEEP)
         self.tick += 1
         if self.tick > ITERS:
             self.reset()
Пример #8
0
 def run(self):
     """Run the """
     global addr
     self.terminate = False
     self.holiday = HolidaySecretAPI(addr=addr)
     self.init()
     self.tick = 0
     while True:
         if self.terminate:
             return
         roff = int(self.tick * RV)
         goff = int(self.tick * GV)
         boff = int(self.tick * BV)
         for i in range(self.holiday.NUM_GLOBES):
             ri = (roff + RMULT * i * self.atog) % SINELENGTH
             gi = (goff + GMULT * i * self.atog) % SINELENGTH
             bi = (boff + BMULT * i * self.atog) % SINELENGTH
             self.holiday.setglobe(i, self.sine[ri], self.sine[gi],
                                   self.sine[bi])
         self.holiday.render()  # Send the colours out
         time.sleep(SLEEP)
         self.tick += 1
Пример #9
0
 def run(self):
     """Go"""
     global addr
     self.terminate = False
     self.holiday = HolidaySecretAPI(addr=addr)
     self.n = 8
     self.setup(self.n)
     while True:
         if self.terminate:
             return
         for j in range(self.n):
             self.drops[j].move()
         for i in range(self.holiday.NUM_GLOBES):
             r = 0.0
             b = 0.0
             g = 0.0
             for j in range(self.n):
                 ( r1, g1, b1 ) = self.drops[j].brightness(i)
                 r += r1
                 g += g1
                 b += b1
             self.holiday.setglobe(i, toholiday(r), toholiday(g), toholiday(b))
         self.holiday.render()       # Send the colours out
         time.sleep(.01)       # And finally, wait.
Пример #10
0
 def __init__(self, ip):
     self.ip = ip
     self.holiday = HolidaySecretAPI(addr=ip)