libpynq (release 5EWC0-2023 version 0.2.2 of 2023-09-24 22:22)
Loading...
Searching...
No Matches
display.h
Go to the documentation of this file.
1/*
2Copyright (c) 2023 Eindhoven University of Technology
3
4Permission is hereby granted, free of charge, to any person obtaining a copy
5of this software and associated documentation files (the "Software"), to deal
6in the Software without restriction, including without limitation the rights
7to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the Software is
9furnished to do so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall be included in all
12copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20SOFTWARE.
21*/
22#ifndef SCREEN_H
23#define SCREEN_H
24
25#include <fontx.h>
26#include <stdbool.h>
27#include <stdint.h>
28#include <stdio.h>
29#include <string.h>
30
79#define DISPLAY_HEIGHT 240
80#define DISPLAY_WIDTH 240
81
85enum colors {
86 RGB_RED = 0xf800,
87 RGB_GREEN = 0x07e0,
88 RGB_BLUE = 0x001f,
89 RGB_BLACK = 0x0000,
90 RGB_WHITE = 0xffff,
91 RGB_GRAY = 0x8c51,
92 RGB_YELLOW = 0xFFE0,
93 RGB_CYAN = 0x07FF,
94 RGB_PURPLE = 0xF81F
95};
96
107
112typedef struct {
113 uint16_t _width;
114 uint16_t _height;
115 uint16_t _offsetx;
116 uint16_t _offsety;
118 uint16_t _font_fill;
122 int16_t _dc;
123 int16_t _bl;
124} display_t;
125
130extern void display_init(display_t *display);
131
136extern void display_destroy(display_t *display);
137
145extern void displayDrawPixel(display_t *display, uint16_t x, uint16_t y,
146 uint16_t color);
147
157extern void displayDrawFillRect(display_t *display, uint16_t x1, uint16_t y1,
158 uint16_t x2, uint16_t y2, uint16_t color);
159
166extern void displayFillScreen(display_t *display, uint16_t color);
167
177extern void displayDrawLine(display_t *display, uint16_t x1, uint16_t y1,
178 uint16_t x2, uint16_t y2, uint16_t color);
179
189extern void displayDrawRect(display_t *display, uint16_t x1, uint16_t y1,
190 uint16_t x2, uint16_t y2, uint16_t color);
191
204extern void displayDrawRectAngle(display_t *display, uint16_t xc, uint16_t yc,
205 uint16_t w, uint16_t h, uint16_t angle,
206 uint16_t color);
207
218extern void displayDrawTriangleCenter(display_t *display, uint16_t xc,
219 uint16_t yc, uint16_t w, uint16_t h,
220 uint16_t angle, uint16_t color);
221
230extern void displayDrawCircle(display_t *display, uint16_t x_center,
231 uint16_t y_center, uint16_t r, uint16_t color);
232
241extern void displayDrawFillCircle(display_t *display, uint16_t x_center,
242 uint16_t y_center, uint16_t r,
243 uint16_t color);
244
255extern void displayDrawRoundRect(display_t *display, uint16_t x1, uint16_t y1,
256 uint16_t x2, uint16_t y2, uint16_t r,
257 uint16_t color);
258
265extern uint16_t rgb_conv(uint16_t r, uint16_t g, uint16_t b);
266
281extern int displayDrawChar(display_t *display, FontxFile *fx, uint16_t x,
282 uint16_t y, uint8_t ascii, uint16_t color);
283
299extern int displayDrawString(display_t *display, FontxFile *fx, uint16_t x,
300 uint16_t y, uint8_t *ascii, uint16_t color);
301
307extern void displaySetFontDirection(display_t *display, uint16_t dir);
308
315extern void displaySetFontFill(display_t *display, uint16_t color);
316
323extern void displayUnsetFontFill(display_t *display);
324
332extern void displaySetFontUnderLine(display_t *display, uint16_t color);
333
338extern void displayUnsetFontUnderLine(display_t *display);
339
344extern void displayDisplayOff(display_t *display);
345
354extern void displayDisplayOn(display_t *display);
355
360extern void displayBacklightOff(display_t *display);
361
366extern void displayBacklightOn(display_t *display);
367
372extern void displayInversionOff(display_t *display);
373
378extern void displayInversionOn(display_t *display);
379
393extern void displayDrawTriangle(display_t *display, uint16_t x1, uint16_t y1,
394 uint16_t x2, uint16_t y2, uint16_t x3,
395 uint16_t y3, uint16_t color);
396
403void display_set_flip(display_t *display, bool xflip, bool yflip);
408#endif /* MAIN_ST7789_H_ */
int displayDrawString(display_t *display, FontxFile *fx, uint16_t x, uint16_t y, uint8_t *ascii, uint16_t color)
Function to draw a string on the display.
Definition display.c:947
void display_set_flip(display_t *display, bool xflip, bool yflip)
Flip the drawing off the screen.
Definition display.c:275
void displayDrawFillRect(display_t *display, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Draw a filled rectangle to the display.
Definition display.c:357
void displaySetFontUnderLine(display_t *display, uint16_t color)
Turns on _font_underline in the display handle and sets the _font_underline_color to the specified co...
Definition display.c:995
void display_destroy(display_t *display)
Stop using the display.
void displaySetFontDirection(display_t *display, uint16_t dir)
Changes the direction the characters will be printed.
Definition display.c:978
void displayDrawTriangle(display_t *display, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3, uint16_t color)
Draw a triangle without infill between the three given points in the given color.
Definition display.c:549
void displaySetFontFill(display_t *display, uint16_t color)
Enables the _font_fill and sets the _font_fill_color in the display handle.
Definition display.c:985
void displayDrawRect(display_t *display, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Draw a filled rectangle.
Definition display.c:474
void displayUnsetFontFill(display_t *display)
Sets the _font_fill parameter to false in the display handle, turns off the font fill.
Definition display.c:993
void display_init(display_t *display)
Initialize the display display.
Definition display.c:297
uint16_t rgb_conv(uint16_t r, uint16_t g, uint16_t b)
RGB conversion for generating a color.
Definition display.c:774
void displayDisplayOff(display_t *display)
Turn off the display.
Definition display.c:399
void displayDrawLine(display_t *display, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Draw a line from two coordinates.
Definition display.c:421
void displayInversionOff(display_t *display)
Turn off inversion of the colors.
Definition display.c:1028
void displayDrawRoundRect(display_t *display, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t r, uint16_t color)
Draw a rectangle with rounded angles.
Definition display.c:704
void displayInversionOn(display_t *display)
Turn on inversion of the colors.
Definition display.c:1035
int displayDrawChar(display_t *display, FontxFile *fx, uint16_t x, uint16_t y, uint8_t ascii, uint16_t color)
Draws a character on the given coordinates of the display.
Definition display.c:778
directions
Enum of directions the text can be printed on on the display.
Definition display.h:100
void displayBacklightOn(display_t *display)
Turn on the display backlight.
Definition display.c:1019
void displayDrawCircle(display_t *display, uint16_t x_center, uint16_t y_center, uint16_t r, uint16_t color)
Draw a circle without infill on the display.
Definition display.c:617
void displayFillScreen(display_t *display, uint16_t color)
Fill entire display with a single color using the ldcDrawFillRect function.
Definition display.c:413
void displayBacklightOff(display_t *display)
Turn off the display backlight.
Definition display.c:1010
void displayDisplayOn(display_t *display)
Initialize DISPLAY screen.
Definition display.c:406
void displayUnsetFontUnderLine(display_t *display)
Turns off _font_underline in the display handle.
Definition display.c:1003
void displayDrawPixel(display_t *display, uint16_t x, uint16_t y, uint16_t color)
Draw a single pixel to the display.
Definition display.c:313
colors
Colors that can be used with the display.
Definition display.h:85
void displayDrawRectAngle(display_t *display, uint16_t xc, uint16_t yc, uint16_t w, uint16_t h, uint16_t angle, uint16_t color)
Draws a rectangle with rounded corners at a specified angle on the display.
Definition display.c:492
void displayDrawFillCircle(display_t *display, uint16_t x_center, uint16_t y_center, uint16_t r, uint16_t color)
Draw a circle with infill on the display.
Definition display.c:658
void displayDrawTriangleCenter(display_t *display, uint16_t xc, uint16_t yc, uint16_t w, uint16_t h, uint16_t angle, uint16_t color)
Draws a triangle at a specified angle on the display.
Definition display.c:576
@ TEXT_DIRECTION180
Definition display.h:103
@ TEXT_DIRECTION90
Definition display.h:102
@ NUM_TEXT_DIRECTIONS
Definition display.h:105
@ TEXT_DIRECTION270
Definition display.h:104
@ TEXT_DIRECTION0
Definition display.h:101
@ RGB_PURPLE
Definition display.h:94
@ RGB_BLACK
Definition display.h:89
@ RGB_BLUE
Definition display.h:88
@ RGB_GRAY
Definition display.h:91
@ RGB_YELLOW
Definition display.h:92
@ RGB_RED
Definition display.h:86
@ RGB_GREEN
Definition display.h:87
@ RGB_WHITE
Definition display.h:90
@ RGB_CYAN
Definition display.h:93
Struct representing a font file.
Definition fontx.h:28
Internal type, do not use. Type of display that stores parameters for usage in different functions.
Definition display.h:112
uint16_t _font_fill_color
Definition display.h:119
uint16_t _font_fill
Definition display.h:118
uint16_t _offsety
Definition display.h:116
uint16_t _width
Definition display.h:113
uint16_t _font_direction
Definition display.h:117
int16_t _bl
Definition display.h:123
int16_t _dc
Definition display.h:122
uint16_t _font_underline_color
Definition display.h:121
uint16_t _font_underline
Definition display.h:120
uint16_t _height
Definition display.h:114
uint16_t _offsetx
Definition display.h:115