Skip to content

A library for managing Inky e-ink displays from Elixir.

License

Notifications You must be signed in to change notification settings

pappersverk/inky

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Inky

CircleCI hex.pm

This is a port of Pimoroni's python Inky library 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.

See the API reference for details on how to use the functionality provided.

Host Development

An inky host development library is underway for allowing host-side development, but until that is finished you can not see results without using a physical device.

Scenic Driver

A basic driver for scenic is in the works, check it out, to follow how it is progressing.

Getting started

Inky is available on Hex. Add inky to your mix.exs deps:

{:inky, "~> 1.0.1"},

Run mix deps.get to get the new dep.

Usage

A sample for Inky only, both host development and on-device is available as pappersverk/sample_inky.

A sample for using it with Scenic both for host development and on-device is available as pappersverk/sample_scenic_inky.

Brief example

In typical usage this would be inside a nerves project. If Inky is installed in your application you can do the following to test it and your display (note the config in init, adjust accordingly):

# Start your Inky process ...
{:ok, pid} = Inky.start_link(:phat, :red, %{name: InkySample})

painter = fn x, y, w, h, _pixels_so_far ->
  wh = w / 2
  hh = h / 2

  case {x >= wh, y >= hh} do
    {true, true} -> :red
    {false, true} -> if(rem(x, 2) == 0, do: :black, else: :white)
    {true, false} -> :black
    {false, false} -> :white
  end
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})