示例#1
0
        if cur_state != prev_state:
            if not cur_state:
                animations.next()
                print("BTN is down")
            else:
                print("BTN is up")
        prev_state = cur_state
        # Read accelerometer
        x, y, z = accel.acceleration
        accel_total = z  # x=tilt, y=rotate
        accel_total_y = y  # x=tilt, y=rotate
        print(accel_total_y)
        if accel_total > THRESHOLD:
            print("THRESHOLD: ", accel_total)
        if MODE == 1:
            animations.animate()
            if animations.current_animation.name == "BLACK":
                MODE = 2
        if MODE == 2:
            if y > CARVE_THRESHOLD:
                black_right.animate()
                carve_left.animate()
            if y < (CARVE_THRESHOLD * -1):
                black_left.animate()
                carve_right.animate()
            #print (MODE)
            cur_state = btn.value
            if cur_state != prev_state:
                if not cur_state:
                    MODE = 1
示例#2
0
    if mode == 0:  # If currently off...
        enable.value = True
        power_on('on', POWER_ON_SOUND_DURATION)  # Power up!
        play_wav('idle', loop=True)  # Play idle sound now
        mode = 1  # Idle mode

    elif mode >= 1:  # If not OFF mode...
        x, y, z = accel.acceleration  # Read accelerometer
        accel_total = x * x + z * z
        # (Y axis isn't needed, due to the orientation that the Prop-Maker
        # Wing is mounted.  Also, square root isn't needed, since we're
        # comparing thresholds...use squared values instead.)
        if accel_total > HIT_THRESHOLD:  # Large acceleration = HIT
            TRIGGER_TIME = time.monotonic()  # Save initial time of hit
            play_wav(random.choice(hit_sounds))  # Start playing 'hit' sound
            solid.animate()
            mode = 3  # HIT mode
        elif mode == 1 and accel_total > SWING_THRESHOLD:  # Mild = SWING
            TRIGGER_TIME = time.monotonic()  # Save initial time of swing
            play_wav(random.choice(
                swing_sounds))  # Randomly choose from available swing sounds
            while audio.playing:
                pass  # wait till we're done
            mode = 2  # we'll go back to idle mode

        elif mode == 1:
            pulse.animate()
        elif mode > 1:  # If in SWING or HIT mode...
            if audio.playing:  # And sound currently playing...
                blend = time.monotonic() - TRIGGER_TIME  # Time since triggered
                if mode == 2:  # If SWING,
示例#3
0
            sample0.file = open(BGM, "rb")
            mixer.voice[0].play(sample0, loop=True)
            vu_strip_animations_mode1.animate()
            pulse_rings_m1.animate()
            pulse_jewel_m1.animate()
            mode_state = 0

    x, _, _ = accel.acceleration  # get accelerometer values

    if not mixer.voice[1].playing:
        if not trig_button.value:  # trigger squeezed
            FX_sample = "/lucio/shoot.mp3"
            sample1.file = open(FX_sample, "rb")
            mixer.voice[1].play(sample1)
            if mode_state:
                solid_white.animate()
            else:
                solid_white.animate()

        if not alt_button.value:  # alt trigger squeezed
            FX_sample = "/lucio/alt_shoot.mp3"
            sample1.file = open(FX_sample, "rb")
            mixer.voice[1].play(sample1)
            if mode_state:
                solid_white.animate()
            else:
                solid_white.animate()

        if accel.acceleration.x > 8:  # reload
            FX_sample = "/lucio/reload.mp3"
            sample1.file = open(FX_sample, "rb")
             elif packet.button == ButtonPacket.BUTTON_2:
                 MODE = 1
                 animations.activate(2)
             elif packet.button == ButtonPacket.BUTTON_3:
                 MODE = 1
                 animations.activate(3)
             elif packet.button == ButtonPacket.BUTTON_4:
                 MODE = 1
                 animations.activate(4)
             # change the mode with right arrow
             elif packet.button == ButtonPacket.RIGHT:
                 MODE = 1
                 animations.next()
             elif packet.button == ButtonPacket.LEFT:
                 MODE = 4
                 off.animate()
             #change the brightness with up and down arrows
             elif packet.button == ButtonPacket.UP:
                 pixels.brightness = pixels.brightness + 0.1
                 pixels.show()
                 if pixels.brightness > 1:
                     pixels.brightness = 1
             elif packet.button == ButtonPacket.DOWN:
                 pixels.brightness = pixels.brightness - 0.1
                 pixels.show()
                 if pixels.brightness < 0.1:
                     pixels.brightness = 0.1
 if MODE == 1:
     animations.animate()
 if MODE == 4:
     animations.freeze()