aboutsummaryrefslogtreecommitdiffstats
path: root/profile.c
AgeCommit message (Collapse)Author
2011-09-30Distinguish internally between min pressure and end pressureGravatar Dirk Hohndel
And don't artificially end dives on min pressure This may be a problem for dive computers like Linus' Suunto Vyper Air where the failure mode seems to be _high_ pressure readings (that's scary, btw). If the transmitter fails at the end of the dive the pressure plot ends with incorrect high pressure. But that's simply a bug with the dive computer and not something that subsurface should hack around. Maybe we should offer a way to edit the incorrect data points instead. Always ending on the minimum pressure is definitely wrong as it causes bogus plots when you do a valve shutdown during the dive (which means that valid data gets plotted incorrectly). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-29Fix the profile coloringGravatar Dirk Hohndel
We were missing the last sample (which is usually a fast ascent). Also, reduced the velocity smoothing to 15 seconds as the 30 seconds were hiding too much valid information Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-28Remove average depth from printGravatar Dirk Hohndel
It looks confusing in black and white Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-22Show events on the dive profileGravatar Linus Torvalds
This is *really* ugly. We really should just create some kind of widget that when moused over will show the event. Or something. Rather than putting text on top of other text: the events - when they happen - are usually bunched together (PO2 warnings, max depth, fast ascent leading to mandatory safety stop, you name it). But at least this way we see that the data is there, even if we see it in ugly ways. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-21Add helper function for doing depth unit calculationsGravatar Linus Torvalds
.. and use it for printing too. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-21Fix array underrun when calculating velocityGravatar Linus Torvalds
That code is messy. And it was buggy. Noticed by valgrind. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-20Fix 'struct plot_info' memory leakGravatar Linus Torvalds
The plot_info was never freed, so every time you'd plot something, we'd leak memory. I'm running valgrind to see if there's anything bad going on. So far it all looks fairly benign. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-20Fix up printing some moreGravatar Linus Torvalds
Use the actual degree sign for temperatures (°F and °C), and make sure everything uses the proper "set_source_rgb[a]()" wrappers to set the colors. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-20Print out only simplified depth profileGravatar Linus Torvalds
None of the colors, nothing like that. Just a gray fill and a plain black depth line. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-20Clean up and simplify depth plotGravatar Linus Torvalds
Dirk wrote this before we have the 'plot_info' structure with the cleaned-up dive info. No need to maintain that separate array of depths and seconds. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-20Don't show the smoothed dive profile or the min/max infoGravatar Linus Torvalds
It was good for debugging, it's not something we really want to show people. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-20Separate out the UI from the program logicGravatar Dirk Hohndel
The following are UI toolkit specific: gtk-gui.c - overall layout, main window of the UI divelist.c - list of dives subsurface maintains equipment.c - equipment / tank information for each dive info.c - detailed dive info print.c - printing The rest is independent of the UI: main.c i - program frame dive.c i - creates and maintaines the internal dive list structure libdivecomputer.c uemis.c parse-xml.c save-xml.c - interface with dive computers and the XML files profile.c - creates the data for the profile and draws it using cairo This commit should contain NO functional changes, just moving code around and a couple of minor abstractions. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-16Attempt to smooth out the velocity readingsGravatar Dirk Hohndel
If the velocity is slower than FAST then we look back up to 30 seconds and calculate the velocity for the past 30 seconds instead. For the first version I'm not doing the average of the changes but simply the change from beginning to end. The alternative would be to do another triangle smoothing or something like that - but as we don't know how many samples we have in the 30 second window, it's a little harder here. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-16Flip tank pressure graph to show the RIGHT wayGravatar Dirk Hohndel
This annoyed me from the first moment Linus added the tank pressure graph. As the pressure goes down, the graph needs to go down. Seriously. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-16Stop plotting the gas / consumption information into the profileGravatar Dirk Hohndel
And move the code into info.c where it now belongs Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-16Make handling of empty airconsumption string consistentGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-16Stop tank / gas / consumption info from changing info_frame sizeGravatar Dirk Hohndel
Simply set it to an empty string with TWO lines when there is nothing to display Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-16Indicate vertical velocity through colorGravatar Dirk Hohndel
So far Linus has hated all of my attempts to visualize vertical velocity through color. This time I'm trying something dramatically new: there is no PURPLE involved. Maybe that will convince him of the value. We simply calculate the vertical velocity for the current plot segment (last sample point to this sample point - in this version even without divisions by zero) and assign a label based on the rate of change. These labels are translated through a predefined table into colors: Dark green is +/- 5ft/min (stable) Light green is descents up to 30ft/min and ascents up to 15ft/min Yellow is descents up to 60ft/min and ascents up to 30ft/min Orange is descents up to 100ft/min and ascents up to 60ft/min Red is outside of those ranges - you are most likely in danger Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-16Show tank / nitrox / air consumption information in the info_frameGravatar Dirk Hohndel
Even though we go down to an 8pt font the info_frame changes size when the air info is added. I don't like this but want to see how Linus would like this resolved before going overboard. Minor tweaks to the formating (we don't need two decimals when printing the liters of air consumed). This patch does NOT remove the plot of the air information in the profile graph. I think we want to remove that once we like the text where it is, but I wanted to do one thing at a time. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-16Tweak temperature plot to look better for small fluctuationsGravatar Dirk Hohndel
If the temperature is in a very narrow range the existing code visually exaggerated the fluctuations. This tries to dampen that effect a bit. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-16Tweak plot scaling a bitGravatar Linus Torvalds
Change the duration max rounding as noted by Dirk, and move the air consumption down further towards the bottom right corner. In particular, I make the text positions not scale with the window size, purely by the size of the text. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-16Minor corrections to printing of the last temperatureGravatar Dirk Hohndel
- the time stamp where we printed the last temp was wrong - we really shouldn't check mK for being identical - especially on dive computers that store a lot of samples Signed-off-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-16Use plot_info for final remaining temperature and pressure data plots tooGravatar Linus Torvalds
Ok, this is pretty much it now. Instead of having various random checks for "is the time of the sample past the end of the dive" hacks, we not plot all graphs from the cleaned-up plot_info structure instead of the raw samples. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-16Plot pressure data based on 'struct plot_info' rather than raw dive dataGravatar Linus Torvalds
Further movement to using the sanitized and cleaned-up plot info rather than the raw data. The raw dive data contains samples from the end of the dive that we don't want to drop, but that we also don't want to actually use for plotting the dive. So the eventual end goal here is to not ever use the raw dive samples directly for plotting, but use the diveplot data that we have analyzed for min/max (properly ignoring final entries) etc. There's still some data that we take from the samples when plotting, but it's getting rarer. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-16Do min/max pressure and temperature based on the non-surface dataGravatar Linus Torvalds
Do the min/max calculations only *after* we have removed the extra surface events at the end. The Uemis data in particular has a lot of surface events after the dive, and we don't really want to take them into account since we won't be plotting them anyway. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-16Plot temperature info using 'struct plot_info' rather than the raw dive samplesGravatar Linus Torvalds
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-16Start using 'plot_info' more for dive-time limitsGravatar Linus Torvalds
.. I'll want to move pressure limit calculations into the 'plot_info', so that we can do several passes of analysis and change dive limits etc without having to actually modify the dive data itself (or add new fields to 'struct dive' just for plotting). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-15Print the end temperature of the diveGravatar Dirk Hohndel
Currently we print the temperature every five minutes. Especially with dive computers that keep rather frequent temperature samples that means that we have one more interesting data point that we don't label: the surface temperature at the end of the dive. This patch adds some logic to try to print the last temperature sample that was recorded before the dive ended - unless that same value has already been printed (to avoid silly duplications on dive computers with less frequent sampling) Signed-off-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-15Don't draw temperature plot past the end of the diveGravatar Dirk Hohndel
Just like we end depth and tank pressure plots once we are on the surface (this is relevant for dive computers like the uemis Zurich that keep recording samples after the end of the dive) Signed-off-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-13I'm trying to figure something out that prints reasonably..Gravatar Linus Torvalds
I'll get there. Shrink it down a bit, start adding notes and location, and maybe put three per page. That might work. .. or maybe I should just take a look at how others have done this. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-13Make the printout look differentGravatar Linus Torvalds
Not *better* mint you. Just different. I suck at graphs. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-13Add the capability to print a dive profileGravatar Linus Torvalds
Ok, this is the ugliest f*&$ing printout I have ever seen in my life, but think of it as a "the concept of printing works" commit, and you'll be able to hold your lunch down and not gouge out your eyeballs with a spoon. Maybe. I'm just doing the cairo display as-is for the printout, which is a seriously bad idea. I need to not try to do colors etc, and instead of having white lines on a black background I just need to make thelines be black on white paper. But that would involve actually changing the current "plot()" routine, which is against the point of the exercise right now. This really is just a demonstration of how to add printing capabilities. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-13Use round line noins and capsGravatar Linus Torvalds
It doesn't really make much of a difference, but it can be visible especially with lots of tight samples. Miter joins really look horrible for acute angles. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-13Label the temperature graphGravatar Linus Torvalds
Oooh, pretty. Or not. The temperature graph is usually ugly as hell, but Dirk has the cool dive computer with lots and lots of temperature readings. Which makes the graph a pretty graph, rather than a butt-ugly staircase like mine. Next time: get a dive computer with an OLED screen, and that can draw pretty temperature graphs. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-12Plot a sick kind of temperature curveGravatar Linus Torvalds
.. without the actual text, because I'm a "random plots that cannot actually be interpreted" kind of guy. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-11Accept a smaller profile windowGravatar Linus Torvalds
I'm trying to make sure that we can shrink the main window and still get a useful experience. Sometimes you have small bad netbooks when diving.. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-09Show tank type and O2 mix for air usageGravatar Linus Torvalds
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-08Use the analyzed local minima/maxima for depth text plottingGravatar Linus Torvalds
Instead of relying on our ad-hoc minmax finder, just use the local minima/maxima information directly. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-08Use an indirect pointer to min/max entry rather than valueGravatar Linus Torvalds
This way we can always find the actual min/max entry that generated the local minima/maxima. Which is useful for visualization. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-08Show the min/max data in funky purple shadingGravatar Linus Torvalds
Dirk likes purple. I mean - Dirk REALLY likes purple. And what's better than "purple"? You got it: "funky purple". So this shows the one- two- and three-minute min/max information in some seriously funky purple fringing. It's not really necessarily meant to be serious, but it's a quick hack to visualize the data until we figure out what to *really* do with it. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-08Start analyzing depth profile: smoothing and time-based min/max/avgGravatar Linus Torvalds
This turns the depth profile into a generic "plot_info" and calculates minima, maxima and averages over 1-, 2- and 3-minute intervals for each point. It also creates a smoothed version. We currently don't actually show the results, but that's the next step.. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-07Remove unused variableGravatar Dirk Hohndel
This fixes a compile warning Signed-off-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-07Show the shallow points of the dive tooGravatar Linus Torvalds
.. unless they are so shallow that they are basically at the surface. These show up automatically in out min/max logic, so just go ahead and show them. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-07Move text rendering function upwardsGravatar Linus Torvalds
No change in semantics, I'm just contemplating doing some text renderign from within the "minmax" function itself. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-07Add font size to the text_render_options structureGravatar Linus Torvalds
Ok, so it's really a 'double', but for now we're only using integer font sizes, so let's see if we ever want to do anything but that. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-07Add vertical alignment setting to text outputGravatar Dirk Hohndel
Add new valign enum to text_render_options_t and update all callers to plot_text Signed-off-by: Dirk Hohndel <dirk@hohndel.org> [ Fixed spelling, updated to newer base - Linus ] Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-07Turn tail recursion back into a loopGravatar Linus Torvalds
I still think there should be some way to partition the space automatically, but the algorithm that worked best was the simple tail-recursive one. Which might as well be expressed as a loop. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-07Get rid of timelimit code and corner casesGravatar Linus Torvalds
The recursive minmax is now robust without them. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-07Clean up plot_text_samples() furtherGravatar Linus Torvalds
We don't actually use the 'dive' structure any more, since we now always have the sample pointers directly. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-07Simplify/clean up depth min/max finderGravatar Linus Torvalds
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>