RP2040-LCD-0.99-B

From Waveshare Wiki
Jump to: navigation, search
RP2040-LCD-0.99-B
RP2040-LCD-0.99-B.jpg

USB Type-C, RP2040
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

Overview

Introduction

RP2040-LCD-0.99-B is a low-cost, high-performance MCU board designed by Waveshare. Tiny size with onboard 0.99inch LCD round display (with flat bottom), 6-axis sensor (3-axis accelerometer and 3-axis gyroscope), and so on, adapting 4 × GPIO pins through SH1.0 6PIN connector, which makes it easy for you to develop and integrate it into products quickly.

Features

  • RP2040 microcontroller chip designed by Raspberry Pi in the United Kingdom.
  • Dual-core Arm Cortex M0+ processor, flexible clock running up to 133 MHz.
  • 264KB of SRAM, and 2MB of onboard Flash memory.
  • Type-C connector, keeps it up to date, easier to use.
  • Onboard 0.99inch 128×115 pixels 65K colorful IPS LCD (with flat bottom) for clear color pictures.
  • 4 × GPIO pins are adapted through the SH1.0 6PIN connector.
  • Adopts CNC metal case with Acrylic dull-polish bottom plate.
  • USB 1.1 with device and host support.
  • Low-power sleep and dormant modes.
  • Drag-and-drop programming using mass storage over USB.
  • 2 × I2C, 4 × 12-bit ADC.
  • Accurate clock and timer on-chip.
  • Temperature sensor.
  • Accelerated floating-point libraries on-chip.
  • 8 × Programmable I/O (PIO) state machines for custom peripheral support.

Parameters

LCD Parameters
Controller GC9107 Resolution 128(H) RGB x 115(V)
Communication Interface SPI Display Dimensions Φ33mm
Display Panel IPS Pixel Size 0.19(H)x 0.19(V)mm


IMU Parameter
Sensor QMI8658
Accelerometer Resolution: 16 bits
Measurement Range (Optional): ±2, ±4, ±8, ±16g
Gyroscope Resolution: 16 bits
Measuremnet Range (Optional): ±16, ±32, ±64, ±128, ±256, ±512, ±1024, ±2048°/sec

Dimensions

RP2040-LCD-0.99-B-Dim.jpg

Pico Quick Start

Download Firmware

  • MicroPython Firmware Download

MicroPython Firmware Download.gif

  • C_Blink Firmware Download

C Blink Download.gif

Video Tutorial

  • Pico Tutorial I - Basic Introduction

  • Pico Tutorial II - GPIO

  • Pico Tutorial III - PWM

  • Pico Tutorial IV - ADC

  • Pico Tutorial V - UART

  • Pico Tutorial VI - To be continued...

MicroPython Series

C/C++ Series

Arduino IDE Series

Install Arduino IDE

  1. Download the Arduino IDE installation package from Arduino website.
    RoArm-M1 Tutorial II01.jpg
  2. Just click on "JUST DOWNLOAD".
    Arduino IDE Pico.png
  3. Click to install after downloading.
    RoArm-M1 Tutorial II02.gif
  4. Note: You will be prompted to install the driver during the installation process, we can click Install.

Install Arduino-Pico Core on Arduino IDE

  1. Open Arduino IDE, click the File on the left corner and choose "Preferences".
    RoArm-M1 Tutorial04.jpg
  2. Add the following link in the additional development board manager URL, then click OK.
    https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json

    RoArm-M1 Tutorial II05.jpg
    Note: If you already have the ESP8266 board URL, you can separate the URLs with commas like this:

    https://dl.espressif.com/dl/package_esp32_index.json,https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
    
  3. Click on Tools -> Dev Board -> Dev Board Manager -> Search for pico, it shows installed since my computer has already installed it.
    Pico Get Start 05.png
    Pico Get Start 06.png

Upload Demo At the First Time

  1. Press and hold the BOOTSET button on the Pico board, connect the Pico to the USB port of the computer via the Micro USB cable, and release the button when the computer recognizes a removable hard drive (RPI-RP2).
    Pico Get Start.gif
  2. Download the demo, open arduino\PWM\D1-LED path under the D1-LED.ino.
  3. Click Tools -> Port, remember the existing COM, do not need to click this COM (different computers show different COM, remember the existing COM on your computer).
    UGV1 doenload02EN.png
  4. Connect the driver board to the computer with a USB cable, then click Tools -> Ports, select uf2 Board for the first connection, and after the upload is complete, connecting again will result in an additional COM port.
    UGV1 doenload03EN.png
  5. Click Tool -> Dev Board -> Raspberry Pi Pico/RP2040 -> Raspberry Pi Pico.
    Pico Get Start02.png
  6. After setting, click the right arrow to upload.
    Pico Get Start03.png
    • If you encounter problems during the period, you need to reinstall or replace the Arduino IDE version, uninstall the Arduino IDE needs to be uninstalled cleanly, after uninstalling the software you need to manually delete all the contents of the folder C:\Users\[name]\AppData\Local\Arduino15 (you need to show the hidden files in order to see it) and then reinstall.


Open Source Demo

API

If you have used our SPI screens before you should be familiar with this demo.

C

Bottom-layer Hardware Interfaces

We have encapsulated the bottom layer, and due to different hardware platforms, the internal implementations vary. If you need to understand the internal implementation, you can refer to the corresponding directory for details.
You can see many definitions in DEV_Config.c(.h) in the directory: c\lib\Config.

  • Data type:
#define UBYTE   uint8_t
#define UWORD   uint16_t
#define UDOUBLE uint32_t
  • Module initialization and exit:
void DEV_Module_Init(void);
void DEV_Module_Exit(void);
Note:
1. Here is the handling of some GPIOs before and after using the LCD.
  • GPIO read/write:
void 	DEV_Digital_Write(UWORD Pin, UBYTE Value);
UBYTE 	DEV_Digital_Read(UWORD Pin);
  • SPI writes data
void DEV_SPI_WriteByte(UBYTE Value);

Upper Layer Application

For the screen, tasks such as drawing, displaying Chinese and English characters, and showing images are typically handled by upper-layer applications. Many users have asked about graphics processing, so we provide some basic functions for this purpose.
You can find the GUI module in the following directory: c\lib\GUI\GUI_Paint.c(.h)
LCD PICO GUI 1.png
In the following directory are the character fonts that the GUI depends on, in the directory: c\lib\Fonts
LCD rpi Font.png

  • Create Image Properties: Create a new set of image properties, including the name of the image buffer, width, height, rotation angle, and color.
void Paint_NewImage(UWORD *image, UWORD Width, UWORD Height, UWORD Rotate, UWORD Color)
Parameters:
 	image: The name of the image buffer is a pointer pointing to the starting address of the image buffer
 	Width: The width of the image cache;
 	Height: The height of the image cache;
 	Rotate: The flipping angle of the image cache;
 	Color: The initial color of the image;
  • Select Image Buffer: The purpose of selecting an image buffer is to enable the creation of multiple image properties. Multiple image buffers can exist, and you can choose each image you have created.
void Paint_SelectImage(UBYTE *image)
Parameters:
 	image: The name of the image buffer is a pointer to the starting address of the image buffer
  • Image Rotation: Set the rotation angle of the selected image. It is recommended to use this function after Paint_SelectImage(). You can choose rotation angles of 0, 90, 180, or 270 degrees.
void Paint_SetRotate(UWORD Rotate)
Parameters:
 	Rotate: The image rotation angle can be selected as ROTATE_0, ROTATE_90, ROTATE_180, and ROTATE_270, corresponding to 0, 90, 180, and 270 degrees respectively.
【Note】 Under different rotation angles, the corresponding starting pixel points for coordinates are different. Here, taking 1.14 as an example, the four images are in the sequence of 0°, 90°, 180°, and 270°. This is for reference only.
Pico LCD Rotate.jpg
  • Image Mirror Flip: Set the mirror flip of the selected image, you can choose No Mirror, Horizontal Mirror, Vertical Mirror, or Image Center Mirror.
void Paint_SetMirroring(UBYTE mirror)
Parameters:
 	mirror: Image mirroring method, you can choose MIRROR_NONE, MIRROR_HORIZONTAL, MIRROR_VERTICAL, MIRROR_ORIGIN corresponds to no mirroring, about horizontal mirroring, about vertical mirroring, about image center mirroring, respectively.
  • Set the display position and color of a point in the buffer: This is the core function of the GUI, handling the display position and color of a point in the buffer.
void Paint_SetPixel(UWORD Xpoint, UWORD Ypoint, UWORD Color)
Parameters:
 	Xpoint: X position of the point in the image cache
 	Ypoint: Y position of the point in the image cache
 	Color: Color of the dot display
  • Image Buffer Fill Color: Fill the image buffer with a certain color, generally used as a screen white-out function.
void Paint_Clear(UWORD Color)
Parameters:
 	Color: fill color
  • Fill a portion of the image buffer with a specified color: This function fills a specified portion of the image buffer with a particular color. It is commonly used for functions such as clearing a window, and often used in displaying time, for example, clearing the display of the previous second.
void Paint_ClearWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color)
Parameters:
 	Xstart: X starting point coordinates of the window
 	Ystart: Y starting point coordinates of the window
 	Xend: X endpoint coordinates of the window
 	Yend: Y endpoint coordinates of the window
 	Color: fill color
  • Draw points: Draw points on (Xpoint, Ypoint) in the image buffer, you can choose the color, point size, and point style.
void Paint_DrawPoint(UWORD Xpoint, UWORD Ypoint, UWORD Color, DOT_PIXEL Dot_Pixel, DOT_STYLE Dot_Style)
Parameters:
 	Xpoint: X coordinate of the point
 	Ypoint: Y coordinate of the point
 	Color:  Fill color
 	Dot_Pixel: Dot size, provides default 8 sizes of dots
 	 	 typedef enum {
 	 	 	 DOT_PIXEL_1X1  = 1,	// 1 x 1
 	 	 	 DOT_PIXEL_2X2  , 		// 2 X 2
 	 	 	 DOT_PIXEL_3X3  , 	 	// 3 X 3
 	 	 	 DOT_PIXEL_4X4  , 	 	// 4 X 4
 	 	 	 DOT_PIXEL_5X5  , 		// 5 X 5
 	 	 	 DOT_PIXEL_6X6  , 		// 6 X 6
 	 	 	 DOT_PIXEL_7X7  , 		// 7 X 7
 	 	 	 DOT_PIXEL_8X8  , 		// 8 X 8
 	 	} DOT_PIXEL;
 	Dot_Style: dot style and size expansion method determine whether the expansion is centered around the point or extends from the bottom left corner of the point towards the top right 
 	 	typedef enum {
 	 	   DOT_FILL_AROUND  = 1,		
 	 	   DOT_FILL_RIGHTUP,
 	 	} DOT_STYLE;
  • Draw Line: Draw a line in the image buffer from (Xstart, Ystart) to (Xend, Yend). You can choose the color, line width, and line style.
void Paint_DrawLine(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color, LINE_STYLE Line_Style , LINE_STYLE Line_Style)
Parameters:
 	Xstart: Coordinates of the X starting point of the line
 	Ystart: Coordinates of the Y starting point of the line
 	Xend: X endpoint coordinates of the line
 	Yend: Y endpoint coordinates of the line
 	Color: Fill color
 	Line_width: Line width, provides default 8 widths
 	 	typedef enum {
 	 	 	 DOT_PIXEL_1X1  = 1,	// 1 x 1
 	 	 	 DOT_PIXEL_2X2  , 		// 2 X 2
 	 	 	 DOT_PIXEL_3X3  ,		// 3 X 3
 	 	 	 DOT_PIXEL_4X4  ,		// 4 X 4
 	 	 	 DOT_PIXEL_5X5  , 		// 5 X 5
 	 	 	 DOT_PIXEL_6X6  , 		// 6 X 6
 	 	 	 DOT_PIXEL_7X7  , 		// 7 X 7
 	 	 	 DOT_PIXEL_8X8  , 		// 8 X 8
 	 	} DOT_PIXEL;
 	 Line_Style: Line style, choose whether the lines are to be connected in a straight line or a dotted line.
 	 	typedef enum {
 	 	 	 LINE_STYLE_SOLID = 0,
 	 	 	 LINE_STYLE_DOTTED,
 	 	} LINE_STYLE;
  • Draw Rectangle: Draw a rectangle from (Xstart, Ystart) to (Xend, Yend) in the image buffer, you can choose the color, the width of the line, and whether to fill the inside of the rectangle or not.
void Paint_DrawRectangle(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)
Parameters:
 	Xstart: X starting point coordinates of the rectangle
 	Ystart: Y starting point coordinates of the rectangle
 	Xend: X endpoint coordinates of the rectangle
 	Yend: Y endpoint coordinates of the rectangle
 	Color: Fill color
 	Line_width: The width of the four sides of the rectangle, providing the default 8 widths
 	 	typedef enum {
 	 	 	 DOT_PIXEL_1X1  = 1,	// 1 x 1
 	 	 	 DOT_PIXEL_2X2  , 		// 2 X 2
 	 	 	 DOT_PIXEL_3X3  ,		// 3 X 3
 	 	 	 DOT_PIXEL_4X4  ,		// 4 X 4
 	 	 	 DOT_PIXEL_5X5  , 		// 5 X 5
 	 	 	 DOT_PIXEL_6X6  , 		// 6 X 6
 	 	 	 DOT_PIXEL_7X7  , 		// 7 X 7
 	 	 	 DOT_PIXEL_8X8  , 		// 8 X 8
 	 	} DOT_PIXEL;
 	Draw_Fill: Fill, in whether to fill the interior of the rectangle
 	 	typedef enum {
 	 	 	 DRAW_FILL_EMPTY = 0,
 	 	 	 DRAW_FILL_FULL,
 	 	} DRAW_FILL;
  • Draw Circle: Draw a circle in the image buffer with (X_Center, Y_Center) as the center and a radius of Radius. You can choose the color, line width, and whether to fill the interior of the circle.
void Paint_DrawCircle(UWORD X_Center, UWORD Y_Center, UWORD Radius, UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)
Parameters:
 	X_Center: X coordinate of the center of the circle
 	Y_Center: Y coordinate of the center of the circle
 	Radius: radius of a circle
 	Color: fill color
 	Line_width: The width of the arc, provides the default 8 widths
 	 	typedef enum {
 	 	 	 DOT_PIXEL_1X1  = 1,	// 1 x 1
 	 	 	 DOT_PIXEL_2X2  , 		// 2 X 2
 	 	 	 DOT_PIXEL_3X3  ,		// 3 X 3
 	 	 	 DOT_PIXEL_4X4  ,		// 4 X 4
 	 	 	 DOT_PIXEL_5X5  , 		// 5 X 5
 	 	 	 DOT_PIXEL_6X6  , 		// 6 X 6
 	 	 	 DOT_PIXEL_7X7  , 		// 7 X 7
 	 	 	 DOT_PIXEL_8X8  , 		// 8 X 8
 	 	} DOT_PIXEL;
 	Draw_Fill: Fill, whether to fill the inside of the circle
 	 	typedef enum {
 	 	 	 DRAW_FILL_EMPTY = 0,
 	 	 	 DRAW_FILL_FULL,
 	 	} DRAW_FILL;
  • Write Ascii Character: Write an Ascii character in the image buffer with (Xstart, Ystart) as the top-left corner. You can choose the Ascii code, visual character font library, foreground color, and background color of the font.
void Paint_DrawChar(UWORD Xstart, UWORD Ystart, const char Ascii_Char, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background)
Parameters:
 	Xstart: X coordinate of the left vertex of the character
 	Ystart: Y coordinate of the left vertex of the character
 	Ascii_Char:Ascii characters
 	Font: Ascii code visual character font, the following fonts are provided in the Fonts folder:
 	 	font8: 5*8 font
 	 	font12: 7*12 font
 	 	font16: 11*16 font
 	 	font20: 14*20 font
 	 	font24: 17*24 font
 	Color_Foreground: font color
 	Color_Background: background color
  • Write English String: Write a string of English characters in the image buffer with (Xstart, Ystart) as the top-left corner. You can choose the Ascii code, visual character font library, foreground color, and background color of the font.
void Paint_DrawString_EN(UWORD Xstart, UWORD Ystart, const char * pString, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background)
Parameters:
 	Xstart: X coordinate of the left vertex of the character
 	Ystart: Y coordinate of the left vertex of the character
 	pString: String, string is a pointer
 	Font: Ascii code visual character font, the following fonts are provided in the Fonts folder:
 	 	font8: 5*8 font
 	 	font12: 7*12 font
 	 	font16: 11*16 font
 	 	font20: 14*20 font
 	 	font24: 17*24 font
 	Color_Foreground: font color
 	Color_Background: background color
  • Write Chinese String: Write a string of Chinese characters in the image buffer with (Xstart, Ystart) as the top-left corner. You can choose the GB2312 encoding character font library, foreground color, and background color of the font.
void Paint_DrawString_CN(UWORD Xstart, UWORD Ystart, const char * pString, cFONT* font, UWORD Color_Foreground, UWORD Color_Background)
Parameters:
        Xstart: X coordinate of the left vertex of the character
 	Ystart: Y coordinate of the left vertex of the character
 	pString: String, string is a pointer
 	Font: GB2312 encoded character font, the following fonts are provided in the Fonts folder:
 	 	font12CN: ascii character font 11*21, Chinese font 16*21
 	 	font24CN: ascii character font 24*41, Chinese font 32*41
 	Color_Foreground: font color
 	Color_Background: Background color
  • Write Numbers: Write a string of numbers in the image buffer with (Xstart, Ystart) as the top-left corner. You can choose the Ascii code, visual character font library, foreground color, and background color of the font.
void Paint_DrawNum(UWORD Xpoint, UWORD Ypoint, double Nummber, sFONT* Font, UWORD Digit,UWORD Color_Foreground, UWORD Color_Background);
Parameters:
 	Xstart: X coordinate of the left vertex of the character
 	Ystart: Y coordinate of the left vertex of the character
 	Nummber: The displayed numbers are stored as 32-bit integers, capable of displaying up to 2147483647.
 	Font: Ascii character visual character font library in the Fonts folder provides the following fonts:
 	 	font8: 5*8 font
 	 	font12: 7*12 font
 	 	font16: 11*16 font
 	 	font20: 14*20 font
 	 	font24: 17*24 font
        Digit: Display decimal places
 	Color_Foreground: font color 
 	Color_Background: Background color
  • Display time: In the image buffer, display a period with (Xstart, Ystart) as the top-left corner. You can choose the Ascii code, visual character font library, foreground color, and background color of the font.
void Paint_DrawTime(UWORD Xstart, UWORD Ystart, PAINT_TIME *pTime, sFONT* Font, UWORD Color_Background, UWORD Color_Foreground)
Parameters:
 	Xstart: X coordinate of the left vertex of the character
 	Ystart: Y coordinate of the left vertex of the character
 	pTime:  The displayed time is defined using a time structure. You only need to pass the individual digits of hours, minutes, and seconds as parameters.
 	Font: Ascii code visual character font, the following fonts are provided in the Fonts folder:
 	 	font8: 5*8 font
 	 	font12: 7*12 font
 	 	font16: 11*16 font
 	 	font20: 14*20 font
 	 	font24: 17*24 font
 	Color_Foreground: Font color
 	Color_Background: Background color

QMI8658

  • Module initialization:
unsigned char QMI8658_init(void);
  • Read data:
void QMI8658_read_xyz(float acc[3], float gyro[3], unsigned int *tim_count);
Parameter:
	 float acc[3]:  An array to store acceleration values, represented as floating-point numbers, containing three elements for the X, Y, and Z axes respectively
	 float gyro[3]: An array to store gyroscope values, represented as floating-point numbers, containing three elements for the angular velocity on the X, Y, and Z axes respectively.

Python

Low-level Hardware Interface

  • Module initialization:
def __init__(self)
  • Send commands:
def write_cmd(self, cmd)
  • Send data:
def write_data(self, buf)
  • Backlight adjustment:
def set_bl_pwm(self,duty)

Drawing GUI

  • Input the library:
import framebuf
  • Create the object:

Customize the class LCD_0inch99 which inherits from the framebuf. FrameBuffer class in MicroPython. This class provides various methods for drawing images. Let's first create an object of the LCD_0inch99 class.

LCD = LCD_0inch99()
  • Draw a line:
LCD.line(x1, y1, x2, y2, color)
Parameter:
	x1, y1: x and y coordinates of the starting point
	x2, y2: x and y coordinates of the ending point
	color:  Line color
  • Draw a rectangle:
LCD.fill_rect(x1, y1, w, h, color)
Parameters:
	x1, y1: The x and y coordinates of the top-left corner of the rectangle
        w, h: Width and height of the rectangle
        color: the filling color of the rectangle
  • Write the text:
LCD.text(str, x, y, color)
Parameters:
         str: display the text
	 x, y:  The x and y coordinates of the upper left corner of the text
         color: text color
  • Change the text size:
LCD.write_text(str, x, y, size, color)
Parameters:
	 size: The difference between this function and LCD.text is that it supports custom font sizes. This parameter is used to specify the font size.
  • Display:
LCD.show()

QMI8658

  • Create an object:
qmi8658=QMI8658()
  • Read and parse XYZ data from sensors:
xyz=qmi8658.Read_XYZ()
Return Value:
          xyz[0]~xyz[2]: The function returns an array, where the first three elements represent the acceleration values on the X, Y, and Z axes respectively.
	  xyz[3]~xyz[5]: These three elements represent the angular velocities in the X, Y, and Z axes.

Resource

Waveshare Resource

Demo

Schematic

Datasheet

Official Resource

Official Raspberry Pi Documents

Raspberry Pi Demo

Development Software

Support



Technical Support

If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)