Skip to content

Conversation

@bmorcelli
Copy link
Member

Still need to add MUTEX to these other libraries

@bmorcelli bmorcelli marked this pull request as draft January 15, 2026 14:35
@bmorcelli bmorcelli marked this pull request as ready for review January 15, 2026 14:50
Comment on lines +26 to +35

void tft_sprite::fillScreen(uint32_t color) { TFT_eSprite::fillSprite(color); }

void tft_sprite::fillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color) {
TFT_eSprite::fillRect(x, y, w, h, color);
}

void tft_sprite::fillCircle(int32_t x, int32_t y, int32_t r, uint32_t color) {
TFT_eSprite::fillCircle(x, y, r, color);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if my solution with implementing it on library side was a mistake.
I think cleaner solution will be to put all code with mutexes in our HAL.
That way we would not modify all libraries that we are including, so we don't have to fork and maintain them.
And when we find that other device (speaker or sensor) that is using the same bus/peripheral and using them simultaneously with display is causing panic and reboots, we can share mutexes between them easily.

So like this:

Suggested change
void tft_sprite::fillScreen(uint32_t color) { TFT_eSprite::fillSprite(color); }
void tft_sprite::fillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color) {
TFT_eSprite::fillRect(x, y, w, h, color);
}
void tft_sprite::fillCircle(int32_t x, int32_t y, int32_t r, uint32_t color) {
TFT_eSprite::fillCircle(x, y, r, color);
}
static SemaphoreHandle_t tftMutex;
void tft_sprite::fillScreen(uint32_t color) {
xSemaphoreTakeRecursive(tftMutex, portMAX_DELAY);
TFT_eSprite::fillSprite(color);
xSemaphoreGiveRecursive(tftMutex);
}
void tft_sprite::fillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color) {
xSemaphoreTakeRecursive(tftMutex, portMAX_DELAY);
TFT_eSprite::fillRect(x, y, w, h, color);
xSemaphoreGiveRecursive(tftMutex);
}
void tft_sprite::fillCircle(int32_t x, int32_t y, int32_t r, uint32_t color) {
xSemaphoreTakeRecursive(tftMutex, portMAX_DELAY);
TFT_eSprite::fillCircle(x, y, r, color);
xSemaphoreGiveRecursive(tftMutex);
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! I'll do it on Monday!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! I'll do it on Monday!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants