From: Jérémie D. <Ba...@us...> - 2010-05-09 21:35:16
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 6641c373d1d83375e9beb62bc56987533f89a32a (commit) from bc4bb4d72adf50b771323b7d2ce8d32908d41a76 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 6641c373d1d83375e9beb62bc56987533f89a32a Author: Jérémie Dimino <je...@di...> Date: Sun May 9 23:32:47 2010 +0200 compute a medium value in the infrared recorder ----------------------------------------------------------------------- Changes: diff --git a/info/control/clients/record_infrared.ml b/info/control/clients/record_infrared.ml index f850fe5..c95081e 100644 --- a/info/control/clients/record_infrared.ml +++ b/info/control/clients/record_infrared.ml @@ -14,6 +14,18 @@ open Lwt_io let step = 10 +let measure_infrareds krobot infrareds = + let rec loop acc1 acc2 = function + | 0 -> + return (acc1 / 20, acc2 / 20) + | n -> + let i1, i2 = React.S.value infrareds in + let acc1 = acc1 + i1 and acc2 = acc2 + i2 in + lwt () = Lwt_unix.sleep 0.05 in + loop acc1 acc2 (n - 1) + in + loop 0 0 20 + lwt () = lwt () = printl "type Ctrl+C to stop" in lwt krobot = Krobot.create () in @@ -21,7 +33,7 @@ lwt () = let oc = Lwt_io.open_file ~mode:Lwt_io.output "infrareds-record" in let rec loop dist = lwt () = Lwt_unix.sleep 1.0 in - let i1, i2 = React.S.value infrareds in + lwt i1, i2 = measure_infrareds krobot infrareds in lwt () = printlf "at distance %d mm: i1 = %d, i2 = %d" dist i1 i2 in lwt () = fprintlf oc "%d %d %d" dist i1 i2 in lwt () = Lwt_io.flush oc in hooks/post-receive -- krobot |