diff --git a/conf/settings/basic.xml b/conf/settings/basic.xml index a8cf113ef9..2029ca94f3 100644 --- a/conf/settings/basic.xml +++ b/conf/settings/basic.xml @@ -16,7 +16,7 @@ - + diff --git a/conf/settings/settings.dtd b/conf/settings/settings.dtd index 2f5a11d5cc..7c14b0bca0 100644 --- a/conf/settings/settings.dtd +++ b/conf/settings/settings.dtd @@ -32,6 +32,7 @@ handler CDATA #IMPLIED auto CDATA #IMPLIED param CDATA #IMPLIED unit CDATA #IMPLIED +values CDATA #IMPLIED > + try + Array.of_list (Str.split pipe_regexp (Xml.attrib dl_setting "values")) + with + _ -> [||] + let one_setting = fun i do_change packing dl_setting (tooltips:GData.tooltips) strip -> let f = fun a -> float_of_string (ExtXml.attrib dl_setting a) in let lower = f "min" @@ -241,9 +248,9 @@ let one_setting = fun i do_change packing dl_setting (tooltips:GData.tooltips) s let auto_but = GButton.check_button ~label:"Auto" ~active:false () in (** For a small number of values, radio buttons, else a slider *) - let _n = truncate ((upper -. lower) /. step_incr) in + let values = values_of_dl_setting dl_setting in let commit = - if step_incr = 1. && upper -. lower <= 2. then + if step_incr = 1. && upper -. lower <= 2. || Array.length values > 0 then (* Discrete values: radio buttons *) let ilower = truncate lower and iupper = truncate upper in @@ -252,7 +259,10 @@ let one_setting = fun i do_change packing dl_setting (tooltips:GData.tooltips) s let group = (GButton.radio_button ())#group in (* Group shared by the buttons *) for j = ilower to iupper do (* Build the button *) - let label = Printf.sprintf "%d" j in + let label = + if Array.length values = 0 + then Printf.sprintf "%d" j + else values.(j) in let b = GButton.radio_button ~group ~label ~packing:hbox#add () in (* Connect the event *) @@ -379,7 +389,13 @@ class settings = fun ?(visible = fun _ -> true) xml_settings do_change strip -> method set = fun i v -> if visible self#widget then let s = string_of_float v in - let (_, _, label_current_value) = variables.(i) in + let (_, dl_setting, label_current_value) = variables.(i) in + let s = + let values = values_of_dl_setting dl_setting in + try + values.(truncate (float_of_string s)) + with + _ -> s in if label_current_value#text <> s then label_current_value#set_text s method assoc var = List.assoc var assocs diff --git a/sw/ground_segment/tmtc/Makefile b/sw/ground_segment/tmtc/Makefile index cd00bd6663..5e659ab96b 100644 --- a/sw/ground_segment/tmtc/Makefile +++ b/sw/ground_segment/tmtc/Makefile @@ -54,7 +54,7 @@ messages : messages.cmo ../../lib/ocaml/xlib-pprz.cma ../../lib/ocaml/lib-pprz.c $(Q)$(OCAMLC) -custom $(INCLUDES) -o $@ unix.cma str.cma xml-light.cma lablgtk.cma glibivy-ocaml.cma lib-pprz.cma gtkInit.cmo $< -settings : settings.cmo ../../lib/ocaml/xlib-pprz.cma ../../lib/ocaml/lib-pprz.cma +settings : settings.cmo ../../lib/ocaml/xlib-pprz.cma ../../lib/ocaml/lib-pprz.cma ../cockpit/pages.cmo @echo OL $@ $(Q)$(OCAMLC) -custom $(INCLUDES) -I ../cockpit -o $@ unix.cma str.cma xml-light.cma lablgtk.cma lablglade.cma $(OCAMLNETCMA) glibivy-ocaml.cma lib-pprz.cma gtkInit.cmo gtk_save_settings.cmo saveSettings.cmo pages.cmo $<