示例#1
0
    def play_animations(self, curr_temerature, sachi_meter, input_type):

        diff_time = (datetime.datetime.now() - self.start_time).total_seconds()
        time_percent = (diff_time % 3.0) / 3.0

        self.temp_stick.set_is_input_mode(
            input_type == Decisions.InputType.TEMPERATURE)
        self.sachi_meter.set_is_input_mode(
            input_type == Decisions.InputType.SACHI)
        self.sheep_animation.set_is_input_mode(
            input_type == Decisions.InputType.SACHI)

        self.flower_animation.apply(time_percent)
        self.grass_animation.apply(time_percent)
        self.lake_animation.apply(time_percent)
        self.sheep_animation.apply(time_percent)
        self.sign_animation.apply(time_percent)
        self.tree_animation.apply(time_percent)
        self.temp_stick.set_temperature(time_percent, curr_temerature)
        self.sachi_meter.set_sachi_meter(time_percent, sachi_meter)

        network.send(flower_data=self.flower.get_array(),
                     sheep_data=self.sheep.get_array(),
                     grass_data=self.grass.get_array(),
                     sign_data=self.sign.get_array(),
                     lake_data=self.lake.get_array(),
                     temp_stick=self.temp_stick.get_array(),
                     sachi_meter=self.sachi_meter.get_array(),
                     tree_data=self.tree.get_array())
示例#2
0
    def play_animations(self, song_time, curr_temerature, sachi_meter=None):

        song_time += self.offset

        self.temp_stick.set_temperature(None, curr_temerature)
        self.sachi_meter.set_sachi_meter(None, sachi_meter)

        if self.current_piece_id < len(
                self.pieces) - 1 and song_time > self.pieces[
                    self.current_piece_id + 1][0]:
            self.current_piece_id += 1
            print str(self.pieces[self.current_piece_id][0]) + " - " + str(
                self.pieces[self.current_piece_id][1])
            self.create_animations(self.pieces[self.current_piece_id][2])

        if self.current_piece_id == len(self.pieces) - 1:
            duration = 30.0
        else:
            duration = self.pieces[self.current_piece_id + 1][0] - self.pieces[
                self.current_piece_id][0]

        num_of_beats = self.pieces[self.current_piece_id][1]
        relative_song_time = song_time - self.pieces[self.current_piece_id][0]

        if self.flower_animation != None:
            flower_num_of_beats = num_of_beats * self.flower_animation_mul
            self.apply_animation(self.flower_animation, flower_num_of_beats,
                                 duration, relative_song_time)

        if self.grass_animation != None:
            grass_num_of_beats = num_of_beats * self.grass_animation_mul
            self.apply_animation(self.grass_animation, grass_num_of_beats,
                                 duration, relative_song_time)

        if self.lake_animation != None:
            lake_num_of_beats = num_of_beats * self.lake_animation_mul
            self.apply_animation(self.lake_animation, lake_num_of_beats,
                                 duration, relative_song_time)

        if self.sheep_animation != None:
            sheep_num_of_beats = num_of_beats * self.sheep_animation_mul
            self.apply_animation(self.sheep_animation, sheep_num_of_beats,
                                 duration, relative_song_time)

        if self.sign_animation != None:
            sign_num_of_beats = num_of_beats * self.sign_animation_mul
            self.apply_animation(self.sign_animation, sign_num_of_beats,
                                 duration, relative_song_time)

        if self.tree_animation != None:
            tree_num_of_beats = num_of_beats * self.tree_animation_mul
            self.apply_animation(self.tree_animation, tree_num_of_beats,
                                 duration, relative_song_time)

        network.send(flower_data=self.flower.get_array(),
                     sheep_data=self.sheep.get_array())
import Network.LedBurnProtocol as network

from UIElements.Lake import Lake

lake = Lake()

from RoundRobinLakeAnimation import RoundRobinLakeAnimation
from ConfettiLakeAnimation import ConfettiLakeAnimation
from NaturalLakeAnimation import NaturalLakeAnimation
from EqLakeAnimation import EqLakeAnimation
from SpiningColorLakeAnimation import SpiningColorLakeAnimation
from StarsLakeAnimation import StarsLakeAnimation
animation = NaturalLakeAnimation(lake, None)

speed = 100  # in 50 hrz
current_time = 0
frame_id = 0

while True:

    time_precent = float(current_time) / speed

    animation.apply(time_precent)

    network.send(lake_data=lake.get_array())

    time.sleep(0.05)
    current_time = (current_time + 1) % speed
    frame_id += 500
示例#4
0
from NaturalFlowerAnimation import NaturalFlowerAnimation
from FireFlowerAnimation import FireFlowerAnimation
from ConfettiFlowerAnimation import ConfettiFlowerAnimation
from GlowFlowerAnimation import GlowFlowerAnimation
from SpikesFlowerAnimation import SpikesFlowerAnimation

# props = {'only_top' : False,
# 		'leds_percent_per_beat' : 0.5,
# 		'brightness': 0.7}
# animation = ConfettiFlowerAnimation(flower, props)
#animation = SpikesFlowerAnimation(flower, {'color':{'type':'const_color', 'hue':0.5}})
animation = ExplosionFlowerAnimation(flower, None)

speed = 200 # in 50 hrz
current_time = 0
frame_id = 0;
    
while True:
        
	time_precent = float(current_time) / speed

	animation.apply(time_precent)

	network.send(flower_data=flower.get_array())

	time.sleep(0.02)
	current_time = (current_time + 1) % speed
 	frame_id += 1


示例#5
0
		print pieces[current_piece_id]
		hue = 0.8 if hue == 0.3 else 0.3

	if current_piece_id == len(pieces) - 1:
		duration = 30.0
 	else:
 		duration = pieces[current_piece_id+1][0] - pieces[current_piece_id][0]


	num_of_beats = pieces[current_piece_id][1]
	relative_song_time = song_time - pieces[current_piece_id][0]

	apply_animation(flower, num_of_beats, duration, relative_song_time)
	apply_animation(sheep, num_of_beats, duration, relative_song_time)
	apply_animation(grass, num_of_beats, duration, relative_song_time)
	apply_animation(sign, num_of_beats, duration, relative_song_time)
	apply_animation(lake, num_of_beats, duration, relative_song_time)

	network.send(flower_data=flower.get_array(),
		sheep_data=sheep.get_array(), 
		grass_data=grass.get_array(), 
		sign_data=sign.get_array(), 
		lake_data=lake.get_array())

	clock.tick(50)
	frame_id += 1




示例#6
0
from RainbowTreeAnimation import RainbowTreeAnimation
from FireTreeAnimation import FireTreeAnimation
from NaturalTreeAnimation import NaturalTreeAnimation
from SpikeTreeAnimation import SpikeTreeAnimation
from SinglePixelTreeAnimation import SinglePixelTreeAnimation

#animation = RoundRobinTreeAnimation(tree, {})
#animation = AlternateTreeAnimation(tree, {})
#animation = ConfettiTreeAnimation(tree, {})
#animation = ExplosionTreeAnimation(tree, {})
#animation = RainbowTreeAnimation(tree, {})
#animation = FireTreeAnimation(tree, {})
#animation = NaturalTreeAnimation(tree, {})
#animation = SpikeTreeAnimation(tree, {'circular': False, 'dir': 'outside'})
animation = SinglePixelTreeAnimation(tree, {})

speed = 15  # in 50 hrz
current_time = 0
frame_id = 0

while True:
    time_precent = float(current_time) / speed

    animation.apply(time_precent)

    network.send(tree_data=tree.get_array())

    time.sleep(0.02)
    current_time = (current_time + 1) % speed
    frame_id += 500
示例#7
0
sheep = SmallSheep()

from SpikeSheepAnimation import SpikeSheepAnimation
from FireSheepAnimation import FireSheepAnimation
from AlternateSheepAnimation import AlternateSheepAnimation
from SheepConfettiAnimation import SheepConfettiAnimation
from RainbowAnimation import RainbowAnimation
from FillFadeSheepAnimation import FillFadeSheepAnimation
from StarsSheepAnimation import StarsSheepAnimation

# animation = SpikeSheepAnimation(sheep, {'hue_start' :0.1})
# animation = FillFadeSheepAnimation(sheep, {'hue_start' : 'Rainbow'})
animation = StarsSheepAnimation(sheep, {'stars_percent': 0.01})

speed = 75  # in 50 hrz
current_time = 0
frame_id = 0

while True:

    time_precent = float(current_time) / speed

    animation.apply(time_precent)

    network.send(sheep_data=sheep.get_array())

    time.sleep(0.02)
    current_time = (current_time + 1) % speed
    frame_id += 500
from FireGrassAnimation import FireGrassAnimation
from RoundRobinGrassAnimation import RoundRobinGrassAnimation
from ConfettiGrassAnimation import ConfettiGrassAnimation
from SpikeGrassAnimation import SpikeGrassAnimation
from StarsGrassAnimation import StarsGrassAnimation
from SwipeGrassAnimation import SwipeGrassAnimation
from AlternateGrassAnimation import AlternateGrassAnimation

# animation = ConfettiGrassAnimation(grass, None)
#animation = SwipeGrassAnimation(grass, {'color': {'type': 'timed_hue', 'hue_start' : 0.0, 'hue_end' : 1.5}})
animation = AlternateGrassAnimation(grass, {})

speed = 75 # in 50 hrz
current_time = 0
frame_id = 0
    
while True:
        
	time_precent = float(current_time) / speed

	animation.apply(time_precent)

	network.send(grass_data=grass.get_array())

	time.sleep(0.02)
	current_time = (current_time + 1) % speed
 	frame_id += 500


import time

import Network.LedBurnProtocol as network

from UIElements.Sign import Sign

sign = Sign()

from FireSignAnimation import FireSignAnimation
from HueSignAnimation import HueSignAnimation
from RainbowSignAnimation import RainbowSignAnimation

#animation = HueSignAnimation(sign, {"animated": True, "full_color": True})
animation = RainbowSignAnimation(sign, None)

speed = 50  # in 50 hrz
current_time = 0
frame_id = 0

while True:

    time_precent = float(current_time) / speed

    animation.apply(time_precent)

    network.send(sign_data=sign.get_array())

    time.sleep(0.05)
    current_time = (current_time + 1) % speed
    frame_id += 500
示例#10
0
    current_time_flower = 0
    animation_time_flower = 0

    animation_obj = animations_sheep_arr[animation_index %
                                         len(animations_sheep_arr)]
    animation_sheep = animation_obj['animation']
    speed_sheep = animation_obj['speed']
    current_time_sheep = 0
    animation_time_sheep = 0


set_new_animation()
while True:

    if animation_time_flower > 600:
        set_new_animation()

    time_precent_flower = float(current_time_flower) / speed_flower
    animation_flower.apply(time_precent_flower)

    time_precent_sheep = float(current_time_sheep) / speed_sheep
    animation_sheep.apply(time_precent_sheep)

    network.send(flower_data=flower.get_array(), sheep_data=sheep.get_array())

    time.sleep(0.03)
    current_time_flower = (current_time_flower + 1) % speed_flower
    animation_time_flower = animation_time_flower + 1
    current_time_sheep = (current_time_sheep + 1) % speed_sheep
    animation_time_sheep = animation_time_sheep + 1
示例#11
0
if __name__ == "__main__":

    import pygame
    import Network.LedBurnProtocol as network
    from UIElements.SmallSheep import SmallSheep
    from UIElements.Flower import Flower

    flower = Flower()
    grass = [0, 0, 0] * 600
    sign = [0, 0, 0] * 150
    lake = [0, 0, 0] * 1800
    sheep = SmallSheep()

    frame_id = random.randint(0, 10000000)
    song = MoominsSong(sheep, flower)

    clock = pygame.time.Clock()
    pygame.mixer.init()
    pygame.mixer.music.load(song.get_audio_file())
    pygame.mixer.music.play(0, 0)

    while pygame.mixer.music.get_busy():
        song_time = (pygame.mixer.music.get_pos() - 170) / 1000.0
        song.apply_animation(song_time)

        network.send(flower.get_array(), sheep.get_array(), grass, sign, lake)

        frame_id += 1

        clock.tick(40)