HyperPixel - GUI required?

Does the HyperPixel need a graphical user interface to operate? I’m not able to see any information about this aspect on the product page, but I’m looking to use it with Raspbian Lite and either pygame or PIL. Do you have any documentation or examples to get started with interfacing with HyperPixel?

It should be possible to use pygame to display directly on HyperPixel via the framebuffer device. I haven’t actually tested this though, although I’ve accomplished it before with other displays. I’ll have to give it a shot and post a mini-tutorial.

Although I think this covers it: https://learn.adafruit.com/raspipe-a-raspberry-pi-pipeline-viewer/running-raspipe-dot-py-on-the-pitft

Great, got my HyperPixel today and hacked together this Python code to display via the framebuffer. It requires PyGame (sudo apt-get install python-pygame). A quick ‘n’ dirty example is shown below:

import pygame, os, time, sys

os.environ["SDL_FBDEV"] = "/dev/fb0"
os.environ["SDL_MOUSEDEV"] = "/dev/input/mouse0"

# HyperPixel screen dimensions
WIDTH = 800
HEIGHT = 480

if __name__ == '__main__':
    # initialise PyGame engine
    pygame.init()
    # set PyGame output to match dimensions of HyperPixel
    size = width, height = WIDTH, HEIGHT
    screen = pygame.display.set_mode(size)
    # hide the mouse pointer
    pygame.mouse.set_visible(0)

    # load a bitmap image for later display
    logo = pygame.image.load("pimoroni-shop-logo.png")
    logo_rect = logo.get_rect()
    logo_rect.centerx = WIDTH / 2.0
    logo_rect.centery = HEIGHT / 2.0

    # create text for later display
    font = pygame.font.Font(None, 150)
    text = font.render("HyperPixel", 0, (32, 32, 32))
    text_rect = text.get_rect()
    text_rect.centerx = WIDTH / 2.0
    text_rect.centery = HEIGHT / 2.0

    # loop example display 5 times...
    for i in range(5):
        # clear screen (R,G,B) (255, 255, 255) = white background
        screen.fill((255, 255, 255))
        screen.blit(logo, logo_rect)
        # show display (as double-buffered)
        pygame.display.flip()
        # one-second delay
        time.sleep(1)
        # clear screen with light blue background colour
        screen.fill((32, 155, 192))
        # show text
        screen.blit(text, text_rect)
        pygame.display.flip()
        time.sleep(1)

    # clear HyperPixel display at end of script
    screen.fill((0,0,0))
2 Likes

Fantastic! Thank you for the example. Might be worth putting something like this in the HyperPixel GitHub repo, since these screens always work their best with a custom UI.

Note: to post code in future, enclose it within 3 backticks:

```
Like so
```