Sandaysoft

Support forum for Cumulus weather station software
It is currently Thu Jun 20, 2013 2:09 am
Please click here before posting. Help me to help you!
Useful Links: Cumulus FAQ • Enhancement requests • Wiki (documentation)
Please put your approximate location into your profile
Add your web site to the Cumulus user map
Vantage Pro2 users with firmware 3.00 should upgrade to fw 3.12 and Cumulus 1.9.4

All times are UTC




Post new topic Reply to topic  [ 299 posts ]  Go to page 1, 2, 3, 4, 5 ... 20  Next
Author Message
 Post subject: Cumulus PHP-GD Banner
PostPosted: Sun Oct 05, 2008 3:13 am 
Offline
User avatar

Joined: Wed Sep 17, 2008 1:34 pm
Posts: 629
Location: Mesa, AZ USA
Weather Station: Davis VP2 Plus w/24 FARS
Operating System: WinX Pro SP3 Dedicated wstn
Cumulus data generated Graphic Banner

I played around a bit with some of the existing banner php scripts out there and got them to work, but ended up just writing one from scratch. This is basically because the other scripts have lots of stuff in them that would not be supported and it will be easier to just build from this one.

This is a simple PHP banner script that uses standard GD and the default fonts (5 of them) that come with the package. I tested this on a PHP5 based server, so I'm not sure if it will work with PHP4.

This script generates an image each time it is called by reading the current realtime.txt file that is on the server.

Sample Output:

Image

It was very kind of Mother Nature to drop some rain so that I could for the first time test Cumulus's recording of rain...

The script is a single script, needs no images to work and uses standard GD (no ttf fonts).

If the script is used in the same web directory that your realtime.txt file is located, you won't need to make any changes except if you use different units for temp, rain, wind and of course you will want to change the station name to yours.

The version number which is not send out in the realtime.txt file is also a manual setting in the script.

Project Page and Downloads

http://cumulus.tnetweather.com/projects/phpggbanner

Collection of other banners in use:

http://cumulus.tnetweather.com/projects/phpggbanner/gallery

_________________
Kevin
Image
All you need is Time, Aptitude and Desire ... and you can build just about anything...
Cumulus User Maps


Last edited by TNETWeather on Sun Oct 05, 2008 5:47 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Cumulus PHP-GD Banner
PostPosted: Sun Oct 05, 2008 3:47 am 
Offline
User avatar

Joined: Wed Sep 17, 2008 1:34 pm
Posts: 629
Location: Mesa, AZ USA
Weather Station: Davis VP2 Plus w/24 FARS
Operating System: WinX Pro SP3 Dedicated wstn
Source Code:

The following will output the current source of the banner.php script:

TNET Cumulus Project Page

_________________
Kevin
Image
All you need is Time, Aptitude and Desire ... and you can build just about anything...
Cumulus User Maps


Top
 Profile  
 
 Post subject: Re: Cumulus PHP-GD Banner
PostPosted: Sun Oct 05, 2008 4:26 am 
Offline

Joined: Thu Sep 18, 2008 8:40 pm
Posts: 61
Location: Tokoroa South Waikato New Zealand
Weather Station: Davis VP pro 2
Operating System: Win7
Many thanks, very easy to understand and use/modify

_________________
http://tokoroa.dyndns.org/ Main Site

IT Fixer


Top
 Profile  
 
 Post subject: Re: Cumulus PHP-GD Banner
PostPosted: Sun Oct 05, 2008 4:42 am 
Offline

Joined: Thu Sep 18, 2008 8:40 pm
Posts: 61
Location: Tokoroa South Waikato New Zealand
Weather Station: Davis VP pro 2
Operating System: Win7
Um forgot
http://chh-p.dyndns.org/banner.php

_________________
http://tokoroa.dyndns.org/ Main Site

IT Fixer


Top
 Profile  
 
 Post subject: Re: Cumulus PHP-GD Banner
PostPosted: Sun Oct 05, 2008 8:03 am 
Offline
User avatar

Joined: Wed Sep 17, 2008 1:34 pm
Posts: 629
Location: Mesa, AZ USA
Weather Station: Davis VP2 Plus w/24 FARS
Operating System: WinX Pro SP3 Dedicated wstn
See Version 1.1... this article has been superseded...

The new version allows you to choose this option in the source code.

One big advantage is that you can use more fonts and more importantly, you can change the size of the same font bigger (the temp) and smaller. The TTF fonts are also clearer in output than the default fonts.

The only issues is that you need to have support for TTF (possible show stopper for some) and of course you need some TTF fonts available on the server (not a big deal).

I've seen some code that allows dealing with flush right, left, center etc.. that would make positioning better. Will play with that tomorrow. Need to add some color shifts based on values as well (around here if it is > 100F, the font gets red, below say 32F blue etc...

_________________
Kevin
Image
All you need is Time, Aptitude and Desire ... and you can build just about anything...
Cumulus User Maps


Last edited by TNETWeather on Sun Oct 05, 2008 6:30 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Cumulus PHP-GD Banner
PostPosted: Sun Oct 05, 2008 6:28 pm 
Offline
User avatar

Joined: Wed Sep 17, 2008 1:34 pm
Posts: 629
Location: Mesa, AZ USA
Weather Station: Davis VP2 Plus w/24 FARS
Operating System: WinX Pro SP3 Dedicated wstn
Version: 1.1

Updated version supports both TTF and Default GD fonts.

If you want to use TTF fonts, you need to set the following variables:

Code:
$SITE['fontdir']      = "fonts/";      # must contain ttf font files!
$SITE['usettf']         = "yes";      # Set to No to use default fonts

The fontdir needs to point to a directory that contains the Truetype fonts you want to use.

I simply copied over a number of fonts I use from time to time with JpGraph:
Code:
-rw-r--r--   1 root     root       16880 Oct  5 00:11 ARIALALS.TTF
-rw-r--r--   1 root     root       24264 Oct  5 00:11 ARIALALT.TTF
-rw-r--r--   1 root     root      288496 Oct  5 00:11 arialbd.ttf
-rw-r--r--   1 root     root      226748 Oct  5 00:11 arialbi.ttf
-rw-r--r--   1 root     root      207808 Oct  5 00:11 ariali.ttf
-rw-r--r--   1 root     root      138468 Oct  5 00:11 ARIALNBI.TTF
-rw-r--r--   1 root     root      139056 Oct  5 00:11 ARIALNB.TTF
-rw-r--r--   1 root     root      134188 Oct  5 00:11 ARIALN.TTF
-rw-r--r--   1 root     root      311636 Oct  5 00:11 arial.ttf
-rw-r--r--   1 root     root      132832 Oct  5 00:11 comic.ttf
-rw-r--r--   1 root     root       49788 Oct  5 00:11 STENCIL.TTF
-rw-r--r--   1 root     root      137616 Oct  5 00:11 verdanab.ttf
-rw-r--r--   1 root     root      155076 Oct  5 00:11 verdanai.ttf
-rw-r--r--   1 root     root      171792 Oct  5 00:11 verdana.ttf
-rw-r--r--   1 root     root      154800 Oct  5 00:11 verdanaz.ttf
-rw-r--r--   1 root     root       37812 Oct  5 00:11 WEATHER.TTF


Further down in the code, you can see where I setup of the use of $font1 $font2 and $font3 like:
Code:
// Path to our font file
$font1 = $SITE['fontdir'] . "arialbd.ttf";
$font2 = $SITE['fontdir'] . "arial.ttf";
$font3 = $SITE['fontdir'] . "verdana.ttf";


Also added logic that if there is no rain, to say No Rain Today instead of Rain 0.00xxx

The link to the source is the same...

Source Code:

TNET Cumulus Project Page

_________________
Kevin
Image
All you need is Time, Aptitude and Desire ... and you can build just about anything...
Cumulus User Maps


Top
 Profile  
 
 Post subject: Re: Cumulus PHP-GD Banner
PostPosted: Sun Oct 05, 2008 10:33 pm 
Offline

Joined: Thu Jun 26, 2008 5:51 am
Posts: 98
Location: Slov.Konjice, Slovenia
Weather Station: Davis VP2 + Solar
Operating System: Win2k SP4@VIA EPIA800
I guess script works in CLI mode ?

Im going to try it out when I get time, nice work TNETWeather Respect :mrgreen:

_________________
Image


Top
 Profile  
 
 Post subject: Re: Cumulus PHP-GD Banner
PostPosted: Sun Oct 05, 2008 11:11 pm 
Offline
User avatar

Joined: Wed Sep 17, 2008 1:34 pm
Posts: 629
Location: Mesa, AZ USA
Weather Station: Davis VP2 Plus w/24 FARS
Operating System: WinX Pro SP3 Dedicated wstn
You could use it in CLI mode.

One way out of the box would be to call the script like:

Code:
# path_to_php/php banner.php > banner.png


If you want to do that though, you should change the output commands and add a filename you want it saved as:

For example:

Code:
imagegif($im, "banner.gif");


Then when the script is called, instead of outputting the image data, it would save it to a file instead.

Code:
# path_to_php/php banner.php

_________________
Kevin
Image
All you need is Time, Aptitude and Desire ... and you can build just about anything...
Cumulus User Maps


Top
 Profile  
 
 Post subject: Re: Cumulus PHP-GD Banner
PostPosted: Sun Oct 05, 2008 11:34 pm 
Offline

Joined: Thu Jun 26, 2008 5:51 am
Posts: 98
Location: Slov.Konjice, Slovenia
Weather Station: Davis VP2 + Solar
Operating System: Win2k SP4@VIA EPIA800
Great! Got it working :D
Since im not that much in PHP coding what should i change so date will be shown as 06.10.08 instead of 08-10-06 :oops:

Thanks in advance!

EDIT: OK nevermind, i fixed it ;)

_________________
Image


Top
 Profile  
 
 Post subject: Re: Cumulus PHP-GD Banner
PostPosted: Mon Oct 06, 2008 7:41 am 
Offline
Site Admin
User avatar

Joined: Mon Jun 02, 2008 6:49 pm
Posts: 17835
Location: Sanday, Orkney
Weather Station: Davis VP2
Operating System: Windows Home Server 2011
These TTF ones are very smart, I'm going to change mine when I get a minute :)

_________________
Steve
Sanday Weather
----------------------------------------------------------------------------------------------------------------------------------
Like Cumulus and want to support it? Please donate! Image


Top
 Profile  
 
 Post subject: Re: Cumulus PHP-GD Banner
PostPosted: Wed Oct 08, 2008 10:03 am 
Offline
User avatar

Joined: Thu Jun 19, 2008 7:45 am
Posts: 281
Location: Brampton, Cumbria, UK
Weather Station: Davis VP2 with solar
Operating System: Windows XP SP3
Kevin

As you can see I use a similar banner at the moment, but would like to switch to the cumulus version. You will have to bare with me or is it bear never can remember. Are there some simple instructions on how to use it/alter it. I have mine installed but completley forgot how to do it - Are there any of those smaller avatars available aswell and last question can any of these banners/scripts etc be use as a footer or signature on an email using Miscrosoft Outlook.

eg of the avatar - http://www.bramptonweather.co.uk/wd/wxg ... ype=avatar

How about a cumulus rapid fire weather - likes wundergrounds but one created for cumulus users as a stand alone system ?

http://www.wunderground.com/swf/Rapid_F ... =ICUMBRIA1

I always have great ideas, but now a clue how to do carry them out

thanks :D

_________________
Paul C
Brampton, Cumbria, UK
117m ASL
http://www.bramptonweather.co.uk | http://www.bramptonweather.co.uk/cumulus |
Image


Top
 Profile  
 
 Post subject: Re: Cumulus PHP-GD Banner
PostPosted: Wed Oct 08, 2008 10:23 am 
Offline
User avatar

Joined: Wed Sep 17, 2008 1:34 pm
Posts: 629
Location: Mesa, AZ USA
Weather Station: Davis VP2 Plus w/24 FARS
Operating System: WinX Pro SP3 Dedicated wstn
Currently, the banner does just one banner output.

The banner you are currently using does have a lot of flexibility in it and in fact, I first hacked that script to make it work with Cumulus. However, the current realtime.txt is much less than what that script is capable of supporting so it was easier to just start over.

I have planned on either making the current script output multiple sized banners or simply creating a new script called... avatar.php. In fact, I almost started playing with that last night (its 3:19am here now), I am watching a server that paged me to see if it is okay.

As for using it, it is almost ready to work right out of the box er... download. It is assumed that you have PHP5 and have GD support included otherwise it won't work. You would need to adjust the information header information so that I knows about information that is not contained within the realtime.txt data file like station name, what unit values are used etc...
Code:
############################################################################
# CONFIGURATION INFORMATION
############################################################################
$SITE['version']        = "1.4";
$SITE['hloc']           = "./";
$SITE['datafile']       = "realtime.txt";
$SITE['fontdir']        = "fonts/";     # must contain ttf font files!
$SITE['usettf']         = "yes";         # Set to No to use default fonts
$SITE['format']         = "png";        # Options: jpeg  gif  png
$SITE['dateiso']        = "no";
$SITE['image_width']    = 468;
$SITE['image_height']   = 60;
$SITE['sitename']       = "Mesa AZ USA - TNET Weather";
$SITE['cumulusver']     = "1.8.2";
$SITE['tempunit']       = "°F";
$SITE['rainunit']       = "in";
$SITE['barounit']       = " mb";
$SITE['windunit']       = " mph";

For most, it doesn't appear to have been too hard to setup especially if you place it in the same directory that the realtime.txt file is located.

Changing the colors, sizes and position, does require some tweaking, but that part is not that dissimilar to the script you are already using.

I think that before I start either adding more formats or creating a new script to do that, I want to come up with some basic functions that make formatting a bit easier. Like the ability to specify flush right, left and center so that changing values remain positioned correctly. There are some functions out there that do that now, I just haven't given them a try yet.

As for your last request... I'm not a flash programmer... though I have started to dabble a bit. I would have a better shot at perhaps an AJAX based web page that does the same.

But before I start down that road, I want to finish the XML stuff as that would then provide a lot more data about the station than just what the realtime.txt file provides. And I currently upload the test XML file once a minute now.

Note that I'm not a big fan of rapid data uploads.... which primarily just show wind changes. I personally, don't have too much time to sit and watch my weather output for hours on end.

Having the XML data available to the banner script would greatly increase the data that could be displayed as well, such as current conditions, historical data like monthly, yearly rain, current cumulus version etc... data that is not contained in the realtime.txt file

I only have so much time to play though...

_________________
Kevin
Image
All you need is Time, Aptitude and Desire ... and you can build just about anything...
Cumulus User Maps


Top
 Profile  
 
 Post subject: Re: Cumulus PHP-GD Banner
PostPosted: Wed Oct 08, 2008 10:52 am 
Offline
User avatar

Joined: Thu Jun 19, 2008 7:45 am
Posts: 281
Location: Brampton, Cumbria, UK
Weather Station: Davis VP2 with solar
Operating System: Windows XP SP3
Thanks for the reply at 0315hrs !! If its any consolation I will be working until 2am tomorrow :D

I will give it a go over the next few days and let you know if I succeed.

I take it I keep using what I have already alongside the new cumulus one ?

cheers

_________________
Paul C
Brampton, Cumbria, UK
117m ASL
http://www.bramptonweather.co.uk | http://www.bramptonweather.co.uk/cumulus |
Image


Top
 Profile  
 
 Post subject: Re: Cumulus PHP-GD Banner
PostPosted: Wed Oct 08, 2008 10:58 am 
Offline
User avatar

Joined: Wed Sep 17, 2008 1:34 pm
Posts: 629
Location: Mesa, AZ USA
Weather Station: Davis VP2 Plus w/24 FARS
Operating System: WinX Pro SP3 Dedicated wstn
Paul C wrote:
I will give it a go over the next few days and let you know if I succeed.

I think you will find it is really easy to use. You should be able to put it on your server and run it without any changes and you will get output. You can then tweak it from there.
Quote:
I take it I keep using what I have already alongside the new cumulus one ?

There should not be any issues as to how many of these types of things you have on your server other than keeping track of which does which.

_________________
Kevin
Image
All you need is Time, Aptitude and Desire ... and you can build just about anything...
Cumulus User Maps


Top
 Profile  
 
 Post subject: Re: Cumulus PHP-GD Banner
PostPosted: Wed Oct 08, 2008 11:42 am 
Offline
Site Admin
User avatar

Joined: Mon Jun 02, 2008 6:49 pm
Posts: 17835
Location: Sanday, Orkney
Weather Station: Davis VP2
Operating System: Windows Home Server 2011
I've been meaning to ask you - I tried to use my banner on another forum, and it said php wasn't allowed for images. Is there a way around this?

_________________
Steve
Sanday Weather
----------------------------------------------------------------------------------------------------------------------------------
Like Cumulus and want to support it? Please donate! Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 299 posts ]  Go to page 1, 2, 3, 4, 5 ... 20  Next

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group