This commit is contained in:
Your Name
2025-03-28 16:25:14 +01:00
parent 4653fe44e3
commit a6cb45a0bb
4 changed files with 109 additions and 4 deletions

View File

@@ -37,11 +37,13 @@ Reload systemd (first time after creating the service):
sudo systemctl daemon-reload sudo systemctl daemon-reload
Enable (once), start (once and after stopping) and restart (after modification)systemd: Enable (once), start (once and after stopping) and restart (after modification)systemd:
sudo systemctl enable master_nebuleair.service sudo systemctl enable master_nebuleair.service
sudo systemctl start master_nebuleair.service sudo systemctl start master_nebuleair.service
sudo systemctl restart master_nebuleair.service sudo systemctl restart master_nebuleair.service
Check the service status: Check the service status:
sudo systemctl status master_nebuleair.service sudo systemctl status master_nebuleair.service

BIN
matrix/test_forms_noFail Normal file

Binary file not shown.

100
matrix/test_forms_noFail.cc Normal file
View File

@@ -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 <signal.h>
#include <unistd.h>
#include <stdio.h>
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;
}

View File

@@ -11,6 +11,9 @@ sudo /var/www/moduleair_pro_4g/matrix/test_text
Pour compiler: Pour compiler:
g++ -Iinclude -Llib test_text.cc -o test_text -lrgbmatrix 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" #include "led-matrix.h"