Real screen dimensions vs size

edited January 2018 in Raspberry PI


I have a commercial screen for 3.5 '' Raspberry, the resolution is 480x320.

When designing I set size(480,320,P2D) but the size of the screen that appears in the sketch does not correspond to the real dimensions of the screen. I would need to be able to get an idea of ​​the final result while designing on my laptop or my desktop PC. I need the real dimensions when I run the processing sketch.





  • Some advice please?

  • Can you take a photo or screenshot that illustrates the problem? I can't see what could be wrong from your description alone.

  • Sorry, may be that English is not my native language has something to do.

  • Sorry, I think the last image was too big. As you can see the size of the screen is smaller than the sketch. The resolution of the screen is 480x320, but if I set the size of the sketch to 480x320 the size of the image and the screen do not match.

    I develop my project in a desktop pc or my laptop, with windows or gnu/linux I know the dpi in windows or gnu/linux is 96, I've read some forums but I can't undestand or apply for what I want to do.



  • @jcduino Thank you for this image, although I am still unsure if I understand you correctly:

    The fact that the 480x320 pixels display window on your PC does not match the size of the screen you have purchased should not concern you. Pixels will have different sizes - some displays have more of them crammed into a smaller surface area, and others have less.

    Try this on the Raspberry Pi:

    void setup() {
    void draw() {
      line(0, 0, 479, 319);
      line(0, 319, 479, 0);

    This should draw two lines, crossing nicely in the center of your screen. Does this work?

  • If you check this link, you will see that devices have higher pixel density than monitors, meaning it requires a smaller area when comparing them based on same dimensions:

    For instance:

    Samsung G4 1080x1920 Display size: 5" PPI:441
    Asus VE228DE 1920x1080 Display size: 27" PPI:100

    I think gohai's idea is a good test to convince you you are working with the same screen dimensions when comparing the device and the sketch window. The next question is that if you could simulate the same pixel density in your actual monitor.


  • Hello, sorry for the delay but I did not have the raspberry power supply...

    Yes, I can see the big X on the screen. The feeling is that in my 23'' samsung monitor everything is bigger due to pixel density.

    Kf, thanks for your answer, I think it may be the key because what I see on the monitor screen is apparently bigger than on the screen of the raspberry. How can I emulate the final result without having to copy the sketch on the respberry every time I want to check how it will look on the 3.5 '' screen?

    Many thanks!

  • @jcduino Why do you care about faithfully emulating the screen? For most applications, one gets away with just working with pixels: i.e. design for 480x320 pixels, regardless of how big (dense) those pixels are.

  • edited February 2018

    Depending on how you use coordinates and translation in your sketch, you might be able to add scale() to the beginning of draw for a quick desktop preview. The window will still be too large, but drawn contents will match your external display size. This extra line of code is a quick hack -- it would need to be taken out before using it with your PI display (or hidden behind a command or auto-stripped during build).

    Calculate the scaling factor between the desktop and PI devices and use that as the argument to scale(). If the horizontal and vertical scaling is different then scale also takes two arguments.

  • Hello,

    It is important for me to know how you are going to see what I am designing, to know the proportions.

    For instance, to make a gauge, if while designing and I see in my desktop pc that the proportions are good and then, when I transfer the design to the 3.5'' screen I see that everything is very small I have a problem.

    The pixels may be the same, but the size is different. If I measure with a rule how much the lines that crossed in the example measure, they have a different measure, that is a fact.

    I do not see any other solution than to work more, make few advances in the desktop PC, which is more comfortable to develop, and every time to pass the work with usb to the raspberry and see how it really looks.

    Thanks for your comments.

  • Three possible solutions:

    1. upload to the device every time you want to check real proportions -- you probably don't need to be doing that constantly, just every once in a while.

    2. scale your desktop preview render, e.g. using "scale" as I described above.

    3. use a different desktop display resolution when working with your target device. this might require a desktop display with a resolution at least as high as your target device.

Sign In or Register to comment.