BinaryMuse

BinaryMuse

Trouble displaying Scenic UI on RPI3 with original 7" touch display

Hi all,

I’m coming to Nerves with considerable Elixir experience but very little hardware experience. I’m trying to use Scenic to display a UI on my Raspberry Pi 3 Model B v1.2 using the original 7" touch display, connected via ribbon cable and powered via the GPIO pins.

I’m able to build firmware and push it to the device, and the IEx console displays on the touch display and works great. I’m also able to run mix scenic.run with MIX_TARGET=host to preview my Scenic UI on my development machine with no problem. However, I can’t get anything to display on the touch display other than the IEx console.

My configuration is as follows (truncated for brevity):

# mix.exs
defmodule HelloNerves.MixProject do
  # ...

  def project do
    [
      app: @app,
      version: @version,
      elixir: "~> 1.18",
      archives: [nerves_bootstrap: "~> 1.13"],
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      releases: [{@app, release()}],
      preferred_cli_target: [run: :host, test: :host]
    ]
  end

  def application do
    [
      extra_applications: [:logger, :runtime_tools, :scenic],
      mod: {HelloNerves.Application, []}
    ]
  end

  defp deps do
    [
      # Dependencies for all targets
      {:nerves, "~> 1.10", runtime: false},
      {:shoehorn, "~> 0.9.1"},
      {:ring_logger, "~> 0.11.0"},
      {:toolshed, "~> 0.4.0"},

      # Allow Nerves.Runtime on host to support development, testing and CI.
      # See config/host.exs for usage.
      {:nerves_runtime, "~> 0.13.0"},

      # Dependencies for all targets except :host
      {:nerves_pack, "~> 0.7.1", targets: @all_targets},
      {:vintage_net_wifi, "~> 0.12", targets: @all_targets},
      # ...
      {:nerves_system_rpi3, "~> 1.24", runtime: false, targets: :rpi3},
      # ...
      {:scenic, "~> 0.11.2", override: true},
      # For local development
      {:scenic_driver_local, "~> 0.11.0-beta.0", targets: :host},
      # For Raspberry Pi rendering
      {:scenic_driver_nerves_rpi,
       git: "git@github.com:boydm/scenic_driver_nerves_rpi.git",
       branch: "v0.11",
       targets: @all_targets},
      # For Raspberry Pi touch input
      {:scenic_driver_nerves_touch,
       git: "git@github.com:boydm/scenic_driver_nerves_touch.git",
       branch: "v0.11",
       targets: @all_targets}
    ]
  end

  def release do
    [
      overwrite: true,
      # Erlang distribution is not started automatically.
      # See https://hexdocs.pm/nerves_pack/readme.html#erlang-distribution
      cookie: "#{@app}_cookie",
      include_erts: &Nerves.Release.erts/0,
      steps: [&Nerves.Release.init/1, :assemble],
      strip_beams: Mix.env() == :prod or [keep: ["Docs"]]
    ]
  end
end
# target.exs
config :hello_nerves, :viewport, %{
  size: {800, 480},
  theme: :dark,
  default_scene: HelloNerves.Scene.Home,
  drivers: [
    [
      module: Scenic.Driver.Nerves.Rpi,
      name: :rpi_driver,
      debug: true
    ],
    [
      module: Scenic.Driver.Nerves.Touch,
      name: :touch_driver,
      device: "raspberrypi-ts",
      calibration: {{1, 0, 0}, {0, 1, 0}}
    ]
  ]
}
# application.ex
defmodule HelloNerves.Application do
  use Application

  require Logger

  @impl true
  def start(_type, _args) do
    Logger.info("Waiting for 1 second to allow touch device to be ready")
    Process.sleep(1000)
    Logger.info("Starting HelloNerves application")
    viewport_config = Application.get_env(:hello_nerves, :viewport)

    children =
      [
        HelloNerves.PubSub.Supervisor,
        {Scenic, [viewport_config]}
      ]

    opts = [strategy: :one_for_one, name: HelloNerves.Supervisor]
    Supervisor.start_link(children, opts)
  end
end

If useful, here are the logs: ringlogger_next.txt · GitHub

I also have some Logger.info calls in my HelloNerves.Scene.Home.init function, and I can see that they’re being called, and I can verify that the Scenic application is running — I just don’t get any UI on the device other than the IEx console.

I’m hoping there’s something simple I’m missing, and any help is very much appreciated!

Most Liked

axelson

axelson

Scenic Core Team

Hi there! :waving_hand:

I see a couple things that could cause issues with your setup. You can remove scenic_driver_nerves_rpi from your mix.exs since scenic_driver local supplants the RPI-specific driver entirely.

And similarly you can remove the two drivers you have in your config, and instead just include scenic_driver_local:

  drivers: [
    [
      module: Scenic.Driver.Local
    ]
  ]

I think that’s likely the problem, i.e. scenic_driver_local isn’t running at all, hence nothing is displaying.

I haven’t tested it recently, but GitHub - ScenicFramework/scenic_nerves_starter should serve as a good starting point for combining Scenic and Nerves. Although I’d really like to create an Igniter-based installer at some point.

I hope that helps you get started!

Where Next?

Popular in Questions Top

ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
Phillipp
Hey, I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

Other popular topics Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement