Skip to content

Commit

Permalink
Improve display in server mode (#314)
Browse files Browse the repository at this point in the history
* Improve display in server mode
* Do not clear the display, when the HTTPSServer ist created. Thus, the APL info stays in the display until the loading bar shows up
* Refine display of ALP message

Co-authored-by: amandel <andreas.mandel@gmail.com>
  • Loading branch information
boldt and amandel authored Dec 3, 2022
1 parent fb3fe4a commit 004c14f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/OpenBikeSensorFirmware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,9 @@ void handleButtonInServerMode() {
button.handle();
if (!configServerWasConnectedViaHttp()) {
if (button.gotPressed()) {
displayTest->clearProgressBar(5);
displayTest->showTextOnGrid(0, 3, "Press the button for");
displayTest->showTextOnGrid(0, 4, "automatic track upload.");
displayTest->clearProgressBar(5);
} else if (button.getPreviousStateMillis() > 0 && button.getState() == HIGH) {
const uint32_t buttonPressedMs = button.getCurrentStateMillis();
displayTest->drawProgressBar(5, buttonPressedMs, LONG_BUTTON_PRESS_TIME_MS);
Expand Down
2 changes: 0 additions & 2 deletions src/configServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,6 @@ static void createHttpServer() {
}
serverSslCert = Https::getCertificate(progressTick);
server = new HTTPSServer(serverSslCert, 443, 2);
displayTest->clear();
updateDisplay(displayTest);
insecureServer = new HTTPServer(80, 2);

beginPages();
Expand Down
16 changes: 9 additions & 7 deletions src/displays.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,15 @@ class SSD1306DisplayDevice : public DisplayDevice {
}

void clearProgressBar(uint8_t y) {
clearTextLine(y);
uint16_t rowOffset = y * 10 + 3;
m_display->setColor(BLACK);
m_display->fillRect(12, rowOffset, 104, 8);
m_display->setColor(WHITE);
m_display->display();
mLastProgress = UINT8_MAX;
if (UINT8_MAX != mLastProgress) {
clearTextLine(y);
uint16_t rowOffset = y * 10 + 3;
m_display->setColor(BLACK);
m_display->fillRect(12, rowOffset, 104, 8);
m_display->setColor(WHITE);
m_display->display();
mLastProgress = UINT8_MAX;
}
}

void clearTextLine(uint8_t y) {
Expand Down
5 changes: 3 additions & 2 deletions src/utils/alpdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ void AlpData::update(SSD1306DisplayDevice *display) {
log_d("Next Update: %s",
TimeUtils::dateTimeToString(lastWrite + 4 * 24 * 60 * 60).c_str());
f.close();
display->showTextOnGrid(0, 5, "ALP not checked.");
return;
}
f.close();
log_d("Existing file last write %s", TimeUtils::dateTimeToString(f.getLastWrite()).c_str());
log_d("Existing file is from %s", lastModified.c_str());
display->showTextOnGrid(0, 5, "ALP data ...");
display->showTextOnGrid(0, 5, "ALP data...");

HTTPClient httpClient;
httpClient.begin(ALP_DOWNLOAD_URL);
Expand Down Expand Up @@ -81,7 +82,7 @@ void AlpData::update(SSD1306DisplayDevice *display) {
display->showTextOnGrid(0, 5, "ALP data updated!");
}
} else if (httpCode == 304) { // Not-Modified
display->showTextOnGrid(0,5, "ALP data up to date.");
display->showTextOnGrid(0, 5, "ALP data was up to date.");
log_i("All fine, not modified!");
} else if (httpCode > 0) {
display->showTextOnGrid(0,4, String("ALP data failed ") + String(httpCode).c_str());
Expand Down

0 comments on commit 004c14f

Please sign in to comment.