@@ -40,7 +40,127 @@ LcdScreen::LcdScreen(uint8_t CS, uint8_t RS, uint8_t RST)
40
40
{ }
41
41
42
42
void LcdScreen::begin () {
43
- // initR(INITR_REDTAB);
44
43
initG ();
45
44
setRotation (1 );
46
45
}
46
+
47
+ // Arduino TFT library compatibility.
48
+
49
+ void LcdScreen::background (uint8_t red, uint8_t green, uint8_t blue) {
50
+ background (Color565 (red, green, blue));
51
+ }
52
+
53
+ void LcdScreen::background (color c) {
54
+ fillScreen (c);
55
+ }
56
+
57
+ void LcdScreen::stroke (uint8_t red, uint8_t green, uint8_t blue) {
58
+ stroke (Color565 (red, green, blue));
59
+ }
60
+
61
+ void LcdScreen::stroke (color c) {
62
+ useStroke = true ;
63
+ strokeColor = c;
64
+ setTextColor (c);
65
+ }
66
+
67
+ void LcdScreen::noStroke () {
68
+ useStroke = false ;
69
+ }
70
+
71
+ void LcdScreen::noFill () {
72
+ useFill = false ;
73
+ }
74
+
75
+ void LcdScreen::fill (uint8_t red, uint8_t green, uint8_t blue) {
76
+ fill (Color565 (red, green, blue));
77
+ }
78
+
79
+ void LcdScreen::fill (color c) {
80
+ useFill = true ;
81
+ fillColor = c;
82
+ }
83
+
84
+ void LcdScreen::point (int16_t x, int16_t y) {
85
+ if (!useStroke)
86
+ return ;
87
+
88
+ drawPixel (x, y, strokeColor);
89
+ }
90
+
91
+ void LcdScreen::text (const char * text, int16_t x, int16_t y) {
92
+ if (!useStroke)
93
+ return ;
94
+
95
+ setTextWrap (false );
96
+ setTextColor (strokeColor);
97
+ setCursor (x, y);
98
+ print (text);
99
+ }
100
+
101
+ void LcdScreen::textSize (uint8_t size) {
102
+ setTextSize (size);
103
+ }
104
+
105
+ void LcdScreen::line (int16_t x1, int16_t y1, int16_t x2, int16_t y2) {
106
+ if (!useStroke)
107
+ return ;
108
+
109
+ if (x1 == x2) {
110
+ if (y1 < y2)
111
+ drawFastVLine (x1, y1, y2 - y1, strokeColor);
112
+ else
113
+ drawFastVLine (x1, y2, y1 - y2, strokeColor);
114
+ }
115
+ else if (y1 == y2) {
116
+ if (x1 < x2)
117
+ drawFastHLine (x1, y1, x2 - x1, strokeColor);
118
+ else
119
+ drawFastHLine (x2, y1, x1 - x2, strokeColor);
120
+ }
121
+ else {
122
+ drawLine (x1, y1, x2, y2, strokeColor);
123
+ }
124
+ }
125
+
126
+ void LcdScreen::rect (int16_t x, int16_t y, int16_t width, int16_t height) {
127
+ if (useFill) {
128
+ fillRect (x, y, width, height, fillColor);
129
+ }
130
+ if (useStroke) {
131
+ drawRect (x, y, width, height, strokeColor);
132
+ }
133
+ }
134
+
135
+ void LcdScreen::rect (int16_t x, int16_t y, int16_t width, int16_t height, int16_t radius) {
136
+ if (radius == 0 ) {
137
+ rect (x, y, width, height);
138
+ }
139
+ if (useFill) {
140
+ fillRoundRect (x, y, width, height, radius, fillColor);
141
+ }
142
+ if (useStroke) {
143
+ drawRoundRect (x, y, width, height, radius, strokeColor);
144
+ }
145
+ }
146
+
147
+ void LcdScreen::circle (int16_t x, int16_t y, int16_t r) {
148
+ if (r == 0 )
149
+ return ;
150
+
151
+ if (useFill) {
152
+ fillCircle (x, y, r, fillColor);
153
+ }
154
+ if (useStroke) {
155
+ drawCircle (x, y, r, strokeColor);
156
+ }
157
+ }
158
+
159
+ void LcdScreen::triangle (int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t x3, int16_t y3) {
160
+ if (useFill) {
161
+ fillTriangle (x1, y1, x2, y2, x3, y3, fillColor);
162
+ }
163
+ if (useStroke) {
164
+ drawTriangle (x1, y1, x2, y2, x3, y3, strokeColor);
165
+ }
166
+ }
0 commit comments