Does anyone have experience running Scenic with Nerves on RPi3, with display output going to a smaller screen that fits on top the the RPi3?
There’s quite a few ways to connect a display to an RPi3 and it’s unclear to me which ones are compatible with Scenic+Nerves.
From looking through the ads and docs of some displays, it seems they need a special driver or library. Curious if anyone has gotten one to work with Scenic+Nerves.
I did get Scenic+Nerves to draw on a regular computer monitor attached to the RPi3 via HDMI.
Hi! I have the officialRaspberry PI touch display (from the ElixirConf nerves training) and it’s working great with Scenic (I even have touch working!). I didn’t have to do any special setup except for configuring scenic_driver_nerves_touch.
Are you using a keyboard with the rpi3? I have an rpi3 and the same touch screen plus a USB keyboard but I am not getting any keyboard events via handle_input/3 in my scene code. Works fine on MacOS, but on rpi no keyboard events.
Also haven’t figured out how touchscreen events work with the handler model in Scenic scenes, does it also work with handle_input/3? what to pattern match on? Any advice?
def handle_input(input, viewport_context, state) do
Logger.info("Received input: #{inspect input}")
do_handle_input(input, viewport_context, state)
end
Then the do_handle_input clauses matches on {:cursor_pos and {:cursor_button:
# Mouse/Touchscreen drag input
def do_handle_input({:cursor_pos, cursor_coords}, _viewport_context, state) do
{:noreply, update_cursor_coords(state, cursor_coords)}
end
# Mouse Click/Touchscreen tap input
def do_handle_input({:cursor_button, {:left, :press, _, cursor_coords}}, _viewport_context, state) do
# track tap
end
Have you used RingLogger to view logs from the device? The logging is the main reason that I keep the top-level handle_input around. If you have ring logger installed you can ssh into your raspberry pi and run RingLogger.tail or RingLogger.attach to view the logs.
If you want to try out my code it’s released as MIT: https://github.com/axelson/scenic_playground It’s a little asteroids clone that’s most of the way done (although there’s no way to move around on a device, unless a keyboard works, also I should rename my repository).
If you cd fw; mix deps.get; mix firmware; and then upload the firmware to your device it should work.
Also are you running your scenic program locally as well? Or just on-device?
Sadly, I don’t think anyone has written a non-touch input driver for Scenic on Nerves yet. The input driver at scenic_driver_nerves_touch only looks for a touchscreen sensor and processes events from it.
It seems like there could be a driver receives input from all input devices and sends them through Scenic. The input_event library looks like some code could enumerate the input sources and then start a listener on all of them. I haven’t studied the glue code to scenic, but I’d hope that the touch driver could serve as a good guide.
Thanks for the info. I now have things set up with nerves init-gadget, firmware_ssh, etc and started using RingLogger over ssh. Your code examples were helpful, thanks again.
To get started, I went ahead and got the official 7" Raspberry Pi screen and a matching stand. This setup will actually be better for my current needs We’ll see where it goes later. Next step for me is to learn more Scenic and read analog input from a linear poti.
Update on input events to Scenic: I just submitted a PR to the input_event library to support generically identifying keyboards, mice, joysticks, touchscreens, and the other random things that show up as input devices like audio input jack detectors and power buttons. Hopefully once it gets merged (it is a big change, so might take a bit), someone can help add the Scenic driver pieces to make it work.
Update: the PR got accepted and an input_event release was made. Thanks @mobileoverlord! Also, @boydm made a new release of scenic_driver_nerves_touch that is compatible with it. There was a breaking API change in the PR, but I think it will go unnoticed.
One last comment: I spent entirely way too much time playing asteroids thanks to @axelson’s scenic_playground. That was fun. Everything happening around scenic really makes me happy.