Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ is in the works, check it out, to follow how it is progressing.
Inky is available on Hex. Add inky to your mix.exs deps:

```elixir
{:inky, "~> 1.0.1"},
{:inky, "~> 1.0.2"},
```

Run `mix deps.get` to get the new dep.
Expand All @@ -38,6 +38,27 @@ A sample for Inky only, both host development and on-device is available as [pap

A sample for using it with Scenic both for host development and on-device is available as [pappersverk/sample_scenic_inky](https://github.com/pappersverk/sample_scenic_inky).

There are multiple variants of wHAT, pHAT, etc, and they are hard to distinguish.
You can read the display information from your Inky's EEPROM by invoking `Inky.EEPROM.read/0`.

```elixir
iex> Inky.EEPROM.read()
{:ok,
%Inky.EEPROM{
color: :red,
display_variant: "Red pHAT (SSD1608)",
height: 104,
pcb_variant: 12,
timestamp: "2021-03-30 08:58:28.9",
width: 212
}}
```
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably should mention what one could do with this information below the example.


Particularly the display variant gives you a clue what type of Inky you are
using, based on which you will determine the options for `Inky.start_link/3`.

`Inky.EEPROM.read/0` works only one time after the display is powered on.

## Brief example

In typical usage this would be inside a nerves project. If Inky is installed in
Expand All @@ -63,5 +84,5 @@ end
Inky.set_pixels(InkySample, painter, border: :white)

# Flip a few pixels
Inky.set_pixels(pid, %{{0,0}: :black, {3,49}: :red, {23, 4}: white})
Inky.set_pixels(pid, %{{0, 0} => :black, {3, 49} => :red, {23, 4} => :white})
```
4 changes: 3 additions & 1 deletion lib/display/display.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ defmodule Inky.Display do
alias Inky.LookupTables

@type t() :: %__MODULE__{}
@type variant :: :phat | :phat_ssd1608 | :what
@type accent :: :black | :red | :yellow
Comment thread
mnishiguchi marked this conversation as resolved.

@enforce_keys [:type, :width, :height, :packed_dimensions, :rotation, :accent, :luts]
defstruct type: nil,
Expand All @@ -16,7 +18,7 @@ defmodule Inky.Display do
accent: :black,
luts: <<>>

@spec spec_for(:phat_ssd1608 | :phat | :what, :black | :red | :yellow) :: Inky.Display.t()
@spec spec_for(variant(), accent()) :: Inky.Display.t()
def spec_for(type, accent \\ :black)

def spec_for(type = :phat_ssd1608, accent) do
Expand Down
1 change: 1 addition & 0 deletions lib/inky.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ defmodule Inky do

See `GenServer.start_link/3` for return values.
"""
@spec start_link(Inky.Display.variant(), Inky.Display.accent(), map()) :: GenServer.on_start()
def start_link(type, accent, opts \\ %{}) do
genserver_opts = if(opts[:name], do: [name: opts[:name]], else: [])
GenServer.start_link(__MODULE__, [type, accent, opts], genserver_opts)
Expand Down