From fb4f285e7dd09d94c238a181587bf23ea8ab4b9f Mon Sep 17 00:00:00 2001
From: jensb <>
Date: Fri, 19 Jan 2018 21:11:06 +0000
Subject: [PATCH] 20_FRM_PWM.pm: new internal "resolution" (Forum #81815)
git-svn-id: https://svn.fhem.de/fhem/trunk@15929 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/FHEM/20_FRM_PWM.pm | 108 +++++++++++++++++++++++-----------------
1 file changed, 63 insertions(+), 45 deletions(-)
diff --git a/fhem/FHEM/20_FRM_PWM.pm b/fhem/FHEM/20_FRM_PWM.pm
index f20a31183..137664fc4 100755
--- a/fhem/FHEM/20_FRM_PWM.pm
+++ b/fhem/FHEM/20_FRM_PWM.pm
@@ -93,7 +93,11 @@ FRM_PWM_Init($$)
return $ret if (defined $ret);
my $firmata = $hash->{IODev}->{FirmataDevice};
my $name = $hash->{NAME};
- my $resolution = $firmata->{metadata}{pwm_resolutions}{$hash->{PIN}} if (defined $firmata->{metadata}{pwm_resolutions});
+ my $resolution = 8;
+ if (defined $firmata->{metadata}{pwm_resolutions}) {
+ $resolution = $firmata->{metadata}{pwm_resolutions}{$hash->{PIN}}
+ }
+ $hash->{resolution} = $resolution;
$hash->{".max"} = defined $resolution ? (1<<$resolution)-1 : 255;
$hash->{".dim"} = 0;
$hash->{".toggle"} = "off";
@@ -332,59 +336,65 @@ FRM_PWM_Attr($$$$)
FRM_PWM
- represents a pin of an Arduino running Firmata
- configured for analog output.
- The value set will be output by the specified pin as a pulse-width-modulated signal.
- Requires a defined FRM-device to work.
+ This module represents a pin of a Firmata device
+ that should be configured as a pulse width modulated output (PWM).
+
+ Requires a defined FRM device to work. The pin must be listed in the internal reading "pwm_pins"
+ of the FRM device (after connecting to the Firmata device) to be used as PWM output.
Define
- define <name> FRM_PWM <pin>
- Defines the FRM_PWM device. <pin>> is the arduino-pin to use.
-
-
-
+ define <name> FRM_PWM <pin>
+
+ Defines the FRM_PWM device. <pin>> is the arduino-pin to use.
+
+
Set
- set <name> on
- sets the pulse-width to 100%
-
-
- set <name> off
- sets the pulse-width to 0%
-
-
-
- set <name> toggle
- toggles the pulse-width in between to the last value set by 'value' or 'dim' and 0 respectivly 100%
-
-
- set <name> value <value>
- sets the pulse-width to the value specified
- Range is from 0 to 255 (for 8-bit resolution) (see analogWrite() for details)
-
-
- set <name> dim <value>
- sets the pulse-width to the value specified in percent
- Range is from 0 to 100
-
-
- set <name> dimUp
- increases the pulse-width by 10%
-
-
- set <name> dimDown
- decreases the pulse-width by 10%
-
+ set <name> on
+ sets the pulse-width to 100%
+
+
+ set <name> off
+ sets the pulse-width to 0%
+
+
+ set extensions are supported
+
+
+ set <name> toggle
+ toggles the pulse-width in between to the last value set by 'value' or 'dim' and 0 respectivly 100%
+
+
+ set <name> value <value>
+ sets the pulse-width to the value specified
+ The min value is zero and the max value depends on the Firmata device (see internal reading
+ "pwm_resolutions" of the FRM device). For 8 bits resolution the range
+ is 0 to 255 (also see analogWrite() for details)
+
+
+ set <name> dim <value>
+ sets the pulse-width to the value specified in percent
+ Range is from 0 to 100
+
+
+ set <name> dimUp
+ increases the pulse-width by 10%
+
+
+ set <name> dimDown
+ decreases the pulse-width by 10%
+
+
+
Get
+
Attributes
-
-
+
+
+
+ Notes
+
+ - attribute stateFormat
+ In most cases it is a good idea to assign "value" to the attribute stateFormat. This will show the
+ current value of the pin in the web interface.
+
+
+
=end html
=cut