Skip to main content

A Python driver for the GC9D01 round LCD display on Raspberry Pi

Project description

GC9D01 Display Driver for Raspberry Pi

This project provides a Python driver for the GC9D01 round LCD display, designed to work with Raspberry Pi. It includes a library file (GC9D01.py) and a test script (displaytest.py) to demonstrate basic functionality.

Hardware Requirements

  • Raspberry Pi (any model with GPIO pins)
  • GC9D01 round LCD display
  • Appropriate connections between the Raspberry Pi and the display

Software Requirements

  • Python 3
  • CircuitPython libraries (adafruit_blinka, adafruit_circuitpython_busdevice)

Installation

  1. Clone this repository or download the gc9d01_library folder.

  2. Install the required libraries:

    pip3 install adafruit-blinka adafruit-circuitpython-busdevice
    

Wiring

Connect your GC9D01 display to the Raspberry Pi as follows:

GC9D01 Pin Raspberry Pi Pin GPIO Number Description
VCC Pin 17 3.3V Power
GND Pin 20 GND Ground
SCL Pin 23 GPIO 11 SPI0 SCLK
SDA Pin 19 GPIO 10 SPI0 MOSI
CS Pin 24 GPIO 8 SPI0 CE0
DC Pin 22 GPIO 25 Data/Command
RST Pin 18 GPIO 24 Reset

Note:

  • The pin numbers refer to the physical pin numbers on the Raspberry Pi GPIO header.
  • You can change the pin assignments in the displaytest.py file if needed, but make sure to update your wiring accordingly.
  • Ensure that your Raspberry Pi is powered off when connecting or disconnecting the display to avoid potential damage.

Usage

  1. Import the GC9D01 module in your Python script:

    import gc9d01_library
    

    Alternatively, you can import the GC9D01 class directly:

    from gc9d01_library import GC9D01
    
  2. Set up the SPI and control pins:

    import board
    import busio
    import digitalio
    
    spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI)
    cs = digitalio.DigitalInOut(board.CE0)
    dc = digitalio.DigitalInOut(board.D25)
    rst = digitalio.DigitalInOut(board.D24)
    
  3. Create a display object:

    display = gc9d01_library.GC9D01(spi, dc, cs, rst)
    

    Or, if you imported the class directly:

    display = GC9D01(spi, dc, cs, rst)
    
  4. Use the display methods to draw on the screen:

    display.fill_screen(0xFFFF)  # Fill screen with white
    display.draw_pixel(80, 80, 0xF800)  # Draw a red pixel at (80, 80)
    

Running the Test Script

To run the provided test script:

  1. Ensure your display is correctly connected to the Raspberry Pi.

  2. Run the following command in the terminal:

    python3 displaytest.py
    

This will cycle through different colors on the display.

Available Methods

  • fill_screen(color): Fill the entire screen with a single color
  • draw_pixel(x, y, color): Draw a single pixel at the specified position
  • display_image(image_data): Display a full-screen image

Colors are represented in 16-bit RGB565 format.

Package Structure

The library is structured as follows:

gc9d01_library/
    __init__.py
    GC9D01.py
    displaytest.py

The __init__.py file allows the library to be imported as a Python package.

Troubleshooting

  • If the display doesn't work, double-check your wiring connections.
  • Ensure that SPI is enabled on your Raspberry Pi (raspi-config > Interface Options > SPI).
  • Check that you have the latest version of the required libraries installed.

Contributing

Feel free to contribute to this project by submitting issues or pull requests.

License

This project is open source and available under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gc9d01_library-0.1.4.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

gc9d01_library-0.1.4-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file gc9d01_library-0.1.4.tar.gz.

File metadata

  • Download URL: gc9d01_library-0.1.4.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for gc9d01_library-0.1.4.tar.gz
Algorithm Hash digest
SHA256 224f51f1e1213cdd044897c8df7bf35b581d2ccdaf5102c92f356253867ec5dc
MD5 2b8045ab2117c74de42ab0d6c90b82a7
BLAKE2b-256 388019b3a94c774cf0a26ae9c7cd4c3d0732a00e1aa7d0629d82d221c915a287

See more details on using hashes here.

File details

Details for the file gc9d01_library-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for gc9d01_library-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 aeeb4ef43ad817483c61b8601d9e90c48fd31aec57d26f4c46371d371aae7a62
MD5 d30044f743c14a1941151006e9baa30e
BLAKE2b-256 31db4f285521b05f1b868fd2615447b8e6bf94e08f8e145fcf17068a6a853d35

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page