mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-16 10:46:03 +00:00
FRM_LCD: add writeXY as implemented by Wzut
git-svn-id: https://svn.fhem.de/fhem/trunk@5061 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
f3d5b60ea1
commit
7666c81cf6
@ -19,12 +19,15 @@ use Device::Firmata::Constants qw/ :all /;
|
|||||||
|
|
||||||
my %sets = (
|
my %sets = (
|
||||||
"text" => "",
|
"text" => "",
|
||||||
"home" => "",
|
"home" => "noArg",
|
||||||
"clear" => "",
|
"clear" => "noArg",
|
||||||
"display" => "on,off",
|
"display" => "on,off",
|
||||||
"cursor" => "",
|
"cursor" => "",
|
||||||
"scroll" => "left,right",
|
"scroll" => "left,right",
|
||||||
);
|
"backlight" => "on,off",
|
||||||
|
"reset" => "noArg",
|
||||||
|
"writeXY" => ""
|
||||||
|
);
|
||||||
|
|
||||||
my %gets = (
|
my %gets = (
|
||||||
);
|
);
|
||||||
@ -151,12 +154,20 @@ sub FRM_LCD_Set(@) {
|
|||||||
return "Need at least one parameters" if(@a < 2);
|
return "Need at least one parameters" if(@a < 2);
|
||||||
my $command = $a[1];
|
my $command = $a[1];
|
||||||
my $value = $a[2];
|
my $value = $a[2];
|
||||||
return "Unknown argument $a[1], choose one of " . join(" ", sort keys %sets)
|
if(!defined($sets{$command})) {
|
||||||
if(!defined($sets{$command}));
|
my @commands = ();
|
||||||
|
foreach my $key (sort keys %sets) {
|
||||||
|
push @commands, $sets{$key} ? $key.":".join(",",$sets{$key}) : $key;
|
||||||
|
}
|
||||||
|
return "Unknown argument $a[1], choose one of " . join(" ", @commands);
|
||||||
|
}
|
||||||
my $lcd = $hash->{lcd};
|
my $lcd = $hash->{lcd};
|
||||||
return unless defined $lcd;
|
return unless defined $lcd;
|
||||||
COMMAND_HANDLER: {
|
COMMAND_HANDLER: {
|
||||||
$command eq "text" and do {
|
$command eq "text" and do {
|
||||||
|
shift @a;
|
||||||
|
shift @a;
|
||||||
|
$value = join(" ", @a);
|
||||||
if (AttrVal($hash->{NAME},"autoClear","on") eq "on") {
|
if (AttrVal($hash->{NAME},"autoClear","on") eq "on") {
|
||||||
$lcd->clear();
|
$lcd->clear();
|
||||||
}
|
}
|
||||||
@ -184,6 +195,11 @@ sub FRM_LCD_Set(@) {
|
|||||||
$lcd->home();
|
$lcd->home();
|
||||||
last;
|
last;
|
||||||
};
|
};
|
||||||
|
$command eq "reset" and do {
|
||||||
|
$lcd->init();
|
||||||
|
# $hash->{lcd} = $lcd;
|
||||||
|
last;
|
||||||
|
};
|
||||||
$command eq "clear" and do {
|
$command eq "clear" and do {
|
||||||
$lcd->clear();
|
$lcd->clear();
|
||||||
main::readingsSingleUpdate($hash,"text","",1);
|
main::readingsSingleUpdate($hash,"text","",1);
|
||||||
@ -210,6 +226,37 @@ sub FRM_LCD_Set(@) {
|
|||||||
}
|
}
|
||||||
last;
|
last;
|
||||||
};
|
};
|
||||||
|
$command eq "backlight" and do {
|
||||||
|
if ($value eq "on") {
|
||||||
|
$lcd->backlight();
|
||||||
|
} else {
|
||||||
|
$lcd->noBacklight();
|
||||||
|
}
|
||||||
|
last;
|
||||||
|
};
|
||||||
|
$command eq "writeXY" and do {
|
||||||
|
my ($x,$y,$l,$al) = split(",",$value);
|
||||||
|
$lcd->setCursor($x,$y);
|
||||||
|
shift @a; shift @a; shift @a;
|
||||||
|
my $t = join(" ", @a);
|
||||||
|
my %umlaute = ("ä" => "ae", "Ä" => "Ae", "ü" => "ue", "Ü" => "Ue", "ö" => "oe", "Ö" => "Oe", "ß" => "ss" ," - " => " " ,"©"=>"@");
|
||||||
|
my $umlautkeys = join ("|", keys(%umlaute));
|
||||||
|
$t =~ s/($umlautkeys)/$umlaute{$1}/g;
|
||||||
|
my $sl = length $t;
|
||||||
|
if ($sl > $l) {
|
||||||
|
$t = substr($t,0,$l);
|
||||||
|
}
|
||||||
|
if ($sl < $l) {
|
||||||
|
my $dif = "";
|
||||||
|
for (my $i=$sl; $i<$l; $i++) {
|
||||||
|
$dif .= " ";
|
||||||
|
}
|
||||||
|
$t = ($al eq "l") ? $t.$dif : $dif.$t;
|
||||||
|
}
|
||||||
|
$lcd->print($t);
|
||||||
|
readingsSingleUpdate($hash,"state",$t,1);
|
||||||
|
last; #"X=$x|Y=$y|L=$l|Text=$t";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,8 +306,17 @@ STATEHANDLER: {
|
|||||||
<a name="FRM_LCDset"></a>
|
<a name="FRM_LCDset"></a>
|
||||||
<b>Set</b><br>
|
<b>Set</b><br>
|
||||||
<ul>
|
<ul>
|
||||||
<code>set <name> text <text to be displayed></code><br>
|
<li><code>set <name> text <text to be displayed></code><br></li>
|
||||||
|
<li><code>set <name> home</code><br></li>
|
||||||
|
<li><code>set <name> clear</code><br></li>
|
||||||
|
<li><code>set <name> display on|off</code><br></li>
|
||||||
|
<li><code>set <name> cursor <...></code><br></li>
|
||||||
|
<li><code>set <name> scroll left|right</code><br></li>
|
||||||
|
<li><code>set <name> backlight on|off</code><br></li>
|
||||||
|
<li><code>set <name> reset</code><br></li>
|
||||||
|
<li><code>set <name> writeXY x-pos,y-pos,len[,l] <text to be displayed></code><br></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<a name="FRM_I2Cget"></a>
|
<a name="FRM_I2Cget"></a>
|
||||||
<b>Get</b><br>
|
<b>Get</b><br>
|
||||||
<ul>
|
<ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user