Electron on resin.io devices

So I built my first project using electron yesterday. Its a node lib that allows you to build cross-platform apps. But the real exciting thing is that it allows you too build GUI apps using web technologies like html and css but it’s not sandboxed like a browser so you still have access to low-level stuff like gpio.

It’s really awesome and I’m definitely going to use it for future projects. Anyway, I’ve made a very basic app so you can get started right away. Just push this to your device and attach a screen and you are in business.

To test on your local machine just run: npm install && npm start

Hope you enjoy electron as much as I did!

1 Like

Hey Craig,

That’s awesome! I just received my raspberry pi screen and wanted to give this spin.

I’m having a couple of issues. Firstly once the app is installed for some reason Electron doesn’t actually show. I just get what appears to be a small white terminal taking up about a 1/4 of the screen with the current path on it.

I logged in with shell session. Killed xinit and ran exactly the same command again and it shows up. Still trying to work this one out. I did try upgrading to electron-prebuild 0.35.1. Same issue.

Also the touch part doesn’t seem to be working at present. I tried modprobe rpi-ft5406, which loaded without issue but still no touch and dmesg doesn’t seem to record any issues.

I’ll keep plugging away at it but any pointers would be appreciated. Thanks

Hey Moose,

hmm, that’s strange, I was testing with a plain HDMI to monitor setup. @shaunmulligan and Pablo made a drum machine with the rpi screen. Here is their code: https://github.com/pcarranzav/resin-electron-app. It’s not documented and has a lot of extras for the drum machine and ssh-access, but may help to debug.

I’ll get a screen soon to test, but if you find time in the interim feel free to submit a PR :smile:

Thanks Craig,

I did manage to get electron working from application boot. The hint came when I was looking up what xinit actually was (and why to use it instead of startx). The docs say that is no x application are started in the init script (in our case launch_app.sh) it will default to starting xterm. Which is exactly what it was doing.

It seems that for some reason or other the docker CMD is calling xinit successfully but not passing through the launch_app.sh script (or that the script fails for some reason) here. Hence it starts xterm. I also tried the other way of defining CMD with:

CMD [“xinit”, “arg1”, “arg2”, “etc…”]

But this made no difference. I’m still unsure as to why this is failing. However, I wrapped the xinit call itself in another bash script and call that from the docker CMD and magically it starts.

Touch is still not working but there are some useful pointers I can try in Pablo’s repo you sent through.

Once I have it all up and running I’ll tidy everything up and open a PR.

Thanks again.

Still no luck with touch using Resin but Raspian works out the box so at least I know my screen actually functions.

Seems at least one yocto user had to add the following to config.txt:

dtoverlay=rpi-ft5406

So I’ll give that a go and see where I get to.

Success!!!

I needed to add the following to the end of my config.txt

device_tree_overlay=rpi-ft5406-overlay.dtb
lcd_rotate=2

The device_tree_overlay entry enabled the touch screen and the lcd_rotate is because my case seems to mount the screen upside down.

I also have a modprobe rpi-ft5406 but I’m not sure if that is really necessary.

Awesome @moose!

How is the rest going of the electron building?

One issue I had was accessing console errors, as my electron app was calling static js that wasn’t outputting to stdout, just meant I had to luanch `mainWindow.webContents.openDevTools();’ when debugging, but it’d be nice to route all logs to resin.

Hey, @moose, here’s a Electron boilerplate / template application that was just updated recently, and should work well with Raspberry Pi, thought it might be interesting for you: https://github.com/resin-io/resin-electronjs/

Come and study with us!!! http://www.kstu.kz/