[gcs] indicate voltage/cell if number of cells is specified (#2732)

Add a define for BAT_NB_CELLS in the BAT section of the airframe file to
activate the display
This commit is contained in:
Gautier Hattenberger
2021-05-20 14:16:34 +02:00
committed by GitHub
parent 030c5e71aa
commit 18945fffcc
4 changed files with 16 additions and 6 deletions
+1
View File
@@ -175,6 +175,7 @@
<section name="BAT">
<define name="CATASTROPHIC_BAT_LEVEL" value="9.3" unit="V"/>
<define name="MilliAmpereOfAdc(_adc)" value="(_adc-632)*4.14"/>
<define name="BAT_NB_CELLS" value="3"/>
</section>
<section name="MISC">
+9 -5
View File
@@ -386,13 +386,16 @@ let get_rc_max_rate = fun af_xml ->
let get_bat_levels = fun af_xml ->
let default_catastrophic_level = 9.
and default_max_level = 12.5 in
and default_max_level = 12.5
and default_nb_cell = None in
try
let bat_section = ExtXml.child af_xml ~select:(fun x -> Xml.attrib x "name" = "BAT") "section" in
let fvalue = fun name default ->
try ExtXml.float_attrib (ExtXml.child bat_section ~select:(fun x -> ExtXml.attrib x "name" = name) "define") "value" with _ -> default in
fvalue "CATASTROPHIC_BAT_LEVEL" default_catastrophic_level, fvalue "MAX_BAT_LEVEL" default_max_level
with _ -> (default_catastrophic_level, default_max_level)
let fvalue_opt = fun name default ->
try Some (ExtXml.float_attrib (ExtXml.child bat_section ~select:(fun x -> ExtXml.attrib x "name" = name) "define") "value") with _ -> default in
fvalue "CATASTROPHIC_BAT_LEVEL" default_catastrophic_level, fvalue "MAX_BAT_LEVEL" default_max_level, fvalue_opt "BAT_NB_CELLS" default_nb_cell
with _ -> (default_catastrophic_level, default_max_level, default_nb_cell)
let get_alt_shift = fun af_xml ->
let default_plus_plus = 30.
@@ -528,10 +531,11 @@ let create_ac = fun ?(confirm_kill=true) alert (geomap:G.widget) (acs_notebook:G
ac_notebook#page_num w#coerce = ac_notebook#current_page in
(** Add a strip *)
let min_bat, max_bat = get_bat_levels af_xml in
let min_bat, max_bat, nb_cell_bat = get_bat_levels af_xml in
let alt_shift_plus_plus, alt_shift_plus, alt_shift_minus = get_alt_shift af_xml in
let icons_theme = get_icons_theme af_xml in
let param = { Strip.color = color; min_bat = min_bat; max_bat = max_bat;
let param = { Strip.color = color;
min_bat = min_bat; max_bat = max_bat; nb_cell_bat = nb_cell_bat;
alt_shift_plus_plus = alt_shift_plus_plus;
alt_shift_plus = alt_shift_plus;
alt_shift_minus = alt_shift_minus;
+5 -1
View File
@@ -55,6 +55,7 @@ type strip_param = {
color : string;
min_bat : float;
max_bat : float;
nb_cell_bat : float option;
alt_shift_plus_plus : float;
alt_shift_plus : float;
alt_shift_minus : float;
@@ -197,6 +198,7 @@ let add = fun config strip_param (strips:GPack.box) ->
let color = strip_param.color
and min_bat = strip_param.min_bat
and max_bat = strip_param.max_bat
and nb_cell_bat = strip_param.nb_cell_bat
and alt_shift_plus_plus = strip_param.alt_shift_plus_plus
and alt_shift_plus = strip_param.alt_shift_plus
and alt_shift_minus = strip_param.alt_shift_minus in
@@ -307,7 +309,9 @@ object
agl#set ~arrow value [0.2, (sprintf "%3.0f" value); 0.8, sprintf "%+.1f" climb]
method set_bat value =
let v = if value < 0.1 then "UNK" else (string_of_float value) in
bat#set value [0.5, v]
match nb_cell_bat with
| None -> bat#set value [0.5, v]
| Some nb -> bat#set value [0.3, v; 0.7, sprintf "%.1f /c" (value /. nb)]
method set_throttle ?(kill=false) value =
let background = if kill then "red" else "orange" in
throttle#set ~background value (sprintf "%.0f%%" value)
+1
View File
@@ -55,6 +55,7 @@ type strip_param = {
color : string;
min_bat : float;
max_bat : float;
nb_cell_bat : float option;
alt_shift_plus_plus : float;
alt_shift_plus : float;
alt_shift_minus : float;