From d3d74938d30bda923553f71f2516d0fa441e2545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomislav=20Kopi=C4=87?= Date: Fri, 1 Nov 2024 19:03:31 +0100 Subject: [PATCH] Change tunes, configure connection --- src/functions.h | 1 + src/main.cpp | 2 +- src/octoprint.h | 24 +++++++++++++++++++----- src/tunes.h | 11 ++++++----- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/functions.h b/src/functions.h index 228a136..b6da455 100644 --- a/src/functions.h +++ b/src/functions.h @@ -78,6 +78,7 @@ void connectToWifi() { display.print("Failed"); display.display(); } + delay(1000); } void commonButtonHandler() { diff --git a/src/main.cpp b/src/main.cpp index bfc2965..ca07fea 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,7 +12,7 @@ void setup() { playTune(1); connectToWifi(); displayOctoPrintVersion(display); - + } void loop() { diff --git a/src/octoprint.h b/src/octoprint.h index 9d0e122..9f5d22f 100644 --- a/src/octoprint.h +++ b/src/octoprint.h @@ -19,21 +19,31 @@ String printerHotend; String printerTarget; 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 -void displayOctoPrintVersion(Adafruit_SSD1306& display) { +bool 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()) { display.clearDisplay(); display.setCursor(0, 0); display.setTextSize(1); display.setTextColor(WHITE); - + display.print("OctoPrint Version:"); display.setCursor(0, 10); + display.setTextSize(2); // Larger text for version display.print(api.octoprintVer.octoprintServer); - + display.display(); // Update the display + playTune(2); + return true; // Indicate success } else { display.clearDisplay(); display.setCursor(0, 0); @@ -43,6 +53,10 @@ void displayOctoPrintVersion(Adafruit_SSD1306& display) { display.setCursor(0, 10); display.print("OctoPrint version."); display.display(); + + // Optionally, add a short delay to show the error playTune(3); + return false; // Indicate failure } + delay(1000); } \ No newline at end of file diff --git a/src/tunes.h b/src/tunes.h index 9e1c556..2670852 100644 --- a/src/tunes.h +++ b/src/tunes.h @@ -2,14 +2,15 @@ #include // 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 melody2[] = { 587, 659, 740, 659 }; // Tune 2 -int noteDuration2[] = { 150, 100, 150, 100 }; +int melody2[] = { 740, 784, 659 }; // Happy Tune +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 void playTune(int tuneIndex) {