From: Jérémie D. <Ba...@us...> - 2011-04-19 19:01:08
|
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 af646d8661612a1b39fe7725d6b747fcec064ab0 (commit) from 627cc580a2169b0b0cec5cb708e601410077633f (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 af646d8661612a1b39fe7725d6b747fcec064ab0 Author: Jérémie Dimino <je...@di...> Date: Tue Apr 19 21:00:01 2011 +0200 [krobot_viewer] cache motor statuses ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/tools/krobot_viewer.ml b/info/control2011/src/tools/krobot_viewer.ml index 7e54aa5..a79ddea 100644 --- a/info/control2011/src/tools/krobot_viewer.ml +++ b/info/control2011/src/tools/krobot_viewer.ml @@ -55,6 +55,9 @@ type viewer = { mutable vertices : vertice list; (* The current trajectory. *) + + mutable motor_status : bool * bool * bool *bool; + (* Status of the four motor controller. *) } (* +-----------------------------------------------------------------+ @@ -345,24 +348,26 @@ let handle_message viewer (timestamp, message) = end | Motor_status(m1, m2, m3, m4) -> - let moving = m1 || m2 in - if moving then begin - viewer.statusbar_context#pop (); - let _ = viewer.statusbar_context#push - (if m1 then - "Moving..." - else - (if m2 then - "Turning..." - else - "") - ) in (); - end else - viewer.statusbar_context#pop (); - viewer.ui#entry_moving1#set_text (if m1 then "yes" else "no"); - viewer.ui#entry_moving2#set_text (if m2 then "yes" else "no"); - viewer.ui#entry_moving3#set_text (if m3 then "yes" else "no"); - viewer.ui#entry_moving4#set_text (if m4 then "yes" else "no") + if (m1, m2, m3, m4) <> viewer.motor_status then begin + viewer.motor_status <- (m1, m2, m3, m4); + if m1 || m2 then begin + viewer.statusbar_context#pop (); + let _ = viewer.statusbar_context#push + (if m1 then + "Moving..." + else + (if m2 then + "Turning..." + else + "") + ) in (); + end else + viewer.statusbar_context#pop (); + viewer.ui#entry_moving1#set_text (if m1 then "yes" else "no"); + viewer.ui#entry_moving2#set_text (if m2 then "yes" else "no"); + viewer.ui#entry_moving3#set_text (if m3 then "yes" else "no"); + viewer.ui#entry_moving4#set_text (if m4 then "yes" else "no") + end | Beacon_position(angle, distance, period) -> let newangle = math_mod_float (viewer.state.theta +. Krobot_config.rotary_beacon_index_pos +. angle) (2. *. pi) in @@ -466,6 +471,7 @@ lwt () = origin = ({ x = 0.; y = 0. }, { vx = 0.; vy = 0. }); vertices = []; statusbar_context = ui#statusbar#new_context ""; + motor_status = (false, false, false, false); } in (* Handle messages. *) hooks/post-receive -- krobot |