Skip to content

Commit

Permalink
Merge pull request tinyelixir#1 from tinyelixir/tft-changes
Browse files Browse the repository at this point in the history
Change from inky to tft
  • Loading branch information
tmecklem authored Oct 25, 2021
2 parents f2938d4 + 6061d4a commit 7a6fe9d
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 206 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ A library to provide a Scenic framework driver implementation for SPI serial con

This driver only runs on RPi devices as far as we know as it is based on the scenic rpi driver generating a framebuffer we can use.

Many thanks to the work on the Inky Scenic Driver folks (https://github.com/pappersverk/scenic_driver_inky) who worked through the framebuffer capturing from rpi, and Frank Hunleth for his tireless work (https://github.com/fhunleth/rpi_fb_capture) (as always)

## Installation

The package can be installed
by adding `scenic_driver_inky` to your list of dependencies in `mix.exs`:
by adding `scenic_driver_fb_tft` to your list of dependencies in `mix.exs`:

```elixir
def deps do
Expand Down
59 changes: 59 additions & 0 deletions lib/scenic_driver_fb_tft.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
defmodule ScenicDriverFBTFT do
use Scenic.ViewPort.Driver

alias Scenic.ViewPort.Driver
require Logger

@default_refresh_rate 200
@minimal_refresh_rate 100

@impl true
def init(viewport, size, config) do
vp_supervisor = vp_supervisor(viewport)
{:ok, _} = Driver.start_link({vp_supervisor, size, %{module: Scenic.Driver.Nerves.Rpi}})

interval =
cond do
is_integer(config[:interval]) and config[:interval] > 100 -> config[:interval]
is_integer(config[:interval]) -> @minimal_refresh_rate
true -> @default_refresh_rate
end

{width, height} = size
{:ok, cap} = RpiFbCapture.start_link(width: width, height: height, display: 0)

Process.send_after(self(), :capture, 4_000)

{:ok,
%{
viewport: viewport,
size: size,
cap: cap,
last_crc: -1,
interval: interval
}}
end

@impl true
def handle_info(:capture, state) do
{:ok, frame} = RpiFbCapture.capture(state.cap, :rgb565)

crc = :erlang.crc32(frame.data)

if crc != state.last_crc do
File.write("/dev/fb1", frame.data)
end

Process.send_after(self(), :capture, state.interval)
{:noreply, %{state | last_crc: crc}}
end

defp vp_supervisor(viewport) do
[supervisor_pid | _] =
viewport
|> Process.info()
|> get_in([:dictionary, :"$ancestors"])

supervisor_pid
end
end
194 changes: 0 additions & 194 deletions lib/scenic_driver_inky.ex

This file was deleted.

13 changes: 6 additions & 7 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ defmodule ScenicDriverInky.MixProject do

def project do
[
app: :scenic_driver_inky,
version: "1.0.0",
app: :scenic_driver_fb_tft,
version: "0.1.0",
elixir: "~> 1.8",
description: description(),
package: package(),
Expand All @@ -28,22 +28,21 @@ defmodule ScenicDriverInky.MixProject do
{:scenic, "~> 0.9"},
{:scenic_driver_nerves_rpi, "~> 0.9", targets: @pi_targets},
{:rpi_fb_capture, "~> 0.1", targets: @pi_targets},
{:inky, "~> 1.0.0"},
{:ex_doc, ">= 0.0.0", only: :dev}
]
end

defp description do
"Pimoroni Inky driver for Scenic"
"Framebuffer TFT driver for Scenic"
end

defp package do
%{
name: "scenic_driver_inky",
name: "scenic_driver_fb_tft",
description:
"A library to provide a Scenic framework driver implementation for the Inky series of eInk displays from Pimoroni. Built on top of the pappersverk/inky library. All in Elixir.",
"A library to provide a Scenic framework driver implementation for generic TFT devices over SPI.",
licenses: ["Apache-2.0"],
links: %{"GitHub" => "https://github.com/lawik/scenic_driver_inky"}
links: %{"GitHub" => "https://github.com/makerion/scenic_driver_fb_tft"}
}
end
end
4 changes: 0 additions & 4 deletions test/scenic_driver_oled_bonnet_test.exs

This file was deleted.

0 comments on commit 7a6fe9d

Please sign in to comment.