Giter Site home page Giter Site logo

clemensatelektor / hyperpixel2r Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 1.0 25 KB

Experimenting with the Pimoroni HyperPixel2r round touch display for Raspberry Pi.

License: GNU General Public License v3.0

Python 100.00%
raspberry-pi raspberrypi hyperpixel

hyperpixel2r's Introduction

The HyperPixel2r from Pimoroni is a round 2.1” IPS capacitive touchscreen with high-speed DPI interface. Like its square and rectangular HyperPixel 4 brothers, the 2r is intended for Raspberry Pi. Actually, the size is optimized for the Raspberry Pi Zero and Zero 2W but, as it has the standard 40-pin HAT connector, it can be plugged on any Raspberry Pi equipped with such a connector as long as you are careful about the mechanical side of things.

The display’s resolution is 480 by 480 pixels, but as it is round, you must, of course, subtract the corners.

Quiz: how many pixels are lost due to the rounded corners?

Answer: 480 × 480 × (1 - 0.25 π) = 49,444 (almost 21.5%).

It has 18-bit color depth (meaning 262,144 colors) and supports up to 60 frames per second (FPS). The viewing area has a 2.1” or 53.3 mm diameter and a viewing angle of 175°. Its full diameter is 72 mm with a height of 11 mm. With a Pi Zero attached with short stand-offs, the total height (or depth, whatever you prefer) is 17 mm.

As the display uses almost every pin of the HAT connector, you cannot add other extension boards. However, the display does provide an alternate I2C port for connecting things to.

To use the HyperPixel 2r on a Raspberry Pi you must install a driver:

$ git clone https://github.com/pimoroni/hyperpixel2r
$ cd hyperpixel2r
$ sudo ./install.sh
$ sudo reboot

The drivers are for Raspberry Pi OS Buster only, but support for Bullseye is being worked on.

To use the display in your own applications, install Pimoroni's hyperpixel2r-python library:

$ git clone https://github.com/pimoroni/hyperpixel2r-python
$ cd hyperpixel2r-python
$ sudo ./install.sh

Note that touch needs a driver to make it work as a mouse on the desktop. Unfortunately, such a driver does not seem to exist yet, but you can use the library example uinput-touch.py as a deamon instead:

$ cd hyperpixel2r-python/examples
$ python3 uinput-touch.py

If the library examples look funny, upgrade pygame:

$ sudo python3 -m pip install pygame --upgrade

Note that for some reason the center of the screen buffer may not exactly be the center of the screen, it can be off in the vertical direction by several pixels. You can correct this by adding an offset, but the sign of the offset depends on the rotation of the screen. You can see in my code how I handled that.

In order to print text on the screen with pygame you may have to install libsdl2-ttf in case you get an error about fonts:

$ sudo apt-get install libsdl2-ttf-2.0-0

In your program you must also call pygame.init and load a font before trying to print anything to the screen.

For the YouTube subscriber counter part, you'll also need httplib2:

$ sudo pip3 install httplib2

To rotate the display 180 degrees, edit /boot/config.txt:

$ sudo nano /boot/config.txt

Add the line:

display_lcd_rotate=2

Save and exit (Ctrl-X, Y, Enter) and reboot:

$ sudo reboot

To find the HyperPixel's alternate I2C port use:

$ i2cdetect -l 

Or look in the /dev folder for files that start with i2c:

$ dir /dev 

In my case it is i2c-11. Redirecting it to i2c-1 makes it work with other libraries that expect i2c-1:

$ sudo ln -s /dev/i2c-11 /dev/i2c-1

Here is a video about this HyperPixel2r project

Run this program:

$ python3 clock-ytsc.py

hyperpixel2r's People

Contributors

clemensatelektor avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

basbaccarne

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.