Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4018) - 28 March 2024

Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

High/Low Pressure Not Being Shown As Raw Data - Rounding?

Discussion of Mark Crossley's HTML5/Javascript gauges

Moderator: mcrossley

Post Reply
Grimers
Posts: 240
Joined: Tue 24 Nov 2015 9:07 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 64-bit
Location: Newton Poppleford, Devon, UK
Contact:

High/Low Pressure Not Being Shown As Raw Data - Rounding?

Post 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
User avatar
mcrossley
Posts: 12694
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: High/Low Pressure Not Being Shown As Raw Data - Rounding

Post 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.
Grimers
Posts: 240
Joined: Tue 24 Nov 2015 9:07 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 64-bit
Location: Newton Poppleford, Devon, UK
Contact:

Re: High/Low Pressure Not Being Shown As Raw Data - Rounding

Post 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. ;)
User avatar
mcrossley
Posts: 12694
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: High/Low Pressure Not Being Shown As Raw Data - Rounding

Post 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.
Grimers
Posts: 240
Joined: Tue 24 Nov 2015 9:07 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 64-bit
Location: Newton Poppleford, Devon, UK
Contact:

Re: High/Low Pressure Not Being Shown As Raw Data - Rounding

Post by Grimers »

I suppose not, but seen as the Davis range provides pressure readings to 2 dp, then why not use it. :P

Thanks for the code, Mark. I really appreciate it. :)
Grimers
Posts: 240
Joined: Tue 24 Nov 2015 9:07 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 64-bit
Location: Newton Poppleford, Devon, UK
Contact:

Re: High/Low Pressure Not Being Shown As Raw Data - Rounding

Post 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?
User avatar
mcrossley
Posts: 12694
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: High/Low Pressure Not Being Shown As Raw Data - Rounding

Post 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">
Grimers
Posts: 240
Joined: Tue 24 Nov 2015 9:07 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 64-bit
Location: Newton Poppleford, Devon, UK
Contact:

Re: High/Low Pressure Not Being Shown As Raw Data - Rounding

Post 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.
Grimers
Posts: 240
Joined: Tue 24 Nov 2015 9:07 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 64-bit
Location: Newton Poppleford, Devon, UK
Contact:

Re: High/Low Pressure Not Being Shown As Raw Data - Rounding

Post by Grimers »

Everything has been changed. Thanks for your time on this, Mark.
User avatar
mcrossley
Posts: 12694
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: High/Low Pressure Not Being Shown As Raw Data - Rounding

Post 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;
Grimers
Posts: 240
Joined: Tue 24 Nov 2015 9:07 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 64-bit
Location: Newton Poppleford, Devon, UK
Contact:

Re: High/Low Pressure Not Being Shown As Raw Data - Rounding

Post by Grimers »

Stupid me! :groan: Thanks a lot for your help, Mark.
Post Reply