[PATCH] planning: Add option to have last stop at 6m/20ft
Henrik Brautaset Aronsen
subsurface at henrik.synth.no
Thu May 2 23:50:21 PDT 2013
I did a git bisect on this. The "last_stop_toggled_cb" function
disappeared in commit f86b13102c0203e16329af04da40a8cca99d1b24:
Author: Dirk Hohndel <dirk at hohndel.org>
Date: Sun Apr 7 20:20:25 2013 -0700
Separate Gtk related code from core logic: planner
Relatively straight forward, just a handful of places where we call
show_error() (a UI function) from the logic code. In the process I
noticed
a few places where error returns weren't dealt with correctly.
Added a new planner.h files for the necessary declarations.
This should make no difference to functionality.
Anton Lundin wrote:
> When diving in areas where there are risk of boats passing above you,
> its common practise to do the last stop at 6m to better stay out of
> harms way. When doing o2-deco, it doesn't matter for the deco time if
> you are doing all the time at 6m, due to that you don't have any inert
> gas in your breathing gas.
>
> This code is a reintroduction of 0b8462bd lost somehow between
> a70a8898..8fae0031
>
> Signed-off-by: Anton Lundin<glance at acc.umu.se>
> ---
> planner-gtk.c | 21 +++++++++++++++++++++
> planner.c | 8 ++++++++
> planner.h | 1 +
> 3 files changed, 30 insertions(+)
>
> diff --git a/planner-gtk.c b/planner-gtk.c
> index 1b99fb3..d5fddec 100644
> --- a/planner-gtk.c
> +++ b/planner-gtk.c
> @@ -253,6 +253,16 @@ static gboolean gf_focus_out_cb(GtkWidget *entry, GdkEvent * event, gpointer dat
> return FALSE;
> }
>
> +static gboolean last_stop_toggled_cb(GtkWidget *entry, GdkEvent * event, gpointer data)
> +{
> + char *error_string = NULL;
> + set_last_stop(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(entry)));
> + show_planned_dive(&error_string);
> + if (error_string)
> + show_error(error_string);
> + return FALSE;
> +}
> +
> static GtkWidget *add_gas_combobox_to_box(GtkWidget *box, const char *label, int idx)
> {
> GtkWidget *frame, *combo;
> @@ -382,6 +392,17 @@ void input_plan()
> add_entry_with_callback(hbox, 12, _("Dive starts when?"), "+60:00", starttime_focus_out_cb, NULL);
> add_entry_with_callback(hbox, 12, _("Surface Pressure (mbar)"), SURFACE_PRESSURE_STRING, surfpres_focus_out_cb, NULL);
>
> + if (get_units()->length == METERS)
> + labeltext = _("Last stop at 6 Meters");
> + else
> + labeltext = _("Last stop at 20 Feet");
> +
> + set_last_stop(FALSE);
> + content = gtk_check_button_new_with_label(labeltext);
> + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(content), 0);
> + gtk_box_pack_start(GTK_BOX(hbox), content, FALSE, FALSE, 6);
> + g_signal_connect(G_OBJECT(content), "toggled", G_CALLBACK(last_stop_toggled_cb), NULL);
> +
> hbox = gtk_hbox_new(FALSE, 0);
> gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
> if (get_units()->volume == CUFT) {
> diff --git a/planner.c b/planner.c
> index 676afd4..71273b3 100644
> --- a/planner.c
> +++ b/planner.c
> @@ -47,6 +47,14 @@ void dump_plan(struct diveplan *diveplan)
> }
> #endif
>
> +void set_last_stop(gboolean last_stop_6m)
> +{
> + if (last_stop_6m == TRUE)
> + decostoplevels[1] = 6000;
> + else
> + decostoplevels[1] = 3000;
> +}
> +
> void get_gas_from_events(struct divecomputer *dc, int time, int *o2, int *he)
> {
> struct event *event = dc->events;
> diff --git a/planner.h b/planner.h
> index 099f640..4de3c46 100644
> --- a/planner.h
> +++ b/planner.h
> @@ -11,6 +11,7 @@ extern timestamp_t current_time_notz(void);
> extern void show_planned_dive(char **error_string_p);
> extern int add_duration_to_nth_dp(struct diveplan *diveplan, int idx, int duration, gboolean is_rel);
> extern void add_po2_to_nth_dp(struct diveplan *diveplan, int idx, int po2);
> +extern void set_last_stop(gboolean last_stop_6m);
>
> extern struct diveplan diveplan;
> extern struct dive *planned_dive;
More information about the subsurface
mailing list