feat: Add interactive LED layout configuration to wled_config_tool

This commit is contained in:
Tobias J. Endres 2025-08-16 00:10:18 +02:00
parent f6dec995f9
commit e43de997c8

View File

@ -3,6 +3,7 @@
#include <QDebug>
#include <QJsonDocument>
#include <QFile>
#include <iostream>
#include "wledconfigclient.h"
int main(int argc, char *argv[])
@ -26,8 +27,66 @@ int main(int argc, char *argv[])
"filepath");
parser.addOption(saveOption);
QCommandLineOption configureLayoutOption(QStringList() << "l" << "configure-layout",
"Start interactive LED layout configuration.");
parser.addOption(configureLayoutOption);
parser.process(app);
if (parser.isSet(configureLayoutOption)) {
// Interactive LED layout configuration
QTextStream cin(stdin);
QTextStream cout(stdout);
cout << "Starting interactive LED layout configuration.\n";
cout.flush();
cout << "Please enter the number of LEDs for each section.\n";
cout.flush();
int ledsToFirstCorner = 0;
cout << "LEDs until the first corner is reached: ";
cout.flush();
cin >> ledsToFirstCorner;
int ledsRightSide = 0;
cout << "LEDs on the right side: ";
cout.flush();
cin >> ledsRightSide;
int ledsTop = 0;
cout << "LEDs on the top: ";
cout.flush();
cin >> ledsTop;
int ledsLeftSide = 0;
cout << "LEDs on the left side: ";
cout.flush();
cin >> ledsLeftSide;
int ledsBottomRemaining = 0;
cout << "LEDs at the bottom again until the last one is reached: ";
cout.flush();
cin >> ledsBottomRemaining;
cout << "\n--- LED Layout Summary ---\n";
cout.flush();
cout << "LEDs to first corner: " << ledsToFirstCorner << "\n";
cout.flush();
cout << "LEDs on right side: " << ledsRightSide << "\n";
cout.flush();
cout << "LEDs on top: " << ledsTop << "\n";
cout.flush();
cout << "LEDs on left side: " << ledsLeftSide << "\n";
cout.flush();
cout << "LEDs bottom remaining: " << ledsBottomRemaining << "\n";
cout.flush();
int totalLeds = ledsToFirstCorner + ledsRightSide + ledsTop + ledsLeftSide + ledsBottomRemaining;
cout << "Total LEDs configured: " << totalLeds << "\n";
return 0; // Exit after configuration
}
if (!parser.isSet(addressOption)) {
qCritical() << "Error: WLED address not specified. Use -a or --address.";
parser.showHelp(1);