Skip to content

PiSugar Whisplay HAT Audio and Image Display Extension Driver

License

Notifications You must be signed in to change notification settings

PiSugar/Whisplay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

English | 中文

PiSugar Whisplay Hat Driver

Project Overview

This project provides comprehensive driver support for the PiSugar Whisplay Hat, enabling easy control of the onboard LCD screen, physical buttons, LED indicators, and audio functions.

More Details please refer to Whisplay HAT Docs


💡 Bus Information Tip 💡

The device utilizes I2C, SPI, and I2S buses. The I2S and I2C buses are used for audio and will be enabled automatically during driver installation.


Installation

After cloning the github project, navigate to the Driver directory and use the script to install.

git clone https://github.com/PiSugar/Whisplay.git --depth 1
cd Whisplay/Driver
sudo bash install_wm8960_drive.sh
sudo reboot

The program can be tested after the driver is installed.

cd Whisplay/example
sudo bash run_test.sh

Driver Structure

All driver files are located in the Driver directory and primarily include:

1. Whisplay.py

  • Function: This script encapsulates the LCD display, physical buttons, and LED indicators into easy-to-use Python objects, simplifying hardware operations.
  • Quick Verification: Refer to example/test.py to quickly test the LCD, LED, and button functions.

2. WM8960 Audio Driver

  • Source: Audio driver support is provided by Waveshare.

  • Installation: Install by running the install_wm8960_drive.sh script:

    cd Driver
    sudo bash install_wm8960_drive.sh

Example Programs

The example directory contains Python examples to help you get started quickly.

run_test.sh

  • Function: This script verifies that the LCD, LEDs, and buttons are functioning correctly.
  • Usage:
    cd example
    sudo bash run_test.sh
    You can also specify an image or sound for testing:
    sudo bash run_test.sh --image data/test2.jpg --sound data/test.mp3
    Effect: When executed, the script will display a test image on the LCD. Pressing any button will change the screen to a solid color, and the RGB LED will simultaneously change to match that color.

mic_test.sh

  • Function: This script tests the microphone functionality.
  • Usage:
    cd example
    sudo bash mic_test.sh
    Effect: The script records audio from the microphone for 10 seconds and plays it back through the speaker.

test2.py

  • Function: This script demonstrates recording audio and playback functionality.
  • Usage:
    cd example
    sudo python3 test2.py
    Effect: The script displays an image indicating the recording stage. Pressing the button to stop recording will switch to the playback stage, displaying a different image while playing back the recorded audio. After playback, it returns to the recording stage again.

play_mp4.py

  • Function: This script plays an MP4 video file on the LCD screen.
  • Prerequisites: Ensure that ffmpeg is installed on your system. You can install it using:
    sudo apt-get install ffmpeg
  • Download Test Video: download a sample MP4 video to the example/data directory:
    cd example
    wget -O data/whisplay_test.mp4 https://img-storage.pisugar.uk/whisplay_test.mp4
  • Usage: execute the script in the example directory:
    sudo python3 play_mp4.py --file data/whisplay_test.mp4
    Effect: The specified MP4 video will be played on the LCD screen.

Note: This software currently only supports the official full version of the operating system.

Links

About

PiSugar Whisplay HAT Audio and Image Display Extension Driver

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published