Welcome to the Cumulus Support forum.

Latest Cumulus MX release v3.4.6 (build 3070) - 23 March 2020
Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014

See the Wiki for downloading either version.

Cumulus PHP-GD Banner

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

Mark14
Posts: 66
Joined: Thu 23 Aug 2012 8:53 pm
Weather Station: WH 2080
Operating System: Windows 7
Location: Konin, Poland

Re: Cumulus PHP-GD Banner

Post by Mark14 » Sun 07 Jul 2019 2:00 pm

To some extent, because I see a banner. It's probably not a wrong path issue.
However, on my main webpage I normally see updated data every minute: http://mark014.beep.pl

The banner is not updated on a regular basis. At the moment, I see measurements from 15 minutes ago: http://mark014.beep.pl/pogoda.php. Strange thing. I did not have such a situation so far.
It looks like the banner refreshed only every hour...
Image

User avatar
beteljuice
Posts: 2863
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: ex XP SP3 - now W10 laptop grr
Location: Dudley, West Midlands, UK

Re: Cumulus PHP-GD Banner

Post by beteljuice » Sun 07 Jul 2019 9:51 pm

Are you sure you don't have TWO realtime.txt ?

http://mark014.beep.pl/realtime.txt is updating correctly, but as you say the banner seems to have a different 'period'.
Why is 'realtime' an extrafile - I don't remember that, but I could be wrong :roll:
Image
......................Imagine, what you will KNOW tomorrow !

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

Re: Cumulus PHP-GD Banner

Post by mcrossley » Mon 08 Jul 2019 3:51 pm

beteljuice wrote:
Sun 07 Jul 2019 9:51 pm
Why is 'realtime' an extrafile - I don't remember that, but I could be wrong :roll:
Correct, Cumulus will upload at the realtime interval so long as you tick the option in settings, no need to add it as an extra file.

Unless you want to upload at longer than the reltime interval I guess?

User avatar
beteljuice
Posts: 2863
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: ex XP SP3 - now W10 laptop grr
Location: Dudley, West Midlands, UK

Re: Cumulus PHP-GD Banner

Post by beteljuice » Mon 08 Jul 2019 9:20 pm

Unless you want to upload at longer than the reltime interval I guess?
That's why I wandering if there were two files in different places ....
Image
......................Imagine, what you will KNOW tomorrow !

Mapantz
Posts: 670
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 10 x64
Location: Dorset - UK
Contact:

Re: Cumulus PHP-GD Banner

Post by Mapantz » Tue 09 Jul 2019 12:49 pm

I had a similar problem when I first started using the banner. It's possible you may have it too.

It turned out to be a caching problem and to solve it, I added this to my .htaccess file

Code: Select all

<Files banner.php>
FileETag None
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</Files>
Image

User avatar
beteljuice
Posts: 2863
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: ex XP SP3 - now W10 laptop grr
Location: Dudley, West Midlands, UK

Re: Cumulus PHP-GD Banner

Post by beteljuice » Tue 09 Jul 2019 2:51 pm

Thanks mapantz - haven't seen that one before.

Does that mean the rest of 'the site' has a cache value set somewhere by hosting admin ?
Image
......................Imagine, what you will KNOW tomorrow !

Mark14
Posts: 66
Joined: Thu 23 Aug 2012 8:53 pm
Weather Station: WH 2080
Operating System: Windows 7
Location: Konin, Poland

Re: Cumulus PHP-GD Banner

Post by Mark14 » Sun 14 Jul 2019 11:49 am

mcrossley wrote:
Mon 08 Jul 2019 3:51 pm
Correct, Cumulus will upload at the realtime interval so long as you tick the extrafile in settings, no need to add it as an extra file.

Unless you want to upload at longer than the reltime interval I guess?
No I want to upload the realtime file every 50 secs.

Maybe I put the extrafile when I had previous problems with paths. But I deleted the option and now it works. Thank you for your help.
Image

Mapantz
Posts: 670
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 10 x64
Location: Dorset - UK
Contact:

Re: Cumulus PHP-GD Banner

Post by Mapantz » Thu 05 Dec 2019 10:16 pm

I was wondering if there were any clever folks (there's lots) that could help me with this banner?

I've been using it for years now, and something I would like to do is to have two separate background images, one for day and one for night.

I have done the same thing to the banner on my website, but it was quite easy to implement. However, the banner originally made by Kevin is a little bit more complicated than what I am used to. :lol:

I have been doing quite a bit of work to tidy up my site and in particular, reduce the amount of data I upload. I don't upload many pages any more, instead I have created a single php file with every CMX webtag that I use on my site. It has reduced my uploading by 80%.

The reason I mention that is, It has my sunrise and sunset times processed, so it might be easier to implement?

$sunrise = "07:53";
$sunset = "16:05";

etc

Many thanks!
Image

Mapantz
Posts: 670
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 10 x64
Location: Dorset - UK
Contact:

Re: Cumulus PHP-GD Banner

Post by Mapantz » Thu 05 Dec 2019 10:56 pm

OK - Looks like I actually managed to do it by myself..

Code: Select all

include 'mytags.php';
date_default_timezone_set('Europe/London');
$current = time();
$daytime = strtotime('$sunrise');
$nighttime = strtotime('$sunset');
if($daytime <= $current && $current < $nighttime) {
	$baseimg = imagecreatefromjpeg("images/day_banner.jpg");
} else {
	$baseimg = imagecreatefromjpeg("images/night_banner.jpg");
}
I added that in and tested by changing $sunrise and $sunset to actual times.

I'm sure that small piece of code is about as bad as you can get, but it worked. :oops:
Image

User avatar
beteljuice
Posts: 2863
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: ex XP SP3 - now W10 laptop grr
Location: Dudley, West Midlands, UK

Re: Cumulus PHP-GD Banner

Post by beteljuice » Thu 05 Dec 2019 11:00 pm

cross posted !!!

Like many others your banner version does not look for the later fields that have been added to realtime.txt.

in your case:
41 (field # 40) 36.0 10-minute high gust <#wgust>
42 (field # 41) 10.3 Heat index <#heatindex>
43 (field # 42) 10.5 Humidex <#humidex>
44 (field # 43) 13 UV Index <#UV>
45 (field # 44) 0.2 evapotranspiration today <#ET>
46 (field # 45) 14 solar radiation W/m2 <#SolarRad>
47 (field # 46) 260 10-minute average wind bearing (degrees) <#avgbearing>
48 (field # 47) 2.3 rainfall last hour <#rhour>
49 (field # 48) 3 The number of the current (Zambretti) forecast as per Strings.ini. <#forecastnumber>
50 (field # 49) 1 Flag to indicate that the location of the station is currently in daylight (1 = yes, 0 = No) <#isdaylight>
51 (field # 50) 1 If the station has lost contact with its remote sensors "Fine Offset only", a Flag number is given (1 = Yes, 0 = No) <#SensorContactLost>
52 (field # 51) NNW Average wind direction <#wdir>
53 (field # 52) 2040 Cloud base <#cloudbasevalue>
54 (field # 53) ft Cloud base units <#cloudbaseunit>
55 (field # 54) 12.3 Apparent temperature <#apptemp>
56 (field # 55) 11.1 Sunshine hours so far today <#SunshineHours>
57 (field # 56) 420.1 Current theoretical max solar radiation <#CurrentSolarMax>
58 (field # 57) 1 Is it sunny? 1 if the sun is shining, otherwise 0 (above or below threshold) <#IsSunny>

You can follow the existing logic and add these to $SITE['cvalues'] = array( ... OR you could simply refer to the array $DATA[#field number]

So your base image ....

Code: Select all

if($DATA[49] == 1) {
// OR if(ret_value("named field") == 1) {
    $baseimg = imagecreatefromjpeg("images/clouds_banner.jpg"); // daytime image
 } else {
     $baseimg = imagecreatefromjpeg("images/clouds__night_banner.jpg"); //night-time image
}
You may need the same logic to alter text colours .....
Last edited by beteljuice on Sun 12 Jan 2020 10:25 pm, edited 1 time in total.
Image
......................Imagine, what you will KNOW tomorrow !

Mapantz
Posts: 670
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 10 x64
Location: Dorset - UK
Contact:

Re: Cumulus PHP-GD Banner

Post by Mapantz » Fri 06 Dec 2019 4:53 pm

ha!

I didn't realise that there were fields missing in the first place. :oops:

Thanks beteljuice. :)
Image

forestedge
Posts: 57
Joined: Sun 29 Jul 2012 11:46 am
Weather Station: Davis Vantage Pro2 Plus
Operating System: Windows 10 64 bit
Location: Ashurst Bridge, Hampshire UK
Contact:

Re: Cumulus PHP-GD Banner

Post by forestedge » Tue 07 Jan 2020 7:24 pm

Returning to this again, I have been unable to change the white background on my banner to an image. :?: Current banner is www.tottonweather.co.uk/banner.php
The Image .NFWbanner is in both jpg and png format.
Any help appreciated.

Code: Select all

// Output the header to let the browser know we are
// sending a graphic file format
header("Content-type: image/" . $SITE['format'] );
$im = @imagecreate($SITE['image_width'], $SITE['image_height'])
    or die("Cannot Initialize new GD image stream");
    
// Set colors we want to use...
// first background is a white background
$background_color   = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
$black              = imagecolorallocate($im, 0x00, 0x00, 0x00);
$green              = imagecolorallocate($im, 0x00, 0x80, 0x00);
$blue               = imagecolorallocate($im, 0x00, 0x00, 0xff);
$red                = imagecolorallocate($im, 0xff, 0x00, 0x00);

$baseimg = imagecreatefromjpeg(".NFWbanner.jpg");
imagecopy($im,$baseimg,0,0,0,0,$SITE['image_width'], $SITE['image_height']);imagedestroy($baseimg);// Make a Border Around the box
ImageRectangle($im, 0, 0, $SITE['image_width'] -1 , 
    $SITE['image_height'] -1, $black);

User avatar
PaulMy
Posts: 2065
Joined: Sun 28 Sep 2008 11:54 pm
Weather Station: Davis Vantage Pro 2+ w/Envoy USB
Operating System: Windows-8
Location: Komoka, ON Canada
Contact:

Re: Cumulus PHP-GD Banner

Post by PaulMy » Tue 07 Jan 2020 10:51 pm

Code: Select all

$baseimg = imagecreatefromjpeg(".NFWbanner.jpg");
Could it be that the image file name has a leading dot (.)?

Your posted code looks very similar to mine other than the jpg file name

Code: Select all

$baseimg = imagecreatefromjpeg("komokaimage1.jpg");
Enjoy,
Paul
Davis Vantage Pro 2 - Windows 8 - Cumulus v1.9.4 b.1099 - CumulusMX/WiFiLogger
www.komokaweather.com
www.komokaweather.com/cumulusmx
www.komokaweather.ca
www.komokaweather.com/pws
Image

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

Re: Cumulus PHP-GD Banner

Post by mcrossley » Wed 08 Jan 2020 10:19 am

and your background image is in the same folder as the script?

User avatar
PaulMy
Posts: 2065
Joined: Sun 28 Sep 2008 11:54 pm
Weather Station: Davis Vantage Pro 2+ w/Envoy USB
Operating System: Windows-8
Location: Komoka, ON Canada
Contact:

Re: Cumulus PHP-GD Banner

Post by PaulMy » Wed 08 Jan 2020 3:14 pm

http://www.tottonweather.co.uk/.NFWbanner.jpg does not exist but http://www.tottonweather.co.uk/NFWbanner.jpg does http://www.tottonweather.co.uk/NFWbanner.jpg
so change your
$baseimg = imagecreatefromjpeg(".NFWbanner.jpg");
by removing the leading dot (.)

Enjoy,
Paul
Davis Vantage Pro 2 - Windows 8 - Cumulus v1.9.4 b.1099 - CumulusMX/WiFiLogger
www.komokaweather.com
www.komokaweather.com/cumulusmx
www.komokaweather.ca
www.komokaweather.com/pws
Image

Post Reply