-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtft.h
163 lines (141 loc) · 3.23 KB
/
tft.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
* File: tft.h
* Author: [email protected]
*
* Created on 6. November 2023, 18:45
*/
#ifndef TFT_H
#define TFT_H
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <util/delay.h>
#include "types.h"
#include "pins.h"
#include "usart.h"
#include "spi.h"
#include "colorspace.h"
#define SWRESET 0x01
#define SLPIN 0x10
#define SLPOUT 0x11
#define NORON 0x13
#define INVOFF 0x20
#define INVON 0x21
#define DISPON 0x29
#define CASET 0x2a
#define RASET 0x2b
#define RAMWR 0x2c
#define MADCTL 0x36
#define COLMOD 0x3a
#ifndef DISPLAY_WIDTH
#define DISPLAY_WIDTH 160
#endif
#ifndef DISPLAY_HEIGHT
#define DISPLAY_HEIGHT 128
#endif
#ifndef BGR
#define BGR 0
#endif
#ifndef INVERT
#define INVERT 0
#endif
#ifndef HFLIP
#define HFLIP 0
#endif
#ifndef VFLIP
#define VFLIP 0
#endif
/**
* Initializes the display.
*/
void initDisplay(void);
/**
* Displays a demo.
*/
void demoDisplay(void);
/**
* Draws a pixel at given coordinates and color.
*
* @param x
* @param y
* @param color
*/
void drawPixel(x_t x, y_t y, uint16_t color);
/**
* Draws a circle at given center coordinates, with given radius and color.
*
* @param x
* @param y
* @param radius
* @param color
*/
void drawCircle(x_t x, y_t y, uint16_t radius, uint16_t color);
/**
* Draws a rectangle at given origin, with given width, height and color.
*
* @param x
* @param y
* @param width
* @param height
* @param color
*/
void drawRectangle(x_t x, y_t y, width_t width, height_t height,
uint16_t color);
/**
* Sets to write data to display RAM.
*/
void writeStart(void);
/**
* Restart writing to display after SPI deselecting it.
*/
void writeRestart(void);
/**
* Writes the given byte to display RAM.
*
* @param byte
*/
void writeByte(uint8_t byte);
/**
* Completes writing data to display RAM.
*/
void writeEnd(void);
/**
* Sets the given color in the given area of the display.
*
* @param x in pixels, origin top left
* @param y in pixels, origin top left
* @param width width in pixels
* @param height height in pixels
* @param color 16-Bit (5/6/5) RGB color
*/
void fillArea(x_t x, y_t y,
width_t width, height_t height,
uint16_t color);
/**
* Sets the area to write image data to.
*
* @param x in pixels, origin top left
* @param y in pixels, origin top left
* @param width width of the bitmap in pixels
* @param height height of the bitmap in pixels
* @param hflip if image should be flipped horizontally
* @param vflip if image should be flipped vertically
*/
void setArea(x_t x, y_t y,
width_t width, height_t height,
bool hflip, bool vflip);
/**
* Writes image data to the previously set area.
*
* @param bitmap pointer to bitmap data in program memory
* @param width width of the bitmap in pixels
* @param height height of the bitmap in pixels
* @param space color space of the bitmap
* @param bg background color (used only with SPACE_MONO1)
* @param fg foreground color (used only with SPACE_MONO1)
*/
void writeData(const __flash uint8_t *bitmap,
width_t width, height_t height,
space_t space, uint16_t bg, uint16_t fg);
#endif /* TFT_H */