Template: Pico 8SEG LED Guide

From Waveshare Wiki
Jump to: navigation, search

Pico User Guide

Hardware connection

Please take care of the direction when you connect Pico, an USB port is printed to indicate . You can also check the pin of Pico and the LCD board when connecting.
You can connect display according to the table.

LCD Pico Description
VCC VSYS Power input
GND GND GND
DIN GP11 Serial data input
CLK GP10 Data input clock pin
RCLK GP9 Output latch register clock pin

Connection

Pico-8SEG-LED-details-3.jpg

Setup environment

Please refer to Raspberry Pi's guide: https://www.raspberrypi.org/documentation/pico/getting-started/

Download example

1. Open a terminal of Raspberry Pi

sudo apt-get install p7zip-full
cd ~
sudo wget  https://files.waveshare.com/upload/2/28/Pico_code.7z
7z x Pico-8SEG-LED-Code.7z -o./Pico-8SEG-LED-Code
cd ~/Pico-8SEG-LED-Code
cd c/build/

Raspberry Pi

  • Open a terminal and go to the C directory:
cd ~/Pico-8SEG-LED-Code/c/
  • Create a build folder and add the path of SDK to it, it is ../../pico-sdk by default, however, it may be different for different users, please check the actual path of your pico.
cd build
export PICO_SDK_PATH=../../pico-sdk
  • run cmake to generate Makefile, and build it.
cmake ..
make -j9
  • A main.uf2 file is generated.
  • Hold the BOOTSEL button of Pico, and connect the USB interface of Pico to Raspberry Pi then release the button.
  • Copy the main.uf2 file to the RPi-RPI2 drive recognized.

Python codes

Use in Windows

  • 1. Press and hold the BOOTSET button on the Pico board, connect the Pico to the USB port of the computer through the Micro USB cable, and release the button after the computer recognizes a removable hard disk (RPI-RP2).
  • 2. Copy the rp2-pico-20210418-v1.15.uf2 file in the python directory to the recognized removable disk (RPI-RP2).
  • 3. Open Thonny IDE (Note: Use the latest version of Thonny, otherwise there is no Pico support package, the latest version under Windows is v3.3.3).
  • 4. Click Tools -> Settings -> Interpreter, and select Pico and the corresponding port as shown in the figure.

Pico-lcd-0.96-img-config.png

  • 5. File -> Open -> the corresponding .py file, click to run, as shown in the following figure:

Pico-Thonny-v1.15.jpg
This demo provides a simple program...

Run in Raspberry Pi

  • 1. The process of firmware flashing is the same as on Windows, you can choose to copy the pico_micropython_20210121.uf2 file into pico on a PC or Raspberry Pi.
  • 2. Open the Thonny IDE on the Raspberry Pi (click Raspberry logo -> Programming -> Thonny Python IDE), you can check the version information in Help -> About Thonny.
  • To make sure your version has the Pico support package, also you can click on Tools -> Options... -> Interpreter to select MicroPico. -> Interpreter to select MicroPython (Raspberry Pi Pico and ttyACM0 port).

As shown in the image:
Pico-lcd-0.96-img-config2.png
If your Thonny doesn't support Pico, you can update it with the following command:

sudo apt upgrade thonny
  • Choose File -> Open...-> python/Pico-8SEG-LED/Pico-8SEG-LED.py, and select the corresponding .py file to run the codes.


Codes Description

C

Buttom interface

In DEV_Config.c(.h) file (...\c\lib\Config)

  • Data type:
#define UBYTE   uint8_t
#define UWORD   uint16_t
#define UDOUBLE uint32_t
  • Mpdule initializes and exit:
void DEV_Module_Init(void);
void DEV_Module_Exit(void);
Note:
1. These are functions that are used to handle GPIO:
  • GPIO Write/read:
void 	DEV_Digital_Write(UWORD Pin, UBYTE Value);
UBYTE 	DEV_Digital_Read(UWORD Pin);
  • SPI write byte
void DEV_SPI_WriteByte(UBYTE Value);