Split the LCD API and the example into two files

This commit is contained in:
dan 2019-06-26 17:22:27 +02:00
parent 2fcb2160f3
commit feb2e218dc
3 changed files with 21 additions and 17 deletions

2
_oasis
View File

@ -22,5 +22,5 @@ Executable "wpi-button-example"
Executable "adafruit-lcd-example"
Path: examples/
BuildTools: ocamlbuild
MainIs: lcd.ml
MainIs: lcd_example.ml
BuildDepends: WiringPi,unix

View File

@ -12,16 +12,6 @@ type mono_lcd = {
d6: pin;
d7: pin
}
let lcd = {
columns = 16;
rows = 2;
rs = GPIO20;
en = GPIO16;
d4 = GPIO19;
d5 = GPIO5;
d6 = GPIO11;
d7 = GPIO10;
}
(** MAGIC NUMBERS *)
(* Commands *)
@ -131,9 +121,3 @@ let set_position lcd x y =
let write_bytes lcd bts =
Bytes.iter (fun c -> write8 lcd c ~char_mode:true) bts
let _ =
setup lcd;
clear lcd;
set_position lcd 0 0;
write_bytes lcd (Bytes.of_string "Hello, world.")

20
examples/lcd_example.ml Normal file
View File

@ -0,0 +1,20 @@
(** An example with Adafruit character LCD, HD44780. *)
open Gpio3
open Lcd
let lcd = {
columns = 16;
rows = 2;
rs = GPIO20;
en = GPIO16;
d4 = GPIO19;
d5 = GPIO5;
d6 = GPIO11;
d7 = GPIO10;
}
let _ =
setup lcd;
clear lcd;
set_position lcd 0 0;
write_bytes lcd (Bytes.of_string "Hello, world.")