diff --git a/_oasis b/_oasis index 89d9ec3..e1ddae6 100644 --- a/_oasis +++ b/_oasis @@ -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 diff --git a/examples/lcd.ml b/examples/lcd.ml index 014a81e..0ef420e 100644 --- a/examples/lcd.ml +++ b/examples/lcd.ml @@ -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.") diff --git a/examples/lcd_example.ml b/examples/lcd_example.ml new file mode 100644 index 0000000..bf67d4b --- /dev/null +++ b/examples/lcd_example.ml @@ -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.")