wip: Stashing away work in progress
This commit is contained in:
parent
24a94a4ab3
commit
9797e17736
@ -44,11 +44,15 @@ add_executable(wled_config_tool
|
||||
wledclient.cpp
|
||||
)
|
||||
|
||||
find_package(yaml-cpp CONFIG REQUIRED)
|
||||
|
||||
target_link_libraries(wled_config_tool
|
||||
Qt6::Core
|
||||
Qt6::Network
|
||||
Qt6::Gui
|
||||
yaml-cpp
|
||||
)
|
||||
|
||||
target_compile_definitions(wled_config_tool PRIVATE WLED_CONFIG_TOOL_BUILD)
|
||||
|
||||
add_executable(hyperion-mock
|
||||
|
||||
@ -991,6 +991,10 @@ Hyperion_Grabber_Wayland_QT_autogen/timestamp: \
|
||||
/usr/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsTargets-relwithdebinfo.cmake \
|
||||
/usr/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsTargets.cmake \
|
||||
/usr/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsVersionlessTargets.cmake \
|
||||
/usr/lib/cmake/yaml-cpp/yaml-cpp-config-version.cmake \
|
||||
/usr/lib/cmake/yaml-cpp/yaml-cpp-config.cmake \
|
||||
/usr/lib/cmake/yaml-cpp/yaml-cpp-targets-release.cmake \
|
||||
/usr/lib/cmake/yaml-cpp/yaml-cpp-targets.cmake \
|
||||
/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/include/stdarg.h \
|
||||
/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/include/stdbool.h \
|
||||
/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/include/stddef.h \
|
||||
|
||||
@ -921,6 +921,10 @@ hyperion-mock_autogen/timestamp: \
|
||||
/usr/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsTargets-relwithdebinfo.cmake \
|
||||
/usr/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsTargets.cmake \
|
||||
/usr/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsVersionlessTargets.cmake \
|
||||
/usr/lib/cmake/yaml-cpp/yaml-cpp-config-version.cmake \
|
||||
/usr/lib/cmake/yaml-cpp/yaml-cpp-config.cmake \
|
||||
/usr/lib/cmake/yaml-cpp/yaml-cpp-targets-release.cmake \
|
||||
/usr/lib/cmake/yaml-cpp/yaml-cpp-targets.cmake \
|
||||
/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/include/stdarg.h \
|
||||
/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/include/stdbool.h \
|
||||
/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/include/stddef.h \
|
||||
|
||||
@ -474,6 +474,10 @@ screen_capture_test_autogen/timestamp: \
|
||||
/usr/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsTargets-relwithdebinfo.cmake \
|
||||
/usr/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsTargets.cmake \
|
||||
/usr/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsVersionlessTargets.cmake \
|
||||
/usr/lib/cmake/yaml-cpp/yaml-cpp-config-version.cmake \
|
||||
/usr/lib/cmake/yaml-cpp/yaml-cpp-config.cmake \
|
||||
/usr/lib/cmake/yaml-cpp/yaml-cpp-targets-release.cmake \
|
||||
/usr/lib/cmake/yaml-cpp/yaml-cpp-targets.cmake \
|
||||
/usr/share/cmake/Modules/CMakeCInformation.cmake \
|
||||
/usr/share/cmake/Modules/CMakeCXXInformation.cmake \
|
||||
/usr/share/cmake/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake \
|
||||
|
||||
BIN
wled_config_tool
BIN
wled_config_tool
Binary file not shown.
@ -8,6 +8,8 @@
|
||||
#include <QTimer>
|
||||
#include <QTime>
|
||||
#include <QSocketNotifier>
|
||||
#include <yaml-cpp/yaml.h>
|
||||
#include <fstream>
|
||||
#include "wledconfigclient.h"
|
||||
#include "wledclient.h"
|
||||
|
||||
@ -78,71 +80,98 @@ int main(int argc, char *argv[])
|
||||
QTextStream cout(stdout);
|
||||
QTextStream cin(stdin);
|
||||
|
||||
cout << "Starting interactive LED layout configuration.\n";
|
||||
cout << "Please enter the number of LEDs for each section.\n";
|
||||
|
||||
int ledsBottom, ledsRight, ledsTop, ledsLeft, offset;
|
||||
bool configConfirmed = false;
|
||||
while (!configConfirmed) {
|
||||
cout << "Starting interactive LED layout configuration.\n";
|
||||
cout << "Please enter the number of LEDs for each section.\n";
|
||||
|
||||
int ledsBottom, ledsRight, ledsTop, ledsLeft, offset;
|
||||
|
||||
cout << "LEDs on the bottom: ";
|
||||
cout.flush();
|
||||
cin >> ledsBottom;
|
||||
cout << "LEDs on the bottom: ";
|
||||
cout.flush();
|
||||
cin >> ledsBottom;
|
||||
cin.readLine(); // Clear the input buffer
|
||||
|
||||
cout << "LEDs on the right side: ";
|
||||
cout.flush();
|
||||
cin >> ledsRight;
|
||||
cout << "LEDs on the right side: ";
|
||||
cout.flush();
|
||||
cin >> ledsRight;
|
||||
cin.readLine(); // Clear the input buffer
|
||||
|
||||
cout << "LEDs on the top: ";
|
||||
cout.flush();
|
||||
cin >> ledsTop;
|
||||
cout << "LEDs on the top: ";
|
||||
cout.flush();
|
||||
cin >> ledsTop;
|
||||
cin.readLine(); // Clear the input buffer
|
||||
|
||||
cout << "LEDs on the left side: ";
|
||||
cout.flush();
|
||||
cin >> ledsLeft;
|
||||
|
||||
cout << "Enter the starting offset (0 if the strip starts at the first LED): ";
|
||||
cout.flush();
|
||||
cin >> offset;
|
||||
cout << "LEDs on the left side: ";
|
||||
cout.flush();
|
||||
cin >> ledsLeft;
|
||||
cin.readLine(); // Clear the input buffer
|
||||
|
||||
cout << "Enter the starting offset (0 if the strip starts at the first LED): ";
|
||||
cout.flush();
|
||||
cin >> offset;
|
||||
cin.readLine(); // Clear the input buffer
|
||||
|
||||
int configuredLeds = ledsBottom + ledsRight + ledsTop + ledsLeft;
|
||||
cout << "Total LEDs configured: " << configuredLeds << "\n";
|
||||
cout.flush();
|
||||
int configuredLeds = ledsBottom + ledsRight + ledsTop + ledsLeft;
|
||||
cout << "Total LEDs configured: " << configuredLeds << "\n";
|
||||
cout.flush();
|
||||
|
||||
if (configuredLeds > totalLeds) {
|
||||
qWarning() << "Warning: The number of configured LEDs (" << configuredLeds
|
||||
<< ") is greater than the number of LEDs reported by the device (" << totalLeds << ").";
|
||||
}
|
||||
if (configuredLeds > totalLeds) {
|
||||
qWarning() << "Warning: The number of configured LEDs (" << configuredLeds
|
||||
<< ") is greater than the number of LEDs reported by the device (" << totalLeds << ").";
|
||||
}
|
||||
|
||||
auto wledClient = new WledClient(wledAddress, wledPort, &app);
|
||||
auto colors = new QVector<QColor>(totalLeds, Qt::black);
|
||||
|
||||
int currentIndex = offset;
|
||||
// Bottom
|
||||
for (int i = 0; i < ledsBottom; ++i) { (*colors)[(currentIndex + i) % totalLeds] = Qt::red; }
|
||||
currentIndex += ledsBottom;
|
||||
// Right
|
||||
for (int i = 0; i < ledsRight; ++i) { (*colors)[(currentIndex + i) % totalLeds] = Qt::green; }
|
||||
currentIndex += ledsRight;
|
||||
// Top
|
||||
for (int i = 0; i < ledsTop; ++i) { (*colors)[(currentIndex + i) % totalLeds] = Qt::blue; }
|
||||
currentIndex += ledsTop;
|
||||
// Left
|
||||
for (int i = 0; i < ledsLeft; ++i) { (*colors)[(currentIndex + i) % totalLeds] = Qt::yellow; }
|
||||
auto wledClient = new WledClient(wledAddress, wledPort, &app);
|
||||
auto colors = new QVector<QColor>(totalLeds, Qt::black);
|
||||
|
||||
int currentIndex = offset;
|
||||
// Bottom
|
||||
for (int i = 0; i < ledsBottom; ++i) { (*colors)[(currentIndex + i) % totalLeds] = Qt::red; }
|
||||
currentIndex += ledsBottom;
|
||||
// Right
|
||||
for (int i = 0; i < ledsRight; ++i) { (*colors)[(currentIndex + i) % totalLeds] = Qt::green; }
|
||||
currentIndex += ledsRight;
|
||||
// Top
|
||||
for (int i = 0; i < ledsTop; ++i) { (*colors)[(currentIndex + i) % totalLeds] = Qt::blue; }
|
||||
currentIndex += ledsTop;
|
||||
// Left
|
||||
for (int i = 0; i < ledsLeft; ++i) { (*colors)[(currentIndex + i) % totalLeds] = Qt::yellow; }
|
||||
|
||||
wledClient->setLedsColor(*colors, 60); // Set timeout to 60 seconds
|
||||
cout << "LEDs have been lit up according to your configuration.\n";
|
||||
cout.flush();
|
||||
wledClient->setLedsColor(*colors, 60); // Set timeout to 60 seconds
|
||||
cout << "LEDs have been lit up according to your configuration.\n";
|
||||
cout.flush();
|
||||
|
||||
printAsciiLayout(ledsBottom, ledsRight, ledsTop, ledsLeft, offset, totalLeds);
|
||||
printAsciiLayout(ledsBottom, ledsRight, ledsTop, ledsLeft, offset, totalLeds);
|
||||
|
||||
cout << "Press Enter to turn off LEDs and exit.\n";
|
||||
cout.flush();
|
||||
cout << "Is this configuration correct? (yes/no): ";
|
||||
cout.flush();
|
||||
QString confirmation = cin.readLine().trimmed().toLower();
|
||||
|
||||
auto notifier = new QSocketNotifier(fileno(stdin), QSocketNotifier::Read, &app);
|
||||
QObject::connect(notifier, &QSocketNotifier::activated, [=, &app]() {
|
||||
colors->fill(Qt::black);
|
||||
wledClient->setLedsColor(*colors);
|
||||
app.quit();
|
||||
});
|
||||
if (confirmation == "yes") {
|
||||
// Save to YAML
|
||||
YAML::Node config;
|
||||
config["wled_layout"]["bottom_leds"] = ledsBottom;
|
||||
config["wled_layout"]["right_leds"] = ledsRight;
|
||||
config["wled_layout"]["top_leds"] = ledsTop;
|
||||
config["wled_layout"]["left_leds"] = ledsLeft;
|
||||
config["wled_layout"]["offset"] = offset;
|
||||
config["wled_layout"]["total_leds"] = totalLeds;
|
||||
|
||||
std::ofstream fout("wled_layout.yaml");
|
||||
fout << config;
|
||||
fout.close();
|
||||
qDebug() << "Configuration saved to wled_layout.yaml";
|
||||
configConfirmed = true;
|
||||
} else {
|
||||
// Clear LEDs before repeating
|
||||
colors->fill(Qt::black);
|
||||
wledClient->setLedsColor(*colors);
|
||||
cout << "Configuration rejected. Repeating the process.\n";
|
||||
cout.flush();
|
||||
}
|
||||
} // End while (!configConfirmed)
|
||||
|
||||
app.quit();
|
||||
});
|
||||
|
||||
QObject::connect(configClient, &WledConfigClient::error, [&](const QString &message) {
|
||||
@ -155,49 +184,52 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
WledConfigClient client(wledAddress);
|
||||
else { // This is the block for --demo, --flash, and config retrieval without --configure-layout
|
||||
auto client = new WledConfigClient(wledAddress, &app); // Corrected: Use WledConfigClient and parent it to app
|
||||
|
||||
QObject::connect(&client, &WledConfigClient::infoReceived, [&](const QJsonObject &info) {
|
||||
if (parser.isSet(demoOption) || parser.isSet(flashOption)) {
|
||||
int totalLeds = info["leds"].toObject()["count"].toInt();
|
||||
if (parser.isSet(demoOption)) {
|
||||
runDemoMode(wledAddress, wledPort, totalLeds);
|
||||
app.quit();
|
||||
} else if (parser.isSet(flashOption)) {
|
||||
runFlashMode(wledAddress, wledPort, totalLeds, parser.value(flashOption));
|
||||
app.quit();
|
||||
}
|
||||
} else {
|
||||
QJsonDocument doc(info);
|
||||
QFile stdoutFile;
|
||||
stdoutFile.open(stdout, QFile::WriteOnly);
|
||||
QTextStream ts(&stdoutFile);
|
||||
ts << "WLED Configuration Info:\n" << doc.toJson(QJsonDocument::Indented) << Qt::endl;
|
||||
stdoutFile.close();
|
||||
|
||||
QString saveFilePath = parser.value(saveOption);
|
||||
if (!saveFilePath.isEmpty()) {
|
||||
QFile file(saveFilePath);
|
||||
if (file.open(QIODevice::WriteOnly)) {
|
||||
file.write(doc.toJson(QJsonDocument::Indented));
|
||||
file.close();
|
||||
qDebug() << "Configuration saved to" << saveFilePath;
|
||||
} else {
|
||||
qWarning() << "Failed to save configuration to" << saveFilePath << ":" << file.errorString();
|
||||
QObject::connect(client, &WledConfigClient::infoReceived, [&](const QJsonObject &info) {
|
||||
if (parser.isSet(demoOption) || parser.isSet(flashOption)) {
|
||||
int totalLeds = info["leds"].toObject()["count"].toInt();
|
||||
if (parser.isSet(demoOption)) {
|
||||
runDemoMode(wledAddress, wledPort, totalLeds);
|
||||
app.quit();
|
||||
} else if (parser.isSet(flashOption)) {
|
||||
runFlashMode(wledAddress, wledPort, totalLeds, parser.value(flashOption));
|
||||
app.quit();
|
||||
}
|
||||
}
|
||||
else {
|
||||
QJsonDocument doc(info);
|
||||
QFile stdoutFile;
|
||||
stdoutFile.open(stdout, QFile::WriteOnly);
|
||||
QTextStream ts(&stdoutFile);
|
||||
ts << "WLED Configuration Info:\n" << doc.toJson(QJsonDocument::Indented) << Qt::endl;
|
||||
stdoutFile.close();
|
||||
|
||||
QString saveFilePath = parser.value(saveOption);
|
||||
if (!saveFilePath.isEmpty()) {
|
||||
QFile file(saveFilePath);
|
||||
if (file.open(QIODevice::WriteOnly)) {
|
||||
file.write(doc.toJson(QJsonDocument::Indented));
|
||||
file.close();
|
||||
qDebug() << "Configuration saved to" << saveFilePath;
|
||||
}
|
||||
else {
|
||||
qWarning() << "Failed to save configuration to" << saveFilePath << ":" << file.errorString();
|
||||
}
|
||||
}
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
QObject::connect(client, &WledConfigClient::error, [&](const QString &message) {
|
||||
qCritical() << "Error:" << message;
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
QObject::connect(&client, &WledConfigClient::error, [&](const QString &message) {
|
||||
qCritical() << "Error:" << message;
|
||||
app.quit();
|
||||
});
|
||||
|
||||
client.getInfo();
|
||||
|
||||
return app.exec();
|
||||
client->getInfo();
|
||||
return app.exec();
|
||||
}
|
||||
}
|
||||
|
||||
// ANSI Color Codes
|
||||
|
||||
@ -941,6 +941,10 @@ wled_config_tool_autogen/timestamp: \
|
||||
/usr/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsTargets-relwithdebinfo.cmake \
|
||||
/usr/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsTargets.cmake \
|
||||
/usr/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsVersionlessTargets.cmake \
|
||||
/usr/lib/cmake/yaml-cpp/yaml-cpp-config-version.cmake \
|
||||
/usr/lib/cmake/yaml-cpp/yaml-cpp-config.cmake \
|
||||
/usr/lib/cmake/yaml-cpp/yaml-cpp-targets-release.cmake \
|
||||
/usr/lib/cmake/yaml-cpp/yaml-cpp-targets.cmake \
|
||||
/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/include/stdarg.h \
|
||||
/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/include/stdbool.h \
|
||||
/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/include/stddef.h \
|
||||
|
||||
7
wled_layout.yaml
Normal file
7
wled_layout.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
wled_layout:
|
||||
bottom_leds: 71
|
||||
right_leds: 20
|
||||
top_leds: 70
|
||||
left_leds: 20
|
||||
offset: 160
|
||||
total_leds: 181
|
||||
Loading…
x
Reference in New Issue
Block a user