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 · GitHub 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

Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
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 Postgres...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
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
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
yawaramin
In the Dialyzer docs ( dialyzer — OTP 29.0.2 (dialyzer 6.0.1) ), there is a way to turn off a specific warning for a function: -dialyzer...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New

Other popular topics Top

AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement