mirror of
				https://github.com/co-dan/ocaml-wiringpi/
				synced 2025-11-04 06:33:51 +01:00 
			
		
		
		
	Split the LCD API and the example into two files
This commit is contained in:
		@@ -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
									
								
							
							
						
						
									
										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