easybotics / node-rpi-rgb-led-matrix

Pilot your rgb led matrix with Nodejs ! Nodejs binding of rpi-rgb-led-matrix library https://github.com/hzeller/rpi-rgb-led-matrix - Actively Maintained!
Do What The F*ck You Want To Public License
57 stars 17 forks source link

drawText don't work. #3

Closed xFlowe closed 5 years ago

xFlowe commented 5 years ago

Hi, the drawText function is not working on my setup. RPI 3+, Adafruit HAT, Node 8.11

Let me know if i've made a code mistake: matrix.drawText(0,0,0,50,255,'text','10x20.bdf'); matrix.update();

No error messages etc.

All other functions are working.

Regards, Flo

ArcaneDiver commented 5 years ago

Hi xFlowe, look the way that you pass the parameters is wrong. if you would use those value x: 0, y: 0 r:0, g:50, b: 255, text: 'text' and the font: '10x20.bdf. ==> matrix.drawText(x, y, text, font, r, g, b); matrix.update(); ==> matrix.drawText(0, 0, 'text', './10x20', 0, 50, 255); matrix.update(); I hope that this will help you :)

keptan commented 5 years ago

You're on the right track, you just need to provide a path to the font instead of a filename; which can be tricky especially when you don't even know how your library will be installed

the way we do it in our node-red module is like this:

const input = "hello world!"; //whever you get the input from
const font  =  __dirname + '/fonts/' + "5x8.bdf";
led.drawText(x, y, 255, 255, 255, input, font);
led.update();

we should probably make it easier to use the 'default' fonts in the future

samturner3 commented 5 years ago

After hours of trying const font = __dirname + '/repo/node-rpi-rgb-led-matrix/external/matrix/fonts/' + "5x8.bdf"; led.drawText(32, 0, 'text', font, 255, 255, 255); led.update(); worked for me. Can you update the readme? led.drawText has wrong params order

keptan commented 5 years ago

https://github.com/easybotics/node-rpi-rgb-led-matrix/commit/c3e4163e176eed57d662a87a1fc5f60399439a42

fixed up the readme