Display Module¶
Note
Drawing¶
Colors¶
Before drawing anything, the desired color needs to be set. There are two colors that can be set, a foreground and a background color.
All primitives as well as text are drawn using the foreground color. The background of characters as well as clearing the screen are using the background color.
// Set the foreground color to yellow
LCD_SetForegroundColor(ColorYellow);
// Set the background color to blue
LCD_SetBackgroundColor(ColorBlue);
-
void LCD_SetForegroundColor(color_t color)¶
Sets the LCD foreground color (used for primitives, text, etc)
- Parameters
color – Foreground color
-
void LCD_SetBackgroundColor(color_t color)¶
- Parameters
Sets – the LCD background color (used for the background)
color – Foreground color
Primitives¶
Primitives are basic shapes that can be combined into more complex shapes.
Rectangles¶
// Draw a green square starting at position [X: 100, Y: 200] with a side length of 50
LCD_SetForegroundColor(ColorGreen);
LCD_Rect(100, 200, 50, 50);
-
result_t LCD_Rect(uint16_t x, uint16_t y, uint16_t width, uint16_t height)¶
Draws a rectangle with the current foreground color.
- Parameters
x – Top left corner X coordinate
y – Top left corner Y coordinate
width – Rectangle width
height – Rectangle height
- Returns
Status result
Lines¶
// Draw a red line from position [X: 50, Y: 80] to [X: 250, Y: 300]
LCD_SetForegroundColor(ColorRed);
LCD_Line(50, 80, 250, 300);;
-
result_t LCD_Line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)¶
Draws a line with the current foreground color.
- Parameters
x1 – X coordinate of the start of the line
y1 – Y coordinate of the start of the line
x2 – X coordinate of the end of the line
y2 – Y coordinate of the end of the line
- Returns
Status result
Circle¶
// Draw a green circle with radius 50 at position [X: 225, Y: 150]
LCD_SetForegroundColor(ColorGreen);
LCD_Circle(225, 150, 50);
-
result_t LCD_Circle(uint16_t center_x, uint16_t center_y, uint16_t radius)¶
Draws a circle with the current foreground color.
- Parameters
center_x – X coordinate of the center of the circle
center_y – Y coordinate of the center of the circle
radius – Circle radius
- Returns
Status result
Text¶
// Draw a green "Hello World" text with a blue background at position [X: 100, Y:300]
LCD_SetForegroundColor(ColorGreen);
LCD_SetBackgroundColor(ColorBlue);
LCD_String(100, 300, "Hello World");
-
result_t LCD_String(uint16_t start_x, uint16_t start_y, const char *string)¶
Draws a NULL terminated string with the current foreground color.
- Parameters
start_x – Start X coordinate of the string
start_y – Start Y coordinate of the string
string – String to draw
- Returns
Status result
Touch Screen¶
The LCD display also has touch support. The currently touched position can be read out using the following code.
LCD_TouchPosition_t touchPosition;
if (R_SUCCESS(LCD_TouchGetPosition(&touchPosition))) {
uint16_t x = touchPosition.x;
uint16_t y = touchPosition.y;
// Use touch coords
}
-
result_t LCD_TouchGetPosition(LCD_TouchPosition_t *position)¶
Gets the currently touched position on the screen.
- Parameters
position – Touch coordinate. (0, 0) if untouched
- Returns
Status result