Files
moduleair_pro_4g/matrix/test_forms.cc
Your Name 4653fe44e3 update
2025-03-28 15:59:54 +01:00

70 lines
1.8 KiB
C++
Executable File

/*
__ __ _ _____ ____ _____ __
| \/ | / \|_ _| _ \|_ _\ \/ /
| |\/| | / _ \ | | | |_) || | \ /
| | | |/ ___ \| | | _ < | | / \
|_| |_/_/ \_\_| |_| \_\___/_/\_\
Script to display a simple square on the matrix LED
sudo /var/www/moduleair_pro_4g/matrix/test_forms --led-no-hardware-pulse
Pour compiler:
g++ -Iinclude -Llib test_forms.cc -o test_forms -lrgbmatrix
Pour le lancer:
sudo /var/www/moduleair_pro_4g/matrix/test_forms
*/
#include "led-matrix.h"
#include "graphics.h"
#include <unistd.h>
using rgb_matrix::RGBMatrix;
using rgb_matrix::Canvas;
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;
rgb_matrix::Color red(255, 0, 0); // Red color
rgb_matrix::Color bg_color(0, 0, 0); // Background color (black)
Canvas *canvas = RGBMatrix::CreateFromFlags(&argc, &argv, &defaults);
if (canvas == NULL)
return 1;
// 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);
}
}
usleep(10000000); // Display for 10 seconds
// Clean up
canvas->Clear();
delete canvas;
return 0;
}