libpynq (release 5EWC0-2023 version 0.2.6 of 2023-10-24 17:28)
Loading...
Searching...
No Matches
display.h
Go to the documentation of this file.
1/*
2MIT License
3
4Copyright (c) 2020
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in all
14copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22SOFTWARE.
23
24Modified by Eindhoven University of Technology 2023.
25*/
26#ifndef SCREEN_H
27#define SCREEN_H
28
29#include <fontx.h>
30#include <stdbool.h>
31#include <stdint.h>
32#include <stdio.h>
33#include <string.h>
34
83#define DISPLAY_HEIGHT 240
84#define DISPLAY_WIDTH 240
85
89enum colors {
90 RGB_RED = 0xf800,
91 RGB_GREEN = 0x07e0,
92 RGB_BLUE = 0x001f,
93 RGB_BLACK = 0x0000,
94 RGB_WHITE = 0xffff,
95 RGB_GRAY = 0x8c51,
96 RGB_YELLOW = 0xFFE0,
97 RGB_CYAN = 0x07FF,
98 RGB_PURPLE = 0xF81F
99};
100
111
116typedef struct {
117 uint16_t _width;
118 uint16_t _height;
119 uint16_t _offsetx;
120 uint16_t _offsety;
122 uint16_t _font_fill;
126 int16_t _dc;
127 int16_t _bl;
128} display_t;
129
134extern void display_init(display_t *display);
135
140extern void display_destroy(display_t *display);
141
149extern void displayDrawPixel(display_t *display, uint16_t x, uint16_t y,
150 uint16_t color);
151
161extern void displayDrawFillRect(display_t *display, uint16_t x1, uint16_t y1,
162 uint16_t x2, uint16_t y2, uint16_t color);
163
170extern void displayFillScreen(display_t *display, uint16_t color);
171
181extern void displayDrawLine(display_t *display, uint16_t x1, uint16_t y1,
182 uint16_t x2, uint16_t y2, uint16_t color);
183
193extern void displayDrawRect(display_t *display, uint16_t x1, uint16_t y1,
194 uint16_t x2, uint16_t y2, uint16_t color);
195
208extern void displayDrawRectAngle(display_t *display, uint16_t xc, uint16_t yc,
209 uint16_t w, uint16_t h, uint16_t angle,
210 uint16_t color);
211
222extern void displayDrawTriangleCenter(display_t *display, uint16_t xc,
223 uint16_t yc, uint16_t w, uint16_t h,
224 uint16_t angle, uint16_t color);
225
234extern void displayDrawCircle(display_t *display, uint16_t x_center,
235 uint16_t y_center, uint16_t r, uint16_t color);
236
245extern void displayDrawFillCircle(display_t *display, uint16_t x_center,
246 uint16_t y_center, uint16_t r,
247 uint16_t color);
248
259extern void displayDrawRoundRect(display_t *display, uint16_t x1, uint16_t y1,
260 uint16_t x2, uint16_t y2, uint16_t r,
261 uint16_t color);
262
269extern uint16_t rgb_conv(uint16_t r, uint16_t g, uint16_t b);
270
285extern int displayDrawChar(display_t *display, FontxFile *fx, uint16_t x,
286 uint16_t y, uint8_t ascii, uint16_t color);
287
303extern int displayDrawString(display_t *display, FontxFile *fx, uint16_t x,
304 uint16_t y, uint8_t *ascii, uint16_t color);
305
311extern void displaySetFontDirection(display_t *display, uint16_t dir);
312
319extern void displaySetFontFill(display_t *display, uint16_t color);
320
327extern void displayUnsetFontFill(display_t *display);
328
336extern void displaySetFontUnderLine(display_t *display, uint16_t color);
337
342extern void displayUnsetFontUnderLine(display_t *display);
343
348extern void displayDisplayOff(display_t *display);
349
358extern void displayDisplayOn(display_t *display);
359
364extern void displayBacklightOff(display_t *display);
365
370extern void displayBacklightOn(display_t *display);
371
376extern void displayInversionOff(display_t *display);
377
382extern void displayInversionOn(display_t *display);
383
397extern void displayDrawTriangle(display_t *display, uint16_t x1, uint16_t y1,
398 uint16_t x2, uint16_t y2, uint16_t x3,
399 uint16_t y3, uint16_t color);
400
407void display_set_flip(display_t *display, bool xflip, bool yflip);
412#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:951
void display_set_flip(display_t *display, bool xflip, bool yflip)
Flip the drawing off the screen.
Definition display.c:279
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:361
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:999
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:982
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:553
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:989
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:478
void displayUnsetFontFill(display_t *display)
Sets the _font_fill parameter to false in the display handle, turns off the font fill.
Definition display.c:997
void display_init(display_t *display)
Initialize the display display.
Definition display.c:301
uint16_t rgb_conv(uint16_t r, uint16_t g, uint16_t b)
RGB conversion for generating a color.
Definition display.c:778
void displayDisplayOff(display_t *display)
Turn off the display.
Definition display.c:403
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:425
void displayInversionOff(display_t *display)
Turn off inversion of the colors.
Definition display.c:1032
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:708
void displayInversionOn(display_t *display)
Turn on inversion of the colors.
Definition display.c:1039
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:782
directions
Enum of directions the text can be printed on on the display.
Definition display.h:104
void displayBacklightOn(display_t *display)
Turn on the display backlight.
Definition display.c:1023
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:621
void displayFillScreen(display_t *display, uint16_t color)
Fill entire display with a single color using the ldcDrawFillRect function.
Definition display.c:417
void displayBacklightOff(display_t *display)
Turn off the display backlight.
Definition display.c:1014
void displayDisplayOn(display_t *display)
Initialize DISPLAY screen.
Definition display.c:410
void displayUnsetFontUnderLine(display_t *display)
Turns off _font_underline in the display handle.
Definition display.c:1007
void displayDrawPixel(display_t *display, uint16_t x, uint16_t y, uint16_t color)
Draw a single pixel to the display.
Definition display.c:317
colors
Colors that can be used with the display.
Definition display.h:89
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:496
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:662
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:580
@ TEXT_DIRECTION180
Definition display.h:107
@ TEXT_DIRECTION90
Definition display.h:106
@ NUM_TEXT_DIRECTIONS
Definition display.h:109
@ TEXT_DIRECTION270
Definition display.h:108
@ TEXT_DIRECTION0
Definition display.h:105
@ RGB_PURPLE
Definition display.h:98
@ RGB_BLACK
Definition display.h:93
@ RGB_BLUE
Definition display.h:92
@ RGB_GRAY
Definition display.h:95
@ RGB_YELLOW
Definition display.h:96
@ RGB_RED
Definition display.h:90
@ RGB_GREEN
Definition display.h:91
@ RGB_WHITE
Definition display.h:94
@ RGB_CYAN
Definition display.h:97
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:116
uint16_t _font_fill_color
Definition display.h:123
uint16_t _font_fill
Definition display.h:122
uint16_t _offsety
Definition display.h:120
uint16_t _width
Definition display.h:117
uint16_t _font_direction
Definition display.h:121
int16_t _bl
Definition display.h:127
int16_t _dc
Definition display.h:126
uint16_t _font_underline_color
Definition display.h:125
uint16_t _font_underline
Definition display.h:124
uint16_t _height
Definition display.h:118
uint16_t _offsetx
Definition display.h:119