Baffled why my code works on a small display but not a larger one

I have written some basic code to display text on my Pimoroni 0.96" breakout display. I now want that same information but on a larger 1.54" breakout display. However, the larger screen displays nothing (though the backlight is on).

When using the larger display I adapted the code below in the following ways:

Line 4:
from picographics import DISPLAY_LCD_240X240

Line 8:
display = PicoGraphics(display=DISPLAY_LCD_240X240, pen_type=PEN_P4, rotate=0)

Anything else I might be missing??

import utime
from pimoroni import Button
from picographics import PicoGraphics
from picographics import DISPLAY_LCD_160X80
from picographics import PEN_P4

display = PicoGraphics(display=DISPLAY_LCD_160X80, pen_type=PEN_P4, rotate=0)

WIDTH, HEIGHT = display.get_bounds()

display.set_backlight(1.0)
display.set_font(“bitmap8”)

RED = display.create_pen(255, 000, 000)
PURPLE = display.create_pen(255, 000, 255)
YELLOW = display.create_pen(255, 255, 000)
GREEN = display.create_pen(000, 255, 000)
CYAN = display.create_pen(000, 255, 255)
BLUE = display.create_pen(000, 000, 255)
WHITE = display.create_pen(255, 255, 255)
BLACK = display.create_pen(0, 0, 0)

def clear():
display.set_pen(BLACK)
display.clear()
display.update()

clear()

display.set_pen(BLUE)
display.set_font(“bitmap6”)
display.text(“PICO Man”,5,5,scale=1) # PICO Man in small blue letters
display.text(“PICO Man”,5,20,scale=2) # there is no “scale 1.5”
display.text(“PICO Man”,5,40,scale=3)
display.update()

utime.sleep(2)

clear()
display.set_pen(RED)
display.set_font(“bitmap8”)
display.text(“PICO Man”,5,5,scale=1) # PICO Man in small blue letters
display.text(“PICO Man”,5,20,scale=2) # there is no “scale 1.5”
display.text(“PICO Man”,5,40,scale=3)
display.update()

utime.sleep(2)

clear()
display.set_pen(GREEN)
display.set_font(“bitmap14_outline”)
display.text(“PICO Man”,5,5,scale=1)
display.text(“PICO Man”,5,15,scale=2)
display.text(“PICO Man”,5,35,scale=3)
display.update()

utime.sleep(2)

clear()
display.set_pen(WHITE)
display.set_font(“sans”)
display.text(“PICO Man”,5,40,scale=1)
display.update()

utime.sleep(2)

clear()
display.set_pen(WHITE)
display.set_font(“serif_italic”)
display.text(“PICO Man”,5,40,scale=1)
display.update()

utime.sleep(2)

clear()
display.set_pen(WHITE)
display.set_font(“serif”)
display.text(“PICO Man”,5,40,scale=1)
display.update()

Just for clarity, are you talking about the 0.96" and 1.54" colour displays which Pimoroni make? How have you got them connected, and what are you controlling them with?

Have you tried running the example code (I assume you’re running micropython here)? That seems to define the pen type as PEN_P8 rather than PEN_P4, so that might be worth trying.

Yes both displays are from Pimoroni, and you have the correct links

I am connecting them with jumper wires and using the raspberry pi pico. The power cable connected to my laptop works correctly.

The wiring for both displays is the same, and I have followed the instructions accordingly from the Pimoroni product pages.

Micropython it is!

PEN_P4 shouldn’t be the issue it’s just the colour depth, PEN_P8 uses more power I thinkkk because there are more colours.

I tried the example code and received this error message:

Traceback (most recent call last):
File “”, line 5, in
MemoryError: memory allocation failed, allocating 57600 bytes

I saw some other posts that had this error message but I found the information confusing. But this error might be a lead to whatever the problem is.

If anybody has any basic basic example code I could use to test my display (specific to Pimoroni 240X240 and Pi Pico) that might be a real help

A larger screen implies more pixels and thus higher memory needs. So there is nothing surprising about your problem. The RAM of the Pico is not very large, and many objects need contiguous memory.

You are loading many different fonts, so this could be the problem. Try running the garbage collector in between your various updates (see: gc – control the garbage collector — MicroPython 1.12 documentation). Maybe this helps.

Okay, that’s really good to know for larger projects, thankyou. I rewrote the code with just one font (see below) but it still doesn’t run on my 1.54" 240X240 screen. Are there any errors in my code?

I didn’t mention this in my original post but I did have the display working yesterday, but then for seemingly no reason it stopped working - and it makes no sense to me…

I managed to correctly run the code in my og post where the display shows a few different fonts in a few different colours, I even have a video of it working. Then I tried running a more complex program with an ASCII font and 300+ lines of code. It started off correctly and I had no error messages. I felt that I hadn’t wired the buttons correctly, and believed the issue to be manageable. With the power still going to my Pico and display I went for a 30 min walk and returned to coding. Then I tried running the og code again where the display shows a few different fonts (the exact same code that just worked) and it didn’t work.

I was so confused so I restart my computer and tried again. The shutdown process was kind of ugly if you know what I mean (this program is still running) and I had a blank white laptop screen for a bit. Any chance my screen is corrupted and the hardware is no longer working. I only bought it yesterday :(

I can’t see any error in your code. But that does not mean anything. I sometimes spend hours searching for errors and at the end it turns out there is a missing comma. What is really helpful is a backtrace of your error.

Do you still have the memory error? And did you try to follow the advice of @Shoe above (i.e. running the example he linked to)?

One other thing to try is to reflash the MicroPython firmware.

The rewrote the code I just posted with PEN_P8 rather than PEN_P4 and got no result sadly. The example code @Shoe suggested (balls_demo) didn’t work due to a memory error. I tried to fix it with import gc commands but I’m new to that so I likely did it wrong.

But there must be an error besides the memory problem because the code I just posted didn’t display anything and it’s a very small bit of code.

Is this what you are suggesting @bablokb ?

This, combined with the mention of jumper cables, makes me suspect your problem is a connection one, rather than anything with your code. Check that all those jumpers are securely plugged in, and ideally replace them in case one or more of the wires are faulty.

Did you buy the Pico with or without headers? If without, it’s also worth checking your soldering.

1 Like

These are generic instructions for a specific board (“pyboard”). You should follow https://learn.pimoroni.com/article/getting-started-with-pico instead. But don’t waste time with that before you checked your cabling as @ahnlak suggested.

And please, also post your backtrace. In one of your posts you posted above, there was a reference to “line 5”, but I am not sure which line this is. Because in your code, that would be an import statement and you should not have a memory error during the first few lines of the code.

You may be right @ahnlak

I pressed run again with this code but pushed the display close to the pins and double checked the jumper wires and got this result :)

I’ve experimented a few times now and whenever I hold the display in like this my programs will run(I’ve tried a couple different programs), but whenever I press run and the display is just sitting without me holding it in I get no response.

My end goal for this project will involve soldering the wires from the Pico to the display. My assumption is that soldering is a very secure way to do a connection (if done correctly). So in the short term I guess I make do with holding the display in when I press run, or might there be a way to improve the connection without buying a breakout board?

Since my problem is a connection one I’m not going to do a factory reset. I’ve done a few google searches and I’m quite confused by ‘back trace’ and what that means and how to do it.

This display uses the fraction-fit system (I think they call it “Breakout Garden”) with pins having a small offset. My experience is that this sometimes works and sometimes does not work. So the first thing would be to solder pins to the display and then plug the pins to the breadboard (and keeping the cables plugged to the breadboard).

You can then actually skip the breadboard and use cables with female pins attached directly to the display-pins. Depending on what I do, I use both options. Another thing for your cheat-sheet: use some tape around your cable-pins. This also sometimes helps.

1 Like

It looks like you’re just resting that board on some header pins without soldering them so, yeah, that’s gonna be your problem.

(FWIW the ‘Breakout Garden’ is a friction fit that “pinches” the board, and doesn’t need soldering - but regular header pins like you’ve got there do)