Exemplo n.º 1
0
def create_discrete_mechanism(all_outputs, gear_radii, pos_thresh, output_min):
    """creates mechanism using RNN output based on discrete gear radius
	options
	
	:param all_outputs: the list of outputs created by RNN
	:param gear_radii: the list of gear radius options
	"""

    r = gear_radii[all_outputs[0][0]]
    mechanism = [Gear(r, (r, r, 0), 0)]
    for index, curr in enumerate(all_outputs[1:]):
        prev_gear = mechanism[-1]

        # get position for the next gear
        new_pos = get_gear_pos_linear(prev_gear.pos, curr[1], prev_gear.radius, gear_radii[curr[0]], \
          pos_thresh, output_min)
        mechanism.append(Gear(gear_radii[curr[0]], new_pos,
                              len(mechanism) - 1))
        prev_gear.next_gears.append(index + 1)

        # find ratio of the current gear
        new_ratio = prev_gear.ratio * (prev_gear.radius / mechanism[-1].radius)
        if (-pos_thresh <= curr[1] <= pos_thresh):
            mechanism[-1].ratio = new_ratio
        else:
            mechanism[-1].ratio = prev_gear.ratio

    return mechanism
Exemplo n.º 2
0
def classical_gear(module, large_teeth, small_teeth):
    xdr = Range1d(start=-300, end=150)
    ydr = Range1d(start=-100, end=100)

    plot = Plot(x_range=xdr, y_range=ydr, plot_width=800, plot_height=800)
    plot.add_tools(PanTool(), WheelZoomTool(), BoxZoomTool(), UndoTool(),
                   RedoTool(), ResetTool())

    radius = pitch_radius(module, large_teeth)
    angle = 0
    glyph = Gear(x=-radius,
                 y=0,
                 module=module,
                 teeth=large_teeth,
                 angle=angle,
                 fill_color=fill_color[0],
                 line_color=line_color)
    plot.add_glyph(glyph)

    radius = pitch_radius(module, small_teeth)
    angle = half_tooth(small_teeth)
    glyph = Gear(x=radius,
                 y=0,
                 module=module,
                 teeth=small_teeth,
                 angle=angle,
                 fill_color=fill_color[1],
                 line_color=line_color)
    plot.add_glyph(glyph)

    return plot
Exemplo n.º 3
0
def classical_gear(module, large_teeth, small_teeth):
    plot = figure(
        x_range=(-300, 150),
        y_range=(-100, 100),
        x_axis_type=None,
        y_axis_type=None,
        width=800,
        height=800,
        tools=tools,
    )

    radius = pitch_radius(module, large_teeth)
    angle = 0
    glyph = Gear(x=-radius,
                 y=0,
                 module=module,
                 teeth=large_teeth,
                 angle=angle,
                 fill_color=fill_color[0],
                 line_color=line_color)
    plot.add_glyph(glyph)

    radius = pitch_radius(module, small_teeth)
    angle = half_tooth(small_teeth)
    glyph = Gear(x=radius,
                 y=0,
                 module=module,
                 teeth=small_teeth,
                 angle=angle,
                 fill_color=fill_color[1],
                 line_color=line_color)
    plot.add_glyph(glyph)

    return plot
    def setUpPlayer(self):
        newGear = Gear(500)
        hunter = Guardian(1, newGear)
        newGear2 = Gear(500)
        warlock = Guardian(2, newGear2)
        newGear3 = Gear(500)
        titan = Guardian(3, newGear3)

        return Player(hunter, warlock, titan)
Exemplo n.º 5
0
def epicyclic_gear(module, sun_teeth, planet_teeth):
    plot = figure(
        x_range=(-150, 150),
        y_range=(-150, 150),
        x_axis_type=None,
        y_axis_type=None,
        width=800,
        height=800,
        tools=tools,
    )

    annulus_teeth = sun_teeth + 2 * planet_teeth

    glyph = Gear(x=0,
                 y=0,
                 module=module,
                 teeth=annulus_teeth,
                 angle=0,
                 fill_color=fill_color[0],
                 line_color=line_color,
                 internal=True)
    plot.add_glyph(glyph)

    glyph = Gear(x=0,
                 y=0,
                 module=module,
                 teeth=sun_teeth,
                 angle=0,
                 fill_color=fill_color[2],
                 line_color=line_color)
    plot.add_glyph(glyph)

    sun_radius = pitch_radius(module, sun_teeth)
    planet_radius = pitch_radius(module, planet_teeth)

    radius = sun_radius + planet_radius
    angle = half_tooth(planet_teeth)

    for i, j in [(+1, 0), (0, +1), (-1, 0), (0, -1)]:
        glyph = Gear(x=radius * i,
                     y=radius * j,
                     module=module,
                     teeth=planet_teeth,
                     angle=angle,
                     fill_color=fill_color[1],
                     line_color=line_color)
        plot.add_glyph(glyph)

    return plot
Exemplo n.º 6
0
def epicyclic_gear(module, sun_teeth, planet_teeth):
    xdr = Range1d(start=-150, end=150)
    ydr = Range1d(start=-150, end=150)

    plot = Plot(x_range=xdr, y_range=ydr, plot_width=800, plot_height=800)
    plot.add_tools(PanTool(), WheelZoomTool(), BoxZoomTool(), UndoTool(),
                   RedoTool(), ResetTool())

    annulus_teeth = sun_teeth + 2 * planet_teeth

    glyph = Gear(x=0,
                 y=0,
                 module=module,
                 teeth=annulus_teeth,
                 angle=0,
                 fill_color=fill_color[0],
                 line_color=line_color,
                 internal=True)
    plot.add_glyph(glyph)

    glyph = Gear(x=0,
                 y=0,
                 module=module,
                 teeth=sun_teeth,
                 angle=0,
                 fill_color=fill_color[2],
                 line_color=line_color)
    plot.add_glyph(glyph)

    sun_radius = pitch_radius(module, sun_teeth)
    planet_radius = pitch_radius(module, planet_teeth)

    radius = sun_radius + planet_radius
    angle = half_tooth(planet_teeth)

    for i, j in [(+1, 0), (0, +1), (-1, 0), (0, -1)]:
        glyph = Gear(x=radius * i,
                     y=radius * j,
                     module=module,
                     teeth=planet_teeth,
                     angle=angle,
                     fill_color=fill_color[1],
                     line_color=line_color)
        plot.add_glyph(glyph)

    return plot
Exemplo n.º 7
0
def mechanism_from_GA(ind):
    """create mechanism representation from GA genome"""

    r = ind[0][0]
    mechanism = [Gear(r, (r, r, 0), 0)]
    end_ind = ind[-1]
    for index, curr in enumerate(ind[1:end_ind]):
        prev_gear = mechanism[-1]

        # get position for the next gear
        new_pos = (prev_gear.pos[0] + prev_gear.radius + curr[0],
                   prev_gear.pos[1], prev_gear.pos[2])
        if (curr[1] == 2):
            new_pos = (prev_gear.pos[0], prev_gear.pos[1],
                       prev_gear.pos[2] + 1)
        elif (curr[1] == 0):
            new_pos = (prev_gear.pos[0], prev_gear.pos[1],
                       prev_gear.pos[2] - 1)
        mechanism.append(Gear(curr[0], new_pos, len(mechanism) - 1))
        prev_gear.next_gears.append(index + 1)

    return mechanism
Exemplo n.º 8
0
class Jewel7(Lights):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.indexed_range = self.indexed_range[:7]
        self.center = self.lattice[self.indexed_range[0]]
        self.gear = Gear(lights=self, indexed_range=self.indexed_range[1:7])

    def model_colors(self):
        yield self.center
        yield from self.gear.model_colors()

    def __repr__(self):
        return "<Jewel7 {} with {}, center {} and {}" \
            .format(self.leds, self.indexed_range, self.center, self.gear)
Exemplo n.º 9
0
class Jewel7(Lights):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.indexed_range = self.indexed_range[:7]
        self.center = self.lattice[self.indexed_range[0]]
        self.gear = Gear(lights=self, indexed_range=self.indexed_range[1:7])
        
    def model_colors(self):
        yield self.center
        yield from self.gear.model_colors()

    def __repr__(self):
        return "<Jewel7 {} with {}, center {} and {}" \
            .format(self.leds, self.indexed_range, self.center, self.gear)
Exemplo n.º 10
0
def create_mechanism_representation(all_outputs, pos_thresh, output_min):
    """uses a list of gear RNN outputs to create a more understandable representation for
	the mechanism, each gear is represented with (radius, position, previous gear, next gears,
	ratio) so that all information for each gear in the mechanism is readily available
	
	this method converts the raw RNN output into the above form - stored as a Gear object
	"""

    # populate mechanism with the first gear
    # ratio set to 1.0 by default when gear is instantiated
    r = all_outputs[0][0]
    init_x = np.cos(np.pi / 4) * r
    init_y = np.sin(np.pi / 4) * r
    mechanism = [Gear(r, (init_x, init_y, 0), 0)]

    # go through all outputs and create a gear object for each one
    for index, curr in enumerate(all_outputs[1:]):
        prev_gear = mechanism[
            -1]  # previous gear is always last outputted mechanism

        # must set padding to true if space should be inserted between gears for 3D printing
        new_pos = get_gear_pos_linear(prev_gear.pos, curr[1], prev_gear.radius,
                                      curr[0], pos_thresh, output_min)
        mechanism.append(Gear(curr[0], new_pos, len(mechanism) - 1))

        # add index of current into list of nxt gears for gear it attaches to
        prev_gear.next_gears.append(index + 1)

        # find ratio of current gear - only changes if not attached to front/back
        new_ratio = prev_gear.ratio * (prev_gear.radius / mechanism[-1].radius)
        if (-pos_thresh <= curr[1] <= pos_thresh):
            mechanism[-1].ratio = new_ratio
        else:
            mechanism[-1].ratio = prev_gear.ratio

    return mechanism
Exemplo n.º 11
0
    def setUp(self):
        #logging.basicConfig(level=logging.INFO)
        ws = self.ws = WS2812(1, 8)
        lights = self.lights = Lights(ws)

        # Fill the lattice with a recognizable pattern
        for i, p in enumerate(tg(len(lights), 0)):
            lat = lights.lattice[i]
            for j, c in enumerate(p):
                lat[j] = c

        # The leds are all clear
        self.assertEqual(sum(sum(c) for c in ws), 0)

        self.gear = Gear(lights=lights)
Exemplo n.º 12
0
def sample_gear():
    xdr = Range1d(start=-30, end=30)
    ydr = Range1d(start=-30, end=30)

    plot = Plot(x_range=xdr, y_range=ydr, plot_width=800, plot_height=800)
    plot.add_tools(PanTool(), WheelZoomTool(), BoxZoomTool(), UndoTool(),
                   RedoTool(), ResetTool())

    glyph = Gear(x=0,
                 y=0,
                 module=5,
                 teeth=8,
                 angle=0,
                 shaft_size=0.2,
                 fill_color=fill_color[2],
                 line_color=line_color)
    plot.add_glyph(glyph)

    return plot
Exemplo n.º 13
0
def individual_gear():
    plot = figure(
        x_range=(-30, 30),
        y_range=(-30, 30),
        x_axis_type=None,
        y_axis_type=None,
        width=800,
        height=800,
        tools=tools,
    )

    glyph = Gear(x=0,
                 y=0,
                 module=5,
                 teeth=8,
                 angle=0,
                 shaft_size=0.2,
                 fill_color=fill_color[2],
                 line_color=line_color)
    plot.add_glyph(glyph)

    return plot
Exemplo n.º 14
0
    def set_up_gears(self):
        self.gears = []
        self.gears_group.remove_all()
        center_gear_location = (Window.width / 6 * 4.5,
                                Window.height / 4 * 2.5)
        center_gear_size = min(Window.width / 10, Window.height / 10)
        self.center_gear = Gear(None, None, center_gear_size, 10, 'center', 0,
                                center_gear_location, center_gear_location, 1,
                                colors['dark_grey'])
        self.canvas.add(self.center_gear.color)
        self.gears_group.add(self.center_gear)

        self.center_gear_center = GearCenter(None, None, center_gear_location,
                                             center_gear_location, 'center',
                                             center_gear_size / 2,
                                             colors['dark_grey'])
        self.canvas.add(colors['dark_grey'])
        self.canvas.add(self.center_gear_center)

        self.play_center_gear = False

        self.music_gears = []

        tempo_location = (center_gear_location[0], center_gear_location[1] +
                          center_gear_size + center_gear_size / 5)
        instrument_location = (center_gear_location[0],
                               center_gear_location[1] - center_gear_size -
                               center_gear_size / 5)
        pitch_location = (center_gear_location[0] + center_gear_size +
                          center_gear_size / 5, center_gear_location[1])
        volume_location = (center_gear_location[0] - center_gear_size -
                           center_gear_size / 5, center_gear_location[1])

        self.music_box_gear_locations = [
            tempo_location, instrument_location, pitch_location,
            volume_location
        ]

        counter = 0

        label_font_size = min(Window.width // 80, Window.height // 80)
        for y in range(0, 4):
            for x in range(len(self.gear_values) // 4):
                gear_type = gear_type_map[y]
                size = min(Window.width / 10, Window.height / 10)

                music_pos = self.music_box_gear_locations[y]
                scaled_x, scaled_y = self.get_scaled_x_y(
                    (Window.width, Window.height), x, y)

                gear = Gear(x, y, size, 8, gear_type,
                            self.gear_values[counter], (scaled_x, scaled_y),
                            music_pos, 0, colors['dark_grey'])
                self.gears.append(gear)
                self.canvas.add(gear.color)
                self.gears_group.add(gear)

                gear_center = GearCenter(x, y, (scaled_x, scaled_y), music_pos,
                                         gear_type, size / 2,
                                         colors['dark_grey'])
                self.gear_centers.append(gear_center)
                self.canvas.add(gear_center)

                ## white dots for storage purposes
                gear_loc = GearLocation((scaled_x, scaled_y), size / 2, x, y,
                                        gear_type)
                self.gear_storage_locations.append(gear_loc)
                self.canvas.add(gear_loc)

                text = str(self.gear_values[counter])
                font_name = './fonts/PassionOne-Regular'
                if y == 3:
                    # get volume as percent
                    text = str(100 * self.gear_values[counter] // 127) + '%'
                if y == 1:
                    # get icon for instrument
                    font_name = './fonts/music-instruments'
                    text = instruments[self.gear_values[counter]]

                label = Label(text=text,
                              font_name=font_name,
                              color=(0, 0, 0, 1),
                              center_x=scaled_x,
                              center_y=scaled_y,
                              font_size=str(label_font_size) + 'sp')
                self.gear_labels.append(label)
                self.add_widget(label)

                counter += 1

        for indx, loc in enumerate(self.music_box_gear_locations):
            gear_type = gear_type_map[indx % 4]
            gear_loc = GearLocation(loc, center_gear_size / 2, None, None,
                                    gear_type)
            self.gear_music_locations.append(gear_loc)
            self.canvas.add(gear_loc)
Exemplo n.º 15
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.indexed_range = self.indexed_range[:7]
     self.center = self.lattice[self.indexed_range[0]]
     self.gear = Gear(lights=self, indexed_range=self.indexed_range[1:7])
Exemplo n.º 16
0
    def __init__(self, cfg_file: str = None, **kwargs):

        self._cfg = Cfg(cfg_file, **kwargs)
        self._discord = commands.Bot(self._cfg.command_prefix)
        self._inferkit = InferKit(self._cfg.inferkit_api_key)
        self._channels = {}
        self._member_mention = {}
        self._mention_regex = None

        self._discord.add_cog(Gear(self))
        cog = self._discord.get_cog('Gear')
        self._cmd_regex = cog.compile_regex()

        @self._discord.event
        async def on_ready():
            # Get member list sorted in reverse order by lower-case
            # display name. This particular sorting choice ensures
            # that a regex matching any member name will find the
            # longest possible match in case of common prefixes.
            def display_name_lc(m):
                return m.display_name.lower()

            members = list(self._discord.get_all_members())
            members.sort(key=display_name_lc, reverse=True)

            arr = []
            for member in members:
                name = member.display_name
                arr.append(re.escape(name))
                # TODO: handle name collisions
                self._member_mention['@' + name.lower()] = member.mention
            self._mention_regex = re.compile('@(' + '|'.join(arr) + ')',
                                             flags=re.I)

            user = self._discord.user
            self._name_regex = re.compile(r'(' + re.escape(user.display_name) +
                                          r')\]\s*',
                                          flags=re.I)
            log.info('Logged in as ' + log.green(str(user), 1))

        @self._discord.event
        async def on_message(msg):
            await self._discord.process_commands(msg)
            is_cmd = self._is_cmd(msg)

            msg_log = self.chan_msg_log(msg.channel.id)
            if len(msg_log) == 0:
                await self.chan_get_history(msg_log, msg.channel)
            else:
                self.chan_append_msg(msg_log, msg, is_cmd,
                                     TwerkBoi.list_tail(msg_log))

            user = self._discord.user

            if msg.author == user:
                return

            if is_cmd:
                return

            user_id = user.id
            mentioned = False

            for member in msg.mentions:
                if member.id == user_id:
                    mentioned = True

            if not mentioned:
                return

            await msg.channel.trigger_typing()

            prompt = self.gen_prompt(msg_log, user.display_name)
            log.debug(
                log.white('<prompt>', 1) + log.yellow(prompt) +
                log.white('</prompt>', 1))
            reply = self._inferkit.generate(prompt)

            if reply == None:
                reply = 'Unable to generate a reply'
            else:
                sanitized = []
                for line in reply.splitlines():
                    if (len(line) > 0) and not line.isspace():
                        sanitized.append(line.strip())
                log.debug(
                    log.white('<generated>', 1) +
                    log.blue('\n'.join(sanitized), 1) +
                    log.white('</generated>', 1))
                arr = []
                for line in sanitized:
                    if line[0] == '[':
                        line = line[1:]
                        m = self._name_regex.match(line)
                        if m == None:
                            break
                        span = m.span()[1]
                        if span >= len(line):
                            continue
                        line = line[span:]
                    arr.append(line)

                if self._cfg.auto_mention:
                    need_receiver_mention = True
                    receiver_mention = msg.author.mention
                else:
                    if len(arr) < 1:
                        return
                    need_receiver_mention = False
                    receiver_mention = None

                tmp = '\n'.join(arr)
                pos = 0
                reply = ''
                mentions_seen = {'@' + user.display_name.lower(): True}
                for m in self._mention_regex.finditer(tmp):
                    span = m.span()
                    reply += tmp[pos:span[0]]
                    pos = span[1]
                    cleaned_mention = m.group(0).lower()
                    if cleaned_mention in mentions_seen:
                        continue
                    mentions_seen[cleaned_mention] = True
                    mention = self._member_mention[cleaned_mention]
                    reply += mention
                    if need_receiver_mention and (mention == receiver_mention):
                        need_receiver_mention = False
                reply += tmp[pos:len(tmp)]

                if need_receiver_mention:
                    if len(reply) > 0:
                        reply = receiver_mention + ' ' + reply
                    else:
                        reply = receiver_mention

            await msg.channel.send(reply)
Exemplo n.º 17
0
    def __init__(self, layer, no, p, button):
        self.layer = layer
        self.no    = no         # motor ID in [0,3]
        self.mask  = 1<<no      # motor bitmask
        self.polarity = p       # polarity direction, +1 or -1
        self.button = button    # digital button on the controller to nudge this motor

pygame.init()
pygame.joystick.init()

j = pygame.joystick.Joystick(0)
j.init()

# gear ratio for the directional motor, in the reverse order
# so as to map the turrent angle to the tacho count
g = Gear(Gear.TURRET, Gear.BIG)

motors  = [Motor(0,0,1,3), Motor(0,1,-1,2), Motor(0,2,1,1), Motor(0,3,-1,0)]
thrusts = [Motor(1,0,1,3), Motor(1,1,-1,2), Motor(1,2,1,1), Motor(1,3,-1,0)]

def reset():
    c = Program()
    # reset tacho counts on all motors
    for m in motors:
        c.output.layer(m.layer).ports(m.mask)
        c.output.reset().clear_count()
        c.output.power(0).polarity(m.polarity).start()
    # activate thrust motors
    for m in thrusts:
        c.output.layer(m.layer).ports(m.mask)
        c.output.power(0).polarity(m.polarity).start()
Exemplo n.º 18
0
class LevelEasyMediumScreen(Screen):
    def __init__(self, level, notes, goal_values, gear_values, **kwargs):
        super(LevelEasyMediumScreen, self).__init__(**kwargs)

        # set up notes for the level
        self.notes = notes

        # set up gear values for the levels
        self.goal_values = goal_values

        # set up gear values for the levels
        self.gear_values = gear_values

        self.level = level

        # only turn on tutorial for level 1
        if self.level == 1:
            self.use_tutorial = True
            self.tutorial_screen = 'A'
            self.goal_play_status = None
            self.gear_play_status = None
            self.size_dim = min(Window.width / 6, Window.height / 6)
            self.tutorial_full_overlay = CRectangle(cpos=(Window.width / 2,
                                                          Window.height / 2),
                                                    csize=(Window.width,
                                                           Window.height))
            self.tutorial_options_overlay = Rectangle(
                pos=(0, 0),
                size=(Window.width, self.size_dim + Window.height / 25))
            self.tutorial_musicbox_overlay = Rectangle(
                pos=(Window.width // 2, self.size_dim + Window.height / 25),
                size=(Window.width / 2,
                      Window.height - (self.size_dim + Window.height / 25)))
            self.tutorial_gearbox_overlay = Rectangle(
                pos=(0, self.size_dim + Window.height / 25),
                size=(Window.width / 2,
                      Window.height - (self.size_dim + Window.height / 25)))
            self.skip_image = CoreImage('images/skip_tutorial.png')
            self.tutorial_skip_button = Rectangle(
                pos=(0.98 * Window.width -
                     (self.skip_image.width * self.size_dim / 300),
                     0.98 * Window.height -
                     self.skip_image.height * self.size_dim / 300),
                size=(self.skip_image.width * self.size_dim / 300,
                      self.skip_image.height * self.size_dim / 300),
                texture=self.skip_image.texture)
        else:
            self.use_tutorial = False

        ############################################
        ###              GOAL MUSIC              ###
        ############################################
        self.goal_audio = Audio(2)
        self.goal_synth = Synth('./data/FluidR3_GM.sf2')

        # create TempoMap, AudioScheduler
        self.goal_tempo_map = SimpleTempoMap(120)
        self.goal_sched = AudioScheduler(self.goal_tempo_map)

        # connect scheduler into audio system
        self.goal_audio.set_generator(self.goal_sched)
        self.goal_sched.set_generator(self.goal_synth)

        # generate goal music
        self.goal_music = MusicPlayer(notes=self.notes,
                                      sched=self.goal_sched,
                                      synth=self.goal_synth,
                                      channel=1,
                                      tempo_map=self.goal_tempo_map)
        self.goal_music.update_tempo(self.goal_values[0])
        self.goal_music.update_instrument(self.goal_values[1])
        self.goal_music.update_pitch(self.goal_values[2])
        self.goal_music.update_volume(self.goal_values[3])

        self.goal_music_seq = self.goal_music.generate()

        ############################################
        ###              GEAR MUSIC              ###
        ############################################
        self.gear_audio = Audio(2)
        self.gear_synth = Synth('./data/FluidR3_GM.sf2')

        # create TempoMap, AudioScheduler
        self.gear_tempo_map = SimpleTempoMap(120)
        self.gear_sched = AudioScheduler(self.gear_tempo_map)

        # connect scheduler into audio system
        self.gear_audio.set_generator(self.gear_sched)
        self.gear_sched.set_generator(self.gear_synth)

        # generate gear music
        self.gear_music = MusicPlayer(notes=self.notes,
                                      sched=self.gear_sched,
                                      synth=self.gear_synth,
                                      channel=1,
                                      tempo_map=self.gear_tempo_map)
        self.gear_music_seq = None

        ############################################
        ###       BACKGROUND UI COMPONENTS       ###
        ############################################
        self.gear_area = GearArea()
        self.canvas.add(self.gear_area)

        self.music_box_area = MusicBoxArea()
        self.canvas.add(self.music_box_area)

        self.options = LevelOptions(
            level=level,
            goal_music_seq=self.goal_music_seq,
            duration=self.goal_music.duration,
            edit_goal_play_status=self.edit_goal_play_status)
        self.canvas.add(self.options)

        self.label = Label(text=kwargs['name'],
                           font_name='./fonts/PassionOne-Regular',
                           color=(.165, .718, .792, 1))
        self.add_widget(self.label)

        ###########################################
        ###             GEAR LABELS             ###
        ###########################################
        self.tempo_label = Label(text='Tempo (bpm)',
                                 font_name='./fonts/PassionOne-Regular',
                                 color=(0.7254901960784313, 0.5529411764705883,
                                        0.8196078431372549, 1),
                                 center_x=(Window.width / 4),
                                 center_y=(Window.height / 5.25 * (0.5 + 0.5) +
                                           self.gear_area.position[1]),
                                 font_size=str(Window.width // 50) + 'sp')
        self.instrument_label = Label(
            text='Instrument',
            font_name='./fonts/PassionOne-Regular',
            color=(0.996078431372549, 0.8431372549019608, 0.4, 1),
            center_x=(Window.width / 4),
            center_y=(Window.height / 5.25 * (1.5 + 0.5) +
                      self.gear_area.position[1]),
            font_size=str(Window.width // 50) + 'sp')
        self.pitch_label = Label(text='Pitch (semitones)',
                                 font_name='./fonts/PassionOne-Regular',
                                 color=(1.0, 0.6509803921568628,
                                        0.09019607843137255, 1),
                                 center_x=(Window.width / 4),
                                 center_y=(Window.height / 5.25 * (2.5 + 0.5) +
                                           self.gear_area.position[1]),
                                 font_size=str(Window.width // 50) + 'sp')
        self.volume_label = Label(
            text='Volume',
            font_name='./fonts/PassionOne-Regular',
            color=(0.9254901960784314, 0.32941176470588235, 0.3176470588235294,
                   1),
            center_x=(Window.width / 4),
            center_y=(Window.height / 5.25 * (3.5 + 0.5) +
                      self.gear_area.position[1]),
            font_size=str(Window.width // 50) + 'sp')
        self.add_widget(self.volume_label)
        self.add_widget(self.pitch_label)
        self.add_widget(self.instrument_label)
        self.add_widget(self.tempo_label)

        ###########################################
        ###          GEAR CONSTRUCTION          ###
        ###########################################

        self.gears = []
        self.gear_centers = []
        self.gears_group = AnimGroup()
        self.canvas.add(self.gears_group)

        ###########################################
        ###                GEARS                ###
        ###########################################
        self.gear_storage_locations = []
        self.gear_music_locations = []
        self.gear_labels = []
        self.set_up_gears()

        ###########################################
        ###           PARTICLE EFFECT           ###
        ###########################################
        self.win_ps = ParticleSystem('particles/star_particle.pex')
        self.win_ps.emitter_x = Window.width / 2
        self.win_ps.emitter_y = Window.height / 2
        self.add_widget(self.win_ps)
        self.you_win_label = Label(text=' ',
                                   font_name='./fonts/PassionOne-Regular',
                                   color=(0.5843137254901961,
                                          0.796078431372549,
                                          0.37254901960784315, 1),
                                   center_x=Window.width / 2,
                                   center_y=Window.height / 2,
                                   font_size=str(Window.width // 10) + 'sp')
        self.add_widget(self.you_win_label)

        self.lose_ps = ParticleSystem('particles/lose_particle.pex')
        self.lose_ps.emitter_x = Window.width / 2
        self.lose_ps.emitter_y = Window.height / 2
        self.add_widget(self.lose_ps)
        self.you_lose_label = Label(text=' ',
                                    font_name='./fonts/PassionOne-Regular',
                                    color=(0.9254901960784314,
                                           0.32941176470588235,
                                           0.3176470588235294, 1),
                                    center_x=Window.width / 2,
                                    center_y=Window.height / 2,
                                    font_size=str(Window.width // 10) + 'sp')
        self.add_widget(self.you_lose_label)

        ###########################################
        ###            ERROR MESSAGE            ###
        ###########################################
        self.error_msg = Label(text=' ',
                               font_name='./fonts/PassionOne-Regular',
                               color=(0.9254901960784314, 0.32941176470588235,
                                      0.3176470588235294, 1),
                               center_x=Window.width / 2,
                               center_y=Window.height / 2,
                               font_size=str(Window.width // 20) + 'sp')
        self.add_widget(self.error_msg)

        # ###########################################
        # ###        ADD TUTORIAL OVERLAYS        ###
        # ###########################################
        if self.use_tutorial:
            self.canvas.add(Color(rgba=(0, 0, 0, 0.85)))
            self.canvas.add(self.tutorial_full_overlay)
            self.tutorial_label = Label(
                markup=True,
                text=
                "[font=./fonts/lato-bold]Welcome to the\n[/font] [font=./fonts/options-icons]|[/font] [font=./fonts/PassionOne-Regular]Play It By Gear Tutorial[/font] [font=./fonts/options-icons]|[/font] [font=./fonts/lato-bold]\n\nThe goal of this game is to make the \n goal song match the song you create by \nplacing the correct gears in a music box \n\n[/font] [font=./fonts/lato-light] (click to see the next \nstep of the tutorial)[/font]",
                color=(86 / 255, 189 / 255, 205 / 255, 1),
                center_x=Window.width / 2,
                center_y=Window.height / 2,
                font_size=str(Window.width // 40) + 'sp',
                halign='center')
            self.add_widget(self.tutorial_label)
            self.canvas.add(self.tutorial_skip_button)

        self.on_layout((Window.width, Window.height))

    def clear_overlays(self):
        if self.tutorial_full_overlay in self.canvas.children:
            self.canvas.remove(self.tutorial_full_overlay)
        if self.tutorial_options_overlay in self.canvas.children:
            self.canvas.remove(self.tutorial_options_overlay)
        if self.tutorial_gearbox_overlay in self.canvas.children:
            self.canvas.remove(self.tutorial_gearbox_overlay)
        if self.tutorial_musicbox_overlay in self.canvas.children:
            self.canvas.remove(self.tutorial_musicbox_overlay)
        while self.tutorial_skip_button in self.canvas.children:
            self.canvas.remove(self.tutorial_skip_button)

    def activate_overlays(self, overlay_names):
        self.clear_overlays()
        self.canvas.add(Color(rgba=(0, 0, 0, 0.85)))
        if 'full' in overlay_names:
            self.canvas.add(self.tutorial_full_overlay)
        if 'options' in overlay_names:
            self.canvas.add(self.tutorial_options_overlay)
        if 'gearbox' in overlay_names:
            self.canvas.add(self.tutorial_gearbox_overlay)
        if 'musicbox' in overlay_names:
            self.canvas.add(self.tutorial_musicbox_overlay)

    def get_scaled_x_y(self, winsize, x, y):
        width, height = winsize
        # scaled_x = width/8 * (x+1)
        scaled_x = width / (len(self.gear_values) // 4 * 2) * (x + 0.5)
        scaled_y = height / 5.25 * (y + 0.5) + self.gear_area.position[1]

        return scaled_x, scaled_y

    def set_up_gears(self):
        self.gears = []
        self.gears_group.remove_all()
        center_gear_location = (Window.width / 6 * 4.5,
                                Window.height / 4 * 2.5)
        center_gear_size = min(Window.width / 10, Window.height / 10)
        self.center_gear = Gear(None, None, center_gear_size, 10, 'center', 0,
                                center_gear_location, center_gear_location, 1,
                                colors['dark_grey'])
        self.canvas.add(self.center_gear.color)
        self.gears_group.add(self.center_gear)

        self.center_gear_center = GearCenter(None, None, center_gear_location,
                                             center_gear_location, 'center',
                                             center_gear_size / 2,
                                             colors['dark_grey'])
        self.canvas.add(colors['dark_grey'])
        self.canvas.add(self.center_gear_center)

        self.play_center_gear = False

        self.music_gears = []

        tempo_location = (center_gear_location[0], center_gear_location[1] +
                          center_gear_size + center_gear_size / 5)
        instrument_location = (center_gear_location[0],
                               center_gear_location[1] - center_gear_size -
                               center_gear_size / 5)
        pitch_location = (center_gear_location[0] + center_gear_size +
                          center_gear_size / 5, center_gear_location[1])
        volume_location = (center_gear_location[0] - center_gear_size -
                           center_gear_size / 5, center_gear_location[1])

        self.music_box_gear_locations = [
            tempo_location, instrument_location, pitch_location,
            volume_location
        ]

        counter = 0

        label_font_size = min(Window.width // 80, Window.height // 80)
        for y in range(0, 4):
            for x in range(len(self.gear_values) // 4):
                gear_type = gear_type_map[y]
                size = min(Window.width / 10, Window.height / 10)

                music_pos = self.music_box_gear_locations[y]
                scaled_x, scaled_y = self.get_scaled_x_y(
                    (Window.width, Window.height), x, y)

                gear = Gear(x, y, size, 8, gear_type,
                            self.gear_values[counter], (scaled_x, scaled_y),
                            music_pos, 0, colors['dark_grey'])
                self.gears.append(gear)
                self.canvas.add(gear.color)
                self.gears_group.add(gear)

                gear_center = GearCenter(x, y, (scaled_x, scaled_y), music_pos,
                                         gear_type, size / 2,
                                         colors['dark_grey'])
                self.gear_centers.append(gear_center)
                self.canvas.add(gear_center)

                ## white dots for storage purposes
                gear_loc = GearLocation((scaled_x, scaled_y), size / 2, x, y,
                                        gear_type)
                self.gear_storage_locations.append(gear_loc)
                self.canvas.add(gear_loc)

                text = str(self.gear_values[counter])
                font_name = './fonts/PassionOne-Regular'
                if y == 3:
                    # get volume as percent
                    text = str(100 * self.gear_values[counter] // 127) + '%'
                if y == 1:
                    # get icon for instrument
                    font_name = './fonts/music-instruments'
                    text = instruments[self.gear_values[counter]]

                label = Label(text=text,
                              font_name=font_name,
                              color=(0, 0, 0, 1),
                              center_x=scaled_x,
                              center_y=scaled_y,
                              font_size=str(label_font_size) + 'sp')
                self.gear_labels.append(label)
                self.add_widget(label)

                counter += 1

        for indx, loc in enumerate(self.music_box_gear_locations):
            gear_type = gear_type_map[indx % 4]
            gear_loc = GearLocation(loc, center_gear_size / 2, None, None,
                                    gear_type)
            self.gear_music_locations.append(gear_loc)
            self.canvas.add(gear_loc)

    def edit_goal_play_status(self, value):
        if self.use_tutorial:
            if self.goal_play_status == None and value == 'started':
                self.goal_play_status = 'started'
            elif self.goal_play_status == 'started' and value == 'finished':
                self.goal_play_status = 'finished'

    def _can_add_gear(self, new_gear):
        for gear in self.music_gears:
            if gear.type == new_gear.type:
                return False
        return True

    def _check_music_gears(self):
        all_types = ['volume', 'pitch', 'tempo', 'instrument']
        for gear in self.music_gears:
            if gear.type in all_types:
                all_types.remove(gear.type)
        return len(all_types) == 0

    def update_center_gear_on_layout(self, winsize):
        width, height = winsize
        center_gear_location = (width / 6 * 4.5, height / 4 * 2.5)
        center_gear_size = min(Window.width / 10, Window.height / 10)

        self.center_gear_center.update_storage_pos(center_gear_location)
        self.center_gear_center.update_music_pos(center_gear_location)
        self.center_gear.update_storage_pos(center_gear_location)
        self.center_gear.update_music_pos(center_gear_location)

        self.center_gear.on_layout(center_gear_location, center_gear_size)
        self.center_gear_center.on_layout(center_gear_location,
                                          center_gear_size / 2)

        tempo_location = (center_gear_location[0], center_gear_location[1] +
                          center_gear_size + center_gear_size / 5)
        instrument_location = (center_gear_location[0],
                               center_gear_location[1] - center_gear_size -
                               center_gear_size / 5)
        pitch_location = (center_gear_location[0] + center_gear_size +
                          center_gear_size / 5, center_gear_location[1])
        volume_location = (center_gear_location[0] - center_gear_size -
                           center_gear_size / 5, center_gear_location[1])

        self.music_box_gear_locations = [
            tempo_location, instrument_location, pitch_location,
            volume_location
        ]

        for indx, loc in enumerate(self.gear_music_locations):
            loc.on_layout(self.music_box_gear_locations[indx],
                          center_gear_size / 2)

    def on_enter(self):
        if not self.use_tutorial and self.level == 1:
            while self.tutorial_skip_button in self.canvas.children:
                self.canvas.remove(self.tutorial_skip_button)

    def on_layout(self, winsize):
        mapped_dic = {'tempo': 0, 'instrument': 1, 'pitch': 2, 'volume': 3}
        self.update_center_gear_on_layout(winsize)

        self.size_dim = min(Window.width / 6, Window.height / 6)
        size = min(Window.width / 10, Window.height / 10)
        label_font_size = min(Window.width // 80, Window.height // 80)

        for loc in self.gear_storage_locations:
            scaled_x, scaled_y = self.get_scaled_x_y(winsize, loc.x, loc.y)
            loc.on_layout((scaled_x, scaled_y), size / 2)

        for indx, gear in enumerate(self.gears):
            scaled_x, scaled_y = self.get_scaled_x_y(winsize, gear.x, gear.y)
            gear.update_storage_pos((scaled_x, scaled_y))
            gear.update_music_pos(
                self.music_box_gear_locations[mapped_dic[gear.type]])
            gear.on_layout((scaled_x, scaled_y), size)

            self.gear_labels[indx].center_x = scaled_x
            self.gear_labels[indx].center_y = scaled_y
            self.gear_labels[indx].font_size = str(label_font_size) + 'sp'

        for center in self.gear_centers:
            scaled_x, scaled_y = self.get_scaled_x_y(winsize, center.x,
                                                     center.y)
            center.update_storage_pos((scaled_x, scaled_y))
            center.update_music_pos(
                self.music_box_gear_locations[mapped_dic[center.type]])
            center.on_layout((scaled_x, scaled_y), size / 2)

        # update level label
        self.label.center_x = self.size_dim * 1.5
        self.label.center_y = self.size_dim * 3 / 5
        self.label.font_size = str(Window.width // 20) + 'sp'

        # update you win label
        self.you_win_label.center_x = (Window.width / 2)
        self.you_win_label.center_y = (Window.height / 2)
        self.you_win_label.font_size = str(Window.width // 10) + 'sp'

        self.tempo_label.center_x = (Window.width / 4)
        self.tempo_label.center_y = (Window.height / 5.25 * (0.5 + 0.5) +
                                     self.gear_area.position[1])
        self.tempo_label.font_size = str(Window.width // 50) + 'sp'
        self.instrument_label.center_x = (Window.width / 4)
        self.instrument_label.center_y = (Window.height / 5.25 * (1.5 + 0.5) +
                                          self.gear_area.position[1])
        self.instrument_label.font_size = str(Window.width // 50) + 'sp'
        self.pitch_label.center_x = (Window.width / 4)
        self.pitch_label.center_y = (Window.height / 5.25 * (2.5 + 0.5) +
                                     self.gear_area.position[1])
        self.pitch_label.font_size = str(Window.width // 50) + 'sp'
        self.volume_label.center_x = (Window.width / 4)
        self.volume_label.center_y = (Window.height / 5.25 * (3.5 + 0.5) +
                                      self.gear_area.position[1])
        self.volume_label.font_size = str(Window.width // 50) + 'sp'

        # update child components
        self.gear_area.on_layout((Window.width, Window.height))
        self.music_box_area.on_layout((Window.width, Window.height))
        self.options.on_layout((Window.width, Window.height))

        # update particle effect and win/lose labels
        self.win_ps.emitter_x = Window.width / 2
        self.win_ps.emitter_y = Window.height / 2
        self.you_win_label.center_x = Window.width / 2
        self.you_win_label.center_y = Window.height / 2
        self.you_win_label.font_size = str(Window.width // 10) + 'sp'

        self.lose_ps.emitter_x = Window.width / 2
        self.lose_ps.emitter_y = Window.height / 2
        self.you_lose_label.center_x = Window.width / 2
        self.you_lose_label.center_y = Window.height / 2
        self.you_lose_label.font_size = str(Window.width // 10) + 'sp'

        # update error message location
        self.error_msg.center_x = Window.width / 2
        self.error_msg.center_y = Window.height / 2
        self.error_msg.font_size = str(Window.width // 20) + 'sp'

        # update tutorial overlays, label, and skip button
        if self.use_tutorial:
            self.update_tutorial_screen(self.tutorial_screen)
            self.tutorial_full_overlay.cpos = (Window.width / 2,
                                               Window.height / 2)
            self.tutorial_full_overlay.csize = (Window.width, Window.height)
            self.tutorial_options_overlay.size = (Window.width, self.size_dim +
                                                  Window.height / 25)
            self.tutorial_musicbox_overlay.pos = (Window.width // 2,
                                                  self.size_dim +
                                                  Window.height / 25)
            self.tutorial_musicbox_overlay.size = (
                Window.width / 2,
                Window.height - (self.size_dim + Window.height / 25))
            self.tutorial_gearbox_overlay.pos = (0, self.size_dim +
                                                 Window.height / 25)
            self.tutorial_gearbox_overlay.size = (
                Window.width / 2,
                Window.height - (self.size_dim + Window.height / 25))
            self.tutorial_skip_button.pos = (
                0.98 * Window.width -
                (self.skip_image.width * self.size_dim / 300),
                0.98 * Window.height -
                self.skip_image.height * self.size_dim / 300)
            self.tutorial_skip_button.size = (self.skip_image.width *
                                              self.size_dim / 300,
                                              self.skip_image.height *
                                              self.size_dim / 300)

    def reset(self):
        for gear in self.gears:
            # reset gear position
            gear.reset()
            # stop gear from rotating
            gear.stop()
        # stop center gear from rotating
        self.center_gear.stop()
        # stop music
        self.goal_music_seq.stop()
        if self.gear_music_seq:
            self.gear_music_seq.stop()

        # end tutorial
        if self.use_tutorial:
            self.tutorial_label.text = ''
            self.use_tutorial = False
            self.clear_overlays()
            while self.tutorial_skip_button in self.canvas.children:
                self.canvas.remove(self.tutorial_skip_button)

    def skip_tutorial_pressed(self, touch):
        if self.use_tutorial:
            if 0.98 * Window.width - (
                    self.skip_image.width * self.size_dim / 300
            ) < touch.pos[
                    0] < 0.98 * Window.width and 0.98 * Window.height - self.skip_image.height * self.size_dim / 300 < touch.pos[
                        1] < 0.98 * Window.height:
                return True
        return False

    def on_touch_up(self, touch):
        # if click is on one of the lower menu buttons, perform the appropriate action
        self.options.on_touch_up(self.switch_to, self.gear_music_seq,
                                 self.check_level_complete(), self.win_ps,
                                 self.you_win_label, self.lose_ps,
                                 self.you_lose_label, self.reset, touch)

        for index, gear in enumerate(self.gears):
            # response is true if you click the current gear
            response = gear.on_touch_up(touch.pos, self.gear_area.max_x,
                                        self._can_add_gear)
            self.gear_centers[index].on_touch_up(touch.pos,
                                                 self.gear_area.max_x,
                                                 self._can_add_gear)

            if response:
                if gear not in self.music_gears:
                    self.music_gears.append(gear)
                    # update the gear music based on the gear that is selected
                    function = 'self.gear_music.update_' + gear.type + '(' + str(
                        gear.value) + ')'
                    eval(function)

            else:
                if gear in self.music_gears:
                    self.music_gears.remove(gear)

        self.center_gear.on_touch_up(touch.pos, self.gear_area.max_x,
                                     self._can_add_gear)

        if self.use_tutorial:
            # if skip button pressed, quit out of tutorial mode
            if self.skip_tutorial_pressed(touch):
                self.use_tutorial = False
                self.remove_widget(self.tutorial_label)
                self.clear_overlays()
                while self.tutorial_skip_button in self.canvas.children:
                    self.canvas.remove(self.tutorial_skip_button)

            elif self.tutorial_screen == 'A':
                # show screen B (musicbox and gearbox covered)
                self.tutorial_screen = 'B'
                self.update_tutorial_screen('B')

            elif self.tutorial_screen == 'B':
                # show screen C (musicbox and options covered)
                self.tutorial_screen = 'C'
                self.update_tutorial_screen('C')

            elif self.tutorial_screen == 'C':
                # show screen D (gearbox and options covered)
                self.tutorial_screen = 'D'
                self.update_tutorial_screen('D')

            elif self.tutorial_screen == 'D':
                # show screen E (options covered)
                self.tutorial_screen = 'E'
                self.update_tutorial_screen('E')

            elif self.tutorial_screen == 'E' and self._check_music_gears():
                # if all gears have been placed, show screen F (gearbox covered)
                self.tutorial_screen = 'F'
                self.update_tutorial_screen('F')

            elif self.tutorial_screen == 'F' and self.gear_play_status == 'finished' and self.goal_play_status == 'finished':
                # if both tunes have been played show screen G (gearbox and musicbox covered)
                self.tutorial_screen = 'G'
                self.update_tutorial_screen('G')

            elif self.tutorial_screen == 'G':
                # end tutorial
                self.use_tutorial = False
                self.remove_widget(self.tutorial_label)
                self.clear_overlays()
                while self.tutorial_skip_button in self.canvas.children:
                    self.canvas.remove(self.tutorial_skip_button)

    def update_tutorial_screen(self, screen):
        if not self.use_tutorial:
            return

        self.remove_widget(self.tutorial_label)

        if self.tutorial_screen == 'A':
            self.activate_overlays(['full'])
            self.tutorial_label.center_x = Window.width / 2
            self.tutorial_label.center_y = Window.height / 2
            self.tutorial_label.text = "[font=./fonts/lato-bold]Welcome to the\n[/font] [font=./fonts/options-icons]|[/font] [font=./fonts/PassionOne-Regular]Play It By Gear Tutorial[/font] [font=./fonts/options-icons]|[/font] [font=./fonts/lato-bold]\n\nThe goal of this game is to make the \n goal song match the song you create by \nplacing the correct gears in a music box \n\n[/font] [font=./fonts/lato-light] (click to see the next \nstep of the tutorial)[/font]"
            self.tutorial_label.font_size = font_size = str(
                Window.width // 40) + 'sp'

        if self.tutorial_screen == 'B':
            self.activate_overlays(['musicbox', 'gearbox'])
            self.tutorial_label.center_x = 1 / 2 * Window.width
            self.tutorial_label.center_y = Window.height / 2 + (min(
                Window.width / 6, Window.height / 6) + Window.height / 25) / 2
            self.tutorial_label.text = "[font=./fonts/lato-bold]\nAt the bottom of the screen is the menu\nbar which contains some helpful buttons\n\nthe [/font] [font=./fonts/options-icons]^[/font] [font=./fonts/lato-bold] button brings\nyou back to the level select menu\n\nthe [/font] [font=./fonts/options-icons]`[/font] [font=./fonts/lato-bold] button resets the level\n\n[/font]  [font=./fonts/lato-light](click to continue)[/font]"
            self.tutorial_label.font_size = font_size = str(
                Window.width // 50) + 'sp'

        elif self.tutorial_screen == 'C':
            self.activate_overlays(['musicbox', 'options'])
            self.tutorial_label.center_x = 3 / 4 * Window.width
            self.tutorial_label.center_y = Window.height / 2 + (min(
                Window.width / 6, Window.height / 6) + Window.height / 25) / 2
            self.tutorial_label.text = "[font=./fonts/lato-bold]The left side of the screen\nhas all the gears you can choose\nfrom in order to make the\nmusic box sound correct\n\n[/font] [font=./fonts/lato-light](click to continue)[/font]"
            self.tutorial_label.font_size = font_size = str(
                Window.width // 60) + 'sp'

        elif self.tutorial_screen == 'D':
            self.activate_overlays(['gearbox', 'options'])
            self.tutorial_label.center_x = 1 / 4 * Window.width
            self.tutorial_label.center_y = Window.height / 2 + (min(
                Window.width / 6, Window.height / 6) + Window.height / 25) / 2
            self.tutorial_label.text = "[font=./fonts/lato-bold]The right side of the screen\nis the music box.  Gears in\nthe music box modify the song.\n\nYou need one gear of each\ntype/color in the music box in\norder for the song to play. \n\n[/font] [font=./fonts/lato-light](click to continue)[/font]"
            self.tutorial_label.font_size = font_size = str(
                Window.width // 60) + 'sp'

        elif self.tutorial_screen == 'E':
            self.activate_overlays(['options'])
            self.tutorial_label.center_x = Window.width / 2
            self.tutorial_label.center_y = (min(
                Window.width / 6, Window.height / 6) + Window.height / 25) / 2
            self.tutorial_label.text = "[font=./fonts/lato-bold]Now drag one gear of each type/color into the music box\n[/font] [font=./fonts/lato-light](when there are 4 gears in the music box, the tutorial will continue)[/font]"
            self.tutorial_label.font_size = font_size = str(
                Window.width // 60) + 'sp'

        elif self.tutorial_screen == 'F':
            self.activate_overlays(['gearbox'])
            self.tutorial_label.center_x = 1 / 4 * Window.width
            self.tutorial_label.center_y = Window.height / 2 + (min(
                Window.width / 6, Window.height / 6) + Window.height / 25) / 2
            self.tutorial_label.text = "[font=./fonts/lato-bold]Play the goal sound by pressing\nthe [/font] [font=./fonts/options-icons]_[/font] [font=./fonts/lato-bold] button, then press\nthe [/font] [font=./fonts/options-icons]~[/font] [font=./fonts/lato-bold] in the center gear to\nplay the song you created\nwith the gears\n\n[/font] [font=./fonts/lato-light](after you play both songs,\nclick again to continue)[/font]"
            self.tutorial_label.font_size = font_size = str(
                Window.width // 60) + 'sp'

        elif self.tutorial_screen == 'G':
            self.activate_overlays(['musicbox', 'gearbox'])
            self.tutorial_label.center_x = 1 / 2 * Window.width
            self.tutorial_label.center_y = Window.height / 2 + (min(
                Window.width / 6, Window.height / 6) + Window.height / 25) / 2
            self.tutorial_label.text = "[font=./fonts/lato-bold]Did the two songs sound the same?\n\nIf yes, you can press the [/font] [font=./fonts/options-icons]{[/font] [font=./fonts/lato-bold] button\n to see if you're correct\n\n If no, you can switch the gears in the music box\nuntil you think both songs sound the same\n\n[/font] [font=./fonts/lato-light](click to exit the tutorial)[/font]"
            self.tutorial_label.font_size = font_size = str(
                Window.width // 55) + 'sp'

        self.add_widget(self.tutorial_label)
        self.canvas.add(self.tutorial_skip_button)

    def on_touch_down(self, touch):
        other_gears = False
        for index, gear in enumerate(self.gears):
            cur_gear = gear.on_touch_down(touch.pos)
            other_gears = other_gears or cur_gear
            self.gear_centers[index].on_touch_down(touch.pos)

        if other_gears:
            if self.gear_music_seq:
                for gear in self.music_gears:
                    gear.stop()
                self.center_gear.stop()
                self.gear_music_seq.stop()
                self.gear_music_seq = None

        else:
            response = self.center_gear.on_touch_down(touch.pos)

            if response:
                if self._check_music_gears():
                    for gear in self.music_gears:
                        gear.toggle_rotate()

                    is_rotating = self.center_gear.toggle_rotate()

                    if is_rotating:
                        self.gear_music_seq = self.gear_music.generate()
                        self.gear_music_seq.start()
                        if self.use_tutorial and self.gear_play_status == None:
                            self.gear_play_status = 'started'
                    else:
                        if self.gear_music_seq:
                            self.gear_music_seq.stop()
                            self.gear_music_seq = None
                else:
                    if not self.use_tutorial:
                        self.error_msg.text = 'Place all 4 gears'

            else:
                self.error_msg.text = ' '
            return

        self.error_msg.text = ' '

    def on_touch_move(self, touch):
        for index, gear in enumerate(self.gears):
            gear.on_touch_move(touch.pos)
            self.gear_centers[index].on_touch_move(touch.pos)

    def on_update(self):
        self.goal_audio.on_update()
        self.gear_audio.on_update()
        self.options.on_update()
        for gear in self.gears:
            gear.on_update(1)
        self.center_gear.on_update(1)

        if self.gear_music_seq and not self.gear_music_seq.playing:
            for gear in self.music_gears:
                gear.stop()
            self.center_gear.stop()
            self.gear_music_seq = None
            if self.use_tutorial and self.gear_play_status == 'started':
                self.gear_play_status = 'finished'

    def check_level_complete(self):
        return self.goal_music.is_equal(self.gear_music)
Exemplo n.º 19
0
 def __init__(self):
     self._collection = Gear.getDict()
Exemplo n.º 20
0
        exc_type, exc_value, exc_traceback = sys.exc_info()
        plist = traceback.format_exception(exc_type, exc_value, exc_traceback)
        print plist
        ctrl.close()
        return True


if __name__ == '__main__':
    m = uut(ipaddr='10.8.8.100', opmode='master')  # 113
    s = uut(ipaddr='10.8.8.108', opmode='slave')  # 138
    m.telnet()
    s.telnet()
    m.web()
    s.web()
    t = thermotron("10.8.9.20")
    gear = Gear(master=m, slave=s, therm=t)

    #    Logname = "fpa031215"
    #    Temp = (1,2, 1)
    #    BW = ( 10,51,10)
    #    Power = ( 10,11,1)
    #    Freq = (5150,5926,50)

    #    Temp = (-40,70, 5)
    #    BW = ( 50,51,1)
    #    Power = ( 10,26,1)
    #    Freq = (5150,5926,1)
    Logname = "5XBigData"
    Temp = (0, 71, 5)
    BW = (50, 51, 1)
    Power = (10, 26, 1)
Exemplo n.º 21
0
    def __init__(self, load, mech, batt_val, prod_era, equip, cost):
        self.weight = mech.weight  # Save weight just in case
        self.artemis4 = load.attributes["fcsa4"].value
        self.artemis5 = load.attributes["fcsa5"].value
        self.apollo = load.attributes["fcsapollo"].value
        self.cost = cost
        self.unit = mech  # Reference to parent

        # Create a container for special abilities
        # ES, SEAL, SOA, SRCH is always available for mechs
        # Combat Vehicles gets SRCH
        if mech.type == "BM":
            self.specials = {"ES": 1, "SEAL": 1, "SOA": 1, "SRCH": 1}
        elif mech.type == "CV":
            self.specials = {"SRCH": 1}

        # Get source
        self.source = get_child_data(load, "source")

        # Get Clan CASE
        # Note that there is currently a bug in combat vehicles regarding
        # Clan CASE.
        if mech.type == "BM":
            clanc = get_child_data(load, "clancase")
        else:
            clanc = "FALSE"

        # Get actuator status
        for act in load.getElementsByTagName("actuators"):
            self.left_hand = act.attributes["lh"].value
            self.left_arm = act.attributes["lla"].value
            self.right_hand = act.attributes["rh"].value
            self.right_arm = act.attributes["rla"].value

        self.batt_val = batt_val
        # Set to zero things that might not get defined otherwise
        self.heatsinks = Heatsinks(None, self)
        self.jjets = JumpJets(None, mech.weight)
        self.partw = PartialWing(mech.weight, False, 2)

        # Assume not mixed tech
        self.mixed = False
        for rll in load.getElementsByTagName("techbase"):
            if gettext(rll.childNodes) == "Mixed":
                self.mixed = True

        # Get Actuator Enhancement System
        self.aes_ra = AES(mech.weight, mech.motive, "None")
        self.aes_la = AES(mech.weight, mech.motive, "None")
        for aes in load.getElementsByTagName("arm_aes"):
            if aes.attributes["location"].value == "LA":
                self.aes_la = AES(mech.weight, mech.motive, "Arm")
            elif aes.attributes["location"].value == "RA":
                self.aes_ra = AES(mech.weight, mech.motive, "Arm")

        # Get jump booster
        jumpb = 0
        for jbo in load.getElementsByTagName("jumpbooster"):
            jumpb = int(jbo.attributes["mp"].value)

        self.jumpb = JumpBoosters(mech.weight, jumpb)

        # Get Armored locations
        self.arm_loc = []
        self.arm_gyro = False
        self.armored = False
        for arm in load.getElementsByTagName("armored_locations"):
            for loc in arm.getElementsByTagName("location"):
                index = int(loc.attributes["index"].value)
                location = gettext(loc.childNodes)
                self.arm_loc.append((location, index))
                self.armored = True
                # Armored Gyro
                if location == "CT" and index == 3:
                    self.arm_gyro = True

        self.prod_era = prod_era

        # Get booby trap
        booby = False
        for bob in load.getElementsByTagName("boobytrap"):
            booby = True
        self.btrap = BoobyTrap(mech.weight, booby)

        # Hack: Get turret
        self.turret = False
        for tur in load.getElementsByTagName("turret"):
            self.turret = True

        self.gear = Gear(mech, self.artemis4, self.artemis5, self.apollo, equip, clanc)

        # Add Power Amplifiers
        if self.unit.engine.etype == "I.C.E. Engine" or self.unit.engine.etype == "No Engine":
            self.power_amp = PowerAmp(self, self.gear.weaponlist.ene_weight)
        else:
            self.power_amp = PowerAmp(self, 0.0)

        self.build_special()
Exemplo n.º 22
0
class Load:
    """
    Parent class for omni loadouts
    """

    def __init__(self, load, mech, batt_val, prod_era, equip, cost):
        self.weight = mech.weight  # Save weight just in case
        self.artemis4 = load.attributes["fcsa4"].value
        self.artemis5 = load.attributes["fcsa5"].value
        self.apollo = load.attributes["fcsapollo"].value
        self.cost = cost
        self.unit = mech  # Reference to parent

        # Create a container for special abilities
        # ES, SEAL, SOA, SRCH is always available for mechs
        # Combat Vehicles gets SRCH
        if mech.type == "BM":
            self.specials = {"ES": 1, "SEAL": 1, "SOA": 1, "SRCH": 1}
        elif mech.type == "CV":
            self.specials = {"SRCH": 1}

        # Get source
        self.source = get_child_data(load, "source")

        # Get Clan CASE
        # Note that there is currently a bug in combat vehicles regarding
        # Clan CASE.
        if mech.type == "BM":
            clanc = get_child_data(load, "clancase")
        else:
            clanc = "FALSE"

        # Get actuator status
        for act in load.getElementsByTagName("actuators"):
            self.left_hand = act.attributes["lh"].value
            self.left_arm = act.attributes["lla"].value
            self.right_hand = act.attributes["rh"].value
            self.right_arm = act.attributes["rla"].value

        self.batt_val = batt_val
        # Set to zero things that might not get defined otherwise
        self.heatsinks = Heatsinks(None, self)
        self.jjets = JumpJets(None, mech.weight)
        self.partw = PartialWing(mech.weight, False, 2)

        # Assume not mixed tech
        self.mixed = False
        for rll in load.getElementsByTagName("techbase"):
            if gettext(rll.childNodes) == "Mixed":
                self.mixed = True

        # Get Actuator Enhancement System
        self.aes_ra = AES(mech.weight, mech.motive, "None")
        self.aes_la = AES(mech.weight, mech.motive, "None")
        for aes in load.getElementsByTagName("arm_aes"):
            if aes.attributes["location"].value == "LA":
                self.aes_la = AES(mech.weight, mech.motive, "Arm")
            elif aes.attributes["location"].value == "RA":
                self.aes_ra = AES(mech.weight, mech.motive, "Arm")

        # Get jump booster
        jumpb = 0
        for jbo in load.getElementsByTagName("jumpbooster"):
            jumpb = int(jbo.attributes["mp"].value)

        self.jumpb = JumpBoosters(mech.weight, jumpb)

        # Get Armored locations
        self.arm_loc = []
        self.arm_gyro = False
        self.armored = False
        for arm in load.getElementsByTagName("armored_locations"):
            for loc in arm.getElementsByTagName("location"):
                index = int(loc.attributes["index"].value)
                location = gettext(loc.childNodes)
                self.arm_loc.append((location, index))
                self.armored = True
                # Armored Gyro
                if location == "CT" and index == 3:
                    self.arm_gyro = True

        self.prod_era = prod_era

        # Get booby trap
        booby = False
        for bob in load.getElementsByTagName("boobytrap"):
            booby = True
        self.btrap = BoobyTrap(mech.weight, booby)

        # Hack: Get turret
        self.turret = False
        for tur in load.getElementsByTagName("turret"):
            self.turret = True

        self.gear = Gear(mech, self.artemis4, self.artemis5, self.apollo, equip, clanc)

        # Add Power Amplifiers
        if self.unit.engine.etype == "I.C.E. Engine" or self.unit.engine.etype == "No Engine":
            self.power_amp = PowerAmp(self, self.gear.weaponlist.ene_weight)
        else:
            self.power_amp = PowerAmp(self, 0.0)

        self.build_special()

    def build_special(self):
        """
        Add special abilities to list
        """
        # Scan equipment
        for equip in self.gear.equiplist.list:
            if equip.count > 0 and equip.name == "C3 Computer (Master)":
                self.specials["C3M"] = equip.count
                self.specials["TAG"] = 1
            if equip.count > 0 and equip.name == "C3 Boosted Computer (Master)":
                self.specials["C3BSM"] = equip.count
                self.specials["TAG"] = 1
            if equip.count > 0 and equip.name == "Improved C3 Computer":
                self.specials["C3I"] = 1
            if equip.count > 0 and equip.name == "C3 Computer (Slave)":
                self.specials["C3S"] = 1
            if equip.count > 0 and equip.name == "C3 Boosted Computer (Slave)":
                self.specials["C3BSS"] = 1
            if equip.count > 0 and equip.name == "TAG":
                self.specials["TAG"] = 1
            if equip.count > 0 and equip.name == "Light TAG":
                self.specials["LTAG"] = 1
            if equip.count > 0 and equip.name == "Watchdog CEWS":
                self.specials["WAT"] = 1
            if equip.count > 0 and (
                equip.name == "Guardian ECM Suite"
                or equip.name == "ECM Suite"
                or equip.name == "Electronic Warfare Equipment"
            ):
                self.specials["ECM"] = 1
            if equip.count > 0 and equip.name == "Angel ECM":
                self.specials["AECM"] = 1
            if equip.count > 0 and equip.name == "Bloodhound Active Probe":
                self.specials["BH"] = 1
                self.specials["RCN"] = 1
            if equip.count > 0 and (equip.name == "Beagle Active Probe" or equip.name == "Active Probe"):
                self.specials["PRB"] = 1
                self.specials["RCN"] = 1
            if equip.count > 0 and equip.name == "Light Active Probe":
                self.specials["LPRB"] = 1
                self.specials["RCN"] = 1
            if equip.count > 0 and equip.name == "Remote Sensor Dispenser":
                self.specials["RSD"] = equip.count
                self.specials["RCN"] = 1
            if equip.count > 0 and equip.name == "C3 Remote Sensor Launcher":
                self.specials["C3RS"] = 1
            if equip.count > 0 and (
                equip.name == "(IS) Anti-Missile System"
                or equip.name == "(CL) Anti-Missile System"
                or equip.name == "(IS) Laser Anti-Missile System"
                or equip.name == "(CL) Laser Anti-Missile System"
            ):
                self.specials["AMS"] = 1

        # Scan weapons
        for weap in self.gear.weaponlist.list.itervalues():
            if weap.count > 0 and (weap.name == "(IS) Narc Missile Beacon" or weap.name == "(CL) Narc Missile Beacon"):
                self.specials["SNARC"] = weap.count
            if weap.count > 0 and (weap.name == "(IS) iNarc Launcher"):
                self.specials["INARC"] = weap.count
            if weap.count > 0 and weap.name == "(IS) BattleMech Taser":
                self.specials["MTAS"] = weap.count
            if weap.count > 0 and weap.name == "(IS) Arrow IV Missile":
                self.specials["ARTAIS"] = weap.count
            if weap.count > 0 and weap.name == "(CL) Arrow IV Missile":
                self.specials["ARTAC"] = weap.count
            if weap.count > 0 and weap.name == "(IS) Sniper":
                self.specials["ARTS"] = weap.count
            # Is this one really correct? Does Artillery Cannons count?
            if weap.count > 0 and weap.name == "Long Tom Artillery Cannon":
                self.specials["ARTLTC"] = weap.count

    def get_name(self):
        """
        Return the name of the Loadout, if any
        """
        raise NotImplementedError

    def get_rules_level(self):
        """
        Return rules level of loadout
        """
        r_level = 0
        # Mixed Tech is advanced rules
        if self.mixed:
            r_level = 2
        r_level = max(r_level, self.gear.get_rules_level())
        r_level = max(r_level, self.heatsinks.get_rules_level())
        r_level = max(r_level, self.jjets.get_rules_level())
        r_level = max(r_level, self.partw.get_rules_level())
        r_level = max(r_level, self.jumpb.get_rules_level())
        r_level = max(r_level, self.btrap.get_rules_level())
        r_level = max(r_level, self.aes_ra.get_rules_level())
        r_level = max(r_level, self.aes_la.get_rules_level())
        r_level = max(r_level, self.power_amp.get_rules_level())

        # Hack: Armored location
        if self.armored == True and r_level < 2:
            r_level = 2

        return r_level

    def get_sink(self):
        """
        Get heatsinking capability
        """
        sink = self.heatsinks.get_sink()
        # coolant pods
        if self.gear.coolant > 0:
            cool = ceil(self.heatsinks.number * (float(self.gear.coolant) / 5.0))
            if cool > (self.heatsinks.number * 2):
                cool = self.heatsinks.number * 2
            sink += cool
        # Partial Wing
        if self.partw.has_wing():
            sink += 3
        return int(sink)

    def get_prod_era(self):
        """
        Get production era
        """
        return self.prod_era

    def get_jump(self):
        """
        Get max jumping range
        """
        # Ordinary jump-jets
        jmp = self.jjets.get_jump()
        # Handle partial wing
        if jmp and self.partw.has_wing():
            if self.weight >= 60:
                jmp += 1
            else:
                jmp += 2
        # Mechanical jump boosters
        jump = max(jmp, self.jumpb.get_jump())
        return jump

    def get_move_heat(self, mech):
        """
        Get maximum heat produced by movement.
        """
        run_heat = 2
        if mech.engine.etype == "XXL Engine":
            run_heat = 6

        move_heat = max(run_heat, self.jjets.get_heat(mech))
        return move_heat

    def get_def_bv(self, mech):
        """
        Get defensive equipment BV
        """
        dbv = self.gear.get_def_bv()
        # Track things left
        arm_loc = self.arm_loc[:]
        # Deal with armored components
        for i in self.arm_loc:
            # Gyros, BV calculated elsewhere
            for j in mech.gyro.get_slots():
                if not cmp(i, j):
                    arm_loc.remove(i)
            # Engines
            for j in mech.engine.get_slots():
                if not cmp(i, j):
                    dbv += 5
                    arm_loc.remove(i)
            # Cockpits
            for j in mech.cockpit.get_slots():
                if not cmp(i, j):
                    dbv += 5
                    arm_loc.remove(i)
            # Actuators
            act_locations = [
                ("LA", 0),
                ("LA", 1),
                ("RA", 0),
                ("RA", 1),
                ("LL", 0),
                ("LL", 1),
                ("LL", 2),
                ("LL", 3),
                ("RL", 0),
                ("RL", 1),
                ("RL", 2),
                ("RL", 3),
            ]
            if self.left_arm == "TRUE":
                act_locations.append(("LA", 2))
            if self.left_hand == "TRUE":
                act_locations.append(("LA", 3))
            if self.right_arm == "TRUE":
                act_locations.append(("RA", 2))
            if self.right_hand == "TRUE":
                act_locations.append(("RA", 3))
            for j in act_locations:
                if not cmp(i, j):
                    dbv += 5
                    arm_loc.remove(i)
        if arm_loc:
            print "Unknown armored items left: ", arm_loc
            raise NotImplementedError
        return dbv

    def off_bv(self, mech, printq):
        """
        Get offensive weapon and ammo BV
        """
        obv = 0.0
        bwbr = 0.0
        heat = 0
        ammo_bv = 0.0

        heat_eff = 6 + self.get_sink() - self.get_move_heat(mech)
        if printq:
            print "Heat Efficiency", heat_eff

        # Check for weapon BV flip
        flip = self.gear.check_weapon_bv_flip()

        w_list = []
        # Weapons
        for weap in self.gear.weaponlist.list.itervalues():
            if weap.count > 0:
                i = weap.count
                left_arm = weap.count_la
                right_arm = weap.count_ra
                if flip and (i - weap.count_la - weap.count_ra - weap.count_tur > 0):
                    batt_val = weap.get_bv(self.gear.tarcomp) / 2.0
                else:
                    batt_val = weap.get_bv(self.gear.tarcomp)
                # Handle AES
                if left_arm > 0 and self.aes_la.type == "Arm":
                    batt_val *= 1.5
                    left_arm -= 1
                elif right_arm > 0 and self.aes_ra.type == "Arm":
                    batt_val *= 1.5
                    right_arm -= 1
                while i:
                    w_list.append((batt_val, weap.get_heat(), weap.name))
                    i -= 1

            # Rear-facing weapons counts as half
            if weap.countrear > 0:
                i = weap.countrear
                if flip:
                    batt_val = weap.get_bv(self.gear.tarcomp)
                else:
                    batt_val = weap.get_bv(self.gear.tarcomp) / 2.0
                while i:
                    w_list.append((batt_val, weap.get_heat(), weap.name))
                    i -= 1

            # Count possible Ammo BV
            ammo_bv += weap.get_ammo_bv()

        # Physical weapons
        for weap in self.gear.physicallist.list:
            # Only offensive physical gear
            if weap.count > 0 and weap.get_bv() > 0:
                i = weap.count
                left_arm = weap.count_la
                right_arm = weap.count_ra
                batt_val = weap.get_bv()
                # Handle AES
                if left_arm > 0 and self.aes_la.type == "Arm":
                    batt_val *= 1.5
                    left_arm -= 1
                elif right_arm > 0 and self.aes_ra.type == "Arm":
                    batt_val *= 1.5
                    right_arm -= 1
                while i:
                    w_list.append((batt_val, weap.heat, weap.name))
                    i -= 1

        # Sort list, from largest BV to smallest,
        # and from lowest heat to highest
        w_list.sort(key=itemgetter(1))  # secondary by heat
        w_list.sort(key=itemgetter(0), reverse=True)  # primary by BV

        # Calculate weapon BV
        over = 0
        for i in w_list:
            if over > 0 and i[1] > 0:
                bwbr += i[0] / 2.0
                heat += i[1]
                if printq:
                    print "Over-heat"
            else:
                bwbr += i[0]
                heat += i[1]
            # We have to much heat, halve future weapon BV
            if heat >= heat_eff and mech.type != "CV":
                over = 1
            if printq:
                print i
        if printq:
            print "BWBR", bwbr
        obv = bwbr

        # Ammo
        obv += ammo_bv
        if printq:
            print "Ammo BV: ", ammo_bv

        # Non-heat gear
        equip_bv = 0
        for equip in self.gear.equiplist.list:
            # Only offensive physical gear
            if equip.count > 0 and equip.off_bv[0] > 0:
                bv_gear = equip.off_bv[0] * equip.count
                equip_bv += bv_gear
                # Handle C3 ammo (and possible other ammo)
                if equip.off_bv[1] > 0 and equip.ammocount > 0:
                    bv_ammo = equip.off_bv[1] * equip.ammo_ton
                    # Disallow ammo BV to be greater than that of
                    # the system itself
                    if bv_ammo > bv_gear:
                        bv_ammo = bv_gear
                    equip_bv += bv_ammo

        obv += equip_bv
        if printq:
            print "Equipment BV: ", equip_bv

        return obv
Exemplo n.º 23
0
class control():

    gear = Gear()

    def __init__(self, **kwargs):  # ctrl = control( Gear=gear )
        got_gear = kwargs.get('Gear', None)
        if got_gear:
            self.gear = copy.copy(got_gear)

    def setfrequency(self, freq):  # frequency in MHz
        cmd = "af set tx1freq %s; af set rxfreq %s" % (freq, freq)
        self.gear.master.t.write_wait(cmd)
        self.gear.slave.t.write_wait(cmd)

    def setpower(self, power):
        cmd = "af set powerout %s" % power
        self.gear.master.t.write_wait(cmd)
        self.gear.slave.t.write_wait(cmd)

    def setbw(self, bw):
        cmd = "af set channelbandwidth %s" % bw
        self.gear.master.t.write_wait(cmd)
        self.gear.slave.t.write_wait(cmd)

    def wait(self, mod_rate, delay=25):
        sleep(2)
        self.gear.slave.t.radio_ready(ready_state=[('slave', 'operational')],
                                      timeout=40)
        self.gear.master.t.radio_ready(ready_state=[('master', 'operational')],
                                       timeout=40)
        print "wait_mod_rate(%s, %d)" % (mod_rate, delay)
        return self.wait_mod_rate(mod_rate, timeout=delay)
#        sleep(3)

    def get_mod_rate(self):
        s_mod_rate = self.gear.slave.w.get_page_field("labefana",
                                                      "Local Mod Rate")
        m_mod_rate = self.gear.master.w.get_page_field("labefana",
                                                       "Local Mod Rate")
        return (s_mod_rate, m_mod_rate)

    # return True if timeout
    def wait_mod_rate(self, mod_rate, timeout=25):
        delay = timeout
        mod = self.get_mod_rate()
        while delay:
            if mod[0] == mod_rate and mod[1] == mod_rate:
                return 0
            mod = self.get_mod_rate()
            delay -= 1
            sleep(1)
        return 1

    def settemp(self, temp):
        if self.gear.therm:
            self.gear.therm.set_temp_chamber(temp)
            print "did set_temp"
            self.gear.therm.waitTempChamber(soak_time=10)
            print "did wait"

    def close(self):
        self.gear.master.close()
        self.gear.slave.close()
Exemplo n.º 24
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.indexed_range = self.indexed_range[:7]
     self.center = self.lattice[self.indexed_range[0]]
     self.gear = Gear(lights=self, indexed_range=self.indexed_range[1:7])
Exemplo n.º 25
0
	def gear(self, storage, interface, **kwargs):
		return Gear(storage, self.router, interface, **kwargs)
Exemplo n.º 26
0
Arquivo: main.py Projeto: kohsuke/ev3
    # c.output.ports(0xF).speed(10).start()
    # c.output.stop(ports=0xF)

    # c.output.layer(0).ports(0xF).speed(10).start()
    # c.output.layer(1).ports(0xF).speed(10).start()

    # c.output.stop(ports=0xF).layer(1).stop(ports=0x0F)

    # c.sound.tone(volume=1, frequency=550, duration=100)
    # c.sound.ready()
    # c.sound.tone(volume=1, frequency=660, duration=100)
    # c.sound.ready()

    c.ui.led(color='orange', mode='off')

    g = Gear(Gear.BIG, Gear.TURRET)

    c.output.ports(1)
    # c.output.polarity(1)

    # move_by_X functions seem to internally reset tacho count
    # so read is not giving me meaningful tacho count
    c.output.move_by_step(g(60), g(240), g(60), speed=20)
    # c.output.move_by_time( 500, 1000, 500, speed=20)

    # c.output.ready()
    # c.output.move_by_step( g(60), g(240), g(60), speed= 20)

    c.send(h)

    for i in range(50):