Skip to content

Commit

Permalink
Document the third layer, controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Willenbrink committed Apr 16, 2020
1 parent d8f4000 commit 1fbe121
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 17 deletions.
4 changes: 2 additions & 2 deletions bin/term/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let rec loop () =
let area = x*8,y*16,x*8+w,y*16+h in
try
Controller.transmit area;
Controller.display area `Fast
Controller.display area Fast
with
_ -> print_endline "Ignored out-of-bounds transmit"
in
Expand All @@ -36,7 +36,7 @@ let rec loop () =
done
done;
*)
EPD.refresh `Medium;
EPD.refresh Medium;
loop ()

(*
Expand Down
6 changes: 3 additions & 3 deletions lib/EPD.ml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ let repeat f =

let test_points () =
draw_points 10000;
refresh `Fast
refresh Fast

let test_lines () =
draw_lines 100;
refresh `Fast
refresh Fast

let loopfb () =
let fb = Unix.openfile "/dev/fb0" [Unix.O_RDONLY] 0o664 in
Expand Down Expand Up @@ -110,7 +110,7 @@ let loopfb () =
try
while true do
loop ();
refresh `Medium
refresh Medium
done
with
| e ->
Expand Down
19 changes: 13 additions & 6 deletions lib/controller.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,24 @@ open State

(* Third layer: Control the IT8951 by sending commands *)

type mode =
| White
| Unknown
| Slow
| Medium
| Fast

let int_of_mode = function
| `White -> 0
| White -> 0
(* TODO what does this mode do? And has this been switched around?
* Unknown works well whereas fast repeatedly fails to display anything.
* Fast only works for bpp8 and Unknown is only quick for the other modes.
* TODO this needs further investigation, because the above sounds improbable.
*)
| `Unknown -> 1
| `Slow -> 2
| `Medium -> 3
| `Fast -> 4
| Unknown -> 1
| Slow -> 2
| Medium -> 3
| Fast -> 4

(* TODO move somewhere appropriate *)
let split_32 value =
Expand Down Expand Up @@ -195,7 +202,7 @@ let init () =
State.set_buffer buffer;

(* Display white screen *)
display (0, 0, dev_info.width, dev_info.height) `White
display (0, 0, dev_info.width, dev_info.height) White

let free () =
Bus.free ()
22 changes: 22 additions & 0 deletions lib/controller.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(** Third layer: Control the IT8951 by sending commands *)

type mode =
| White
| Unknown
| Slow
| Medium
| Fast

(** TODO *)

val init : unit -> unit
(** [init ()] Initialises the library and raises an exception when it fails. It queries the IT8951 for screen dimensions and then allocates a buffer of the correct size. The initialised values are saved in the State module TODO until a better solution is implemented. *)

val free : unit -> unit
(** [free ()] Frees the allocated resources.*)

val transmit : (int * int * int * int) -> unit
(** TODO use Area module [transmit (x,y,w,h)] transmits an area of the buffer to the IT8951. This area is not displayed immediately. [x] and [y] refer to the upper left corner of the displayed area, [w] and [h] to the width and height respectively. To display the area use the display function. *)

val display : (int * int * int * int) -> mode -> unit
(** [display (x,y,w,h) mode] displays the area specified by (x,y,w,h) and passes the [mode] along to determine the display speed/clarity. *)
8 changes: 4 additions & 4 deletions tests/diag.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ let () =
List.init 600 (fun i -> (i,i))
|> List.iter (fun (x,y) ->
EPD.plot (x,y); EPD.plot(599-x,y));
EPD.refresh `Medium;
EPD.refresh Medium;
List.init 600 (fun i -> (i,i))
|> List.iter (fun (x,y) ->
EPD.plot (x+200,y); EPD.plot(x+200,599-y));
EPD.refresh `Medium;
EPD.refresh Medium;
EPD.line ((400,0),(400,598));
EPD.refresh `Medium;
EPD.refresh Medium;
EPD.line ((0,300),(798,300));
EPD.refresh `Medium;
EPD.refresh Medium;
Controller.free ()

4 changes: 2 additions & 2 deletions tests/loading_bar.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ let _ =
Text.init ();
EPD.line ((98,10),(98,590));
EPD.line ((115,10),(115,590));
EPD.refresh `Medium;
EPD.refresh Medium;
List.init 58 (fun i -> ('G',i*10+10,100))
|> List.iter (fun (c,x,y) -> Text.draw_char c (x,y); EPD.refresh `Fast)
|> List.iter (fun (c,x,y) -> Text.draw_char c (x,y); EPD.refresh Fast)

0 comments on commit 1fbe121

Please sign in to comment.