Skip to content

Commit

Permalink
fix: make display thread safe
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ-Koenig committed Apr 30, 2024
1 parent 39ee15f commit 7b8b6a1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Software/src/ossm/OSSM.Help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "qrcode.h"

void OSSM::drawHelp() {
displayMutex.lock();
display.clearBuffer();

static QRCode qrcode;
Expand Down Expand Up @@ -43,4 +44,5 @@ void OSSM::drawHelp() {
display.drawUTF8(0, 38, UserConfig::language.GetHelpLine2.c_str());
display.drawUTF8(0, 62, UserConfig::language.Skip.c_str());
display.sendBuffer();
displayMutex.unlock();
}
2 changes: 2 additions & 0 deletions Software/src/ossm/OSSM.StrokeEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
#include "extensions/u8g2Extensions.h"

void OSSM::startStrokeEngine() {
displayMutex.lock();
display.clearBuffer();

drawStr::title(UserConfig::language.StrokeEngine);
drawStr::multiLine(0, 40, UserConfig::language.InDevelopment);

display.sendBuffer();
displayMutex.unlock();
}
6 changes: 6 additions & 0 deletions Software/src/ossm/OSSM.Update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,32 @@
#include "Arduino.h"
#include "extensions/u8g2Extensions.h"
void OSSM::drawUpdate() {
displayMutex.lock();
display.clearBuffer();
String title = "Checking for update...";
drawStr::title(title);

// TODO - Add a spinner here
display.sendBuffer();
displayMutex.unlock();
}

void OSSM::drawNoUpdate() {
displayMutex.lock();
display.clearBuffer();
String title = "No Update Available";
drawStr::title(title);
display.drawUTF8(0, 62, UserConfig::language.Skip.c_str());
display.sendBuffer();
displayMutex.unlock();
}

void OSSM::drawUpdating() {
displayMutex.lock();
display.clearBuffer();
String title = "Updating OSSM...";
drawStr::title(title);
drawStr::multiLine(0, 24, UserConfig::language.UpdateMessage);
display.sendBuffer();
displayMutex.unlock();
}
2 changes: 2 additions & 0 deletions Software/src/ossm/OSSM.WiFi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "qrcode.h"

void OSSM::drawWiFi() {
displayMutex.lock();
display.clearBuffer();

static QRCode qrcode;
Expand Down Expand Up @@ -43,6 +44,7 @@ void OSSM::drawWiFi() {
display.drawUTF8(0, 38, UserConfig::language.WiFiSetupLine2.c_str());
display.drawUTF8(0, 62, UserConfig::language.Restart.c_str());
display.sendBuffer();
displayMutex.unlock();

wm.setConfigPortalTimeout(120);
wm.setDisableConfigPortal(false);
Expand Down
2 changes: 2 additions & 0 deletions Software/src/ossm/OSSM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ void OSSM::drawError() {
ESP_LOGD("OSSM::drawError", "Caught exception: %s", e.what());
}

displayMutex.lock();
display.clearBuffer();
drawStr::title(UserConfig::language.Error);
drawStr::multiLine(0, 20, errorMessage);
display.sendBuffer();
displayMutex.unlock();
}

0 comments on commit 7b8b6a1

Please sign in to comment.