Increased Frame Rate on a cheap Raspberry Pi LCD - Make Your SPI Display Playable

Поделиться
HTML-код
  • Опубликовано: 23 апр 2021
  • There are a number of cheap LCD screens for your Raspberry Pi. If you're just using them for a control panel or mobile desktop the default settings can work fine. But if you want to play games or any sort of video or animations the 5 frames per second just won't cut it!
    In this video I'll show you how to set up an LCD screen for a mobile games console project. We'll install the default drivers and then tweak the settings to get to a useable frame rate. I'll also show some of the issues you'll come across as you push the SPI channel too far.
    This is the first of 2 videos on tuning your LCD display. The second shows you how to replace the default drivers with much better ones to get even better frame rates.
    Please check out my main website pages for more details on this project.
    bytesnbits.co.uk/raspberry-pi...
    The screen I'm using in this project is...
    amzn.to/32MkoLM - Waveshare
    amzn.to/3nlZcFV - Generic
    Timestamps
    03:26 - Installing Retropie
    06:22 - Which LCD screen and software to use
    10:25 - Installing the LCD software
    15:17 - Default settings frame rate test (~5 fps)
    16:59 - What controls the frame rate
    19:36 - Pushing the SPI bus to its rated max
    25:09 - Faster fps but poor colour accuracy
    26:06 - Finding the best frame rate with correct colours

Комментарии • 59

  • @waisemthecrab
    @waisemthecrab Месяц назад

    amazing been 7 hours trying to get it to work reflashing the sd card hoping it wont fail now it works all thanks to you!!

    • @BytesNBits
      @BytesNBits  Месяц назад

      Glad it helped. That's a long time!!

  • @BrothasOnline
    @BrothasOnline 4 месяца назад +1

    this definitely helped me. I don't have the waveshare version. But was able to find the dtoverlay that was active (not commented out) and added the additional information. 2400000 works great for me.

    • @BytesNBits
      @BytesNBits  4 месяца назад +1

      Good to hear you got it working.

  • @alguiendesconocido7294
    @alguiendesconocido7294 2 года назад +3

    This work very well on my raspberry pi 4B (4gb) with Raspbian (Raspberry pi Os). Now the display 3.5 is much faster. Thanks!!!

    • @alguiendesconocido7294
      @alguiendesconocido7294 2 года назад

      but in speed 24000000 the colours and the resolution looks very bad, i set the speed in 42000000 and the colour of the screen is violet but is usable any solution for raspbian? (raspberry os)

    • @BytesNBits
      @BytesNBits  2 года назад +2

      Hi. I made a couple of other videos which get the speeds up to around 50-60 fps using one of these spi screens. Have a look at
      ruclips.net/video/uz4sa24C4gk/видео.html
      It does depend on what screen you have. My tutorials use screens with an ILI9341 driver chip, but it will work with others.

    • @alguiendesconocido7294
      @alguiendesconocido7294 2 года назад

      @@BytesNBits Oh ok Thanks! And work on Raspberry Pi Os or only in Retropie?

    • @BytesNBits
      @BytesNBits  2 года назад

      Hi. This should work on any raspberry pi. I've only tried it on a zero and 3B. It copies the HDMI output to the LCD panel so should work with anything that uses the normal display output. Let me know how you get on.

    • @alguiendesconocido7294
      @alguiendesconocido7294 2 года назад

      @@BytesNBits Ok Thanks, i still have not tried, possibly tomorrow i will, i will try on a Raspberry Pi 4b

  • @sochy7153
    @sochy7153 2 года назад

    Perfect thanks!

  • @jonas_epic_gamer
    @jonas_epic_gamer 10 месяцев назад +1

    hey, sorry this comment is really late, but the tutorial was great, and it works properly! I was just wondering if there is a way to fix the weird color renderer, it only happens on the homescreen, and when playing ps1 games. If not, thats okay. Thanks!

    • @BytesNBits
      @BytesNBits  10 месяцев назад +1

      You can try playing with the spi speed. That can sometimes help. I did make another video with even better performance over spi. Have a look at that one as well.

  • @stoptho4314
    @stoptho4314 6 месяцев назад

    Amazing video you need more credit man. Truly professional and informative. Incredible!

    • @BytesNBits
      @BytesNBits  6 месяцев назад

      thanks. Glad you liked it!

    • @Meeeeeh
      @Meeeeeh 25 дней назад

      This is actually not professional. First, options are not explained. hdmi_drive selects the mode of the digital transceiver, aka DVI mode (1) or HDMI mode (2). They mostly diver by providing audio over the connector and what resolution calibration modes are available. The SPI display has no audio, so going for driving it in HDMI mode may not be the that useful. hdmi_group picks the calibration mode, CEA (1) or DMT (2). CEA is the older more classic one, supporting lower resolutions while DMT mode is the modern one starting at VGA resolutions (aka 640x480@60 - mode 4, 640x400@85 - mode 2, 720x400@85 - mode 3 or for real nostalgia junkies 640x350@85 - mode 1). So yeah, none of these match the 480x320 SPI displays. The CEA calibration in contrast does support everything starting at 240p modes. The fun part is, it does not really matter, well, depending on how you drive the display. There are 3 methods:
      1. direct access via a 307200 bytes memory-mapped buffer (I bet retropi uses that one)
      2. direct access via a 307200 bytes memory-mapped buffer but with a clever DMA based copy mechanism (hello fbcp-ili9341 github.com/juj/fbcp-ili9341)
      3. DRM/KMS drivers aka tinydrm (not available for a very few selected displays)
      Option 3 is what you want, because this is a proper GPU driver on Linux. Hence, you get all the stuff you like, Vulkan, OpenGL, GLES, accelerated 2D etc..
      But there is a problem, that are actually not SPI displays. They have some kind of parallel interface and there is a serial to parallel converter in there. Referring back to the fbcp lib, that ili9341 is such a converter chip. To make it short, all this is completely fucked up, because the converters are far to slow. No matter what display you pick, transferring full 300kb frames is just to much and you never get beyond 20 fps. fpcp uses some DMA techniques, clever data packaging an only updates parts of the framebuffer that actually change. In the case of the waveshare 3.5 inch 125 MHz SPI display you get about 50 fps. Using the proper ili9486 driver and the matching piscreen.dtbo overlay (dtoverlay=piscreen,speed=125000000,fps=60,drm) you get a proper DRM display at about 19 fps. Configuring the SPI speed is another topic. The base frequency of the SPI controller is 250 MHz, but don't even try this, that won't go over the I/O-pins. That value is cut down by dividers following the scheme base_clock/8_bit_devider. So the fastest possible value is 125 MHz matching the high speed display. But like I said, this is a lie/false advertisement, because the converter can not even keep up with 62.5 MHz. And dont't get confused, fbcp supports quite a range of these converter chips. And the FPS option just drives the refresh rate of the display driver and actually doesn't do much (and the default is 30 anyway). The hdmi_mode=87 is not part of the official RPi video modes list, 86 is the last one. It is a way to define your own custom mode if you drive the display in DMT mode. So using hdmi_cvt you can actually set the proper values using "hdmi_cvt=480 320 60 1 0 0 0". But it does only matter if you use option 2 from my list up there, because there everything is rendered into the HDMI framebuffer and copied to the SPI display framebuffer via fbcp. You also may want to set correct framebuffer values (in case of your driver/kernel does not figure it out by itself - which basically never happens), "framebuffer_width=480", "framebuffer_height=320", "framebuffer_depth=16" and setting proper GPU memory sizes may also help. Setting it to 64 or 128 mb was reported to yield a slightly better performance ("gpu_mem=64").
      If you want proper frameframes and a proper interface (aka DRM) go for a MIPI DSI display, like the official RPi 7inch touch screen. And you want a DRM interface because then you can use all the nice libs like SDL2, SFML, Raylib, Imgui etc on a framebuffer (aka no X11 or Wayland). To make a point: Raylib works superb for this, knowing this because I do coding using these libs and being the maintainer of raylib (DRM version, tailored to a RPi1-5 framebuffer) for a big Linux distro also helps a lot.
      Or to make it short: This is how "professional" looks like. Uhm, ignore this, I just like to rant. 🤣Conclusion: basically all SPI displays beyond 320x240 are really odd designs, they would be able to run 60 or at least 30 fps, if proper components were picked. But this is not the case, don't know why, maybe it is reducing cost thing.

  • @eliutrodriguez4634
    @eliutrodriguez4634 10 месяцев назад

    Hi, you where right it get better framerate in a chinese screen, i mean the part of config.txt, but i have the same problem with the messing colors, there is anything that i can change to get the original color and the high speed? Thank you

    • @BytesNBits
      @BytesNBits  10 месяцев назад

      It did seem to be a serial speed issue. The only way to get the colours back was to drop the speed.

  • @elektron2kim666
    @elektron2kim666 Год назад +1

    Got mine to run a bit faster. It's the same line where "rotate=XX" can be - if that is a problem (which many ask about.)

    • @BytesNBits
      @BytesNBits  Год назад

      Hi. What did you do to increase the speed?

    • @elektron2kim666
      @elektron2kim666 Год назад

      @@BytesNBits With your numbers in comparison to not editing config.txt. Sorry, if that wasn't clear.

  • @sanketbharadwaj6264
    @sanketbharadwaj6264 28 дней назад

    hello sir i treid it have to admit this one is cool made my thing lot more usable but i lost the sound am on a raspbery pi 3b and the audio dont come via the 3.5mm jack

    • @BytesNBits
      @BytesNBits  26 дней назад

      Make sure you check your config.txt settings to ensure the audio drivers are turned on.

  • @umutkayacan7659
    @umutkayacan7659 3 года назад +1

    Nice video! Sorry i am lil late :P (btw u got a bot in your comment section.)

    • @BytesNBits
      @BytesNBits  3 года назад +1

      Hi there. Good to see you again. Thanks for the heads up on the bot comment. I'll knock that out now.

  • @AppliedCryogenics
    @AppliedCryogenics Год назад +1

    I wish I had seen this video before trying the prebuilt SD image! It was so disappointing. I'd not yet thrown the LCD into the trash, luckily.

    • @BytesNBits
      @BytesNBits  Год назад

      Great. Hope you get it working OK.

  • @kiyoshinakamura8747
    @kiyoshinakamura8747 Год назад

    The screen works but its slow
    If I overclock my rpi0 the screen gets messed up.
    There's a setting to overclock and use this method?!

    • @BytesNBits
      @BytesNBits  Год назад

      Hi. It's really a matter of playing with the various settings to get the best compromise between overclock / spi bandwidth / screen performance. The screen should be OK with overclocking but you might have to lower the speed setting.

  • @TT-it9gg
    @TT-it9gg Год назад +1

    The native resolution of the LCD is not 640x480. If you try to fit 640x480 into 480x320, what would be the best aspect ratio? 1 or 6?

    • @BytesNBits
      @BytesNBits  Год назад

      Hi. A lot of this is trial and error to try to get the best display. Not all native resolutions are supported. I used values that should work for most of these smaller displays but please do play around.

    • @TT-it9gg
      @TT-it9gg Год назад

      @@BytesNBits Roger. I tried to fit 720x480 into 480x320 to keep the native ratio. Seems better than 640x480. ^_^

    • @BytesNBits
      @BytesNBits  Год назад +1

      @@TT-it9gg Great! If it works use it!

  • @user-ev4lx3fc3f
    @user-ev4lx3fc3f Год назад

    Hey great tutorial ,but when i decreased to 1000000 it still looks good and it still has bad fps?

    • @BytesNBits
      @BytesNBits  Год назад

      10MHz is the default setting so you're back to the very low frame rate. You need to try to get a higher bit rate to get better animation. Don't forget there is a second part to this video which combines data rate and data size optimisations for a much better performance.

  • @chotalamechupa7266
    @chotalamechupa7266 3 дня назад

    hi!! can i use framebuffer in my pi zero through my hdmi output? want to run pac-man mame in raspbian or other linux from command line no x11

    • @BytesNBits
      @BytesNBits  2 дня назад

      You'll need to do a bit of research to get a Linux build that provides the right display driver for your code. It can all be done, it's just down to finding the drivers or writing them yourself.

    • @chotalamechupa7266
      @chotalamechupa7266 2 дня назад

      @@BytesNBits i just want to run mame 2d games like pac-man on pi zero for the onboard dvi output.

  • @richanddarksbane1439
    @richanddarksbane1439 2 года назад

    Can you recommend any displays that well, don't run this badly?

    • @BytesNBits
      @BytesNBits  2 года назад

      Your best bet is to use an hdmi or DSI based display. You can get 3-4 inch ones for around £40 I think on eBay and Amazon. I did recently test out a 7in display so have a look at that video. Anything that uses the SPI interface is going to give you frame rate issues. I did do a few more videos on improving the frame rate to get full 50-60fps. Please have a look at those.

  • @bihi1010
    @bihi1010 Год назад

    Does this work with Joy-it 3.2 " TFT Display

    • @BytesNBits
      @BytesNBits  Год назад

      Hi. I don't know. This display uses an SPI interface with an ILI9341 driver chip. The library code covers a range of display drivers so you need to make sure you use the correct one for your screen.

  • @Blu-ray
    @Blu-ray Год назад

    /boot/config.text shows up as a new file it doesn't exist?

    • @BytesNBits
      @BytesNBits  Год назад

      Hi. Sorry the file should be config.txt (no e).

    • @Blu-ray
      @Blu-ray Год назад

      @@BytesNBits no problem, i realised that but not before putting the sd card into my pc and changing it manually from there lol

  • @thebeatsaberrepairguy3386
    @thebeatsaberrepairguy3386 Год назад

    I get an error saying “error creating self window” “render failed to initialize and window failed to initialize after I install the driver, and i can’t figure out why🙃

    • @BytesNBits
      @BytesNBits  Год назад

      I'm not sure what that would be. I guess it's some issue with the driver software. Is this a fresh install or are you modifying an existing setup? Might be some incompatibility. I'd try creating a fresh SD card and install the drivers to get the screen working. If that's all OK you know the screen and driver are OK and can start from there.

    • @thebeatsaberrepairguy3386
      @thebeatsaberrepairguy3386 Год назад

      @@BytesNBits ok I’ll restart it and try again, if it doesn’t work again I might try installing the pi 3 version on my pi 4b thanks! And it is a fresh install

    • @BytesNBits
      @BytesNBits  Год назад

      @@thebeatsaberrepairguy3386 Your other option is to use a different lcd driver. I used this to get a more playable frame rate in this project. It uses different software so may get around any issues you are experiencing. ruclips.net/video/w1PQXpp6jC8/видео.html

    • @thebeatsaberrepairguy3386
      @thebeatsaberrepairguy3386 Год назад

      @@BytesNBits alright thanks!

  • @bimog8923
    @bimog8923 11 дней назад

    why does it shows (on my lcd) randome pixels..?

    • @BytesNBits
      @BytesNBits  11 дней назад +1

      If you push the bandwidth up too high it will start to glitch.

    • @bimog8923
      @bimog8923 11 дней назад

      @@BytesNBits Yeah.. The problem is that I am stuck on SSH, and when I run the "./LCD35-show", it says "0 configuration", and it reboots on SSH, and the screen is.. wel.. randome pixels..

  • @Laleluis
    @Laleluis 2 года назад

    26:08

    • @BytesNBits
      @BytesNBits  2 года назад

      ?

    • @Laleluis
      @Laleluis 2 года назад

      @@BytesNBits i did this to remeber where i was

  • @MariusPov
    @MariusPov Год назад

    videos where the sound is not calibrated....does the intro really have to blast the speakers, and after that voice really low? no, first start with your low sounding voice and then blast the intro. smart

    • @BytesNBits
      @BytesNBits  Год назад

      Hi. This is an old video. Hopefully the new ones have better sound leveling.