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.display();
}
delay(1000);
}
void commonButtonHandler() {

View File

@ -12,7 +12,7 @@ void setup() {
playTune(1);
connectToWifi();
displayOctoPrintVersion(display);
}
void loop() {

View File

@ -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);
}

View File

@ -2,14 +2,15 @@
#include <Arduino.h>
// 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) {