summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README32
-rw-r--r--profile.c47
2 files changed, 79 insertions, 0 deletions
diff --git a/README b/README
index 0ff77c375..a9eb649ee 100644
--- a/README
+++ b/README
@@ -38,3 +38,35 @@ my divemaster course, so they are from following open water students
along (many of them the confined*water dives). There a lot of the
action is at the surface, so some of the "dives" are 4ft deep and 2min
long.
+
+Contributing:
+
+Please either send me signed-off patches or a pull request with
+signed-off commits. If you don't sign off on them, I will not accept
+them. This means adding a line that says "Signed-off-by: Name <email>"
+at the end of each commit, indicating that you wrote the code and have
+the right to pass it on as an open source patch.
+
+See: http://gerrit.googlecode.com/svn/documentation/2.0/user-signedoffby.html
+
+Also, please write good git commit messages. A good commit message
+looks like this:
+
+ header line: explaining the commit in one line
+
+ Body of commit message is a few lines of text, explaining things
+ in more detail, possibly giving some background about the issue
+ being fixed, etc etc.
+
+ The body of the commit message can be several paragrahps, and
+ please do proper word-wrap and keep columns shorter than about
+ 74 characters or so. That way "git log" will show things
+ nicely even when it's indented.
+
+ Reported-by: whoever-reported-it
+ Signed-off-by: Your Name <youremail@yourhost.com>
+
+where that header line really should be meaningful, and really should be
+just one line. That header line is what is shown by tools like gitk and
+shortlog, and should summarize the change in one readable line of text,
+independently of the longer explanation.
diff --git a/profile.c b/profile.c
index f0a4c7030..af1976e61 100644
--- a/profile.c
+++ b/profile.c
@@ -280,6 +280,50 @@ static void plot_cylinder_pressure(struct dive *dive, cairo_t *cr,
cairo_stroke(cr);
}
+/*
+ * Return air usage (in liters).
+ */
+static double calculate_airuse(struct dive *dive)
+{
+ double airuse = 0;
+ int i;
+
+ for (i = 0; i < MAX_CYLINDERS; i++) {
+ cylinder_t *cyl = dive->cylinder + i;
+ int size = cyl->type.size.mliter;
+ double kilo_atm;
+
+ if (!size)
+ continue;
+
+ kilo_atm = (cyl->start.mbar - cyl->end.mbar) / 1013250.0;
+
+ /* Liters of air at 1 atm == milliliters at 1k atm*/
+ airuse += kilo_atm * size;
+ }
+ return airuse;
+}
+
+static void plot_info(struct dive *dive, cairo_t *cr,
+ double topx, double topy, double maxx, double maxy)
+{
+ text_render_options_t tro = {0.2, 1.0, 0.2, LEFT};
+ const double liters_per_cuft = 28.317;
+ double airuse;
+
+ airuse = calculate_airuse(dive);
+ if (!airuse)
+ return;
+
+ /* I really need to start addign some unit setting thing */
+ airuse /= liters_per_cuft;
+ plot_text(cr, &tro, maxx*0.95, maxy*0.9, "cuft: %4.2f", airuse);
+ if (dive->duration.seconds) {
+ double pressure = 1 + (dive->meandepth.mm / 10000.0);
+ double sac = airuse / pressure * 60 / dive->duration.seconds;
+ plot_text(cr, &tro, maxx*0.95, maxy*0.95, "SAC: %4.2f", sac);
+ }
+}
static void plot_cylinder_pressure_text(struct dive *dive, cairo_t *cr,
double topx, double topy, double maxx, double maxy)
@@ -318,6 +362,9 @@ static void plot(cairo_t *cr, int w, int h, struct dive *dive)
plot_depth_text(dive, cr, topx, topy, maxx, maxy);
plot_cylinder_pressure_text(dive, cr, topx, topy, maxx, maxy);
+ /* And info box in the lower right corner.. */
+ plot_info(dive, cr, topx, topy, maxx, maxy);
+
/* Bounding box last */
scalex = scaley = 1.0;
cairo_set_source_rgb(cr, 1, 1, 1);