2013-12-03 10:49:04 +01:00
|
|
|
open WiringPiOcaml;;
|
|
|
|
open ShiftReg;;
|
|
|
|
|
2013-12-08 00:18:56 +01:00
|
|
|
(* Ici on utilise des fonctions plus souples mais moins agréables pour les tests. Pour voir les fonctions classiques, cf anim_01 *)
|
|
|
|
let test reg leds =
|
2013-12-07 22:52:01 +01:00
|
|
|
lightLeds leds;
|
|
|
|
(* Pour montrer la différence entre les deux modes *)
|
2013-12-08 00:18:56 +01:00
|
|
|
Printf.printf "The pulse mode...\n%!";
|
2013-12-07 22:52:01 +01:00
|
|
|
applyRegPulse reg leds 2.;
|
2013-12-08 00:18:56 +01:00
|
|
|
|
|
|
|
Printf.printf "The classic mode...\n%!";
|
|
|
|
applyRegAll reg leds;
|
2013-12-07 22:52:01 +01:00
|
|
|
Unix.sleep 2;
|
2013-12-08 00:18:56 +01:00
|
|
|
|
|
|
|
Printf.printf "Only one led :\n%!";
|
2013-12-07 22:52:01 +01:00
|
|
|
clearLeds leds;
|
|
|
|
leds.(1) <- true;
|
2013-12-08 00:18:56 +01:00
|
|
|
Printf.printf "The pulse mode...\n%!";
|
2013-12-07 22:52:01 +01:00
|
|
|
applyRegPulse reg leds 2.;
|
2013-12-08 00:18:56 +01:00
|
|
|
|
|
|
|
Printf.printf "The classic mode...\n%!";
|
|
|
|
applyRegAll reg leds;
|
|
|
|
Unix.sleep 2
|
|
|
|
|
|
|
|
(* S'inspirer de ce schéma pour les animations *)
|
|
|
|
let anim_01 reg leds n =
|
|
|
|
for i = 0 to n do
|
2013-12-07 22:52:01 +01:00
|
|
|
clearLeds leds;
|
2013-12-03 10:49:04 +01:00
|
|
|
for k = 0 to (Array.length leds) - 1 do
|
|
|
|
leds.(k) <- true;
|
2013-12-08 00:18:56 +01:00
|
|
|
applyReg reg leds 0.1;
|
2013-12-03 10:49:04 +01:00
|
|
|
leds.(k) <- false
|
|
|
|
done;
|
|
|
|
for k = (Array.length leds) - 2 downto 0 do
|
|
|
|
leds.(k) <- true;
|
2013-12-08 00:18:56 +01:00
|
|
|
applyReg reg leds 0.1;
|
2013-12-03 10:49:04 +01:00
|
|
|
leds.(k) <- false
|
|
|
|
done;
|
|
|
|
lightLeds leds;
|
2013-12-08 00:18:56 +01:00
|
|
|
applyReg reg leds 1.;
|
|
|
|
done
|
|
|
|
|
|
|
|
let _ =
|
|
|
|
(* On choisit le mode d'affichage Phys *)
|
|
|
|
ignore(setupPhys ());
|
|
|
|
(* reg : pin_value = p_v, pin_shift = p_s, pin_apply = p_a *)
|
|
|
|
(* On crée le register *)
|
2013-12-11 23:04:49 +01:00
|
|
|
(* En mode pulse : *)
|
|
|
|
(* let reg = genReg 11 13 15 ~pulse:true in *)
|
2013-12-08 00:18:56 +01:00
|
|
|
let reg = genReg 11 13 15 in
|
|
|
|
(* On initialise *)
|
|
|
|
let leds = initReg reg ~nb_reg:1 in
|
2013-12-11 23:04:49 +01:00
|
|
|
let t = true
|
|
|
|
and f = false in
|
2013-12-08 00:18:56 +01:00
|
|
|
Printf.printf "Début\n%!";
|
|
|
|
(* And a pretty animation *)
|
|
|
|
anim_01 reg leds max_int;
|
|
|
|
(* findLedNumber reg leds *)
|