-
Notifications
You must be signed in to change notification settings - Fork 32
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
Frame buffer Rotation for portrait LCD module #20
Comments
Ok, so following a deep dive into the Pico DMA documentation, I can see that’s what is reading from the frame buffer as a continuous stream so reading every 480th bit for a scan line might not be possible with DMA. Could I use the second DMA to copy the frame buffer to a new FB organised as 480x640 and tweek the existing dma to output 480 pixel lines from the new FB? |
Am I right in thinking that the code that writes the video to the frame buffer is part of the Mac ROM, not your umac code? |
Nick, sorry for the usual late replies! It is not a reflection of my interest in your cool project. :-) On the HW side, wiring all the data inputs to the single output will probably work "enough" to see something in prototyping but you may need to move to adding an external buffer there (e.g. maybe even driving 4 buffer inputs from the 2040 pin and then driving 4 LCD pins from each of those). 16 pins are a lot to drive from one (and it'll be fairly fast, 25MHz). But it may just work. The 68K code that writes into the framebuffer -- you're right, it's Quickdraw in the ROM, plus application/OS stuff loaded from disc. I would say it's not fun to hack that end of it. I think a good approach would be:
It's annoying, but I can't think of a way to make DMA extract say all bit 7s into a row, then all bit 6s, ... etc. One option would be to get the CPU to do this, on the fly. In Re DE: I will have to add this at some point! I just bought a replacement Ambernic RG35XX LCD panel (3.5" VGA) to try to join in the fun; parts arrive soon. I want to try driving that from the Pico (not necessarily with pico-mac but that would be good too) and that will need DE. Maybe DE mode will help your LCD spring into life? Other Q for you is does the LCD have any pins that configure H/V scan? I've seen some that have top/bottom and left/right inversion via pins that you strap to Vcc/Gnd, maybe yours really can do landscape somehow? (Is the data sheet online OOI?) To try with this code's video output, munge the Finally once you get step 1 working there is IMHO another option versus rotating the framebuffer.... that is, a portrait Mac :) See #14 -- I had some luck this week with changing video resolution and I just checked, it works at 480x640 too. A wacky portrait Mac would be really cool :) See: |
Thanks for detailed reply. I will digest all that and look into those option but wanted to let you know that I had also looked at changing the screen pixel dimensions but with a view to using my 2” 480x640 display without rotating the image. It occurred to me that 480 was not much less than the native 512 Mac width so maybe I could put the landscape image across the portrait panel. So, like you, I looked at modifying the Mac ROM and managed to change the screen width to 480 and I have that running in umac. It looks OK. I haven’t had a chance to try this on the LCD yet but this approach presents another problem. In portrait orientation the lcd panel is too tall to fit in the body of the Mac if the Mac is scaled based on the screen image. |
Hi Matt, Can you clarify what VIDEO_HSW and VIDEO_VSW are? Are they the width of the sync pulses? I'm not sure what the strip down the right hand side is. Sometimes it's there and sometimes not. Maybe I damaged the LCD at some point. |
After playing around with porch and clock settings for a few hours, I wasn’t making any progress with the syncing so decided to try setting the frame buffer width back to 512 in hw.h just in case the changes I made to the max rom and umac code had not resulted in a 480x342 frame buffer. |
(replying to the great success reported in #8 (comment) by @all2coolnick )
Great to see that screen running! What was the bug, in the end? I didn't completely understand whether it was umac or pico-umac displaying 640 or 512, earlier in the thread, but looks like you solved it. (My first thought was a It'll look really great in that 3DP case, well done! In other LCD news, I finally managed to spend some time on the Anbernic RG35XX replacement I bought from AliExpres (640x480x24 3.5" thing), and finally got it working. It turns out that it, too, needs a bunch of magic SPI commands before taking any RGB. ;( Funny seeing such pixel density with the Mac UI -- and your 480x342 must be even more dense. Biro for scale: I pushed some hacky stuff into https://github.com/evansm7/pico-mac/tree/wip-lcd (in turn based off
There's also a tweak to reduce the drive strength of the video out pin to 4mA: in the hacky prototype, I tried out driving [7:6] of R,G,B from the one pin without any more buffering. With the 12mA drive (from the picomac drive-VGA stuff) it was ringing horribly and pixels were twinkling/colours shadowed. |
Thanks Matt. The initial problem was that to test the SPI initialisation I was using commands that turned all pixels white then black at the end of the init commands the manufacturer sent me. What I didn’t realise was that these commands took the LCD back out of RGB input mode. When I removed these I got the scrambled image and this was resolved by setting the FB width back to 512px. As far as I can tell, the memory block that the Mac ROM is writing the frame buffer into is still using 512px rows even though I managed to modify the ROM to create a 480px wide screen image. What disassembler do you use? Regarding the video out line. I initially just used the blue msb, then the msb of each colour and once I had it working I gradually increased the number of lines linked to the video data line. I found I was able to drive all 16 rgb inputs linked together with no visible problems to the screen image and without the rp2040 getting hot. From what I could gather from the data sheet, the input current for each rgb input to the lcd controller is only 1uA. |
Hola,
it sounds like some of the code’s patched but not all of it; there are various “words per line” constants too. The code in
I’m just going off of https://www.bigmessowires.com/rom-adapter/plus-rom-listing.asm (one of the reasons I’m sticking to the Mac Plus ROM).
Yeah AE is terrible … It was hard to find the controller. I got this one: https://www.aliexpress.com/item/1005007347112636.html I got 2 for about £20 inc shipping.
Speaker is the easy bit :) need to add emulation to umac, not terrible but something to do.
:) current isn’t too much of a worry, it’s more signal integrity with many loads (at 25MHz). It’d be more reliable considering variation in screens to use a (CMOS) buffer IMHO but if it works it works! |
I've made some progress with the little TFT module I told you about. I've got the 3-wire, 9-bit SPI configuration command communication working to put it in RGB mode (I can execute basic commands like all pixels on and all pixels off) so now I'm working on the RGB data. I'm not getting anything on the LCD using the standard picomac video out signals (minus the resistors) but I assume this is because the LCD module is 480x640 portrait (with no rotation command). I'm guessing it can't make sense of the data and sync signals.
I've been trying to understand your video code to find the best way to write the frame buffer out as portrait but I'm stuck. I stepped through pio_video.pio but as I understand it, this is essentially just reading the data from the output shift registers so does not control the order the data is read from the frame buffer. I've looked at video.c but what I can't seem to locate is the code loop that continually reads the frame buffer and sends the data to the pio registers. Could you give me a pointer (no pun intended)?
I thought it might be simpler to modify this code to read the framebuffer in a different order (bottom to top, left to right) but as you wrote all this amazing code, is this how you would do it?
The other option I can think of is trying to modify umac to actually write the frame buffer in portrait but then I would still need to modify the read code so it was sending 640 lines of 480 pixels rather than vice-versa.
I'm linking all the 565RGB data inputs to the LCD panel and driving these directly from the picomac video data pin. I can't think of any reason why that would not work since all I need to send is either all 1s or all 0s. Would you foresee any problems with this approach? The TFT module has two RGB modes; DE and HV. That latter is what I'm trying to use as this does not require the Data Enable which I know you have not implemented yet.
Thanks as always,
N
The text was updated successfully, but these errors were encountered: