Need Help Controlling OLED Display on Pi-Top [4] with Button Press

Hello everyone,


I’m working on a project with my Pi-Top [4], and I’m trying to control the OLED display so that it remains off by default and only turns on when I press a specific button. Here’s what I’ve done so far:

  1. Script to Control OLED: I wrote a Python script using the pi-top command to clear the display and turn it off initially. When I press the button, the OLED displays a message, and when I press it again, it clears the display.
  2. Current Behavior: The script works to an extent—the display turns off as intended, but it comes back on after a few seconds, even if I don’t press the button again. I suspect this might be due to some background service or process that reinitializes the OLED.
  3. Tried Solution: I considered stopping the pt-device-manager service or similar processes that might be controlling the OLED, but I feel this might not be the best approach. I want to avoid disabling essential services if possible.
    Script is in the attachment

My Questions:

  1. Has anyone successfully managed to control the OLED display in a similar way without the screen turning back on by itself?
  2. Is there a recommended method for fully controlling the OLED power or display state without stopping important services like pt-device-manager?
  3. Could there be another service or process responsible for this behavior, and how can I manage it properly?

Any advice or suggestions would be greatly appreciated! Thank you in advance for your help.

Hi @qudiepie,

The pi-top oled display command is designed for only brief control of the display - it has a default timeout of 10 seconds, though this can be extended by passing a --timeout argument.

Instead you should look into using the SDK’s miniscreen API within your script - docs here.

When you create this Miniscreen object in your python script, it will clear the display by default for the duration of your script. You can then use the python APIs such as miniscreen.display_multiline_text, miniscreen.clear or more advanced canvas graphics shown in the docs. Once your script is complete the miniscreen will be taken over again by the system menu, which is actually the service pt-miniscreen.

You can also find tutorials, code examples and project guides (some of which must be purchased) for the pi-top on our learning website Further, such as this Miniscreen tutorial: