-
Notifications
You must be signed in to change notification settings - Fork 12
Start work on on Inky Impression #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
7d80cce
Start work on on Inky Impression
lawik 8ee2dda
More work on setup and update for Inky Impression
lawik 6e11741
Add all of the Impression code but not working, added cs0 but that wo…
lawik c56c9be
Kinda working!
axelson e415e0e
Kind of like a flag
axelson fc37b1f
Cleaning
axelson cc82eda
Clean up cs pin calls
axelson 99d2cd5
clean
axelson 7a636df
Merge pull request #42 from axelson/jax/inky-impression
lawik 753d5a8
Fix log typo
3f46d9a
Adds comments to byte commands defined for Impression in hal
3142798
Fix typo in comment
ae2e48f
Update mix deps for development on jasonmj
07f75e6
Update display definition for impression
63cdb4f
Add handling for impression in packed_width and packed_height
13793cd
Fix usage of state in log function
853021b
Add set_dimensions to do_update for impression
46a3b40
Replace buffer generation with PixelUtil.pixels_to_bits
9dfa181
Add a color_map for the impression
5bfb57f
Add notes about WIP toward impression support
4689834
Reverting dev changes to mix.exs
3bcf4f1
Cleaning up unused code
590c25f
Adding bit_size option to PixelUtil.pixels_to_bits
d5bca11
Merge pull request #46 from jasonmj/impression
lawik 9abc79f
Cleans up code for PR
80bdee8
Adds painter test
f86d1b8
Support circuits_gpio 1.0
axelson b30be19
Merge pull request #47 from axelson/impression
a68e31a
Add support for buttons on Inky Impression
40cda84
Support sending button messages to a process by registered atom name
6a6cd42
Merge pull request #48 from jasonmj/impression
lawik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,8 +9,45 @@ defmodule Inky.Impression.RpiHAL do | |
|
|
||
| @behaviour Inky.HAL | ||
|
|
||
| @color_map_black %{black: 0, miss: 1} | ||
| @color_map_accent %{red: 1, yellow: 1, accent: 1, miss: 0} | ||
| @colors %{ | ||
| :black => 0, | ||
| :white => 1, | ||
| :green => 2, | ||
| :blue => 3, | ||
| :red => 4, | ||
| :yellow => 5, | ||
| :orange => 6, | ||
| :clean => 7 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should probably be named |
||
| } | ||
|
|
||
| @psr 0x00 | ||
| @pwr 0x01 | ||
| @pof 0x02 | ||
| @pfs 0x03 | ||
| @pon 0x04 | ||
| @btst 0x06 | ||
| @dslp 0x07 | ||
| @dtm1 0x10 | ||
| @dsp 0x11 | ||
| @drf 0x12 | ||
| @ipc 0x13 | ||
| @pll 0x30 | ||
| @tsc 0x40 | ||
| @tse 0x41 | ||
| @tws 0x42 | ||
| @tsr 0x43 | ||
| @cdi 0x50 | ||
| @lpd 0x51 | ||
| @tcon 0x60 | ||
| @tres 0x61 | ||
| @dam 0x65 | ||
| @rev 0x70 | ||
| @flg 0x71 | ||
| @amv 0x80 | ||
| @vv 0x81 | ||
| @vdcs 0x82 | ||
| @pws 0xE3 | ||
| @tsset 0xE5 | ||
|
|
||
| alias Inky.Display | ||
| alias Inky.HAL | ||
|
|
@@ -52,7 +89,6 @@ defmodule Inky.Impression.RpiHAL do | |
| accent_bits = PixelUtil.pixels_to_bits(pixels, w, h, r, @color_map_accent) | ||
|
|
||
| reset(state) | ||
| soft_reset(state) | ||
|
|
||
| case pre_update(state, push_policy) do | ||
| :cont -> do_update(state, display, border, black_bits, accent_bits) | ||
|
|
@@ -77,9 +113,18 @@ defmodule Inky.Impression.RpiHAL do | |
| end | ||
|
|
||
| defp do_update(state, display, border, buf_black, buf_accent) do | ||
| d_pd = display.packed_dimensions | ||
|
|
||
| state | ||
| |> set_resolution(display.packed_resolution) | ||
| |> set_panel() | ||
| |> set_power() | ||
| |> set_pll_clock_frequency() | ||
| |> set_tse_register() | ||
| |> set_vcom_data_interval_setting(border) | ||
| |> set_gate_source_data_interval_setting() | ||
| |> disable_external_flash() | ||
| |> set_pws_whatever_that_means() | ||
| # TODO: Continue with update here from https://github.com/pimoroni/inky/blob/master/library/inky/inky_uc8159.py#L311 | ||
|
|
||
| |> set_analog_block_control() | ||
| |> set_digital_block_control() | ||
| |> set_gate(d_pd.height) | ||
|
|
@@ -118,6 +163,60 @@ defmodule Inky.Impression.RpiHAL do | |
| end | ||
|
|
||
| defp soft_reset(state), do: write_command(state, 0x12) | ||
|
|
||
| # >HH struct.pack, so big-endian, unsigned-sort * 2 | ||
| defp set_resolution(state, packed_resolution), do: write_command(state, @tres, packed_resolution) | ||
|
|
||
| # Panel Setting | ||
| # 0b11000000 = Resolution select, 0b00 = 640x480, our panel is 0b11 = 600x448 | ||
| # 0b00100000 = LUT selection, 0 = ext flash, 1 = registers, we use ext flash | ||
| # 0b00010000 = Ignore | ||
| # 0b00001000 = Gate scan direction, 0 = down, 1 = up (default) | ||
| # 0b00000100 = Source shift direction, 0 = left, 1 = right (default) | ||
| # 0b00000010 = DC-DC converter, 0 = off, 1 = on | ||
| # 0b00000001 = Soft reset, 0 = Reset, 1 = Normal (Default) | ||
| defp set_panel(state), do: write_command(state, @psr, [0b11101111, 0x08] | ||
|
|
||
| defp set_power(state), do: write_command(state, @pwr, [ | ||
| Bitwise.bor( | ||
| Bitwise.bor( | ||
| Bitwise.bor( | ||
| # ??? - not documented in UC8159 datasheet | ||
| Bitwise.<<<(0x06, 3), | ||
| # SOURCE_INTERNAL_DC_DC | ||
| Bitwise.<<<(0x01, 2) | ||
| ), | ||
| # GATE_INTERNAL_DC_DC | ||
| Bitwise.<<<(0x01, 1) | ||
| ), | ||
| # LV_SOURCE_INTERNAL_DC_DC | ||
| 0x01 | ||
| ), | ||
| # VGx_20V | ||
| 0x00, | ||
| # UC8159_7C | ||
| 0x23, | ||
| # UC8159_7C | ||
| 0x23 | ||
| ]) | ||
|
|
||
| # Set the PLL clock frequency to 50Hz | ||
| # 0b11000000 = Ignore | ||
| # 0b00111000 = M | ||
| # 0b00000111 = N | ||
| # PLL = 2MHz * (M / N) | ||
| # PLL = 2MHz * (7 / 4) | ||
| # PLL = 2,800,000 ??? | ||
| defp set_pll_clock_frequency(state), do: write_command(state, 0x3C) | ||
|
|
||
| defp set_tse_register(state), do: write_command(state, 0x00) | ||
|
|
||
| defp set_vcom_data_interval_setting(state, border), do: write_command(state, @cdi, [Bitwise.bor(Bitwise.<<<(@colors[border], 5), 0x17)]) | ||
| defp set_gate_source_non_overlap_period(state), do: write_command(state, @tcon, 0x22) | ||
| defp disable_external_flash(state), do: write_command(state, @dam, 0x00) | ||
| defp set_pws_whatever_that_means(state), do: write_command(state, @pws, 0xAA) | ||
| defp power_off_sequence(state), do: write_command(state, @pfs, 0x00) | ||
|
|
||
| defp set_analog_block_control(state), do: write_command(state, 0x74, 0x54) | ||
| defp set_digital_block_control(state), do: write_command(state, 0x7E, 0x3B) | ||
| defp set_gate(state, packed_height), do: write_command(state, 0x01, packed_height <> <<0x00>>) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some observations...
(2*255 + 88) = 600-2 = 598(1*255 + 192) = 488-1 = 447How do these numbers relate to whatever input you put into python? Also, if we're not going to do this properly in elixir, we should at the very least have the actual code here, not just a mention of "it was done in python".
The dimensions for the Inky were kept in a struct, why not do the same thing here and convert it to a binary when it's required?