@@ -40,7 +40,21 @@ void GigaDisplay_GFX::startWrite() {
40
40
41
41
void GigaDisplay_GFX::endWrite () {
42
42
// refresh_sem.release();
43
- _refresh_thd->flags_set (0x1 );
43
+ if (!buffering)
44
+ _refresh_thd->flags_set (0x1 );
45
+ }
46
+
47
+ // If buffering, defer endWrite calls until endBuffering is called.
48
+ void GigaDisplay_GFX::startBuffering () {
49
+ buffering = true ;
50
+ }
51
+
52
+ void GigaDisplay_GFX::endBuffering () {
53
+ if (buffering)
54
+ {
55
+ buffering = false ;
56
+ endWrite ();
57
+ }
44
58
}
45
59
46
60
void GigaDisplay_GFX::drawPixel (int16_t x, int16_t y, uint16_t color) {
@@ -102,6 +116,7 @@ uint16_t GigaDisplay_GFX::getRawPixel(int16_t x, int16_t y) {
102
116
103
117
void GigaDisplay_GFX::fillScreen (uint16_t color) {
104
118
if (hasBuffer ()) {
119
+ startWrite (); // PR #3
105
120
uint8_t hi = color >> 8 , lo = color & 0xFF ;
106
121
if (hi == lo) {
107
122
memset (buffer, lo, WIDTH * HEIGHT * 2 );
@@ -110,6 +125,7 @@ void GigaDisplay_GFX::fillScreen(uint16_t color) {
110
125
for (i = 0 ; i < pixels; i++)
111
126
buffer[i] = color;
112
127
}
128
+ endWrite (); // PR #3
113
129
}
114
130
}
115
131
@@ -215,19 +231,23 @@ void GigaDisplay_GFX::drawFastHLine(int16_t x, int16_t y, int16_t w,
215
231
216
232
void GigaDisplay_GFX::drawFastRawVLine (int16_t x, int16_t y, int16_t h,
217
233
uint16_t color) {
234
+ startWrite ();
218
235
// x & y already in raw (rotation 0) coordinates, no need to transform.
219
236
uint16_t *buffer_ptr = buffer + y * WIDTH + x;
220
237
for (int16_t i = 0 ; i < h; i++) {
221
238
(*buffer_ptr) = color;
222
239
buffer_ptr += WIDTH;
223
240
}
241
+ endWrite ();
224
242
}
225
243
226
244
void GigaDisplay_GFX::drawFastRawHLine (int16_t x, int16_t y, int16_t w,
227
245
uint16_t color) {
246
+ startWrite ();
228
247
// x & y already in raw (rotation 0) coordinates, no need to transform.
229
248
uint32_t buffer_index = y * WIDTH + x;
230
249
for (uint32_t i = buffer_index; i < buffer_index + w; i++) {
231
250
buffer[i] = color;
232
251
}
252
+ endWrite ();
233
253
}
0 commit comments