zetsin / node-sdl2

Bindings for SDL2 in Node
54 stars 14 forks source link

No available video device (Raspbian Stretch) #9

Open uwe76 opened 6 years ago

uwe76 commented 6 years ago

Hi Zetsin,

I would like to run two graphical JavaScript applications on two separate displays. Right now, I'm using multiple Adafruit displays with a Raspberry Pi Zero W. They're registered as /dev/fb1 and /dev/fb2 via SPI and display overlays. I set an environmental variable via export SDL_FBDEV="/dev/fb1". If I'm now running your test.js I end up with the error "No available video device" after I modified app.js slightly:

const SDL_error = require('../dep/SDL_error') [...] if(SDL.SDL_Init(flags) != 0) { console.log(flags); console.log(SDL_error.SDL_GetError()); this.quit() return }

Can you hint me how to use node-sdl2 with multiple dedicated framebuffer devices?

Cheers, Uwe

zetsin commented 6 years ago

Hi, it seems that error is thrown by SDL2.0, https://gist.github.com/zetsin/9d524ed07aaf974f4bb2e45bdabed3f5#file-sdl_video-c-L516

you should predefine macro SDL_VIDEO_DRIVER_RPI when compiling SDL2 lib

uwe76 commented 6 years ago

Hi, thanks for the quick reply. Inspired by your answer I've been looking around more and found my mistake(s). For a start, Raspbian Stretch SDL2 (v2.0.5) is only supporting X11 (as you already pointed out implicitly) - not direct output via the Raspberry video driver "RPI" nor the framebuffer driver "directfb". But, before I recompile SDL2 from scratch I tried X11 instead. So, after configuring my xorg.conf to use SPI framebuffer devices and setting the correct environmental variables I was able to start your test.js :-). Thank you very much for the push in the right direction.

xorg.conf:

[...] Section "Device" Identifier "fbtft_dev" Driver "fbdev" Option "fbdev" "/dev/fb1" EndSection [...]

console:

export $DISPLAY=:0.0 export SDL_VIDEODRIVER=x11 node test.js

zetsin commented 6 years ago

It's cool. Where is your project, may I have a look? I've never developed with Raspbian, that I started to have a little bit interest in.

uwe76 commented 6 years ago

I don't have my projects (yet) on GitHub. Until now, I'm using my own Git server; let's see what happens when Microsoft chips in to GitHub ;-) - I just registered to GitHub recently. I was using https://github.com/vesteraas/node-pitft to write some simple JavaScript thingys (like e.g. a Mario inspired jump and run) displaying some stuff on Adafruit displays. I love the low entry point and ease of use. But, because the Raspberry Pi Zero is so slow to dev/run the code I've been looking around for alternative dev options. Basically, I would like to write and test my code on a PC using an emulator or such. It's such a struggle to test any graphical output on a real Raspi + TFT display in JavaScript. It would be nice to have a separate dev environment and only go to HW when you're ready about it.