From 1a7b22e8d495876fc1c70f401e0f531651e2563d Mon Sep 17 00:00:00 2001 From: Tobias Bora Date: Sun, 15 Dec 2013 07:40:30 +0100 Subject: [PATCH] Add test_led with lot's of interesting test functions (not documented yet), and the file sapin_noel is for 2 reg now. --- Makefile | 1 + sapin_noel.bin | Bin 292324 -> 292966 bytes sapin_noel.ml | 27 ++++++++++++++--- test_led.ml | 80 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 104 insertions(+), 4 deletions(-) create mode 100644 test_led.ml diff --git a/Makefile b/Makefile index f821564..bd347bf 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ OUTPUT=$(MAIN:.ml=.bin) all: $(OBJECTS) $(CC) $(OPT) -cclib -lwiringPi unix.cma $(SOURCES) $(MAIN) -o $(OUTPUT) + $(CC) $(OPT) -cclib -lwiringPi unix.cma $(SOURCES) test_led.ml -o test_led.bin clean: rm -f *.cmo *.cmi *.cmx diff --git a/sapin_noel.bin b/sapin_noel.bin index 1336651acc49919801c2d3f1de882f79f0b8951f..d28e7966f7c07255e482e6e1032984c654453277 100755 GIT binary patch delta 809 zcma))&ubG=5XblJPSX@q(`^Hl<`CNy6BV&wQw$2(hzQb6vPeA?tcnJ$A}y&Dgjy1$ z5-A8CgrOe9gTED}TDyWdD0t9=G|)dl52A-$3hhx{zf&4T?4bi6X5PHn`SE7I*3559 zW@$>z>0MP{B5@{vs<#}k>TbMhe4j{;C{5e0Y1$5;g9Nw-hQVgg1Oi|Z90gavF+gnD z)UJYD%^8tobj_QGmgrXC2Pc3JNY?ux2#y1ZHwC_9Q@CL@oGUi%Ha~lwcN#ZsK>8v6 zVN-NN1s))L{Q}MZ^usOvMr`oELil9TsnR)+TRLcg(vYc>t2$Kse!Pq>nyi|Q%&WGTYo9Oav&s$_o7l`N&W z&7lwna}-ds>|`mXUht(XQWbO5ot7?l0+H!oo+m3C0!6Ge0xeyiUDFq!rBl(HKp%LC z-BGl24rYBg8Mq6a1Cma{UUA5wSfc)fGP^8?fQYPHew4HvAaZAbB$(%6ha$>#uQ}A$ zVXnaS4!32z(kH*Be{mPi(>7l(+>oV|q=Ix?e~mq>vYZOsni2W<$KZwnl@0600lr?K zsCvz_1)5g#ynhTQ*F8B#H}#e`Gq>}p#oEu}p{c8*wGWd_SmYU3PM;9KqRzN#`i=k=XU5gj{{*nuPtOlv zX_>x1kVQo|gMon|7KrN^85rb&G#?PB12I1k=KwJ;l;#G~8PipQSd7wglo$+n)rnm`Mqq z1G4upFff-eFfi@oU|>44T|1XWjZI+IOc2;<&jV#lZ!HFT*>O653D5O7*{LOw9y;Gtt_N-@S<)kTW_nvW%Q_)#m4F~mUj_y#4Hw4{M+OGA KN7LOZSQG%x_hIP( diff --git a/sapin_noel.ml b/sapin_noel.ml index 61bf295..9f6c3f9 100644 --- a/sapin_noel.ml +++ b/sapin_noel.ml @@ -28,18 +28,37 @@ let anim_01 reg leds n = clearLeds leds; for k = 0 to (Array.length leds) - 1 do leds.(k) <- true; - applyReg reg leds 0.1; + applyReg reg leds 0.2; leds.(k) <- false done; for k = (Array.length leds) - 2 downto 0 do leds.(k) <- true; - applyReg reg leds 0.1; + applyReg reg leds 0.2; leds.(k) <- false done; lightLeds leds; applyReg reg leds 1.; done +let anim_02 reg leds n = + let t = ref 1. in + for i = 0 to n do + clearLeds leds; + for k = 0 to (Array.length leds) - 1 do + leds.(k) <- true; + applyReg reg leds (!t /. 10.); + leds.(k) <- false + done; + for k = (Array.length leds) - 2 downto 0 do + leds.(k) <- true; + applyReg reg leds (!t /. 10.); + leds.(k) <- false + done; + lightLeds leds; + applyReg reg leds !t; + t := !t /. 1.2; + done + let _ = (* On choisit le mode d'affichage Phys *) ignore(setupPhys ()); @@ -47,9 +66,9 @@ let _ = (* On crée le register *) (* En mode pulse : *) (* let reg = genReg 11 13 15 ~pulse:true in *) - let reg = genReg 11 13 15 in + let reg = genReg 11 13 15 ~invert:false in (* On initialise *) - let leds = initReg reg ~nb_reg:1 in + let leds = initReg reg ~nb_reg:2 in let t = true and f = false in Printf.printf "Début\n%!"; diff --git a/test_led.ml b/test_led.ml new file mode 100644 index 0000000..fec2304 --- /dev/null +++ b/test_led.ml @@ -0,0 +1,80 @@ +open WiringPiOcaml;; +open ShiftReg;; + +let test reg leds = + lightLeds leds; + (* Pour montrer la différence entre les deux modes *) + Printf.printf "The pulse mode...\n%!"; + applyRegPulse reg leds 2.; + + Printf.printf "The classic mode...\n%!"; + applyRegAll reg leds; + Unix.sleep 2; + + Printf.printf "Only one led :\n%!"; + clearLeds leds; + leds.(1) <- true; + Printf.printf "The pulse mode...\n%!"; + applyRegPulse reg leds 2.; + + Printf.printf "The classic mode...\n%!"; + applyRegAll reg leds; + Unix.sleep 2 + +let _ = + let what = Sys.argv.(1) in + Printf.printf "%s\n" Sys.argv.(1); + ignore(setupPhys ()); + let reg = genReg 11 13 15 ~invert:false in + let leds = initReg reg ~nb_reg:2 in + let t = true + and f = false in + clearLeds leds; + if what = "g" then begin + let make_t n k = + clearLeds leds; + for k = 0 to Array.length leds - 1 do + if k mod 3 = 0 then + leds.(k) <- t; + done + in + make_t 3 0; + let t1 = Array.copy leds in + make_t 3 1; + let t2 = Array.copy leds in + make_t 3 2; + let t3 = Array.copy leds in + let t = [|t1;t2;t3|] in + while true do + applyReg reg t1 0.5; + applyReg reg t2 0.5; + applyReg reg t3 0.5; + done + end + else if what = "a" then begin + lightLeds leds; + while true do + applyReg reg leds 10.; + done; + end + else if what = "e" then begin + clearLeds leds; + while true do + applyReg reg leds 10.; + done; + end + else if what = "f" then begin + findLedNumber reg leds; + end + else if what = "obo" then begin + clearLeds leds; + leds.(int_of_string Sys.argv.(2)) <- t; + applyReg reg leds 10.; + end + + + +(* + 9 -> saute la 7e (première du nvx) + 15 --> réagit légèrement +*)