Page 1 of 1
High/Low Pressure Not Being Shown As Raw Data - Rounding?
Posted: Sat 06 Aug 2016 2:36 pm
by Grimers
Hi everyone,
On the SteelSeries Gauges, I am wondering what code is controlling the high and low's for specifically pressure? I want to try and print ".00" after the pressure when it's shown as a whole number. For example, currently when the pressure high/low is a whole number, there is no ".00" afterwards. However, I am trying to understand on how I would print this as "1017.00 hPa", seems specific I know but wanted it to be the same as what is shown in other areas of the website.
I hope I've made sense.
Thanks,
William
Re: High/Low Pressure Not Being Shown As Raw Data - Rounding
Posted: Sat 06 Aug 2016 4:46 pm
by mcrossley
I'll fix the number of decimals displayed for the lows/highs in the next release.
The code uses 1 dp for hPa/mb, 2 dp for kPa, and 3 dp for inchesHg for the current reading and trend.
Quoting the hPa/mb to 2 dp is pretty meaningless, especially as the Davis kit does not provide that resolution anyway - it may show 2 dp, but not all the hundredths values are available, and moving your senor up or down a few feet would change the reading at that resolution.
Re: High/Low Pressure Not Being Shown As Raw Data - Rounding
Posted: Sat 06 Aug 2016 5:13 pm
by Grimers
2 dp is shown for Davis pressure and is used widely.
I'm seeing 2 dp on every reading except a whole number, is this code declared somewhere in the gauges.js file?
I've made quite a few changes to the file, so would appreciate a guide as to where this code is, if that's possible. You don't have to change it for the next release then.

Re: High/Low Pressure Not Being Shown As Raw Data - Rounding
Posted: Sat 06 Aug 2016 9:00 pm
by mcrossley
Well it still needs fixing for everyone if it displays integer values when the decimals are zero.
Here is what I will be putting the next release...
Code: Select all
function update() {
var tip, t1, dps;
...
if (data.pressunit === 'hPa' || data.pressunit === 'mb') {
// min range 990-1030 - steps of 10 hPa
cache.minValue = Math.min(Math.floor((cache.recLow - 2) / 10) * 10, 990);
cache.maxValue = Math.max(Math.ceil((cache.recHigh + 2) / 10) * 10, 1030);
dps = 1; // 1 decimal place
} else if (data.pressunit === 'kPa') {
// min range 99-105 - steps of 1 kPa
cache.minValue = Math.min(Math.floor(cache.recLow - 0.2), 99);
cache.maxValue = Math.max(Math.ceil(cache.recHigh + 0.2), 105);
dps = 2;
} else {
// inHg: min range 29.5-30.5 - steps of 0.5 inHg
cache.minValue = Math.min(Math.floor((cache.recLow - 0.1) * 2) / 2, 29.5);
cache.maxValue = Math.max(Math.ceil((cache.recHigh + 0.1) * 2) / 2, 30.5);
dps = 3;
}
cache.trendValRnd = cache.trendVal.toFixed(dps);
cache.todayLowRnd = cache.todayLow.toFixed(dps);
cache.todayHighRnd = cache.todayHigh.toFixed(dps);
...
tip = strings.baro_info + ':' +
'<br>' +
'- ' + strings.minimum_info + ': ' + cache.todayLowRnd + ' ' + data.pressunit + ' ' + strings.at + ' ' + data.TpressTL +
' | ' + strings.maximum_info + ': ' + cache.todayHighRnd + ' ' + data.pressunit + ' ' + strings.at + ' ' + data.TpressTH;
Change the dps value as you want, I still think a hPa value to 2 dp is meaningless though, do you really know your sensors height above sea level to the nearest 8.5 cm?
The met office consider a 'good' barometer is accurate to 0.2 hPa.
Re: High/Low Pressure Not Being Shown As Raw Data - Rounding
Posted: Sat 06 Aug 2016 9:03 pm
by Grimers
I suppose not, but seen as the Davis range provides pressure readings to 2 dp, then why not use it.
Thanks for the code, Mark. I really appreciate it.

Re: High/Low Pressure Not Being Shown As Raw Data - Rounding
Posted: Sat 06 Aug 2016 9:57 pm
by Grimers
Hmm, I've only replaced what you've put there and it's broken the script, thank god I've backed it up.
I did presume the "..." was the rest of the code in between those snippets?
Re: High/Low Pressure Not Being Shown As Raw Data - Rounding
Posted: Mon 08 Aug 2016 10:46 am
by mcrossley
You have missed the 'dps' variable declaration on the first line of the function, but that shouldn't stop it working.
I was trying to look at your page to debug what was going wrong, but it is impossible as you have a forced page refresh every 60 seconds. You might want to remove that! - <meta http-equiv="refresh" content="60">
Re: High/Low Pressure Not Being Shown As Raw Data - Rounding
Posted: Mon 08 Aug 2016 4:06 pm
by Grimers
Ok, I see. I've replaced the script with my old script, I'll replace it with the one I've attached and turn off auto update for you.
Re: High/Low Pressure Not Being Shown As Raw Data - Rounding
Posted: Mon 08 Aug 2016 4:11 pm
by Grimers
Everything has been changed. Thanks for your time on this, Mark.
Re: High/Low Pressure Not Being Shown As Raw Data - Rounding
Posted: Mon 08 Aug 2016 7:36 pm
by mcrossley
OK, it is just that you have missed the variable declaration for 'dps' in the function.
Code: Select all
function update() {
var tip, t1, dps;
Re: High/Low Pressure Not Being Shown As Raw Data - Rounding
Posted: Mon 08 Aug 2016 8:59 pm
by Grimers
Stupid me!

Thanks a lot for your help, Mark.