mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: introduce a few user-defined literals for unit types
Thise makes initialization of unit types more palatable. For example: surface.time = sample.time - duration_t { .seconds = 20 }; => surface.time = sample.time - 20_sec; delta_depth.mm = feet_to_mm(1.0); // 1ft => delta_depth = 1_ft; get_cylinderid_at_time(..., { .seconds = 20 * 60 + 1 })); => get_cylinderid_at_time(..., 20_min + 1_sec)); Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
f09601bc93
commit
ae81b42fe2
36 changed files with 320 additions and 264 deletions
|
@ -254,7 +254,7 @@ void uemis::event(struct dive *dive, struct divecomputer *dc, struct sample *sam
|
|||
sample->in_deco = true;
|
||||
sample->stopdepth.mm = stopdepth;
|
||||
sample->stoptime.seconds = u_sample->hold_time * 60;
|
||||
sample->ndl.seconds = 0;
|
||||
sample->ndl = 0_sec;
|
||||
} else if (flags[0] & 128) {
|
||||
/* safety stop - distinguished from deco stop by having
|
||||
* both ndl and stop information */
|
||||
|
@ -266,8 +266,8 @@ void uemis::event(struct dive *dive, struct divecomputer *dc, struct sample *sam
|
|||
/* NDL */
|
||||
sample->in_deco = false;
|
||||
lastndl = sample->ndl.seconds = u_sample->hold_time * 60;
|
||||
sample->stopdepth.mm = 0;
|
||||
sample->stoptime.seconds = 0;
|
||||
sample->stopdepth = 0_m;
|
||||
sample->stoptime = 0_sec;
|
||||
}
|
||||
#if UEMIS_DEBUG & 32
|
||||
printf("%dm:%ds: p_amb_tol:%d surface:%d holdtime:%d holddepth:%d/%d ---> stopdepth:%d stoptime:%d ndl:%d\n",
|
||||
|
@ -326,9 +326,9 @@ void uemis::parse_divelog_binary(std::string_view base64, struct dive *dive)
|
|||
*/
|
||||
cylinder_t *cyl = dive->get_or_create_cylinder(i);
|
||||
cyl->type.size.mliter = lrintf(volume);
|
||||
cyl->type.workingpressure.mbar = 202600;
|
||||
cyl->type.workingpressure = 202600_mbar;
|
||||
cyl->gasmix.o2.permille = *(uint8_t *)(data.data() + 120 + 25 * (gasoffset + i)) * 10;
|
||||
cyl->gasmix.he.permille = 0;
|
||||
cyl->gasmix.he = 0_percent;
|
||||
}
|
||||
/* first byte of divelog data is at offset 0x123 */
|
||||
size_t i = 0x123;
|
||||
|
@ -353,7 +353,7 @@ void uemis::parse_divelog_binary(std::string_view base64, struct dive *dive)
|
|||
u_sample++;
|
||||
}
|
||||
if (sample)
|
||||
dive->dcs[0].duration = sample->time - duration_t { .seconds = 1 };
|
||||
dive->dcs[0].duration = sample->time - 1_sec;
|
||||
|
||||
/* get data from the footer */
|
||||
add_extra_data(dc, "FW Version",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue