@@ -15,9 +15,6 @@ defmodule Inky.HAL.PhatSSD1608 do
1515 @ color_map_black % { black: 0 , miss: 1 }
1616 @ color_map_accent % { red: 1 , yellow: 1 , accent: 1 , miss: 0 }
1717
18- @ cols 136
19- @ rows 250
20- @ rotation - 90
2118 @ lut_data << 0x02 , 0x02 , 0x01 , 0x11 , 0x12 , 0x12 , 0x22 , 0x22 , 0x66 , 0x69 , 0x69 , 0x59 , 0x58 , 0x99 ,
2219 0x99 , 0x88 , 0x00 , 0x00 , 0x00 , 0x00 , 0xF8 , 0xB4 , 0x13 , 0x51 , 0x35 , 0x51 , 0x51 , 0x19 ,
2320 0x01 , 0x00 >>
@@ -71,14 +68,15 @@ defmodule Inky.HAL.PhatSSD1608 do
7168
7269 @ impl Inky.HAL
7370 def handle_update ( pixels , border , push_policy , state = % State { } ) do
74- black_bits = PixelUtil . pixels_to_bits ( pixels , @ rows , @ cols , @ rotation , @ color_map_black )
75- accent_bits = PixelUtil . pixels_to_bits ( pixels , @ rows , @ cols , @ rotation , @ color_map_accent )
71+ % { width: width , height: height , rotation: rotation } = state . display
72+ black_bits = PixelUtil . pixels_to_bits ( pixels , width , height , rotation , @ color_map_black )
73+ accent_bits = PixelUtil . pixels_to_bits ( pixels , width , height , rotation , @ color_map_accent )
7674
7775 state |> set_reset ( 0 ) |> sleep ( 500 ) |> set_reset ( 1 ) |> sleep ( 500 )
7876 state |> write_command ( @ cmd_soft_reset ) |> sleep ( 1000 )
7977
8078 case pre_update ( state , push_policy ) do
81- :cont -> do_update ( state , state . display , border , black_bits , accent_bits )
79+ :cont -> do_update ( state , border , black_bits , accent_bits )
8280 :halt -> { :error , :device_busy }
8381 end
8482 end
@@ -100,15 +98,17 @@ defmodule Inky.HAL.PhatSSD1608 do
10098 end
10199 end
102100
103- @ spec do_update ( State . t ( ) , Inky.Display . t ( ) , atom ( ) , binary ( ) , binary ( ) ) :: :ok
104- defp do_update ( state , _display , border , black_bits , accent_bits ) do
101+ @ spec do_update ( State . t ( ) , atom ( ) , binary ( ) , binary ( ) ) :: :ok
102+ defp do_update ( state , border , black_bits , accent_bits ) do
103+ % { width: width , height: height } = state . display
104+
105105 state
106- |> write_command ( @ cmd_set_driver_output , [ @ rows - 1 , ( @ rows - 1 ) >>> 8 , 0x00 ] )
106+ |> write_command ( @ cmd_set_driver_output , [ width - 1 , ( width - 1 ) >>> 8 , 0x00 ] )
107107 |> write_command ( @ cmd_set_dummy_line_period , [ 0x1B ] )
108108 |> write_command ( @ cmd_set_gate_line_width , [ 0x0B ] )
109109 |> write_command ( @ cmd_set_data_entry_mode , [ 0x03 ] )
110- |> write_command ( @ cmd_set_ram_x_position , [ 0x00 , div ( @ cols , 8 ) - 1 ] )
111- |> write_command ( @ cmd_set_ram_y_position , [ 0x00 , 0x00 , @ rows - 1 , ( @ rows - 1 ) >>> 8 ] )
110+ |> write_command ( @ cmd_set_ram_x_position , [ 0x00 , div ( height , 8 ) - 1 ] )
111+ |> write_command ( @ cmd_set_ram_y_position , [ 0x00 , 0x00 , width - 1 , ( width - 1 ) >>> 8 ] )
112112 |> write_command ( @ cmd_write_vcom , [ 0x70 ] )
113113 |> write_command ( @ cmd_write_lut , @ lut_data )
114114 |> set_border_color ( border )
0 commit comments