How do you send a singular specific effect? #505
Replies: 3 comments
-
Hi, Sean.
I'd hoped that others that were better at gentle message would pipe in
here, but it looks like I'm your helper today. I'm also a software engineer
since we were programming on rocks (still warm...) and can sound a bit
snobbish but I can be helpful. :-)
Everything you asked for is possible. It's a mere matter of programming.
Software engineering, as you've probably gathered, is a skill of its own.
Most anyone can learn it, but wide-open questions like this are kind of
awkward to answer concisely as we don't know your level of experience or
commitment. (sorry.) Im going to assume you're at least comfortable with
computers and building code and so on.
Rutger (the day to day leader of the project) assembled a high-level guide
to the code. You can find it in the source tree or on the web at
https://github.com/PlummersSoftwareLLC/NightDriverStrip/blob/main/CODEBASE_INTRO.md
It's a pretty good block level diagram, but your question comes across that
you're looking more for help on a line-by-line question and honestly,
that's going to be hard to get. Still, let me try to fill in some
background, address your questions with some reasonable sense of resolution
and then give you some free unsolicited advice.
This list seems backward ("Hey, man, I just work here. :-)") but
https://www.youtube.com/playlist?list=PLF2KJ6Gy3cZ7ynsp8s4tnqEFmY15CKhmH
has some guy talking about LED programming in general. I'll recommend this
series specifically because the code he's talking about happens to be
(mostly, I think) in this very project. Outside of this series, search YT
for [esp32 dave's garage] as that same guy has other introductions on how
programming tiny computers is different than programming Real Computers,
talking about the ESP32 (the microncontroller that happens to be used here)
and tools like the editor and debugger that are probably the most natural
to use on that code. It's been years if I've seen these, if at all (I'm
really not the target audience) so if you have questions about the details
include links and be specific. Some of the videos are a couple of years old
and may no longer match this project - if it ever did - but the basics of
how you push blinkies around should overall stick. (To be clear on
my dry delivery, that "some guy" is Dave, the founder of *this* project.)
"How do I call one meteor?" "You can't." Well, of course you CAN. As a
programmer, you're the blacksmith. You can forge a horseshoe into a space
shuttle. Just apply time and money. :-) He even talks about the comet
<https://www.youtube.com/watch?v=yM5dY7K2KHM> effect which becomes a
butterfly^Wmeteor about halfway through the video. In this project, that
code should be approximately
https://github.com/PlummersSoftwareLLC/NightDriverStrip/blob/main/include/effects/strip/meteoreffect.h
That directory is the effects for LED strips - as opposed to LED matrices.
This is a good segue to the dark side of the answer.
The thing is that in this project, the effects are reactive. The
effectmanager (see Rutger's doc) decides which effect gets called, how
long we wait between them, and so on. This project really is about
animating frames and it's all about doing them over and over. So 30 times a
second (or whatever) it's going to call into the Draw method of this effect
(assuming it's enabled, on screen, etc.) and th ecode in Draw
<https://github.com/PlummersSoftwareLLC/NightDriverStrip/blob/916c083e476fa0144be2cf68cadf7755a550ffb4/include/effects/strip/meteoreffect.h#L89>,
which hopefully looks recognizable with that in the video is responsible
for looping around and drawing one frame of "video".
Reading SNMP is beyond the scope of this project, of course. I'd have to
look it up myself.
Now you can go into effectmanager.cpp and friends and try to build an API
that you can call from some other project that changes its mind about what
gets drawn and how often and such. I can't help but suspect, however, that
NightDriverLED is just going to be the wrong tool for you. You're likely to
spend as much time breaking it apart and trying to insert behavioural
change that it's just going to keep fighting. So that's the tough love:
NightDriverLED is probably the wrong tool for the task.
The good news is that I'd suggest the same library that NDL actually uses.
That tool was even mentioned in the first few minutes of the video and,
predictably, is going to work pretty similarly to the parts of LED that's
used here.
It's likely that FastLED <http://fastled.io/> is going to be MUCH easier to
get your head around for the kind of use you describe. Find a FastLED
project on a microcontroller you like (ESP32 is really nice, but Arduino is
undeniably a hacker's leading choice.) and start with that. It's going to
be a much simpler model - you define an array of LEDs. you write colords
(CRGB pixels) into the pixels you want to change, you call leds.show() and
the colors appear. Now instead of trying to wedge a nework API into
NightDriverLED, you can just build your own thing grom the ground up. Your
project of showing the amount of traffic flowing, the direction, the
intensity in brightness/colors all sounds very cool, but IMO it's just
going to be a batch match to try to fit into NDL.
The code itself tends to be a much more pedestrian style of C instead of
C++ that actually looks almost like BASIC the way most of the eamples are
written. That simplicity has a place in homemade projects like you're
describing. If you look at something like
https://github.com/FastLED/FastLED/blob/master/examples/TwinkleFox/TwinkleFox.ino,
you can see it's still doing the same kind of pixel filling that you saw in
meteoreffect and it should be recognizable from the demo, though details
will be different.. Draw calls happen when you call them, ot repeating
every 60Hz. So probably you read the SNMP thingie and you draw pixels
instead of trying to shim it into the existing code.
You can probably find examples of how to bounce balls or shooting stars in
https://github.com/PlummersSoftwareLLC/NightDriverStrip/tree/main/include/effects/strip
or you can find them closer to fitting at
https://github.com/FastLED/FastLED/tree/master/examples or literally
hundreds of other open source projects around the web.
I (and hopefully others) will try to answer specific questions, but I
really suspect you'll be happier in Fastled.io. Heck, I'll even offer tips
like recommending the awesome Wokwi simulator for developing and testing
your code independently of your SNMP reader thing and offer that I might be
able to help once or twice with FastLED questions IF you can get a fastled
problem you're running into reproduced on the simulator.
https://www.hackster.io/ldir-arcostasi-urish-sutaburosu-stevesigma-stepko-on-wokwi-discord/100-fastled-projects-wokwi-embedded-systems-simulator-2022-39fcc0
So there you go. An incredibly details answer ... telling you to use a
different project. Sorry if that seems weird, but I hope it gets you
pointed into a happier direction while you're still early enough in the
projeect that you can get to a healthy start and not get tangled up in our
internals. But if you really want to stick with us and are prepared to do a
LOT of your own groundwork on the integratoin, I'll (we'll) help as we can.
Good luck!
RJL
…On Mon, Nov 13, 2023 at 9:22 AM SeanMcKeen ***@***.***> wrote:
What I'm trying to figure out is how do I send 1 of an effect, instead of
a continuous stream of them?
For example, I notice there's a "meteoreffect" and that umbrella,
atomlight, and some other things use it. But how do I call a single meteor
down a LED strip? I want to personalize how frequently they're sent, and
change it periodically. Right now I have no idea how I would call the
meteor from another part of the script, I'm fairly new to all of this so I
don't understand yet how everything on NightDriver interacts with each
other.
Essentially, my end goal is a LED strip (or multiple actually) that sends
pulses depending on the amount of data that a computer is pulling and
sending, using SNMP. That way the LED strip would send more or less pulses
for more or less data being sent/recieved, going either direction down the
strip. Is this possible?
—
Reply to this email directly, view it on GitHub
<#505>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACCSD3ZFJ7E5SRNSVUEW3CDYEI3MXAVCNFSM6AAAAAA7JKLMSGVHI2DSMVQWIX3LMV43ERDJONRXK43TNFXW4OZVHA2DOMBUGI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
SeanMcKeen
-
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Licensing gets a little bit fuzzy, but the meteor effect that I pointed you
to is largely FastLED with a thick paste of C++ and NightDriverLED wrapped
around it. If you look inside Draw() and read it in a funny accent
(probably after watching the cited video) you can almost copy-paste it into
a raw FastLED project. Almost. It's pretty mechanical
For all the LEDs
see if anything needs faded to black
for all the meteors
compute the speed
figure out if we're going backward or forward
... and so on.
There's no real rocket surgery in there. Sure, it's doing C++-y things
like pGFX->GetLEDCount(); instead of a constant NLEDS, but it's pretty
readable.
Of course, I'd share your suspicion that there are greener fields to
harvest elsewhere on GitHub. FastLED is a quite popular project. You're
quite likely to find a quite usable snippet inside another project.
IIRC, WLED also uses FastLED and should be a wealth of inspiration. I thin
kthey're the project with the nifty online effect viewer so you can see
snippets of what each effect looks like before you "port" it.
Sorry for the tough love, but good luck!
… Message ID:
<PlummersSoftwareLLC/NightDriverStrip/repo-discussions/505/comments/7599612
@github.com>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What I'm trying to figure out is how do I send 1 of an effect, instead of a continuous stream of them?
For example, I notice there's a "meteoreffect" and that umbrella, atomlight, and some other things use it. But how do I call a single meteor down a LED strip? I want to personalize how frequently they're sent, and change it periodically. Right now I have no idea how I would call the meteor from another part of the script, I'm fairly new to all of this so I don't understand yet how everything on NightDriver interacts with each other.
Essentially, my end goal is a LED strip (or multiple actually) that sends pulses depending on the amount of data that a computer is pulling and sending, using SNMP. That way the LED strip would send more or less pulses for more or less data being sent/recieved, going either direction down the strip. Is this possible?
Beta Was this translation helpful? Give feedback.
All reactions