Updated text-example.cc for stream and brightness

Hello all,

I have updated the text-example.cc to read the text to display and the brightness from a file.
This way we can change the text and the brightness on the fly.

text-example.cc

if you use -t ABCD it will display ABCD or if you use -t stream it will read from the file.
you can specify the file with -T

You can specify the brightness file with -b and it will read form the file when you use --led-brightness=1
Fell free to use/update where ever you want.

if you don’t specify the files, it is reading from:
Text: /var/local/stream.txt
Brightness: /var/local/brightness

Best regards

1 Like

Hi,
I am more user than programmer :wink:
So I am not able to use your file. I have to do make? But I got several errors.
In wich directory I have to put your file?
I tried it in /rpi-rgb-led-matrix/examples-api-use
I edited you file in these lines
#include β€œβ€¦/include/led-matrix.h”
#include β€œβ€¦/include/graphics.h”
But still there are arrors:

make text-exampe-2

g++ -Wall -O3 -g -Wextra -Wno-unused-parameter -L…/lib -lrgbmatrix -lrt -lm -lpthread text-exampe-2.cc -o text-exampe-2
/usr/bin/ld: /tmp/ccWs4HaD.o: in function usage(char const*)': /home/backtolife/rpi-rgb-led-matrix/examples-api-use/text-exampe-2.cc:40: undefined reference to rgb_matrix::RGBMatrix::Options::Options()’
/usr/bin/ld: /home/backtolife/rpi-rgb-led-matrix/examples-api-use/text-exampe-2.cc:40: undefined reference to rgb_matrix::RuntimeOptions::Runti meOptions()' /usr/bin/ld: /home/backtolife/rpi-rgb-led-matrix/examples-api-use/text-exampe-2.cc:40: undefined reference to rgb_matrix::PrintMatrixFlags(IO FILE*, rgb_matrix::RGBMatrix::Options const&, rgb_matrix::RuntimeOptions const&)’
/usr/bin/ld: /tmp/ccWs4HaD.o: in function main': /home/backtolife/rpi-rgb-led-matrix/examples-api-use/text-exampe-2.cc:55: undefined reference to rgb_matrix::RGBMatrix::Options::Options()’
/usr/bin/ld: /home/backtolife/rpi-rgb-led-matrix/examples-api-use/text-exampe-2.cc:56: undefined reference to rgb_matrix::RuntimeOptions::Runti meOptions()' /usr/bin/ld: /home/backtolife/rpi-rgb-led-matrix/examples-api-use/text-exampe-2.cc:57: undefined reference to rgb_matrix::ParseOptionsFromFlags (int*, char***, rgb_matrix::RGBMatrix::Options*, rgb_matrix::RuntimeOptions*, bool)’
/usr/bin/ld: /home/backtolife/rpi-rgb-led-matrix/examples-api-use/text-exampe-2.cc:153: undefined reference to rgb_matrix::Font::Font()' /usr/bin/ld: /home/backtolife/rpi-rgb-led-matrix/examples-api-use/text-exampe-2.cc:154: undefined reference to rgb_matrix::Font::LoadFont(char const*)’
/usr/bin/ld: /home/backtolife/rpi-rgb-led-matrix/examples-api-use/text-exampe-2.cc:165: undefined reference to rgb_matrix::Font::CreateOutlineF ont() const' /usr/bin/ld: /home/backtolife/rpi-rgb-led-matrix/examples-api-use/text-exampe-2.cc:168: undefined reference to rgb_matrix::RGBMatrix::CreateFro mOptions(rgb_matrix::RGBMatrix::Options const&, rgb_matrix::RuntimeOptions const&)’
/usr/bin/ld: /home/backtolife/rpi-rgb-led-matrix/examples-api-use/text-exampe-2.cc:275: undefined reference to rgb_matrix::DrawText(rgb_matrix: :Canvas*, rgb_matrix::Font const&, int, int, rgb_matrix::Color const&, rgb_matrix::Color const*, char const*, int)' /usr/bin/ld: /home/backtolife/rpi-rgb-led-matrix/examples-api-use/text-exampe-2.cc:282: undefined reference to rgb_matrix::DrawText(rgb_matrix: :Canvas*, rgb_matrix::Font const&, int, int, rgb_matrix::Color const&, rgb_matrix::Color const*, char const*, int)’
/usr/bin/ld: /home/backtolife/rpi-rgb-led-matrix/examples-api-use/text-exampe-2.cc:153: undefined reference to rgb_matrix::Font::~Font()' /usr/bin/ld: /home/backtolife/rpi-rgb-led-matrix/examples-api-use/text-exampe-2.cc:177: undefined reference to rgb_matrix::RGBMatrix::SetPWMBit s(unsigned char)’
/usr/bin/ld: /home/backtolife/rpi-rgb-led-matrix/examples-api-use/text-exampe-2.cc:234: undefined reference to rgb_matrix::DrawText(rgb_matrix: :Canvas*, rgb_matrix::Font const&, int, int, rgb_matrix::Color const&, rgb_matrix::Color const*, char const*, int)' /usr/bin/ld: /home/backtolife/rpi-rgb-led-matrix/examples-api-use/text-exampe-2.cc:205: undefined reference to rgb_matrix::RGBMatrix::SetBright ness(unsigned char)’
/usr/bin/ld: /home/backtolife/rpi-rgb-led-matrix/examples-api-use/text-exampe-2.cc:244: undefined reference to rgb_matrix::DrawText(rgb_matrix: :Canvas*, rgb_matrix::Font const&, int, int, rgb_matrix::Color const&, rgb_matrix::Color const*, char const*, int)' /usr/bin/ld: /home/backtolife/rpi-rgb-led-matrix/examples-api-use/text-exampe-2.cc:153: undefined reference to rgb_matrix::Font::~Font()’
collect2: error: ld returned 1 exit status
make: *** [: text-exampe-2] Error 1

Can you please help me?
Gavor