diff --git a/sw/configurator/Makefile b/sw/configurator/Makefile index 3ae1af8a38..dc57bedddc 100644 --- a/sw/configurator/Makefile +++ b/sw/configurator/Makefile @@ -23,7 +23,7 @@ OCAMLC=ocamlc -g -I +labltk -I +lablgtk2 -I ../lib/ocaml -SRC = env.ml tty.ml varXml.ml console.ml tkXml.ml flasher.ml notebook.ml welcome.ml hardware.ml radio.ml servos.ml adc.ml infrared.ml attitude.ml autopilot.ml airframe.ml flightplan.ml upload.ml simulator.ml monitor.ml logalizer.ml main.ml +SRC = env_conf.ml notebook.ml tty.ml varXml.ml console.ml tkXml.ml flasher.ml welcome.ml hardware.ml radio.ml servos.ml adc.ml infrared.ml attitude.ml autopilot.ml airframe.ml flightplan.ml upload.ml simulator.ml monitor.ml logalizer.ml main.ml CMO = $(SRC:.ml=.cmo) all : configurator medit.out diff --git a/sw/configurator/env.ml b/sw/configurator/env_conf.ml similarity index 73% rename from sw/configurator/env.ml rename to sw/configurator/env_conf.ml index 944e39d9fd..0667336ff4 100644 --- a/sw/configurator/env.ml +++ b/sw/configurator/env_conf.ml @@ -24,14 +24,7 @@ * *) -let pprz_dir = - try - Sys.getenv "PAPARAZZI_DIR" - with - Not_found -> - Filename.concat (Filename.dirname Sys.argv.(0)) "../.." - -let abs = fun x -> pprz_dir ^ "/" ^ x +let abs = fun x -> Env.paparazzi_src ^ "/" ^ x let configurator_dir = abs "sw/configurator" @@ -48,10 +41,3 @@ let tty_rate = Serial.B38400 (* Initialization very early for creation of Textvariables *) let _ = Tk.openTk () - -let select_one_file = fun ?(filter="*.xml") use -> - let action = function - [] -> () - | [f] -> use f - | _ -> failwith "Env.select_one_file: unepected several files" in - Fileselect.f ~title:"File Selection" ~action ~filter ~file:"" ~multi:false ~sync:false diff --git a/sw/configurator/env.mli b/sw/configurator/env_conf.mli similarity index 88% rename from sw/configurator/env.mli rename to sw/configurator/env_conf.mli index cf56bedcfd..2078d48317 100644 --- a/sw/configurator/env.mli +++ b/sw/configurator/env_conf.mli @@ -24,8 +24,6 @@ * *) -val pprz_dir : string - val configurator_dir : string val fbw_dir : string val ap_dir : string @@ -36,6 +34,3 @@ val ap_tty : string val modem_tty : string val tty_rate : Serial.speed - -val select_one_file : ?filter:string -> (string -> unit) -> unit -(** File selector. Default [filter] is "*.xml" *) diff --git a/sw/configurator/flasher.ml b/sw/configurator/flasher.ml index a68b66b98e..9dbe0d3680 100644 --- a/sw/configurator/flasher.ml +++ b/sw/configurator/flasher.ml @@ -50,7 +50,7 @@ let warn = let erase_AP = fun () -> if switch Ap = 0 then - let command = Printf.sprintf "cd %s; make erase" Env.ap_dir in + let command = Printf.sprintf "cd %s; make erase" Env_conf.ap_dir in Console.exec command; destroy () in diff --git a/sw/configurator/flightplan.ml b/sw/configurator/flightplan.ml index bb08e8db48..bc8d6e1039 100644 --- a/sw/configurator/flightplan.ml +++ b/sw/configurator/flightplan.ml @@ -56,7 +56,7 @@ let create_sheet = fun sheets -> let f = Frame.create sheets in Notebook.create_sheet sheets "Flight Plan" f; - let b = Button.create ~text:"Calibrate IGN tile" ~command:(fun () -> Env.select_one_file ~filter:"*.png" calibrate_ign_tile) f in + let b = Button.create ~text:"Calibrate IGN tile" ~command:(fun () -> Notebook.select_one_file ~filter:"*.png" calibrate_ign_tile) f in Tk.pack [b]; diff --git a/sw/configurator/hardware.ml b/sw/configurator/hardware.ml index 9adf8c7e67..f1533c0a6b 100644 --- a/sw/configurator/hardware.ml +++ b/sw/configurator/hardware.ml @@ -27,22 +27,22 @@ module FbwMcu = struct let name = "Fly by wire" let sort = Flasher.Fbw - let path = Env.fbw_dir - let default_tty = Env.fbw_tty + let path = Env_conf.fbw_dir + let default_tty = Env_conf.fbw_tty end module ApMcu = struct let name = "Autopilot" let sort = Flasher.Ap - let path = Env.ap_dir - let default_tty = Env.ap_tty + let path = Env_conf.ap_dir + let default_tty = Env_conf.ap_tty end module ModemMcu = struct let name = "Ground Modem" let sort = Flasher.Modem - let path = Env.modem_dir - let default_tty = Env.modem_tty + let path = Env_conf.modem_dir + let default_tty = Env_conf.modem_tty end module type MCU = sig diff --git a/sw/configurator/notebook.ml b/sw/configurator/notebook.ml index d26a8aaf69..8bc5fbd2ab 100644 --- a/sw/configurator/notebook.ml +++ b/sw/configurator/notebook.ml @@ -60,3 +60,11 @@ let create_sheet w name child = +let select_one_file = fun ?(filter="*.xml") use -> + let action = function + [] -> () + | [f] -> use f + | _ -> failwith "Env.select_one_file: unepected several files" in + Fileselect.f ~title:"File Selection" ~action ~filter ~file:"" ~multi:false ~sync:false + + diff --git a/sw/configurator/notebook.mli b/sw/configurator/notebook.mli index 59e0d54586..b55447f563 100644 --- a/sw/configurator/notebook.mli +++ b/sw/configurator/notebook.mli @@ -26,3 +26,7 @@ val create_sheet : 'a Widget.widget -> string -> 'b Widget.widget -> unit (** [create_sheet parent name frame] adds the new [frame] tab *) + + +val select_one_file : ?filter:string -> (string -> unit) -> unit +(** File selector. Default [filter] is "*.xml" *) diff --git a/sw/configurator/radio.ml b/sw/configurator/radio.ml index 4e1ee08303..b7e28f390d 100644 --- a/sw/configurator/radio.ml +++ b/sw/configurator/radio.ml @@ -139,7 +139,7 @@ let one_channel = fun parent i xml_channel -> let program_board = fun w cs () -> - Flasher.make Flasher.Fbw (Printf.sprintf "%s/test" Env.fbw_dir) "TARGET=rc_transmitter load"; + Flasher.make Flasher.Fbw (Printf.sprintf "%s/test" Env_conf.fbw_dir) "TARGET=rc_transmitter load"; let tty = Hardware.Fbw.get_tty () in Tty.connect tty; diff --git a/sw/configurator/servos.ml b/sw/configurator/servos.ml index 17838cf444..abc0300997 100644 --- a/sw/configurator/servos.ml +++ b/sw/configurator/servos.ml @@ -112,7 +112,7 @@ let create_sheet = fun sheets airframe_xml -> in let program = fun () -> - Flasher.make Flasher.Fbw (Printf.sprintf "%s/test" Env.fbw_dir) "TARGET=setup_servos load" in + Flasher.make Flasher.Fbw (Printf.sprintf "%s/test" Env_conf.fbw_dir) "TARGET=setup_servos load" in let legend = Frame.create channels and slider = Scale.create tf ~orient:`Horizontal ~min:min_min ~max:max_max ~digits:4 ~label:"micro-seconds" ~resolution:1. ~length:300 diff --git a/sw/configurator/tkXml.ml b/sw/configurator/tkXml.ml index da91e93960..cfaa0f6c54 100644 --- a/sw/configurator/tkXml.ml +++ b/sw/configurator/tkXml.ml @@ -44,7 +44,7 @@ let create_display_frame = fun f xml appli -> close_out f; destroy () in - let save_button = Button.create ~text:"Save Config" ~command:(fun _ -> Env.select_one_file save) tf + let save_button = Button.create ~text:"Save Config" ~command:(fun _ -> Notebook.select_one_file save) tf and cancel_button = Button.create ~text:"Cancel" ~command:destroy tf in Tk.pack [l] ~side:`Left; @@ -66,7 +66,7 @@ let create = fun top appli -> Console.write (Printf.sprintf "Reading from \"%s\"\n" file); create_display_frame f (VarXml.of_xml (Xml.parse_file file)) appli in - let load_button = Button.create ~text:"Load Config" ~command:(fun _ -> Env.select_one_file load) top in + let load_button = Button.create ~text:"Load Config" ~command:(fun _ -> Notebook.select_one_file load) top in Tk.pack [load_button]; Tk.pack [f] diff --git a/sw/configurator/tty.ml b/sw/configurator/tty.ml index 8b7048651c..d0669d6cb3 100644 --- a/sw/configurator/tty.ml +++ b/sw/configurator/tty.ml @@ -42,7 +42,7 @@ let connect = fun tty -> if Hashtbl.mem ttys tty then deconnect tty; let buffer = String.create buffer_len in - let fd = Serial.opendev tty Env.tty_rate in + let fd = Serial.opendev tty Env_conf.tty_rate in let log = fun () -> let n = Unix.read fd buffer 0 buffer_len in let s = String.sub buffer 0 n in diff --git a/sw/configurator/welcome.ml b/sw/configurator/welcome.ml index 7979492665..bdb269387f 100644 --- a/sw/configurator/welcome.ml +++ b/sw/configurator/welcome.ml @@ -30,7 +30,7 @@ let create_sheet = fun sheets -> let l = Label.create ~text:"WELCOME TO THE PAPARAZZI CONFIGURATOR" welcome in let img = Imagephoto.create() in - Imagephoto.configure img ~file:(Env.configurator_dir^"/penguin.gif") ~format:"gif"; + Imagephoto.configure img ~file:(Env.paparazzi_src^"/data/pictures/penguin_logo.gif") ~format:"gif"; let l1 = Label.create ~image:img welcome in Tk.pack [l; l1];