diff --git a/master.py b/master.py index f0cf452..5262133 100755 --- a/master.py +++ b/master.py @@ -37,12 +37,14 @@ Reload systemd (first time after creating the service): sudo systemctl daemon-reload Enable (once), start (once and after stopping) and restart (after modification)systemd: - sudo systemctl enable master_nebuleair.service - sudo systemctl start master_nebuleair.service - sudo systemctl restart master_nebuleair.service + +sudo systemctl enable master_nebuleair.service +sudo systemctl start master_nebuleair.service +sudo systemctl restart master_nebuleair.service Check the service status: - sudo systemctl status master_nebuleair.service + +sudo systemctl status master_nebuleair.service Specific scripts can be disabled with config.json diff --git a/matrix/test_forms_noFail b/matrix/test_forms_noFail new file mode 100644 index 0000000..e9f5ae4 Binary files /dev/null and b/matrix/test_forms_noFail differ diff --git a/matrix/test_forms_noFail.cc b/matrix/test_forms_noFail.cc new file mode 100644 index 0000000..81f7412 --- /dev/null +++ b/matrix/test_forms_noFail.cc @@ -0,0 +1,100 @@ +/* + + __ __ _ _____ ____ _____ __ + | \/ | / \|_ _| _ \|_ _\ \/ / + | |\/| | / _ \ | | | |_) || | \ / + | | | |/ ___ \| | | _ < | | / \ + |_| |_/_/ \_\_| |_| \_\___/_/\_\ + + +Script to display a simple square on the matrix LED +sudo /var/www/moduleair_pro_4g/matrix/test_forms_noFail --led-no-hardware-pulse + +Pour compiler: +g++ -Iinclude -Llib test_forms_noFail.cc -o test_forms_noFail -lrgbmatrix + +*/ +#include "led-matrix.h" +#include "graphics.h" +#include +#include +#include + +using rgb_matrix::RGBMatrix; +using rgb_matrix::Canvas; + +volatile bool running = true; + +static void InterruptHandler(int signo) { + running = false; +} + +int main(int argc, char *argv[]) { + RGBMatrix::Options defaults; + + defaults.hardware_mapping = "moduleair_pinout"; + defaults.rows = 64; + defaults.cols = 128; + defaults.chain_length = 1; + defaults.parallel = 1; + defaults.row_address_type = 3; + defaults.show_refresh_rate = true; + defaults.brightness = 100; + defaults.pwm_bits = 1; + defaults.panel_type = "FM6126A"; + defaults.disable_hardware_pulsing = false; + + // Set up signal handlers for clean exit + signal(SIGTERM, InterruptHandler); + signal(SIGINT, InterruptHandler); + + // Try creating the matrix with a few attempts + Canvas *canvas = NULL; + int attempts = 0; + while (canvas == NULL && attempts < 3) { + canvas = RGBMatrix::CreateFromFlags(&argc, &argv, &defaults); + if (canvas == NULL) { + fprintf(stderr, "Creating canvas failed, attempt %d/3. Retrying...\n", attempts + 1); + attempts++; + usleep(500000); // Wait 500ms before retry + } + } + + if (canvas == NULL) { + fprintf(stderr, "Failed to create canvas after multiple attempts.\n"); + return 1; + } + + // Always clear the canvas first to reset any previous state + canvas->Clear(); + usleep(100000); // Small delay after clearing + + rgb_matrix::Color red(255, 0, 0); // Red color + + // Define the top-left corner of the square + int start_x = 10; // X coordinate + int start_y = 10; // Y coordinate + int square_size = 8; // Size of the square (8x8) + + // Draw a filled square + for (int x = start_x; x < start_x + square_size; ++x) { + for (int y = start_y; y < start_y + square_size; ++y) { + canvas->SetPixel(x, y, red.r, red.g, red.b); + } + } + + // Keep running until signaled + int seconds = 0; + while (running && seconds < 10) { + sleep(1); + seconds++; + } + + // Always ensure we clean up + canvas->Clear(); + usleep(100000); // Small delay after clearing + delete canvas; + + fprintf(stderr, "Display completed successfully.\n"); + return 0; +} \ No newline at end of file diff --git a/matrix/test_text.cc b/matrix/test_text.cc index 83f2dd3..1724972 100755 --- a/matrix/test_text.cc +++ b/matrix/test_text.cc @@ -11,6 +11,9 @@ sudo /var/www/moduleair_pro_4g/matrix/test_text Pour compiler: g++ -Iinclude -Llib test_text.cc -o test_text -lrgbmatrix + +Pour lancer: +sudo /var/www/moduleair_pro_4g/matrix/test_text */ #include "led-matrix.h"