Change tunes, configure connection

This commit is contained in:
Tomislav Kopić 2024-11-01 19:03:31 +01:00
parent ec6af93cfe
commit d3d74938d3
4 changed files with 27 additions and 11 deletions

View File

@ -78,6 +78,7 @@ void connectToWifi() {
display.print("Failed"); display.print("Failed");
display.display(); display.display();
} }
delay(1000);
} }
void commonButtonHandler() { void commonButtonHandler() {

View File

@ -19,10 +19,17 @@ String printerHotend;
String printerTarget; String printerTarget;
String payload; String payload;
OctoprintApi api(client, (char*)OCTOPRINT_HOST, OCTOPRINT_PORT, OCTOPRINT_API_KEY); OctoprintApi api(client, OCTOPRINT_HOST, OCTOPRINT_PORT, OCTOPRINT_API_KEY);
// Function to fetch and display OctoPrint version bool displayOctoPrintVersion(Adafruit_SSD1306& display) {
void displayOctoPrintVersion(Adafruit_SSD1306& display) { display.clearDisplay();
display.setCursor(0, 0);
display.setTextSize(1);
display.setTextColor(WHITE);
display.print("Fetching OctoPrint Version...");
display.display(); // Show loading message
// Attempt to fetch the OctoPrint version
if (api.getOctoprintVersion()) { if (api.getOctoprintVersion()) {
display.clearDisplay(); display.clearDisplay();
display.setCursor(0, 0); display.setCursor(0, 0);
@ -31,9 +38,12 @@ void displayOctoPrintVersion(Adafruit_SSD1306& display) {
display.print("OctoPrint Version:"); display.print("OctoPrint Version:");
display.setCursor(0, 10); display.setCursor(0, 10);
display.setTextSize(2); // Larger text for version
display.print(api.octoprintVer.octoprintServer); display.print(api.octoprintVer.octoprintServer);
display.display(); // Update the display display.display(); // Update the display
playTune(2);
return true; // Indicate success
} else { } else {
display.clearDisplay(); display.clearDisplay();
display.setCursor(0, 0); display.setCursor(0, 0);
@ -43,6 +53,10 @@ void displayOctoPrintVersion(Adafruit_SSD1306& display) {
display.setCursor(0, 10); display.setCursor(0, 10);
display.print("OctoPrint version."); display.print("OctoPrint version.");
display.display(); display.display();
// Optionally, add a short delay to show the error
playTune(3); playTune(3);
return false; // Indicate failure
} }
delay(1000);
} }

View File

@ -2,14 +2,15 @@
#include <Arduino.h> #include <Arduino.h>
// Define melodies and their durations // Define melodies and their durations
int melody1[] = { 440, 523, 659, 587 }; // Happy tune int melody1[] = { 440, 523, 659, 587 }; // Startup tune
int noteDuration1[] = { 100, 50, 100, 150 }; int noteDuration1[] = { 100, 50, 100, 150 };
int melody2[] = { 587, 659, 740, 659 }; // Tune 2 int melody2[] = { 740, 784, 659 }; // Happy Tune
int noteDuration2[] = { 150, 100, 150, 100 }; int noteDuration2[] = { 120, 120, 120 };
int melody3[] = { 440, 349, 392 }; // Sad Tune
int noteDuration3[] = { 150, 100, 150 };
int melody3[] = { 440, 392 }; // Sad Tune
int noteDuration3[] = { 200, 150 };
// Function to play a specified tune // Function to play a specified tune
void playTune(int tuneIndex) { void playTune(int tuneIndex) {