mirror of
https://github.com/co-dan/ocaml-wiringpi/
synced 2025-10-29 20:13:52 +01:00
Split the LCD API and the example into two files
This commit is contained in:
2
_oasis
2
_oasis
@@ -22,5 +22,5 @@ Executable "wpi-button-example"
|
|||||||
Executable "adafruit-lcd-example"
|
Executable "adafruit-lcd-example"
|
||||||
Path: examples/
|
Path: examples/
|
||||||
BuildTools: ocamlbuild
|
BuildTools: ocamlbuild
|
||||||
MainIs: lcd.ml
|
MainIs: lcd_example.ml
|
||||||
BuildDepends: WiringPi,unix
|
BuildDepends: WiringPi,unix
|
||||||
|
|||||||
@@ -12,16 +12,6 @@ type mono_lcd = {
|
|||||||
d6: pin;
|
d6: pin;
|
||||||
d7: pin
|
d7: pin
|
||||||
}
|
}
|
||||||
let lcd = {
|
|
||||||
columns = 16;
|
|
||||||
rows = 2;
|
|
||||||
rs = GPIO20;
|
|
||||||
en = GPIO16;
|
|
||||||
d4 = GPIO19;
|
|
||||||
d5 = GPIO5;
|
|
||||||
d6 = GPIO11;
|
|
||||||
d7 = GPIO10;
|
|
||||||
}
|
|
||||||
|
|
||||||
(** MAGIC NUMBERS *)
|
(** MAGIC NUMBERS *)
|
||||||
(* Commands *)
|
(* Commands *)
|
||||||
@@ -131,9 +121,3 @@ let set_position lcd x y =
|
|||||||
|
|
||||||
let write_bytes lcd bts =
|
let write_bytes lcd bts =
|
||||||
Bytes.iter (fun c -> write8 lcd c ~char_mode:true) 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
20
examples/lcd_example.ml
Normal 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.")
|
||||||
Reference in New Issue
Block a user