libpynq (release 5EWC0-2023 version 0.1.0 of 2023-08-14 14:01)
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
77#define DISPLAY_HEIGHT 240
78#define DISPLAY_WIDTH 240
79
83enum colors {
84 RGB_RED = 0xf800,
85 RGB_GREEN = 0x07e0,
86 RGB_BLUE = 0x001f,
87 RGB_BLACK = 0x0000,
88 RGB_WHITE = 0xffff,
89 RGB_GRAY = 0x8c51,
90 RGB_YELLOW = 0xFFE0,
91 RGB_CYAN = 0x07FF,
92 RGB_PURPLE = 0xF81F
93};
94
105
110typedef struct {
111 uint16_t _width;
112 uint16_t _height;
113 uint16_t _offsetx;
114 uint16_t _offsety;
116 uint16_t _font_fill;
120 int16_t _dc;
121 int16_t _bl;
122} display_t;
123
128void display_init(display_t *display);
129
135
143void displayDrawPixel(display_t *display, uint16_t x, uint16_t y,
144 uint16_t color);
145
155void displayDrawFillRect(display_t *display, uint16_t x1, uint16_t y1,
156 uint16_t x2, uint16_t y2, uint16_t color);
157
164void displayFillScreen(display_t *display, uint16_t color);
165
175void displayDrawLine(display_t *display, uint16_t x1, uint16_t y1, uint16_t x2,
176 uint16_t y2, uint16_t color);
177
187void displayDrawRect(display_t *display, uint16_t x1, uint16_t y1, uint16_t x2,
188 uint16_t y2, uint16_t color);
189
202void displayDrawRectAngle(display_t *display, uint16_t xc, uint16_t yc,
203 uint16_t w, uint16_t h, uint16_t angle,
204 uint16_t color);
205
216void displayDrawTriangleCenter(display_t *display, uint16_t xc, uint16_t yc,
217 uint16_t w, uint16_t h, uint16_t angle,
218 uint16_t color);
219
228void displayDrawCircle(display_t *display, uint16_t x_center, uint16_t y_center,
229 uint16_t r, uint16_t color);
230
239void displayDrawFillCircle(display_t *display, uint16_t x_center,
240 uint16_t y_center, uint16_t r, uint16_t color);
241
252void displayDrawRoundRect(display_t *display, uint16_t x1, uint16_t y1,
253 uint16_t x2, uint16_t y2, uint16_t r, uint16_t color);
254
261uint16_t rgb_conv(uint16_t r, uint16_t g, uint16_t b);
262
273int displayDrawChar(display_t *display, FontxFile *fx, uint16_t x, uint16_t y,
274 uint8_t ascii, uint16_t color);
275
287int displayDrawString(display_t *display, FontxFile *fx, uint16_t x, uint16_t y,
288 uint8_t *ascii, uint16_t color);
289
295void displaySetFontDirection(display_t *display, uint16_t dir);
296
303void displaySetFontFill(display_t *display, uint16_t color);
304
311void displayUnsetFontFill(display_t *display);
312
320void displaySetFontUnderLine(display_t *display, uint16_t color);
321
327
332void displayDisplayOff(display_t *display);
333
342void displayDisplayOn(display_t *display);
343
348void displayBacklightOff(display_t *display);
349
354void displayBacklightOn(display_t *display);
355
360void displayInversionOff(display_t *display);
361
366void displayInversionOn(display_t *display);
367
381void displayDrawTriangle(display_t *display, uint16_t x1, uint16_t y1,
382 uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3,
383 uint16_t color);
384
389#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:924
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:334
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:972
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:955
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:526
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:962
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:451
void displayUnsetFontFill(display_t *display)
Sets the _font_fill parameter to false in the display handle, turns off the font fill.
Definition display.c:970
void display_init(display_t *display)
Initialize the display display.
Definition display.c:275
uint16_t rgb_conv(uint16_t r, uint16_t g, uint16_t b)
RGB conversion for generating a color.
Definition display.c:751
void displayDisplayOff(display_t *display)
Turn off the display.
Definition display.c:376
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:398
void displayInversionOff(display_t *display)
Turn off inversion of the colors.
Definition display.c:1005
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:681
void displayInversionOn(display_t *display)
Turn on inversion of the colors.
Definition display.c:1012
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:755
directions
Enum of directions the text can be printed on on the display.
Definition display.h:98
void displayBacklightOn(display_t *display)
Turn on the display backlight.
Definition display.c:996
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:594
void displayFillScreen(display_t *display, uint16_t color)
Fill entire display with a single color using the ldcDrawFillRect function.
Definition display.c:390
void displayBacklightOff(display_t *display)
Turn off the display backlight.
Definition display.c:987
void displayDisplayOn(display_t *display)
Initialize DISPLAY screen.
Definition display.c:383
void displayUnsetFontUnderLine(display_t *display)
Turns off _font_underline in the display handle.
Definition display.c:980
void displayDrawPixel(display_t *display, uint16_t x, uint16_t y, uint16_t color)
Draw a single pixel to the display.
Definition display.c:290
colors
Colors that can be used with the display.
Definition display.h:83
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:469
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:635
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:553
@ TEXT_DIRECTION180
Definition display.h:101
@ TEXT_DIRECTION90
Definition display.h:100
@ NUM_TEXT_DIRECTIONS
Definition display.h:103
@ TEXT_DIRECTION270
Definition display.h:102
@ TEXT_DIRECTION0
Definition display.h:99
@ RGB_PURPLE
Definition display.h:92
@ RGB_BLACK
Definition display.h:87
@ RGB_BLUE
Definition display.h:86
@ RGB_GRAY
Definition display.h:89
@ RGB_YELLOW
Definition display.h:90
@ RGB_RED
Definition display.h:84
@ RGB_GREEN
Definition display.h:85
@ RGB_WHITE
Definition display.h:88
@ RGB_CYAN
Definition display.h:91
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:110
uint16_t _font_fill_color
Definition display.h:117
uint16_t _font_fill
Definition display.h:116
uint16_t _offsety
Definition display.h:114
uint16_t _width
Definition display.h:111
uint16_t _font_direction
Definition display.h:115
int16_t _bl
Definition display.h:121
int16_t _dc
Definition display.h:120
uint16_t _font_underline_color
Definition display.h:119
uint16_t _font_underline
Definition display.h:118
uint16_t _height
Definition display.h:112
uint16_t _offsetx
Definition display.h:113