mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-14 21:49:12 +00:00
added GIF to layout items in 02_RSS.pm
git-svn-id: https://svn.fhem.de/fhem/trunk@1403 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
90788c72ca
commit
70d63ed168
@ -21,6 +21,7 @@
|
||||
- feature: remove dependency on Google::Weather, major rewrite (Boris)
|
||||
- feature: started experimental interface implementation (fhem API v2) (Boris)
|
||||
- feature: sleep issued in at/notify/etc is not blocking fhem anymore
|
||||
- feature: new module 02_RSS.pm
|
||||
|
||||
|
||||
- 2011-12-31 (5.2)
|
||||
|
@ -197,6 +197,14 @@ RSS_returnRSS($) {
|
||||
# Library
|
||||
##################
|
||||
|
||||
sub
|
||||
RSS_xy($$$) {
|
||||
my ($S,$x,$y)= @_;
|
||||
if($x<1) { $x*= $S->width; }
|
||||
if($y<1) { $y*= $S->height; }
|
||||
return($x,$y);
|
||||
}
|
||||
|
||||
sub
|
||||
RSS_color {
|
||||
my ($S,$rgb)= @_;
|
||||
@ -207,8 +215,7 @@ RSS_color {
|
||||
sub
|
||||
RSS_itemText {
|
||||
my ($S,$x,$y,$text,%params)= @_;
|
||||
if($x<1) { $x*= $S->width; }
|
||||
if($y<1) { $y*= $S->height; }
|
||||
($x,$y)= RSS_xy($S,$x,$y);
|
||||
$S->stringFT(RSS_color($S,$params{rgb}),$params{font},$params{pt},0,$x,$y,$text);
|
||||
}
|
||||
|
||||
@ -219,6 +226,20 @@ RSS_itemTime {
|
||||
RSS_itemText($S,$x,$y,sprintf("%02d:%02d", $hour, $min),%params);
|
||||
}
|
||||
|
||||
sub
|
||||
RSS_itemGif {
|
||||
my ($S,$x,$y,$host,$filename,%params)= @_;
|
||||
return if($host eq "");
|
||||
return if($filename eq "");
|
||||
($x,$y)= RSS_xy($S,$x,$y);
|
||||
my $data = GetHttpFile($host,$filename);
|
||||
return unless(defined($data));
|
||||
my $I= GD::Image->newFromGifData($data);
|
||||
my ($width,$height)= $I->getBounds();
|
||||
Log 5, "RSS placing $host$filename ($width x $height) at ($x,$y)";
|
||||
$S->copy($I,$x,$y,0,0,$width,$height);
|
||||
}
|
||||
|
||||
|
||||
##################
|
||||
sub
|
||||
@ -232,7 +253,7 @@ RSS_evalLayout($$@) {
|
||||
$params{pt}= 12;
|
||||
$params{rgb}= "ffffff";
|
||||
|
||||
my ($x,$y, $text);
|
||||
my ($x,$y,$text,$host,$filename);
|
||||
|
||||
my $cont= "";
|
||||
foreach my $line (@layout) {
|
||||
@ -263,6 +284,10 @@ RSS_evalLayout($$@) {
|
||||
} elsif($cmd eq "time") {
|
||||
($x,$y)= split("[ \t]+", $def, 2);
|
||||
RSS_itemTime($S,$x,$y,%params);
|
||||
} elsif($cmd eq "gif") {
|
||||
($x,$y,$host,$filename)= split("[ \t]+", $def,4);
|
||||
my $fn= AnalyzePerlCommand(undef, $filename);
|
||||
RSS_itemGif($S,$x,$y,$host,$fn,%params);
|
||||
} else {
|
||||
Log 1, "$name: Illegal command $cmd in layout definition.";
|
||||
}
|
||||
|
@ -5209,7 +5209,8 @@ Attributes:<br>
|
||||
<i>Layout control commands</i>
|
||||
<ul>
|
||||
<li>font <font><br>Sets the font. <font> is the name of a TrueType font (e.g.
|
||||
<code>Arial</code>) or the full path to a TrueType font (e.g. <code>/usr/share/fonts/truetype/arial.ttf</code>),
|
||||
<code>Arial</code>) or the full path to a TrueType font
|
||||
(e.g. <code>/usr/share/fonts/truetype/arial.ttf</code>),
|
||||
whatever works on your system.</li><br>
|
||||
|
||||
<li>rgb <color><br>Sets the color. <color> is a 6-digit hex number, every 2 digits
|
||||
@ -5230,6 +5231,10 @@ Attributes:<br>
|
||||
access device readings and do some programming on the fly. See below for examples.</li><br>
|
||||
|
||||
<li>time <x> <y><br>Renders the current time in HH:MM format.</li><br>
|
||||
<li>gif <x> <y> <hostname> <filename> <br>Renders the GIF picture
|
||||
that is downloaded from the given host. You can use
|
||||
<code>{ <a href="#perl"><perl special></a> }</code> for <filename>. See below for example.</li><br>
|
||||
</li><br>
|
||||
</ul>
|
||||
|
||||
This is how a layout definition might look like:<p>
|
||||
@ -5240,6 +5245,7 @@ Attributes:<br>
|
||||
time 0.10 0.90<br>
|
||||
pt 24<br>
|
||||
text 0.10 0.95 { ReadingsVal("MyWeather","temperature","?"). "°C" }<br>
|
||||
gif 20 530 www.google.com:80 { ReadingsVal("e.ext.Weather","icon","") }<br>
|
||||
</code>
|
||||
|
||||
</ul>
|
||||
|
Loading…
x
Reference in New Issue
Block a user