-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pixel line skew between top and bottom panel halves when horizontal scrolling - P3 #338
Comments
This is due to the panels being two seperate halves top and bottom. As the eye follows the text across the screen there is a difference where the scans are. Top line will be in the same position as the top of the bottom half. You can reduce the effect by getting the scan rate as high as possible (increase the clock frequency and reduce the colour depth) but it will still be there. The other option for scrolling is to do bit manipulation on the DMA buffers themselves, I have modified the library to make the buffers public so I can then rotate the colour bits without moving the row select bits to facilitate scrolling without having to redraw the whole display. |
Hi @xemjeff, I've noticed this as well. What version of the library are you using? 2.0.7 or what's in the repository? What ESP32 hardware variant? Oh, and are you using double buffering? |
|
Yes they are shifted at the same time but row 15 isn't, it is one full scan behind |
Version (from library.json) is 2.0.6. I am using flipBuffer(), so I guess that GFX version of double buffering. Is there perhaps double buffering also in the library? |
Can you post a test sketch? |
@DarrylStrong OK, I don't understand what you mean - forgive my ignorance. |
@mrfaptastic ok - I'll put something simple together to show the effect. |
It's not human, there seems to be some weird delay between what is pumped out to the RGB1 vs RGB2 pins. I don't know if there's some hidden byte ordering issue or DMA update internal silicon delay. Or perhaps the boards are slow to latch the bottom half vs. top. |
it is because your eye tracks across the leds as the text moves. That is what causes scrolling text on 7 row signs to tilt. |
I have been working in the LED display industry for thirty years. Static driven led matrices smear when scrolled, row scanned tilt and column scanned get shorter. This effect is something we had to work with on one of our 16 row boards which was scanned 8:1. We had to artificially shift one set of 8 rows sideways to remove the step. |
This is just a low scan rate. I have seen this many times. Addition |
Here's a test sketch. The skew only happens at the mid panel. I can run 6,8 ms and there is no skew if I display on the top half or the bottom half - as long as it does not cross the middle row. @board707 the skew still happens at 20-40 ms. @mrfaptastic this is using double buffering from the library (set to "true") Thanks to everyone for suggestions. Hopefully the test sketch will help. |
Right, so basically the DMA buffer is being outputted slower to the panels than the CPU is updating the DMA buffer and causing essentially tearing. Hmmmm. |
So this is why I don't see it as badly then as I move the dma buffers for scrolling rather than redrawing the whole screen. |
Why is the tearing always at the mid-line? The data are shift loaded in parallel, the OE and LATCH are used for both. If the CPU is updating the buffer at varying rates based on scroll rate, wouldn't the tear change row location? |
I think I understand what's going on: If this correct, then it's not tearing. I'm not sure if increasing the update rate would help. |
That's exactly what I was trying to explain. Hence why we had to offset the bottom half of our display by one pixel. |
@DarrylStrong Yes - I understand now - it just took me a while :-) I tried offsetting the bottom panel by one pixel. That works at the fast speeds. I'm curious why manipulating the DMA buffer would make any difference. This would still result in the slant effect, no? Added: |
I didn't explain myself very well 😊 It is just faster manipulating the buffers, I am using the library for 384x64 displays so the redraw takes a while 😉 |
I didn't explain myself very well 😊 It is just faster manipulating the buffers, I am using the library for 384x64 displays so the redraw takes a while 😉 It was also helped when we did this pixel shift that the scroll speed was synchronised with the scan rate. |
But I am wondering why the double buffering do not fix this artefacts. As far as understand it, with double buffering whole picture should updated in one time. |
It is written at the same time but your eyes follow the image across so see the columns in different positions as the text scrolls. Of course there are only two rows on at a time... Refer to the fantastic diagram above 😊 |
expanding on @DarrylStrong's explanation: Your eye is following the line as is moves. The pixels are displayed one row at a time. (in my case one pixel per row) |
That's your problem. You need to use 2.0.7 If you are using double buffering, and you give a few milliseconds from when you stop drawing to when you call 'flipDMABuffer', then you shouldn't have this issue... but only if you're using 2.0.7 We had this problem previously and I found a way to fix it in 2.0.7 Don't use the latest git version either as it's probably broken again. |
If it was only an optical effect, we would not see a shift in the photo, as in the first message. |
@mrfaptastic I tried 2.0.7, and introduced 2ms and 4ms delay before flipping the buffer. (dbuff = true). Same shift effect. @board707 : Added: I just tested with 2 chained boards instead of 3 (64x32). Same problem. |
@board707 has a good point. Why would it show up skewed in the slo-mo video? I changed the code to draw a 2 pixel vertical line across the mid row. |
I ran another test: Two pixel, as above, but from left to right rather than right to left. My conclusions.
I am curious as to why @board707 is not seeing this effect. |
Please try again with the latest git version. The Skew with double buffering still exists as this is a optical illusion. When turning off double buffering you don't see the skew as the whole panel is skewed because the drawing by the CPU is occuring as you see it, from top to bottom. |
I just built from master branch. In the source for the
|
One thing we aren't testing in the example is the vertical line going from left to right and then right to left. If the pixel offset is the same both directions then perhaps it is a data sync issue. If the pixel offset changes the other way around then proves that it's an optical illusion to do with the row scanning. If that's the case then there's no fix other than to offset all fast coords in the bottom half of a panel. |
@mrfaptastic : I've tested in both directions. The shift follows the direction. But I'm not convinced this is an optical illusion. First, I'd like to understand more about how to time the buffer flip. In my app, I'm flipping buffers every frame, each time I redraw the display, shifting the column offset by 1. Should that be synced with the DMA transfer? Second, we could change the order in which the A,B,C,D pattern is output with matching row data. Let me know which direction (or both) I could follow. I'm happy to do the work with your guidance in a forked repo and issue a PR when it's working. /Jeff |
No, it's the responsibility of the library.
Is the shift still the same on whole height of the line? Or, are the both lines ( above and below middle-level) straight vertical? |
@board707 This is hard to tell - but I see the lines are always vertical. I captured video with iPhone at 240fps (slo-mo), and the extracted frames using ffmpeg. Here is a sequence. @mrfaptastic : Maybe we could capture this with a logic analyzer and provide a buffer switch GPIO output - high for buffer1, low for buffer2. Then look at the outputs of A,B,C,D and ensure that buffers only switch at transition from 1111 to 0000. If that were verified, then we would know the buffer switch is not the cause. Let me know what you think. |
@xemjeff That would be usefull to double confirm it is an issue. From a code perspective, one option is to start from scratch using this example that Espressif's Sprite_TM created (which was actually the genesis code for the creation of this library). Hack it right back to the bare bones just to draw a line and see if the same issue happens as well: https://www.esp32.com/viewtopic.php?f=17&t=3188 If I find time I will try look at this as an intellectual curiosity more than anything. A time sink this will be. Curious to see if we have this same issue on the ESP S2 and S3 devices now. |
Actually, your buffer switch GPIO suggestion I'll have to incorporate into any new test case based on my comment above. So don't hack the library and bother doing this yourself. |
Spent hours on this and created a basic example that only barely works. Seems I don't get the skew issue for double buffering now.... hmmm... Example uses default ESP32 pin connections. |
@mrfaptastic Thanks for the zip file and for putting the time into this. I know it's nagging problem and a time sink. Also, I'ver ordered a USB/logic analyzer with 16 channels and 400Mhz sampling rate to get a look at the signals. This would allow me to compare this working model with the output from the shifted version. Still, I will need to add a GPIO for buffer swap indicator. |
@xemjeff - Feel free to run it, but all it does is confirm that your persistence has paid off. There is an issue somewhere, and I'm sure it's a simplex fix, problem is finding the root cause. Over the coming days I will look to see if it's an issue that has been introduced over time with this library inadvertantly. e.g. Testing the line scrolling example with version 1.1.0 of this library - problem is that version of the library doesn't compile anymore as Espressif have changed the idf so much ! Will work on it over coming days.
Wow. You mean business! |
@mrfaptastic The logic analyzers are fairly inexpensive. My $12 version (24Mhz) is not up to the task, and I find it very handy for protocol debugging. I really appreciate your persistence and patience with this issue. |
So I used the very earliest version of this library I ever made, and it has this same issue. It shares a lot of code with that example in the zip file I provided, which doesn't have this offset issue. The bug hunt continues. |
OK. Here's PlatformIO Project (Arduino based) which I would like you to test when you get your logic analyzer. As far as I can see I have fixed the skew. That work OK? |
got it - thanks. I'll test with my board, and also check it out with the logic analyzer when that arrives. |
No problems. In any case I've decided to work on a new fork of this library that rewrites the core bitplane buffer alloc, DMA linked list creation and ordering (to try implement your suggestion as well about the row output ordering) etc. This should be transparent to most people, but fix this issue hopefully. Will see what this brings, hopefully not new issues 🤣 |
@mrfaptastic Hate to bug you with this, but I can seem to get your test example I verified the CLK pin and speed with serial debug output: |
Have implemented various hacks. The rewrite didn't solve the issue, but I learnt what one of the causes of the problem was - it was some weird bug. Have added randomisation. It helps a bit, but it'll never be perfect for fast moving stuff. |
New compile time option: ROW_SCAN_SHUFFLE Don't update rows in sequential order.
Try compiling with a global define called 'ROW_SCAN_SHUFFLE' defined and try without this being defined. |
I downloaded the master branch with your recent changes. This is what I've observed: a) The single line scroll is improved with ROW_SCAN_SHUFFLE not defined, in double buffer mode. The skew is still there, but less so. b) In my main application with ROW_SCAN_SHUFFLE undefined, I am seeing a lot of flickering. This might be due to changes from 2.0.6 to 3.0 so I need to test that next. In my app, I am scrolling two lines at different speeds (top/bottom halves separately). That worked perfectly in 2.0.6. c) In my main application with ROW_SCAN_SHUFFLE defined, I am seeing ghosting on the rows. Faint images of the text showing above or below the text line display. I can capture videos and share if that will help. (flicker, ghosting, etc) |
Ok so a) is it then. The shuffle idea doesn't look like it works. Perhaps the panels don't like being driven in random orders electrically and some residual capitance issue comes out of the woodwork causing ghosting. You can fiddle with the order in the code. I don't see the other issues however, so I'll leave it to the signal diagnosis to see if there are any other issues beyond the optical illusion caused by row scanning. |
I got the Platform.io version working ESP32_HUB75_ArduinoDoubleBufferTearingTest.zip that you posted 3 days ago. That version has no skew with a 10ms delay between columns shifts, so I'll build upon that. My application is quite simple - 3 horizontal panels. Thanks for your patience and perseverance through this issue. |
I'm not sure how you get no skew, I still see it (but no where near as bad). I think it comes down to how quickly the app refreshes and the timing - so it's not consistent. Glad it worked however. |
@xemjeff - Uploaded the .zip code as a seperate repo @ https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-DMA-Lite Did some minor optimisations etc. |
@mrfaptastic Thanks for that. I posted a minor issue there regarding initialization of the gpio_matrix for the clock line. Verified using my newly arrive logic analyzer. |
When horizontal scrolling, the P3 (64x32) display shows an offset between panel top and bottom at the halfway mark.
I have 3 panels chained. The offset increases the faster the scroll. In the image below, I am writing out the lower case letter 'L' with a delay of 4ms between scroll shifts (one pixel to the left each cycle, blank the screen, redraw the text).
Seems like it's related to #133, but it does not happen with a static display - and it gets worse the faster the scroll.
Any thoughts on what to adjust or where to look?
The P3 panel has this chip:
CHIPONE ICN2037BP
Here's a link to the docs for the chip:
https://olympianled.com/wp-content/uploads/2021/05/ICN2037_datasheet_EN_2017_V2.0.pdf
I tried changing the driver to ICN2038S, but that does not help - same effect.
The text was updated successfully, but these errors were encountered: