[PATCH] MOD of oxygen at pO2 of 1.6 is 20ft

Robert C. Helling helling at atdotde.de
Sun Jul 5 15:16:31 PDT 2015


> On 05 Jul 2015, at 21:31, Dirk Hohndel <dirk at hohndel.org> wrote:
> 
> On Sun, Jul 05, 2015 at 12:11:15PM -0700, Linus Torvalds wrote:
>> On Sun, Jul 5, 2015 at 11:56 AM, Dirk Hohndel <dirk at hohndel.org> wrote:
>>> static inline depth_t gas_mod(struct gasmix *mix, pressure_t po2_limit, int roundto) {
>>>        depth_t depth;
>>>        depth.mm = ((po2_limit.mbar * 1000 / get_o2(mix) * 10 - 10000) / roundto) * roundto;
>>>        return depth;
>>> }
>>> 
>>> So all we need to do is adjust this function to add (roundto - 1) to the
>>> enumerator before deviding by roundto, correct?
>> 
>> Ugh. I think it would be better to write it more readably first.
>> That's a particularly unreadable line of noise.
> 
> Well, Robert wrote it, now he can fix it.

I couldn’t remember but git blame says so. But I only added the rounding, the poor man’s pressure to depth conversion was there before.

So, here is a patch that gets the maths right (boy, that was more complicated than I thought).

I did not touch the roundto arguments that this is called with (3m or 10ft) as I would still think this is what people expect. But feel free to change those (but only in a way that gives 6m/20ft for O2 and 21m/70ft for EAN50 please).

The second patch fixes a compiler warning. I did not really check the logic to figure out what was actually meant there but the compiler is right: What’s was written there makes no sense (to me).

Best
Robert
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0001-To-compute-expected-MOD-of-gas-round-rather-than-trunc.txt
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20150706/b5b218b4/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0002-Correct-logic.txt
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20150706/b5b218b4/attachment-0001.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20150706/b5b218b4/attachment.sig>


More information about the subsurface mailing list