Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    What do I misunderstand about rgbled()?

    Scheduled Pinned Locked Moved Discussion
    26 Posts 5 Posters 169 Views 5 Watching
    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.
    • G Offline
      Gijs
      last edited by

      So if I understand this correctly, the loop

      pycom.heartbeat(False)
      While True:
         rgbled(green)
      

      does not show a green color on the led because we call it too fast, leaving no time to actually change the led as we queue another task to change the led color right after the first one, squashing the first one? That would make sense.

      Thanks for the thorough explanation! I would not have expected that and figured the method to be blocking until the LED color actually changed. Do you think this is a bug, or a feature?

      Gijs

      robert-hhR 2 Replies Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @Gijs
        last edited by

        @Gijs Not really. It is not that a follow up call to rgbled() squashes the previous one. It is the opposite. If the follwow-up call is too early, it will be ignored. And in the example it was the rgbled(white) which came too soon, only ~50 µs after the previous one.
        The messages themselves had proper structure, only the time between them was too short.
        shortburst.png
        Adding more time (here 144 µs) made it work.
        shortburst_145_pass.png
        I made a PR ensuring at least 280 µs, because that's what I found in the datasheet of the WS2812B-V4 (opposed to 50µs in the WS2812B datasheet).

        1 Reply Last reply Reply Quote 1
        • robert-hhR Offline
          robert-hh @Gijs
          last edited by

          @Gijs said in What do I misunderstand about rgbled()?:

          I would not have expected that and figured the method to be blocking until the LED color actually changed. Do you think this is a bug, or a feature?

          Using the RMT is definitly a feature. The code actually waits until a previous transmission is finished. And that's the heart of my PR. I just insert another wait pulse cycle pair to the RMT chain, which causes a sufficient delay. I was not able to find the place causing the 50µs delay which is initially there.

          P 1 Reply Last reply Reply Quote 0
          • P Offline
            Paul Holthuizen @robert-hh
            last edited by

            @robert-hh

            For my benefit: what's the RMT?

            robert-hhR 1 Reply Last reply Reply Quote 0
            • robert-hhR Offline
              robert-hh @Paul Holthuizen
              last edited by

              @Paul-Holthuizen That is the Remote Controller Unit of the ESP32. Intended to send and receive messages for remote controllers. But it is also fine for creating and timing bit patterns with high precision. See https://docs.pycom.io/firmwareapi/pycom/machine/rmt/#app

              P 1 Reply Last reply Reply Quote 0
              • P Offline
                Paul Holthuizen @robert-hh
                last edited by

                @robert-hh

                And precise enough to create the timing signals for a WS2812! I remember writing a piece of C-code for a PIC microcontroller controlling a whole string of these leds and wrestling with that for a bit.

                Thanks for your support. I was getting a little bit frustrated with the lopy on my bench but am starting to realize now that the difficult bit here is not in the networking but in the way a high-level language like Python interfaces with low level hardware. Just more stuff to learn :-)

                1 Reply Last reply Reply Quote 1

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                • 1
                • 2
                • 2 / 2
                • First post
                  Last post

                Pycom on Twitter

                Pycom