boydm / scenic_driver_nerves_rpi

Scenic render-only driver for the Raspberry Pi under Nerves
Apache License 2.0
22 stars 12 forks source link

How to do windowed scene? #16

Open Cowa opened 3 years ago

Cowa commented 3 years ago

Hello!

I'm working on figuring out how to do windowed scene with the rpi driver. Currently it works only in fullscreen mode.

I managed to get it mostly working.

The changes can be found here: https://github.com/Cowa/scenic_driver_nerves_rpi/commit/6f8b05533d3a0b2527a11d1831f4fbb37f82343d

Here an example, with this config:

config :phenix_player, :id_overlay, %{
  size: {1080, 100},
  default_scene: {PhenixPlayer.Debug.IdOverlay, nil},
  drivers: [
    %{
      module: Scenic.Driver.Nerves.Rpi,
      opts: [layer: 99_000, global_opacity: 200, position: {0, 500}]
    }
  ]
}

The scenic scene is correctly positioned and sized (the black rectangle with ID and MAC):

snapshot-ref_scenic-highlighted

Everything looks fine but actually no if we look at the build_graph function:

data = """
ID: #{format_id(player_id)}
MAC: #{mac_address}
"""

graph_elements = [
  text_spec(data, translate: {20, 1860})
]

The text must be positioned at (20, 1860) to be visible (my screen is 1920x1080 in portrait mode). Whereas I would have expected it to be at (20, 20).

The top-left corner of the black rectangle should be (0, 0).

snapshot-ref 2

Something is wrong and I can't figure out where the problem is. Changes made: https://github.com/Cowa/scenic_driver_nerves_rpi/commit/6f8b05533d3a0b2527a11d1831f4fbb37f82343d

If you have any idea, I would really appreciate it.

Thank you!

boydm commented 3 years ago

Setting up windows directly on the hardware system is delving into the dark arts. I'm not surprised the origin is messed up since that is going to be hardware specific. You probably need to put a global translate on the driver itself in the config.

config :phenix_player, :id_overlay, %{
  size: {1080, 100},
  default_scene: {PhenixPlayer.Debug.IdOverlay, nil},
  drivers: [
    %{
      module: Scenic.Driver.Nerves.Rpi,
      opts: [layer: 99_000, global_opacity: 200, position: {0, 500}, translate: {20, 1860}]
    }
  ]
}

Give it a try. Not sure it will work tho. I'll be getting to RPI driver in the v.11 work in a few weeks. Would be good to know how this plays out before then.

boydm commented 3 years ago

I don't know anything about the overall app. Is the background dynamic or is it a static image? Can you just make the whole thing a Scenic app and let it be full-screen? That's certainly what I had in mind as I built it. Didn't really plan for hardware level windowing in the rpi driver

Cowa commented 3 years ago

Thanks for replying @boydm!

I tried with the translate but the issue is still here.

And for more context about the app:

A playlist of videos is played in the background using OMX Player. No user input. It's "just" a screen.

We use Scenic as overlays to show informations on top of the videos. It's used for debugging purposes (to inspect the global state) or to provide necessary informations when provisionning and installing a new screen.

These are our 2 usages for now:

debug-overlay

shot-id

boydm commented 3 years ago

OK. Thank you for the context.

I'll be getting into the code for the rpi driver soon, so will take a look at it.

Out of curiosity, if Scenic had a Video primitive (and... obviously... support for audio), would you consider using it for the whole UI?

Cowa commented 3 years ago

If it was possible with Scenic we would definitely consider using it if it manages all our expectations.

Avoiding the mixing of UNIX and BEAM processes in our application would simplify it (we have to use dbus-server to send commands to OMX Player instances).

cblavier commented 3 years ago

@boydm do you think video support could land in Scenic in a near future?