63 lines
1.8 KiB
C++
Executable File
63 lines
1.8 KiB
C++
Executable File
/*
|
|
Script to display a simple text on the matrix LED
|
|
sudo /var/www/moduleair_pro_4g/matrix/test_text --led-no-hardware-pulse
|
|
|
|
Pour compiler:
|
|
g++ -Iinclude -Llib test_text.cc -o test_text -lrgbmatrix
|
|
*/
|
|
|
|
#include "led-matrix.h"
|
|
#include "graphics.h"
|
|
|
|
#include <unistd.h>
|
|
#include <string.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.panel_type = "FM6126A";
|
|
|
|
rgb_matrix::Color color1(255, 0, 0); // Red color for the first line
|
|
rgb_matrix::Color color2(0, 0, 255); // Blue color for the second line
|
|
rgb_matrix::Color bg_color(0, 0, 0); // Background color (black)
|
|
|
|
int letter_spacing = 0;
|
|
|
|
Canvas *canvas = RGBMatrix::CreateFromFlags(&argc, &argv, &defaults);
|
|
if (canvas == NULL)
|
|
return 1;
|
|
|
|
// Load font
|
|
rgb_matrix::Font font;
|
|
if (!font.LoadFont("fonts/8x13.bdf")) return 1;
|
|
|
|
// Define text for each line
|
|
const char *line1 = "Plouf Les amis!";
|
|
const char *line2 = "Salut a tous!";
|
|
|
|
// Display first line with color1
|
|
int x = 0;
|
|
int y1 = font.baseline(); // First line position
|
|
rgb_matrix::DrawText(canvas, font, x, y1, color1, &bg_color, line1, letter_spacing);
|
|
|
|
// Display second line with color2
|
|
int y2 = y1 + font.height(); // Second line position, just below the first line
|
|
rgb_matrix::DrawText(canvas, font, x, y2, color2, &bg_color, line2, letter_spacing);
|
|
|
|
usleep(4000000); // Display for 4 seconds
|
|
|
|
// Clean up
|
|
canvas->Clear();
|
|
delete canvas;
|
|
return 0;
|
|
} |