Esempio n. 1
0
def mode_buttons():
    global octave
    global delay
    # render_ui()

    alive = True
    while alive:
        speaker.enabled(True)

        if is_pressed(Buttons.JOY_Up):
            delay += 10
        if is_pressed(Buttons.JOY_Down):
            if delay > 10:
                delay -= 10

        if is_pressed(Buttons.JOY_Left):
            if 1 < octave:
                octave -= 1
        if is_pressed(Buttons.JOY_Right):
            if octave < 6:
                octave += 1

        rand_temp = str(Sensors.get_hdc_temperature()).split('.')[-1]

        rand_num = int(rand_temp) % len(notes)

        rest_delay = int(rand_temp) % 100

        note_to_play = notes[rand_num]
        render_ui(note_to_play, delay, octave, rest_delay)
        # octave = random.randint(1,5)
        speaker.note("{}{}".format(note_to_play, octave))
        sleep.sleep_ms(delay)

        speaker.enabled(False)
        sleep.sleep_ms(rest_delay)
Esempio n. 2
0
 def test_enabled(self):
     self.assertEqual(speaker.enabled(), True)
     speaker.enabled(False)
     self.assertEqual(speaker.enabled(), False)
     speaker.enabled(True)
     self.assertEqual(speaker.enabled(), True)
Esempio n. 3
0
    dialogs.notice("Please repeat your personal lucky melody a bit louder.", title=APP_TITLE)
    ugfx.display_image(0, 0, LOCAL_FOLDER % "rec.gif")
    sleep.sleep_ms(4000)

    dialogs.notice("Unfortunately, this tone\nwas wrong. Please repeat\nyour personal lucky melody\nonce again.", title=APP_TITLE)
    ugfx.display_image(0, 0, LOCAL_FOLDER % "rec.gif")
    sleep.sleep_ms(6000)

    dialogs.notice("This lucky melody will help you in every situation.\nMany thanks.", title=APP_TITLE)

    show_next_step()

#
# INITIALIZATION
#

ugfx_helper.init()
speaker.enabled(True)
STEPS = [show_start, show_coin, show_coin_again, show_weight, show_std, show_melody, show_repeat]

#
# START
#

while True:
    show_next_step()

speaker.stop()
restart_to_default()