Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Text c scroll in c with rpi-rgb-led-matrix and P10 64x64 A.Villanueva
- * https://github.com/hzeller/rpi-rgb-led-matrix
- *- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
- *
- * Using the C-API of this library.
- *
- */
- #include "led-matrix-c.h"
- #include <stdio.h>
- #include <string.h>
- #include <unistd.h>
- int main(int argc, char **argv) {
- struct RGBLedMatrixOptions options;
- struct RGBLedMatrix *matrix;
- struct LedCanvas *offscreen_canvas;
- const char FONT[] ="../fonts/texgyre-27.bdf";
- const char *message="HOLA COMO ESTAS ";
- uint8_t r=0,g=255,b=0;//Color RGB
- int width, height;
- int x=128, y=32, i;
- memset(&options, 0, sizeof(options));
- options.rows = 64;
- options.cols =64;
- options.chain_length = 6;
- /* This supports all the led commandline options. Try --led-help */
- matrix = led_matrix_create_from_options(&options, &argc, &argv);
- if (matrix == NULL)
- return 1;
- /* Let's do an example with double-buffering. We create one extra
- * buffer onto which we draw, which is then swapped on each refresh.
- * This is typically a good aproach for animations and such.
- */
- offscreen_canvas = led_matrix_create_offscreen_canvas(matrix);
- led_canvas_get_size(offscreen_canvas, &width, &height);
- fprintf(stderr, "Size: %dx%d. Hardware gpio mapping: %s\n",
- width, height, options.hardware_mapping);
- // Draw text, a standard NUL terminated C-string encoded in UTF-8,
- // with given "font" at "x","y" with "color".
- // Draw text as above, but vertically (top down).
- // The text is a standard NUL terminated C-string encoded in UTF-8.
- // "font, "x", "y", "color" and "background_color" are same as DrawText().
- // "kerning_offset" allows for additional spacing between characters (can be
- // negative).
- // Returns font height to advance up on the screen.
- //int vertical_draw_text(struct LedCanvas *c, struct LedFont *font, int x, int y,
- // uint8_t r, uint8_t g, uint8_t b,
- // const char *utf8_text, int kerning_offset = 0)
- for (int temp=0;temp<1000;temp++){
- printf ("how many pixels we advanced on the screen = %d \n",draw_text( offscreen_canvas,load_font(FONT), x, y,r,g,b ,message,0));
- /* Now, we swap the canvas. We give swap_on_vsync the buffer we
- * just have drawn into, and wait until the next vsync happens.
- * we get back the unused buffer to which we'll draw in the next
- * iteration.
- */
- offscreen_canvas = led_matrix_swap_on_vsync(matrix, offscreen_canvas);
- }
- led_matrix_delete(matrix);
- return 0;
- }
Add Comment
Please, Sign In to add comment