Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/Arduino_GigaDisplay_GFX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,21 @@ void GigaDisplay_GFX::startWrite() {

void GigaDisplay_GFX::endWrite() {
//refresh_sem.release();
_refresh_thd->flags_set(0x1);
if (!buffering)
_refresh_thd->flags_set(0x1);
}

// If buffering, defer endWrite calls until endBuffering is called.
void GigaDisplay_GFX::startBuffering() {
buffering = true;
}

void GigaDisplay_GFX::endBuffering() {
if (buffering)
{
buffering = false;
endWrite();
}
}

void GigaDisplay_GFX::drawPixel(int16_t x, int16_t y, uint16_t color) {
Expand Down Expand Up @@ -102,6 +116,7 @@ uint16_t GigaDisplay_GFX::getRawPixel(int16_t x, int16_t y) {

void GigaDisplay_GFX::fillScreen(uint16_t color) {
if (hasBuffer()) {
startWrite(); // PR #3
uint8_t hi = color >> 8, lo = color & 0xFF;
if (hi == lo) {
memset(buffer, lo, WIDTH * HEIGHT * 2);
Expand All @@ -110,6 +125,7 @@ void GigaDisplay_GFX::fillScreen(uint16_t color) {
for (i = 0; i < pixels; i++)
buffer[i] = color;
}
endWrite(); // PR #3
}
}

Expand Down Expand Up @@ -215,19 +231,23 @@ void GigaDisplay_GFX::drawFastHLine(int16_t x, int16_t y, int16_t w,

void GigaDisplay_GFX::drawFastRawVLine(int16_t x, int16_t y, int16_t h,
uint16_t color) {
startWrite();
// x & y already in raw (rotation 0) coordinates, no need to transform.
uint16_t *buffer_ptr = buffer + y * WIDTH + x;
for (int16_t i = 0; i < h; i++) {
(*buffer_ptr) = color;
buffer_ptr += WIDTH;
}
endWrite();
}

void GigaDisplay_GFX::drawFastRawHLine(int16_t x, int16_t y, int16_t w,
uint16_t color) {
startWrite();
// x & y already in raw (rotation 0) coordinates, no need to transform.
uint32_t buffer_index = y * WIDTH + x;
for (uint32_t i = buffer_index; i < buffer_index + w; i++) {
buffer[i] = color;
}
endWrite();
}
5 changes: 4 additions & 1 deletion src/Arduino_GigaDisplay_GFX.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class GigaDisplay_GFX : public Adafruit_GFX {

void startWrite();
void endWrite();
void startBuffering();
void endBuffering();

uint16_t color565(uint8_t red, uint8_t green, uint8_t blue) {
return ((red & 0xF8) << 8) | ((green & 0xFC) << 3) | (blue >> 3);
Expand All @@ -45,7 +47,8 @@ class GigaDisplay_GFX : public Adafruit_GFX {
private:
Arduino_H7_Video* display;
void refresh_if_needed();
bool need_refresh = false;
//bool need_refresh = false;
bool buffering = false;
uint32_t last_refresh = 0;
rtos::Thread* _refresh_thd;
};
Expand Down