Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Neopixels are fun little widgets

Neopixels are fun little widgets

Scheduled Pinned Locked Moved The Lounge
graphicsdesignpythoncomiot
10 Posts 5 Posters 0 Views 1 Watching
  • 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 Offline
    H Offline
    honey the codewitch
    wrote on last edited by
    #1

    A neopixel is an RGB LED with a 1 wire daisy chainable interface. You can string many together into panels or single strands, or whatever. Some of them however, have a strange color model. They have R, G, B, and W(hite) channels. That caused me some grief because representing colors on these is a bit tricky. Well, I finally, after looking at some python code someone dreamed up by hand fiddling came up with an RGBW "color model" in my graphics library. The upshot is I can now for example, pretty faithfully represent a JPG or a GIF (the latter would be fun!) given a large enough panel. Kinda proud of this. It's an elegant solution.

    #include using namespace gfx;

    ...

    // create a bitmap in the rgbw color format
    auto bmp = create_bitmap>({64,64});
    if(bmp.begin()) {
    file_stream fs("./test.jpg");
    draw::image(bmp,bmp.bounds(),&fs);
    fs.close();
    // render the bitmap out to leds here...
    free(bmp.begin());
    }

    Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

    J A B G 4 Replies Last reply
    0
    • H honey the codewitch

      A neopixel is an RGB LED with a 1 wire daisy chainable interface. You can string many together into panels or single strands, or whatever. Some of them however, have a strange color model. They have R, G, B, and W(hite) channels. That caused me some grief because representing colors on these is a bit tricky. Well, I finally, after looking at some python code someone dreamed up by hand fiddling came up with an RGBW "color model" in my graphics library. The upshot is I can now for example, pretty faithfully represent a JPG or a GIF (the latter would be fun!) given a large enough panel. Kinda proud of this. It's an elegant solution.

      #include using namespace gfx;

      ...

      // create a bitmap in the rgbw color format
      auto bmp = create_bitmap>({64,64});
      if(bmp.begin()) {
      file_stream fs("./test.jpg");
      draw::image(bmp,bmp.bounds(),&fs);
      fs.close();
      // render the bitmap out to leds here...
      free(bmp.begin());
      }

      Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

      J Offline
      J Offline
      jeron1
      wrote on last edited by
      #2

      Nice! We use a good number of the RGB type, and they are straight forward to use.

      "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

      H 1 Reply Last reply
      0
      • J jeron1

        Nice! We use a good number of the RGB type, and they are straight forward to use.

        "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

        H Offline
        H Offline
        honey the codewitch
        wrote on last edited by
        #3

        Trying to get them to color match is tricky, even with straight RGB because the behavior is far different than an LCD screen.

        Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

        J 1 Reply Last reply
        0
        • H honey the codewitch

          Trying to get them to color match is tricky, even with straight RGB because the behavior is far different than an LCD screen.

          Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

          J Offline
          J Offline
          jeron1
          wrote on last edited by
          #4

          On that I agree, I normally do several passes before I get the color how I want.

          "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

          1 Reply Last reply
          0
          • H honey the codewitch

            A neopixel is an RGB LED with a 1 wire daisy chainable interface. You can string many together into panels or single strands, or whatever. Some of them however, have a strange color model. They have R, G, B, and W(hite) channels. That caused me some grief because representing colors on these is a bit tricky. Well, I finally, after looking at some python code someone dreamed up by hand fiddling came up with an RGBW "color model" in my graphics library. The upshot is I can now for example, pretty faithfully represent a JPG or a GIF (the latter would be fun!) given a large enough panel. Kinda proud of this. It's an elegant solution.

            #include using namespace gfx;

            ...

            // create a bitmap in the rgbw color format
            auto bmp = create_bitmap>({64,64});
            if(bmp.begin()) {
            file_stream fs("./test.jpg");
            draw::image(bmp,bmp.bounds(),&fs);
            fs.close();
            // render the bitmap out to leds here...
            free(bmp.begin());
            }

            Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

            A Offline
            A Offline
            Alister Morton
            wrote on last edited by
            #5

            Fun indeed - we recently used some high density pixel addressable tape in our amateur theatre production of treasure island, where the parrot was named, not Captain Flint, but Alexa, and had a pulsating necklace which mimicked the effects of the earlier Alexa units when you spoke to the "parrot". Alexa (there were two of them, depending on which side of the stage it was to come from) was a children's stuffed parrot toy, wearing a loop of pixel tape, connected to an Arduino nano IOT which was receiving artnet over WIFI from the lighting desk, all powered by a small USB power bank and the electronics stuffed inside the toy. This meant the toy could be carried around with no trailing cables, and the lighting desk could sent it commands to run patterns and effects on its "necklace". The patterns were programmed into the Arduino rather than sending them directly from the desk so saving on channels in the desk. The necklace had enough pixels tightly packed that the two parrots together would have used up almost half a universe of addresses, whereas the technique used only required two addresses per parrot - intensity and pattern number.

            1 Reply Last reply
            0
            • H honey the codewitch

              A neopixel is an RGB LED with a 1 wire daisy chainable interface. You can string many together into panels or single strands, or whatever. Some of them however, have a strange color model. They have R, G, B, and W(hite) channels. That caused me some grief because representing colors on these is a bit tricky. Well, I finally, after looking at some python code someone dreamed up by hand fiddling came up with an RGBW "color model" in my graphics library. The upshot is I can now for example, pretty faithfully represent a JPG or a GIF (the latter would be fun!) given a large enough panel. Kinda proud of this. It's an elegant solution.

              #include using namespace gfx;

              ...

              // create a bitmap in the rgbw color format
              auto bmp = create_bitmap>({64,64});
              if(bmp.begin()) {
              file_stream fs("./test.jpg");
              draw::image(bmp,bmp.bounds(),&fs);
              fs.close();
              // render the bitmap out to leds here...
              free(bmp.begin());
              }

              Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

              B Offline
              B Offline
              bryanren
              wrote on last edited by
              #6

              Your lighting reminds me of Stand-up Maths video. I don't remember him doing more than patterns across a Xmas tree. The follow-up video as others optimized his coding was interesting as well. I wired my tree with 500 LED lights and calculated their 3D coordinates. - YouTube[^]

              H 1 Reply Last reply
              0
              • B bryanren

                Your lighting reminds me of Stand-up Maths video. I don't remember him doing more than patterns across a Xmas tree. The follow-up video as others optimized his coding was interesting as well. I wired my tree with 500 LED lights and calculated their 3D coordinates. - YouTube[^]

                H Offline
                H Offline
                honey the codewitch
                wrote on last edited by
                #7

                This is my latest Neopixel panel + htcw_gfx - YouTube[^]

                Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                1 Reply Last reply
                0
                • H honey the codewitch

                  A neopixel is an RGB LED with a 1 wire daisy chainable interface. You can string many together into panels or single strands, or whatever. Some of them however, have a strange color model. They have R, G, B, and W(hite) channels. That caused me some grief because representing colors on these is a bit tricky. Well, I finally, after looking at some python code someone dreamed up by hand fiddling came up with an RGBW "color model" in my graphics library. The upshot is I can now for example, pretty faithfully represent a JPG or a GIF (the latter would be fun!) given a large enough panel. Kinda proud of this. It's an elegant solution.

                  #include using namespace gfx;

                  ...

                  // create a bitmap in the rgbw color format
                  auto bmp = create_bitmap>({64,64});
                  if(bmp.begin()) {
                  file_stream fs("./test.jpg");
                  draw::image(bmp,bmp.bounds(),&fs);
                  fs.close();
                  // render the bitmap out to leds here...
                  free(bmp.begin());
                  }

                  Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                  G Offline
                  G Offline
                  Gary R Wheeler
                  wrote on last edited by
                  #8

                  The idea of an RGBW color model boggles my mind :wtf: . I work in the printing industry so we use CMYK and RGB. If we still had a color scientist (they were a thing for us at one time), I'd ask them about RGBW just to watch their brain asplode.

                  Software Zen: delete this;

                  H 1 Reply Last reply
                  0
                  • G Gary R Wheeler

                    The idea of an RGBW color model boggles my mind :wtf: . I work in the printing industry so we use CMYK and RGB. If we still had a color scientist (they were a thing for us at one time), I'd ask them about RGBW just to watch their brain asplode.

                    Software Zen: delete this;

                    H Offline
                    H Offline
                    honey the codewitch
                    wrote on last edited by
                    #9

                    I agree. It's maddening, and my library doesn't fully support it because conversions are not symmetric - IOW, translating to the RGBW model and back to something else again yields a different result than the initial value. It supports it well enough though, but unfortunately you can't do like rgbw32_colors::antique_white without causing a compile error due to how the color system works. You can however, either manually construct such a color, or convert it from another color model. It makes no sense. Basically what I did is used someone's hand tuned algorithm for approximating the colors based on an initial Hue/Saturation/Lightness value. It works well enough, but it's not very quick as it actually involves things like cosine computations.

                    Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                    G 1 Reply Last reply
                    0
                    • H honey the codewitch

                      I agree. It's maddening, and my library doesn't fully support it because conversions are not symmetric - IOW, translating to the RGBW model and back to something else again yields a different result than the initial value. It supports it well enough though, but unfortunately you can't do like rgbw32_colors::antique_white without causing a compile error due to how the color system works. You can however, either manually construct such a color, or convert it from another color model. It makes no sense. Basically what I did is used someone's hand tuned algorithm for approximating the colors based on an initial Hue/Saturation/Lightness value. It works well enough, but it's not very quick as it actually involves things like cosine computations.

                      Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                      G Offline
                      G Offline
                      Gary R Wheeler
                      wrote on last edited by
                      #10

                      Translating between color models is always problematic... sometimes they don't even agree on what white is :rolleyes: . A fair amount of the time you can do conversions with precomputed tables. Of course I don't know how well that would work for you in your constrained IoT environment.

                      Software Zen: delete this;

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups