Welcome to the Cumulus Support forum.

Latest Cumulus MX release v3.4.0 (build 3064) - 19 February 2020.
    Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014

    See the Wiki for downloading either version.

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

    Discussion of Mark Crossley's HTML5/Javascript gauges

    Moderator: mcrossley

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

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

    Post by Grimers » Sat 06 Aug 2016 2:36 pm

    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
    William Grimsley.

    User avatar
    mcrossley
    Posts: 5997
    Joined: Thu 07 Jan 2010 9:44 pm
    Weather Station: Davis VP2
    Operating System: Stretch Lite rPi
    Location: Wilmslow, Cheshire, UK
    Contact:

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

    Post by mcrossley » Sat 06 Aug 2016 4:46 pm

    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.

    User avatar
    Grimers
    Posts: 208
    Joined: Tue 24 Nov 2015 9:07 am
    Weather Station: Davis Vantage Pro2
    Operating System: Windows 10 64-bit
    Location: Newton Poppleford, Devon, UK
    Contact:

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

    Post by Grimers » Sat 06 Aug 2016 5:13 pm

    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. ;)
    William Grimsley.

    User avatar
    mcrossley
    Posts: 5997
    Joined: Thu 07 Jan 2010 9:44 pm
    Weather Station: Davis VP2
    Operating System: Stretch Lite rPi
    Location: Wilmslow, Cheshire, UK
    Contact:

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

    Post by mcrossley » Sat 06 Aug 2016 9:00 pm

    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.

    User avatar
    Grimers
    Posts: 208
    Joined: Tue 24 Nov 2015 9:07 am
    Weather Station: Davis Vantage Pro2
    Operating System: Windows 10 64-bit
    Location: Newton Poppleford, Devon, UK
    Contact:

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

    Post by Grimers » Sat 06 Aug 2016 9:03 pm

    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. :)
    William Grimsley.

    User avatar
    Grimers
    Posts: 208
    Joined: Tue 24 Nov 2015 9:07 am
    Weather Station: Davis Vantage Pro2
    Operating System: Windows 10 64-bit
    Location: Newton Poppleford, Devon, UK
    Contact:

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

    Post by Grimers » Sat 06 Aug 2016 9:57 pm

    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?
    William Grimsley.

    User avatar
    mcrossley
    Posts: 5997
    Joined: Thu 07 Jan 2010 9:44 pm
    Weather Station: Davis VP2
    Operating System: Stretch Lite rPi
    Location: Wilmslow, Cheshire, UK
    Contact:

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

    Post by mcrossley » Mon 08 Aug 2016 10:46 am

    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">

    User avatar
    Grimers
    Posts: 208
    Joined: Tue 24 Nov 2015 9:07 am
    Weather Station: Davis Vantage Pro2
    Operating System: Windows 10 64-bit
    Location: Newton Poppleford, Devon, UK
    Contact:

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

    Post by Grimers » Mon 08 Aug 2016 4:06 pm

    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.
    William Grimsley.

    User avatar
    Grimers
    Posts: 208
    Joined: Tue 24 Nov 2015 9:07 am
    Weather Station: Davis Vantage Pro2
    Operating System: Windows 10 64-bit
    Location: Newton Poppleford, Devon, UK
    Contact:

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

    Post by Grimers » Mon 08 Aug 2016 4:11 pm

    Everything has been changed. Thanks for your time on this, Mark.
    William Grimsley.

    User avatar
    mcrossley
    Posts: 5997
    Joined: Thu 07 Jan 2010 9:44 pm
    Weather Station: Davis VP2
    Operating System: Stretch Lite rPi
    Location: Wilmslow, Cheshire, UK
    Contact:

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

    Post by mcrossley » Mon 08 Aug 2016 7:36 pm

    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;
    

    User avatar
    Grimers
    Posts: 208
    Joined: Tue 24 Nov 2015 9:07 am
    Weather Station: Davis Vantage Pro2
    Operating System: Windows 10 64-bit
    Location: Newton Poppleford, Devon, UK
    Contact:

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

    Post by Grimers » Mon 08 Aug 2016 8:59 pm

    Stupid me! :groan: Thanks a lot for your help, Mark.
    William Grimsley.

    Post Reply