Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
7d80cce
Start work on on Inky Impression
lawik Oct 10, 2021
8ee2dda
More work on setup and update for Inky Impression
lawik Oct 27, 2021
6e11741
Add all of the Impression code but not working, added cs0 but that wo…
lawik Oct 27, 2021
c56c9be
Kinda working!
axelson Nov 8, 2021
e415e0e
Kind of like a flag
axelson Nov 8, 2021
fc37b1f
Cleaning
axelson Nov 9, 2021
cc82eda
Clean up cs pin calls
axelson Nov 9, 2021
99d2cd5
clean
axelson Nov 9, 2021
7a636df
Merge pull request #42 from axelson/jax/inky-impression
lawik Nov 9, 2021
753d5a8
Fix log typo
Jul 3, 2022
3f46d9a
Adds comments to byte commands defined for Impression in hal
Jul 3, 2022
3142798
Fix typo in comment
Jul 3, 2022
ae2e48f
Update mix deps for development on jasonmj
Jul 3, 2022
07f75e6
Update display definition for impression
Jul 3, 2022
63cdb4f
Add handling for impression in packed_width and packed_height
Jul 3, 2022
13793cd
Fix usage of state in log function
Jul 3, 2022
853021b
Add set_dimensions to do_update for impression
Jul 3, 2022
46a3b40
Replace buffer generation with PixelUtil.pixels_to_bits
Jul 3, 2022
9dfa181
Add a color_map for the impression
Jul 3, 2022
5bfb57f
Add notes about WIP toward impression support
Jul 3, 2022
4689834
Reverting dev changes to mix.exs
Jul 3, 2022
3bcf4f1
Cleaning up unused code
Jul 8, 2022
590c25f
Adding bit_size option to PixelUtil.pixels_to_bits
Jul 8, 2022
d5bca11
Merge pull request #46 from jasonmj/impression
lawik Jul 11, 2022
9abc79f
Cleans up code for PR
Jul 12, 2022
80bdee8
Adds painter test
Jul 12, 2022
f86d1b8
Support circuits_gpio 1.0
axelson Jul 13, 2022
b30be19
Merge pull request #47 from axelson/impression
Jul 13, 2022
a68e31a
Add support for buttons on Inky Impression
Jul 23, 2022
40cda84
Support sending button messages to a process by registered atom name
Aug 1, 2022
6a6cd42
Merge pull request #48 from jasonmj/impression
lawik Aug 1, 2022
35eb6cd
WIP
axelson Jul 30, 2023
765d6ff
Merge remote-tracking branch 'origin/master' into impression73-messy
axelson Aug 7, 2023
2fa18a3
Refactor!
axelson Aug 7, 2023
5d65f09
Fix credo issues
axelson Aug 7, 2023
f6e11c7
Allow newer versions of circuits libraries
axelson Aug 7, 2023
975d63b
Rename phat_original to phat_il91874
axelson Aug 13, 2023
4174f7e
Rename Buttons to ImpressionButtons
axelson Aug 13, 2023
c81122d
Improve the readme
axelson Aug 13, 2023
83a37a8
Rename bit_size to bit_count
axelson Aug 13, 2023
535ba1d
IO.Phat moduledoc
axelson Aug 13, 2023
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
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

This is a port of Pimoroni's [python Inky
library](https://github.com/pimoroni/inky) written in Elixir. This library is
intended to support both Inky pHAT and wHAT, but since we only have pHATs, the
wHAT support may not be fully functional.
intended to support the Inky pHAT and Inky Impression. Eventually it will support the Inky wHAT as well but it is not currently supported.

See the [API reference](https://hexdocs.pm/inky/api-reference.html) for details
on how to use the functionality provided.
Expand All @@ -19,15 +18,15 @@ can not see results without using a physical device.

### Scenic Driver

A [basic driver](https://github.com/pappersverk/scenic_driver_inky) for scenic
is in the works, check it out, to follow how it is progressing.
There is [basic driver](https://github.com/pappersverk/scenic_driver_inky) for use with
[scenic](https://github.com/ScenicFramework/scenic).

## Getting started

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 @@ -46,7 +45,8 @@ config in init, adjust accordingly):

Comment thread
axelson marked this conversation as resolved.
```elixir
# Start your Inky process ...
{:ok, pid} = Inky.start_link(:phat, :red, %{name: InkySample})
type = :phat_il91874
{:ok, pid} = Inky.start_link(type, accent: :red, name: InkySample)

painter = fn x, y, w, h, _pixels_so_far ->
wh = w / 2
Expand All @@ -65,3 +65,12 @@ Inky.set_pixels(InkySample, painter, border: :white)
# Flip a few pixels
Inky.set_pixels(pid, %{{0,0}: :black, {3,49}: :red, {23, 4}: white})
```

## Figuring out the value to pass for `type`

- Inky pHAT ordered roughly before 2019 -> `:phat_il91874`
- Inky pHAT ordered roughly after 2019 -> `:phat_ssd1608`
- Inky Impression 4" -> `:impression_4`
- Inky Impression 5.7" -> `:impression_5_7`
- Inky Impression 7.3" -> `:impression_7_3`
- Inky wHAT: **Not currently supported**
2 changes: 1 addition & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
#
# This configuration file is loaded before any dependency and
# is restricted to this project.
use Mix.Config
import Config
65 changes: 60 additions & 5 deletions lib/display/display.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,68 @@ defmodule Inky.Display do
width: 0,
height: 0,
packed_dimensions: %{},
packed_resolution: nil,
rotation: 0,
accent: :black,
luts: <<>>

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

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.

Is :none actually needed here? Would be nice to exclude on models that do not have an accent.

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.

It is, if it's going to be a clause in the same function, since arity is part of function identity... or maybe it isn't in Elixir, in contrast to Erlang?

def spec_for(type = :impression_7_3, :none) do
width = 800
height = 480

%__MODULE__{
type: type,
width: width,
height: height,
packed_dimensions: %{},
packed_resolution:
<<width::unsigned-big-integer-size(16)>> <> <<height::unsigned-big-integer-size(16)>>,
rotation: 0,
accent: nil,
luts: <<>>
}
end

@spec spec_for(:impression_5_7, :none) :: Inky.Display.t()
def spec_for(type = :impression_5_7, :none) do
width = 600
height = 448

%__MODULE__{
type: type,
width: width,
height: height,
packed_dimensions: %{},
packed_resolution:
<<width::unsigned-big-integer-size(16)>> <> <<height::unsigned-big-integer-size(16)>>,
rotation: 0,
accent: nil,
luts: <<>>
}
end

# WARNING: This is untested on actual hardware

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.

Hmm, I wonder if Pimoroni would be willing to send us one? I went ahead and wrote a quick note to their support team to see if there's a chance.

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.

Pimoroni is sending me a 4" Impression for testing 🎉

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Wow, that's great!!

@spec spec_for(:impression_4, :none) :: Inky.Display.t()
def spec_for(type = :impression_4, :none) do
width = 640
height = 400

%__MODULE__{
type: type,
width: width,
height: height,
packed_dimensions: %{},
packed_resolution:
<<width::unsigned-big-integer-size(16)>> <> <<height::unsigned-big-integer-size(16)>>,
rotation: 0,
accent: nil,
luts: <<>>
}
end

@spec spec_for(:phat_il91874 | :phat_ssd1608 | :what, :black | :red | :yellow) ::
Inky.Display.t()
def spec_for(type = :phat_ssd1608, accent) do
# Keep it minimal. Details are specified in `Inky.HAL.PhatSSD1608`.
%__MODULE__{
Expand All @@ -32,7 +87,7 @@ defmodule Inky.Display do
}
end

def spec_for(type = :phat, accent) do
def spec_for(type = :phat_il91874, accent) do
%__MODULE__{
type: type,
width: 212,
Expand Down Expand Up @@ -78,7 +133,7 @@ defmodule Inky.Display do
columns =
case type do
:what -> width
:phat -> height
:phat_il91874 -> height
:test_small -> height
end

Expand All @@ -89,7 +144,7 @@ defmodule Inky.Display do
rows =
case type do
:what -> height
:phat -> width
:phat_il91874 -> width
:test_small -> width
end

Expand Down
9 changes: 5 additions & 4 deletions lib/display/pixelutil.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Inky.PixelUtil do
PixelUtil maps pixels to bitstrings to be sent to an Inky screen
"""

def pixels_to_bits(pixels, width, height, rotation_degrees, color_map) do
def pixels_to_bits(pixels, width, height, rotation_degrees, color_map, bit_count \\ 1) do
{outer_axis, dimension_vectors} =
rotation_degrees
|> normalised_rotation()
Expand All @@ -13,7 +13,8 @@ defmodule Inky.PixelUtil do
|> rotated_ranges(width, height)
|> do_pixels_to_bits(
&pixels[pixel_key(outer_axis, &1, &2)],
&(color_map[&1] || color_map.miss)
&(color_map[&1] || color_map.miss),
bit_count
)
end

Expand Down Expand Up @@ -61,10 +62,10 @@ defmodule Inky.PixelUtil do
defp rotated_dimension(_width, height, {:y, 1}), do: 0..(height - 1)
defp rotated_dimension(_width, height, {:y, -1}), do: (height - 1)..0

defp do_pixels_to_bits({i_range, j_range}, pixel_picker, cmap) do
defp do_pixels_to_bits({i_range, j_range}, pixel_picker, cmap, bit_count) do
for i <- i_range,
j <- j_range,
do: <<cmap.(pixel_picker.(i, j))::size(1)>>,
do: <<cmap.(pixel_picker.(i, j))::size(bit_count)>>,
into: <<>>
end

Expand Down
Loading