🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    M5StickC, UIFlow, Play Tone or Speaker.beep - how to add silence

    UIFlow
    2
    6
    9.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Happy Hippo
      last edited by Happy Hippo

      I'm testing out the speaker hat on my newly acquired M5StickC. I wrote a program which does other things but when I push Button B, I want it to play the first 6 notes of the Mario song. I tried both the Play Tone and Speaker.beep functions but they both do the same thing. Even though I'm specifying the first 3 notes, it is being played as if it were one note. I put wait time between with no effect. I need some separation between the notes. I need staccato, not legato :) Also, the end note continues to play, even after it exits this module. Here's what I did (shown in Python):

      def buttonB_wasPressed():
      global q, i, bv, iv
      hat_spk1.tone(329, 200)
      wait_ms(200)
      hat_spk1.tone(329, 200)
      wait_ms(200)
      hat_spk1.tone(329, 200)
      wait_ms(200)
      hat_spk1.tone(523, 200)
      wait_ms(200)
      hat_spk1.tone(329, 200)
      wait_ms(200)
      hat_spk1.tone(784, 200)
      wait_ms(200)
      pass
      btnB.wasPressed(buttonB_wasPressed

      1 Reply Last reply Reply Quote 0
      • ajb2k3A
        ajb2k3
        last edited by

        Can you post a screen shot of your program.

        Are you using the Button loop?

        UIFlow, so easy an adult can learn it!
        If I don't know it, be patient!
        I've ether not learned it or am too drunk to remember it!
        Author of the WIP UIFlow Handbook!
        M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

        1 Reply Last reply Reply Quote 0
        • H
          Happy Hippo
          last edited by

          0_1572195557039_1f9b5dbf-f001-4647-93f0-57348dca08db-image.png

          H 1 Reply Last reply Reply Quote 0
          • H
            Happy Hippo @Happy Hippo
            last edited by

            @happy-hippo
            I made a better sounding one; however, it seems like the speaker.beep function is not paying any attention to the duration. Like I said, the first 3 notes sound as one.

            0_1572203612469_d4a5edb6-6f8e-4589-925d-9c2c3ef2ccdb-image.png

            H 1 Reply Last reply Reply Quote 0
            • H
              Happy Hippo @Happy Hippo
              last edited by

              @happy-hippo
              Here is the entire code I've been playing around with. Basically, I'm flashing the LED for 100 times. There is supposed to be a beep at the beginning of each flash. That is not happening. If I push Button A, the battery voltage and current displays. That is working. If I push Button B, the first 6 notes of Mario plays. That sort of works, except there is no separation between notes. And the last note plays forever. I know this is super basic but I've just starting using this.

              I can run this in Arduino IDE with no problem; however, that doesn't help me learning UIFlow.

              0_1572204923451_da6e3a16-e2c9-4e6c-bd82-2d4effdc285d-image.png

              ajb2k3A 1 Reply Last reply Reply Quote 0
              • ajb2k3A
                ajb2k3 @Happy Hippo
                last edited by

                @happy-hippo Music is not properly implemented in UIFlow and the walkaround for it is a bit complicated. but in essence I had to create variable for beats and DPM and then tie them all together.
                Unfortunately I seam to have misplaced the timing demo.

                UIFlow, so easy an adult can learn it!
                If I don't know it, be patient!
                I've ether not learned it or am too drunk to remember it!
                Author of the WIP UIFlow Handbook!
                M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post