AnaviTechnology / anavi-examples

Examples for getting started and testing ANAVI Internet of Things and add-on boards (HAT & pHAT) for Raspberry Pi
MIT License
47 stars 19 forks source link

Specify a specific LED in a string? #6

Closed SysInt17 closed 1 month ago

SysInt17 commented 1 year ago

Excellent code, thank you!

I have a project working that is based on: https://github.com/prueker/METARMap/blob/main/metar.py

I was able to re-create your code here and can get it to light up all of the LEDs on my project with the rainbow format. Looks great!

However, I'm not an expert in writing Python and this is a tad bit out of my league. But, can this be modified to only show a rainbow pattern on a Specific Pixel or Pixel(s)? My use case is that in my project listed above, from time to time, we have an airport that does NOT have any data, therefore the current code just turns off the LED. I'd like it to show a rainbow color instead. That way I know that the LED is not broken and that a rainbow pattern would indicate as such.

Much appreciated :)

leon-anavi commented 1 year ago

Hi @SysInt17,

Yes, just modify the value of variable num_pixels which contains the number of NeoPixels, by default it is 10: https://github.com/AnaviTechnology/anavi-examples/blob/master/anavi-miracle-uhat/neopixels/rainbow.py#L18

For your metar.py, there is a similar variable LED_COUNT which is set to 50. Probably instead of modify it (aka to avoid breaking the existing logic) you better change the algorithm for the particular condition to set the color of the first LED only (aka in pixels, for example pixels[0]).

Best regards, Leon