Skip to content

Commit 9e53bd3

Browse files
author
mariuste
committed
Add nozzle temperature handling for unavailable state in display functions
1 parent c330b9f commit 9e53bd3

1 file changed

Lines changed: 38 additions & 18 deletions

File tree

firmware/prusalink/src/main.cpp

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ void drawTinyGlyph(char c, int x, int y, uint16_t color);
144144
void drawTinyText(const String &text, int x, int y, uint16_t color);
145145
bool isPrinterUnavailableState(const char *state);
146146
bool isIpShowButtonPressed();
147+
bool isNozzleTempUnavailable(int temp);
147148
int scaleFloatToInteger(float progress);
148149
void printPrusaLinkDebug();
149150
// ---------------------------
@@ -321,6 +322,11 @@ bool isPrinterUnavailableState(const char *state) {
321322
|| (strcmp(state, "N/A") == 0);
322323
}
323324

325+
bool isNozzleTempUnavailable(int temp) {
326+
// Prusa XL reports 6C when no tool head is active (parked).
327+
return temp == 6;
328+
}
329+
324330
void setupOta() {
325331
if (otaInitialized || WiFi.status() != WL_CONNECTED) {
326332
return;
@@ -599,19 +605,26 @@ void displayPrinterPrinting(int seconds, float progress, int temp_T0, int temp_B
599605
matrix.drawRect(1, 20, 62, 1, matrix.color565(255, 255, 255)); // white
600606

601607
// Display T0 (Nozzle)
602-
if (temp_T0 < 10) textX = 16;
608+
if (isNozzleTempUnavailable(temp_T0)) textX = 14;
609+
else if (temp_T0 < 10) textX = 16;
603610
else if (temp_T0 < 100) textX = 10;
604611
else textX = 4;
605612
textY = 23;
606-
if (temp_T0 >= tempGood_T0) matrix.setTextColor(matrix.color565(255, 0, 0)); // red
607-
else matrix.setTextColor(matrix.color565(0, 255, 0)); // green
613+
if (isNozzleTempUnavailable(temp_T0)) {
614+
matrix.setTextColor(0xFFFF); // white
615+
} else if (temp_T0 >= tempGood_T0) matrix.setTextColor(matrix.color565(255, 0, 0)); // red
616+
else matrix.setTextColor(matrix.color565(0, 255, 0)); // green
608617
matrix.setCursor(textX, textY);
609-
matrix.print(temp_T0);
610-
// display "°C" for T0
611-
matrix.setTextColor(matrix.color565(255, 255, 255)); // white
612-
matrix.setCursor(26, 23);
613-
matrix.print("C");
614-
matrix.drawCircle(24, 23, 1, matrix.color565(255, 255, 255)); // white
618+
if (isNozzleTempUnavailable(temp_T0)) {
619+
matrix.print("-");
620+
} else {
621+
matrix.print(temp_T0);
622+
// display "°C" for T0
623+
matrix.setTextColor(matrix.color565(255, 255, 255)); // white
624+
matrix.setCursor(26, 23);
625+
matrix.print("C");
626+
matrix.drawCircle(24, 23, 1, matrix.color565(255, 255, 255)); // white
627+
}
615628

616629
// Display Slash
617630
matrix.setCursor(33, 23);
@@ -665,19 +678,26 @@ void displayPrinterReady(int temp_T0, int temp_Bed) {
665678
matrix.drawRect(1, 20, 62, 1, matrix.color565(255, 255, 255)); // white
666679

667680
// Display T0 (Nozzle)
668-
if (temp_T0 < 10) textX = 16;
681+
if (isNozzleTempUnavailable(temp_T0)) textX = 14;
682+
else if (temp_T0 < 10) textX = 16;
669683
else if (temp_T0 < 100) textX = 10;
670684
else textX = 4;
671685
textY = 23;
672-
if (temp_T0 >= tempGood_T0) matrix.setTextColor(matrix.color565(255, 0, 0)); // red
673-
else matrix.setTextColor(matrix.color565(0, 255, 0)); // green
686+
if (isNozzleTempUnavailable(temp_T0)) {
687+
matrix.setTextColor(0xFFFF); // white
688+
} else if (temp_T0 >= tempGood_T0) matrix.setTextColor(matrix.color565(255, 0, 0)); // red
689+
else matrix.setTextColor(matrix.color565(0, 255, 0)); // green
674690
matrix.setCursor(textX, textY);
675-
matrix.print(temp_T0);
676-
// display "°C" for T0
677-
matrix.setTextColor(matrix.color565(255, 255, 255)); // white
678-
matrix.setCursor(26, 23);
679-
matrix.print("C");
680-
matrix.drawCircle(24, 23, 1, matrix.color565(255, 255, 255)); // white
691+
if (isNozzleTempUnavailable(temp_T0)) {
692+
matrix.print("-");
693+
} else {
694+
matrix.print(temp_T0);
695+
// display "°C" for T0
696+
matrix.setTextColor(matrix.color565(255, 255, 255)); // white
697+
matrix.setCursor(26, 23);
698+
matrix.print("C");
699+
matrix.drawCircle(24, 23, 1, matrix.color565(255, 255, 255)); // white
700+
}
681701

682702
// Display Slash
683703
matrix.setCursor(33, 23);

0 commit comments

Comments
 (0)