applet.video.ws2812_output: Remove deprecated stuff#1072
applet.video.ws2812_output: Remove deprecated stuff#1072dratini0 wants to merge 7 commits intoGlasgowEmbedded:mainfrom
Conversation
1c99b06 to
2d354b0
Compare
|
Hi! I'm very excited to have another (potential) contributor on board, as the project desperately needs more. I am especially happy to see you porting applets to the V2 API.
It is, yeah.
Same here; anything with
I think it should be a setup time argument, yeah. I'm not following; which attribute? I should also explain how we're using privacy in this codebase. Java-style privacy (per class) is what people usually do in Python, but it's impractical: it sometimes requires you to make implementation details public solely to satisfy the compiler. Rust-style privacy (per module) is what we're using here. That is, if your module has
No, I don't think so. I should mention that this applet is quite old and wasn't written by me, so I'm in the same position as you are when looking at the code. From first principles:
and everything else is stuff that shouldn't be there at all as the Do you have the ability to check if the code works well with a large panel? If not, I wonder if @marcan would be able to re-test the updated applet. |
On main, buffer_size ends up getting passed to
Yup, that seems to work well
Yes, I have two 20x20 light curtains with me. I can't chain them (I think it's the kind where all the DINs are connected in parallel) but I can hook them up in parallel (and test that function too). I can get to some performance testing in a few days. |
|
|
||
| async def write(self, data): | ||
| await self._pipe.send(data) | ||
| await self._pipe.flush() |
There was a problem hiding this comment.
This flush comes from line 209, however that has wait=False on it. I need to investigate if this flush is necessary, and if so, I need to consider adding _wait=False.
There was a problem hiding this comment.
The reason _wait exists is so that certain applets that I didn't want to re-test could be guaranteed to use the old behavior. I would expect its use to not be necessary with the V2 API (.send() alone should be enough).
glasgow/software/glasgow/hardware/assembly.py
Lines 366 to 367 in 05b4df4
I think this applet was one of those certain applets.
Note that there is a major semantic distinction between having .flush() and not having .flush() at all. This comes back to the other set of questions about latency. If you're just piping precomputed data, you never want to flush and you want your host buffer to be as big as reasonable. The on-device buffer should be sized only according to the required throughput (multiplying throughput by the p99.9 latency, or something similar).
Oh, so there are two different buffers in play: the one in the FPGA and the one on the host. They are not equivalent at all. The on-FPGA buffer is used to compensate for packet-to-packet latency spikes and must be sized carefully because it can never be more than 14K, and making it significantly bigger than 512 causes various issues. The host buffer can be as large as you want; its use is more about compensating for the input latency spikes. So I think your change needs to be considered carefully: it is possible that one or the other is more appropriate depending on the task; I haven't thought a lot about the task. Is the applet handling real-time data or is it more queueing the video upfront? How bad are potential underflows? These are all important questions to ask. |
|
The applet seems to be optimized for streaming out data (almost) as fast as the protocol allows. (800 kbps + 300 us/frame) Before e8b21b7, it was broken and it was only able to output full buffers (i. e. The consequence of an underflow between frames is inconsistent frame timing, but if it happens within a frame, the frame gets split into two parts, and the second part starts getting applied over the first half of the string. Worst case scenario, flickering lights. I think the original implementation used the USB buffer, and as does my revision. It certainly gets the same bitstream ID even with two very different values of |
|
(I probably have some LEDs around I could wire up in a pinch, but probably not any more useful than @dratini0's light curtains and I haven't used this code in a long while, so unsubscribing from this one) |
There are two general approaches that can be used here:
|
e8b21b7 to
86466c9
Compare
|
Please also add documentation: every V2 applet must have, at a minimum, the CLI documentation. Just the CLI documentation (see other applets for how to wire it up) is enough for this applet, especially considering that the |
Light curtains on Aliexpress seem to follow this standard.
86466c9 to
506082d
Compare
|
Well, I want to get rid of
Please don't proliferate
Sure |
I will test tonight what happens if this applet relinquishes all control of the out pipe's buffer (i. e. no flush, no specifying buffer size). That would have the beneficial side-effect of making
Sorry, I keep forgetting frozen
Will do. |
|
Ok, not great. Things I have tried so far:
|
|
Specific details about this applet aside, I think that we should consider changing the scheduling logic in For an example of where this behavior change would be useful, consider an applet that forwards commands to the Glasgow, where the command stream may be very fast or very slow. Also, the applet doesn't know the throughput in advance. If the command stream were slow, there'd be significantly more latency without explicitly flushing, and if the command stream were fast, explicitly flushing after every command would reduce the throughput. As an alternative, the applet could implement logic for flushing, but I think that eagerly submitting transfers when there are no pending transfers would be a better solution. |
Yes, I agree. I will find some time to think about it in the next few days. |
|
Ok, I think I am just about ready to give up on writing tests. Apparently the tests run at 1MHz, and I'm not sure I can override that. This poses problems with a serial protocol running at a fixed 800 kHz. One more thing I'm wondering about is all of my classes being prefixed by the taxon, e. g. Finally, what do you want to do about merging this? Wait for you to resolve the scheduling situation, I remove flush, retest, and then it can be considered for merge again? |
Apologies! The test fixture is quite immature and writing tests isn't anywhere nearly as pleasant as I'd like it to be. There is IIRC currently no override and we could just add one. In the past, I would simply lower the simulation step, which makes all tests slower, which is why I stopped at 1 MHz (or lowered it at all).
There is no fully consistent rule for this.
I'd say: use your judgement, try to think of the downstream uses and whether they'd be confusing. We have a mix of "this class is supposed to be imported on its own" and "this class is namespaced by its module name" which is unfortunate but I don't know what to do with in the short term.
That sounds reasonable. I'm currently dealing with an extremely disruptive personal event, so my availability will be inconsistent for at least a month. It may end up with me spending either more time on Glasgow or less time on Glasgow depending entirely on my health. I was planning for it to be "more" but it is not be entirely up to me. |
Hmm, if I'm touching anything outside this applet, I think I will want to open another PR for that.
I think I will just stop trying to overthink it and leave it as-is.
I hope you get better soon! |
Yes, this is preferred. |
Hi!
This is me trying to get my feet wet with this project.
Dubious stuff: