Shop OBEX P1 Docs P2 Docs Learn Events
Raspberry Pi Zero as GPU over SPI — Parallax Forums

Raspberry Pi Zero as GPU over SPI

RaymanRayman Posts: 14,646
edited 2019-11-26 02:02 in Propeller 2
It's working! Lots of work to do but check out what this code does (see code screenshot and monitor pic).
For $5, you can add a RasPi Zero to your system and get HDMI 24-bit color graphics!
900 x 722 - 67K
4032 x 3024 - 2M

Comments

  • RaymanRayman Posts: 14,646
    edited 2019-11-26 02:01
    This is 24-bit graphics at 1080p
    Seems lower left corner is the origin for coordinates...

    This is over HDMI.
    The mini-HDMI connector on the RasPi Zero is a bit of a pain, but just need the right adapter or cable.
  • RaymanRayman Posts: 14,646
    One sort of issue is that OpenVG wants screen coordinates as floating point, but Spin doesn't handle that so well (or does it?).
    So, I'm just sending integers and converting to float in the RasPi...
  • Nice one Rayman. What GUI is that? Is that Eclipse with your own customizations?
  • RaymanRayman Posts: 14,646
    edited 2019-11-26 02:04
    Gui is "SpinEdit". I've made it look as close as possible to the Prop Tool. But, it is mainly for Windows.
    The screenshot may have been a shameless plug for SpinEdit :(
  • Spinedit certainly has the prop tool look and feel to it. Remind me to show you it next time you stop by Roger
  • jmgjmg Posts: 15,173
    Rayman wrote: »
    ..For $5, you can add a RasPi Zero to your system and get HDMI 24-bit color graphics!

    Plus the HDMI cable adaptor ;)

    What link speeds did you achieve ?
    Even UARTS should be able to go over 12MBd, tho the FIFOs on those are modest. If the code is mostly in Pi, the link speed may not be so important ?

  • Rayman wrote: »
    One sort of issue is that OpenVG wants screen coordinates as floating point, but Spin doesn't handle that so well (or does it?).
    So, I'm just sending integers and converting to float in the RasPi...

    You could always use C or BASIC instead of Spin. Those both handle (32 bit) floats natively. If you're using FlexGUI you could write the float handling routines in C or BASIC and do the main code in Spin, if you prefer that.
  • RaymanRayman Posts: 14,646
    edited 2019-11-26 20:56
    That is one big advantage of you FastSpin… Nice to know that I can drop in C, if need be.
    But, my Spin2 driver for OpenVG is similar to my Spin driver for EVE2 and with that it was all integer based.
    So, I'm not convinced that I actually need to work in floating point to do what I want to do.
    I'm not fully decided on this yet...
  • RaymanRayman Posts: 14,646
    jmg wrote: »
    Plus the HDMI cable adaptor ;)

    What link speeds did you achieve ?

    I am able to get to 5 MHz on the SPI bus without trying very hard. I think it's good enough for now.

    BTW: You also need to add $5 or so for a uSD card.
    I may have made a mistake in getting a giant, 60 GB one.
    Problem is that I've found that you want to back up this uSD card, once you get it the way you want it.
    But, the backup and restore tools only work on the whole disk.
    So, it takes over an hour for me to backup the disk!
    I need to start over with a small disk and then back that up.
    I think the tool will let me burn a small image onto a big disk...

  • RaymanRayman Posts: 14,646
    edited 2019-11-26 21:10
    Shoot, I just came across the "compute module"...
    I really am living under a rock...
    That may be a lot better. But, with a painful looking connector...

    I'd like to have the P2 to show HDMI boot screen until the RasPi boots up and is ready to go.
    The compute module might make it easier to connect RasPi and P2 HDMI pins together...
  • jmgjmg Posts: 15,173
    Rayman wrote: »
    Shoot, I just came across the "compute module"...
    I really am living under a rock...
    That may be a lot better. But, with a painful looking connector...
    That compute module is more expensive, but the Pi Zero has limits they will sell per customer I think ?
    Do you intend this to be a production item ?

  • Wuerfel_21Wuerfel_21 Posts: 5,053
    edited 2019-11-26 22:26
    Rayman wrote: »

    I'd like to have the P2 to show HDMI boot screen until the RasPi boots up and is ready to go.
    The compute module might make it easier to connect RasPi and P2 HDMI pins together...

    Can't you just enable the boot splash screen on the Pi? It's enabled in raspi-config and you can change the image shown by replacing /usr/share/plymouth/themes/pix/splash.png with another PNG. At least that's what a quick look on the internet returned.
    You can also remove stuff you don't need from the OS to reduce the boot time to just a few seconds.
  • RaymanRayman Posts: 14,646
    edited 2019-11-27 13:04
    Now that I think about it more, maybe the zero is good enough for what I want to do.
    Also, it's less expensive and easier to use.
    You can buy as many as you want at Microcenter.com, although the price increases with qty...
    No, I don't do production.

    I do want to either keep HDMI off or show some special splash screen until it's ready. Have to look into that more.
    I've read about some things to increase boot speed
    Definitely need to look into that as it is way to slow now...
  • As well as 3d graphics use etc I think the RasPi is also compelling to add to P2 just for its networking support. You get a proper IP stack from Linux with wifi etc for such a low price. The pricier RasPi models include Ethernet too if you need that. Almost competes on price with some of the ESP stuff, yet still adds so much. However it is still slow to boot and can't easily sleep without burning current. That's something that really bugs me about the RasPi.
  • JonnyMacJonnyMac Posts: 9,104
    edited 2019-11-27 15:19
    If you go with the Pi0W you could also add wifi -- no?

    I like the IDE you're using. Is it available for download? Does it use FastSpin behind the scenes? I like the behavior of FlexGUI (was fun to write a program in C that used a bunch of my Spin objects), but it's not as aesthetically pleasing as Propeller Tool, which is my choice for the P1.
  • RaymanRayman Posts: 14,646
    edited 2019-11-27 16:12
    Yes, wifi and Bluetooth is also on my list to add (for home use).
    I think the W version is a security issue for use at work though... I just read how NASA got hacked into by somebody connecting a W to their network...
    Good thing there is a regular version without wifi…

    Jon, thanks! You can get the SpinEdit IDE here: https://forums.parallax.com/discussion/169259/spinedit-editor-for-spin-spin2-and-fastbasic/p1
    and yes, uses Fastspin for P2
  • RaymanRayman Posts: 14,646
    edited 2019-11-27 17:39
    Making some progress... Added lines and rectangles...
    Interestingly, there is no point function...
    4032 x 3024 - 1M
    843 x 734 - 82K
  • tritoniumtritonium Posts: 543
    edited 2019-11-27 20:07
    Hi
    I had a go with a similar idea some time ago, but using freebasic on the Pi and communicating using normal ttl 232 serial. Parsing the serial input and converting to shapes colours shades even text was possible (text was a bit clunky- the font had to be rendered in advance).
    Worked ok as a cheap hi-res display device. Done just for fun- no ultimate application.
    Dave

    Oh just noticed this is prop2 category- I was using prop1 :clown:
  • RaymanRayman Posts: 14,646
    My Bezier curve test almost looks like art :)
            gui.Stroke(25,5,20,1)
            gui.StrokeWidth(5)
            gui.Arc(600,800,200,400,20,160) 
            gui.ArcOutline(700,200,200,400,180,100) 
            gui.Qbezier(1200,500,200,400,20,160) 
            gui.QbezierOutline(1600,800,200,400,180,100) 
            gui.Stroke(205,205,50,1)
            gui.Cbezier(500,800,200,400,300, 100,20,160) 
            gui.CbezierOutline(1200,500,200,400,1000,60, 180,100) 
            gui.EndDisplayList
    
    4032 x 3024 - 2M
  • RaymanRayman Posts: 14,646
    Got Text working :)
    This one took a bit more coding...
            gui.Text(100,100,@TestString,1,80)
            gui.Text(100,500,@TestString2,2,100)
            gui.Text(100,800,@TestString3,3,60)
    
    4032 x 3024 - 2M
  • RaymanRayman Posts: 14,646
    edited 2019-11-27 23:44
    Image works!
    This is great. Had to increase the memory split. I gave GPU 256MB as it crashed with 64MB...

    I was wondering where the image file needs to be... Turns out (at least, I think so) it needs to be in same folder as the Raspi executable.

    This is showing a 1920x1080x24-bit color image (attached) with the other stuff on top:
    PUB Main|data,x,y
        'First, set the clock
        clkset(_clkmode, _clkfreq)
        waitcnt(clkfreq + cnt)
        
        'Start up the SPI GUI interface to Raspberry Pi Zero
        gui.start 
        
        
        repeat 1
            gui.StartDisplayList
            gui.BackgroundColor(20,55,180) 'r,g,b
            gui.FillColor(200,55,55,1)    
            { 
            gui.Circle(400,400,300)     
            gui.FillColor(20,155,50,1)
            gui.Circle(1920/2,1080/2,200)   
            gui.Stroke(255,5,250,1)
            gui.StrokeWidth(5)
            gui.Line(0,0,rnd(1920),rnd(1080))   
            gui.FillColor(200,255,55,1) 
            gui.Stroke(255,255,250,1)
            gui.Rect(100,600,300,400) 'Filled rectangle
            gui.RectOutline(1200,500,400,200) 
            gui.FillColor(20,155,255,1) 
            gui.Stroke(25,5,20,1)
            gui.Roundrect(600,100,300,400,30,50) 'Filled rectangle
            gui.RoundrectOutline(500,700,400,200,40,60) 
            gui.Stroke(205,205,50,1)
            gui.CircleOutline(800,200,300)
            gui.Ellipse(1500,800,200,100)
            gui.EllipseOutline(900,300,200,400)        
            gui.Stroke(205,205,150,1)
            }
            gui.Image(0,0,1920,1080,string("Geastrum.jpg"))
            
            gui.Stroke(25,5,20,1)
            gui.StrokeWidth(5)
            gui.Arc(600,800,200,400,20,160) 
            gui.ArcOutline(700,200,200,400,180,100) 
            gui.Qbezier(1200,500,200,400,20,160) 
            gui.QbezierOutline(1600,800,200,400,180,100) 
            gui.Stroke(205,205,50,1)
            gui.Cbezier(500,800,200,400,300, 100,20,160) 
            gui.CbezierOutline(1200,500,200,400,1000,60, 180,100) 
            gui.FillColor(200,255,255,1)  
            gui.Text(100,100,@TestString,1,80)
            gui.TextMid(1920/2,500,@TestString2,2,100)
            gui.TextEnd(1920,800,@TestString3,3,60)
            
            gui.EndDisplayList
    
    4032 x 3024 - 4M
    1920 x 1280 - 424K
  • RaymanRayman Posts: 14,646
    edited 2019-11-30 23:55
    It's done!
    Check out this test of 1080p graphics in 24-bit color:
  • Nice one Rayman.

    We're just about getting there natively on the P2. Once a suitable HyperRAM driver is done large frame buffers will be doable too, though 1080p 24bpp would probably need 2 HyperRAM modules, overclocking and sysclk/1 operation. Before then 1080p 16bpp would be somewhat easier to achieve and a better use of RAM bandwidth (24bpp wastes 25% of the 32bits transferred) but even that still needs something in the the vicinity of 150MB/s which is a lot unless you overclock to ~300MHz.
Sign In or Register to comment.