diff options
Diffstat (limited to 'planner.c')
-rw-r--r-- | planner.c | 29 |
1 files changed, 19 insertions, 10 deletions
@@ -112,7 +112,7 @@ double tissue_at_end(struct dive *dive, char **cached_datap) for (j = t0; j < t1; j++) { int depth = interpolate(lastdepth, sample->depth.mm, j - t0, t1 - t0); tissue_tolerance = add_segment(depth_to_mbar(depth, dive) / 1000.0, - &dive->cylinder[gasidx].gasmix, 1, sample->po2 / 1000.0, dive); + &dive->cylinder[gasidx].gasmix, 1, sample->po2, dive); } psample = sample; t0 = t1; @@ -139,7 +139,7 @@ int time_at_last_depth(struct dive *dive, int next_stop, char **cached_data_p) while (deco_allowed_depth(tissue_tolerance, surface_pressure, dive, 1) > next_stop) { wait++; tissue_tolerance = add_segment(depth_to_mbar(depth, dive) / 1000.0, - &dive->cylinder[gasidx].gasmix, 1, sample->po2 / 1000.0, dive); + &dive->cylinder[gasidx].gasmix, 1, sample->po2, dive); } return wait; } @@ -202,7 +202,7 @@ struct dive *create_dive_from_plan(struct diveplan *diveplan) add_gas(dive, oldo2, oldhe); while (dp) { int o2 = dp->o2, he = dp->he; - int po2 = dp->po2 ? : oldpo2; + int po2 = dp->po2; int time = dp->time; int depth = dp->depth; @@ -218,11 +218,18 @@ struct dive *create_dive_from_plan(struct diveplan *diveplan) he = oldhe; } + /* Check for SetPoint change */ + if (oldpo2 != po2) { + if (lasttime) + add_event(dc, lasttime, 20, 0, po2, "SP change"); // SAMPLE_EVENT_PO2 + oldpo2 = po2; + } + /* Create new gas, and gas change event if necessary */ if (o2 != oldo2 || he != oldhe) { int value = (o2 / 10) | (he / 10 << 16); add_gas(dive, o2, he); - add_event(dc, lasttime, 11, 0, value, "gaschange"); + add_event(dc, lasttime, 25, 0, value, "gaschange"); // SAMPLE_EVENT_GASCHANGE2 oldo2 = o2; oldhe = he; } @@ -236,7 +243,6 @@ struct dive *create_dive_from_plan(struct diveplan *diveplan) sample->depth.mm = depth; finish_sample(dc); lasttime = time; - oldpo2 = po2; dp = dp->next; } if (dc->samples <= 1) { @@ -465,7 +471,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive) he = dive->cylinder[0].gasmix.he.permille; do { const char *depth_unit; - char gas[12]; + char gas[64]; double depthvalue; int decimals; double used; @@ -493,7 +499,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive) /* do we want to skip this leg as it is devoid of anything useful? */ if (!dp->entered && o2 == newo2 && he == newhe && nextdp && dp->depth != lastdepth && nextdp->depth != dp->depth) continue; - get_gas_string(o2, he, gas, 12); + get_gas_string(o2, he, gas, sizeof(gas)); gasidx = get_gasidx(dive, o2, he); len = strlen(buffer); if (dp->depth != lastdepth) { @@ -515,7 +521,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive) gas); } consumption[gasidx] += used; - get_gas_string(newo2, newhe, gas, 12); + get_gas_string(newo2, newhe, gas, sizeof(gas)); if (o2 != newo2 || he != newhe) { len = strlen(buffer); snprintf(buffer + len, sizeof(buffer) - len, _("Switch gas to %s\n"), gas); @@ -536,7 +542,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive) len = strlen(buffer); volume = get_volume_units(consumption[gasidx], NULL, &unit); get_gas_string(dive->cylinder[gasidx].gasmix.o2.permille, - dive->cylinder[gasidx].gasmix.he.permille, gas, 12); + dive->cylinder[gasidx].gasmix.he.permille, gas, sizeof(gas)); snprintf(buffer + len, sizeof(buffer) - len, _("%.0f%s of %s\n"), volume, unit, gas); } dive->notes = strdup(buffer); @@ -1042,7 +1048,10 @@ static gboolean po2_focus_out_cb(GtkWidget *entry, GdkEvent * event, gpointer da static timestamp_t current_time_notz(void) { timestamp_t now = time(NULL); - int offset = g_time_zone_get_offset(g_time_zone_new_local(), 1); + GTimeZone *tz = g_time_zone_new_local(); + gint interval = g_time_zone_find_interval(tz, G_TIME_TYPE_UNIVERSAL, now); + gint32 offset = g_time_zone_get_offset(tz, interval); + g_time_zone_unref(tz); return now + offset; } |