Romonaga / Ws2811Wrapper

Wrapper for https://github.com/jgarff/rpi_ws281x
3 stars 0 forks source link

How to build #1

Open atsu7 opened 4 years ago

atsu7 commented 4 years ago

I'm sorry for posting a basic question. I would love to use this wrapper, but I don't have idea how to use this. I put these files in the directory rpi_ws281x, and added files in rpi-rgb-led-matrix/lib (Are they needed?). I tried g++ ws2811wrapper.cpp but errors happened.

/usr/bin/ld: /tmp/ccVVmUV4.o: in function Ws2811Wrapper::Ws2811Wrapper()': ws2811wrapper.cpp:(.text+0x1c): undefined reference torgb_matrix::RGBMatrix::Options::Options()' /usr/bin/ld: ws2811wrapper.cpp:(.text+0x2c): undefined reference to rgb_matrix::RuntimeOptions::RuntimeOptions()' /usr/bin/ld: /tmp/ccVVmUV4.o: in functionWs2811Wrapper::show()': ws2811wrapper.cpp:(.text+0x2a8): undefined reference to ws2811_render' /usr/bin/ld: ws2811wrapper.cpp:(.text+0x484): undefined reference torgb_matrix::RGBMatrix::SwapOnVSync(rgb_matrix::FrameCanvas, unsigned int)' /usr/bin/ld: /tmp/ccVVmUV4.o: in function Ws2811Wrapper::cleanUpWs2811()': ws2811wrapper.cpp:(.text+0x598): undefined reference tows2811_fini' /usr/bin/ld: /tmp/ccVVmUV4.o: in function Ws2811Wrapper::initStrip(ws2811Channel, unsigned int, unsigned int, LedStripType, int, int, matrixDirection)': ws2811wrapper.cpp:(.text+0x9c0): undefined reference tows2811_init' /usr/bin/ld: /tmp/ccVVmUV4.o: in function Ws2811Wrapper::initStrip(unsigned int, unsigned int, LedStripType, matrixDirection, Wiring2121)': ws2811wrapper.cpp:(.text+0xe90): undefined reference torgb_matrix::RGBMatrix::SwapOnVSync(rgb_matrix::FrameCanvas, unsigned int)' /usr/bin/ld: /tmp/ccVVmUV4.o: in function Ws2811Wrapper::setBrightness(unsigned char)': ws2811wrapper.cpp:(.text+0x1904): undefined reference torgb_matrix::RGBMatrix::SetBrightness(unsigned char)' /usr/bin/ld: /tmp/ccVVmUV4.o: in function Ws2811Wrapper::getws2811ErrorString(ws2811_return_t)': ws2811wrapper.cpp:(.text+0x1e94): undefined reference tows2811_get_return_t_str' /usr/bin/ld: /tmp/ccVVmUV4.o: in function rgb_matrix::CreateMatrixFromOptions(rgb_matrix::RGBMatrix::Options const&, rgb_matrix::RuntimeOptions const&)': ws2811wrapper.cpp:(.text._ZN10rgb_matrix23CreateMatrixFromOptionsERKNS_9RGBMatrix7OptionsERKNS_14RuntimeOptionsE[_ZN10rgb_matrix23CreateMatrixFromOptionsERKNS_9RGBMatrix7OptionsERKNS_14RuntimeOptionsE]+0x1c): undefined reference torgb_matrix::RGBMatrix::CreateFromOptions(rgb_matrix::RGBMatrix::Options const&, rgb_matrix::RuntimeOptions const&)' collect2: error: ld returned 1 exit status

How can I build them? Do I need qt and qmake on raspberrypi?

Romonaga commented 4 years ago

Yes, the directions to build this are not clear. Yes, this is for a raspberry pi.

However, please look at the larger project https://github.com/Romonaga/rpiLightSystem you will find instructions for the larger project.

I copied the section that should be most important to you.

Or you can follow the below steps that achive the same thing.

sudo apt install git qt5-default libqt5sql5-mysql build-essential gcc make cmake cmake-gui cmake-curses-gui libssl-dev wiringpi libi2c-dev libcppunit-dev scons doxygen
Clone or download DNRLogger from this repo. https://github.com/Romonaga/DNRLogger
    qmake .
    make
    sudo make install
Time to build the WS2811 support.
    clone or download the rpi_ws281x lib from this repo. https://github.com/Romonaga/rpi_ws281x ** You must use the one from this repo, it has changes the wrapper needs. I am hoping my changes make it into the main repo at some point. **
    run scons, this will build the lib.
        sudo cp *.h /usr/local/include/.
        sudo cp libws2811.a /usr/local/lib/.
Time to build the rpi-rgb-led-matrix
    make
    sudo cp lib/*.h /usr/local/include
    sudo cp lib/*.a /usr/local/lib
Lets build my wrapper around that fantastic lib!
clone or download Ws2811Wrapper from this repo https://github.com/Romonaga/Ws2811Wrapper
    run qmake .
    make
    sudo make install
atsu7 commented 4 years ago

Thank you very much. I followed your guide and built them successfully. By the way, how can I use their functions ? I want to learn how to write cpp file with this wrapper to turn on led-matrix.

Romonaga commented 4 years ago

This wrapper was built to support this project https://github.com/Romonaga/rpiLightSystem I would suggest that you examine https://github.com/Romonaga/rpiLightSystem/blob/master/src/lightsystem.cpp and examine function bool LightSystem::startSystem() This is where I do the initialization of the wrapper.

As to how to use this wrapper, there are many built in cpp classes to the rpiLightSystem. I suggest you examine the following for ideas as well as examples to use the API. There are examples of using LED Strips as well as matrix.

All of the code that manipulates LEDS or Matrix's are based on this Interface https://github.com/Romonaga/rpiLightSystem/blob/master/src/ilightshow.cpp

As you can see I have many helper functions in this class that you might be interested in.

For Matrix Check out https://github.com/Romonaga/rpiLightSystem/blob/master/src/matrixdisplayfile.cpp (This will show you how to use animated gifs) https://github.com/Romonaga/rpiLightSystem/blob/master/src/matrixscrolltext.cpp

I guess the question that I would have is what are you trying to build. Based on your GIT it appears that you have some python code that will drive them, but refresh is to slow. https://github.com/atsu7/neopixel_movieplayer_python

If your intent is to improve upon that, then I am not sure that my wrapper is what you need, as at this point I have not added the support for video (I am working on it.").

The https://github.com/hzeller/rpi-rgb-led-matrix project is far more powerful then the fraction of it I exposed in my wrapper, and if I am guessing correctly, my wrapper might not expose all the functionality you need to stream video at this time. However, if you look at the examples, if I am not mistaken, it shows how the lib can be used to display video.

What I can say, while I have had good luck with animated gif's I am interested to see if video playback frustrates would be to slow.

atsu7 commented 4 years ago

Thank you for your response. My goal is to play .mp4 file on neopixel matrix with c++ (because I want to use opencv and other c++ libs). I'm going to make function to read movie with opencv, so I just want a function like "setPixelColer[i][color]" . How can I use the function in my cpp file?

Romonaga commented 3 years ago

Sorry, have been busy. But, assuming you are using this lib and using a matrix, you would need to use void Ws2811Wrapper::setPixelColor(u_int32_t row, u_int32_t pixel, ws2811_led_t value)

row, col, color.