These are chat archives for nightscout/ios

19th
May 2015
Pete
@someoneAnyone
May 19 2015 02:01 UTC
Hi all, was wondered what the best practice for calculating the raw data? I'm writing a swift class to do the conversation.
Jason Calabrese
@jasoncalabrese
May 19 2015 03:00 UTC
Scott Leibrand
@scottleibrand
May 19 2015 05:15 UTC
My function is still best practice? Scary. :-)
jwedding
@jwedding
May 19 2015 12:31 UTC
Why mess with a good thing?
Scott Leibrand
@scottleibrand
May 19 2015 14:27 UTC
heh. my threshold is always "just barely good enough to be functional": almost all my code could use some refactoring. :)
Jason Calabrese
@jasoncalabrese
May 19 2015 17:30 UTC
I thought most/all of that logic came from Adrian
Pete
@someoneAnyone
May 19 2015 20:39 UTC
Ok, thanks! I have the following in my planpen.

func rawIsigToRawBg(unfiltered: Int = 0, filtered: Int = 0, sgv:Int, scale: Int = 0, intercept: Int = 0, slope: Int = 0) -> Double {

var raw: Int = 0

if (slope == 0 || unfiltered == 0 || scale == 0) {
raw = 0;
} else if (filtered == 0 || sgv < 40) {
raw = scale * (unfiltered - intercept) / slope;
} else {
var ratio = scale * (filtered - intercept) / slope / sgv;
raw = scale * (unfiltered - intercept) / slope / ratio;
}

return round(Double(raw))

}

oops that didn't markup nicely.
Scott Leibrand
@scottleibrand
May 19 2015 22:19 UTC
@jasoncalabrese yeah, the logic was adrian's, but my implementation was simplified quite a bit. that's part of my surprise: that no one implemented his full algorithm.
Jason Calabrese
@jasoncalabrese
May 19 2015 22:22 UTC
my theory is that all the fancy algorithms are only need for the old 7+ sensors, bad insertions, bad sensors, etc. I'd take the current simple raw values over dexcom values anyday
they just trick you into thinking the sensor is working
that was probably needed at first since it would have been impossible to sell the old sensors without it
Scott Leibrand
@scottleibrand
May 19 2015 22:24 UTC
yeah, could be.