mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-28 11:01:59 +00:00
20_FRM_PWM.pm: new internal "resolution" (Forum #81815)
git-svn-id: https://svn.fhem.de/fhem/trunk@15929 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
a9cf0fbb70
commit
fb4f285e7d
@ -93,7 +93,11 @@ FRM_PWM_Init($$)
|
|||||||
return $ret if (defined $ret);
|
return $ret if (defined $ret);
|
||||||
my $firmata = $hash->{IODev}->{FirmataDevice};
|
my $firmata = $hash->{IODev}->{FirmataDevice};
|
||||||
my $name = $hash->{NAME};
|
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->{".max"} = defined $resolution ? (1<<$resolution)-1 : 255;
|
||||||
$hash->{".dim"} = 0;
|
$hash->{".dim"} = 0;
|
||||||
$hash->{".toggle"} = "off";
|
$hash->{".toggle"} = "off";
|
||||||
@ -332,59 +336,65 @@ FRM_PWM_Attr($$$$)
|
|||||||
<a name="FRM_PWM"></a>
|
<a name="FRM_PWM"></a>
|
||||||
<h3>FRM_PWM</h3>
|
<h3>FRM_PWM</h3>
|
||||||
<ul>
|
<ul>
|
||||||
represents a pin of an <a href="http://www.arduino.cc">Arduino</a> running <a href="http://www.firmata.org">Firmata</a>
|
This module represents a pin of a <a href="http://www.firmata.org">Firmata device</a>
|
||||||
configured for analog output.<br>
|
that should be configured as a pulse width modulated output (PWM).<br><br>
|
||||||
The value set will be output by the specified pin as a pulse-width-modulated signal.<br>
|
|
||||||
Requires a defined <a href="#FRM">FRM</a>-device to work.<br><br>
|
Requires a defined <a href="#FRM">FRM</a> device to work. The pin must be listed in the internal reading "<a href="#FRMinternals">pwm_pins</a>"<br>
|
||||||
|
of the FRM device (after connecting to the Firmata device) to be used as PWM output.<br><br>
|
||||||
|
|
||||||
<a name="FRM_PWMdefine"></a>
|
<a name="FRM_PWMdefine"></a>
|
||||||
<b>Define</b>
|
<b>Define</b>
|
||||||
<ul>
|
<ul>
|
||||||
<code>define <name> FRM_PWM <pin></code> <br>
|
<code>define <name> FRM_PWM <pin></code><br><br>
|
||||||
Defines the FRM_PWM device. <pin>> is the arduino-pin to use.
|
|
||||||
</ul>
|
Defines the FRM_PWM device. <pin>> is the arduino-pin to use.
|
||||||
|
</ul><br>
|
||||||
|
|
||||||
<br>
|
|
||||||
<a name="FRM_PWMset"></a>
|
<a name="FRM_PWMset"></a>
|
||||||
<b>Set</b><br>
|
<b>Set</b><br>
|
||||||
<ul>
|
<ul>
|
||||||
<code>set <name> on</code><br>
|
<li><code>set <name> on</code><br>
|
||||||
sets the pulse-width to 100%<br>
|
sets the pulse-width to 100%<br>
|
||||||
</ul>
|
</li>
|
||||||
<ul>
|
<li>
|
||||||
<code>set <name> off</code><br>
|
<code>set <name> off</code><br>
|
||||||
sets the pulse-width to 0%<br>
|
sets the pulse-width to 0%<br>
|
||||||
</ul>
|
</li>
|
||||||
<ul>
|
<li>
|
||||||
<a href="#setExtensions">set extensions</a> are supported<br>
|
<a href="#setExtensions">set extensions</a> are supported<br>
|
||||||
</ul>
|
</li>
|
||||||
<ul>
|
<li>
|
||||||
<code>set <name> toggle</code><br>
|
<code>set <name> toggle</code><br>
|
||||||
toggles the pulse-width in between to the last value set by 'value' or 'dim' and 0 respectivly 100%<br>
|
toggles the pulse-width in between to the last value set by 'value' or 'dim' and 0 respectivly 100%<br>
|
||||||
</ul>
|
</li>
|
||||||
<ul>
|
<li>
|
||||||
<code>set <name> value <value></code><br>
|
<code>set <name> value <value></code><br>
|
||||||
sets the pulse-width to the value specified<br>
|
sets the pulse-width to the value specified<br>
|
||||||
Range is from 0 to 255 (for 8-bit resolution) (see <a href="http://arduino.cc/en/Reference/AnalogWrite">analogWrite()</a> for details)<br>
|
The min value is zero and the max value depends on the Firmata device (see internal reading<br>
|
||||||
</ul>
|
"<a href="#FRMinternals">pwm_resolutions</a>" of the FRM device). For 8 bits resolution the range
|
||||||
<ul>
|
is 0 to 255 (also see <a href="http://arduino.cc/en/Reference/AnalogWrite">analogWrite()</a> for details)<br>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
<code>set <name> dim <value></code><br>
|
<code>set <name> dim <value></code><br>
|
||||||
sets the pulse-width to the value specified in percent<br>
|
sets the pulse-width to the value specified in percent<br>
|
||||||
Range is from 0 to 100<br>
|
Range is from 0 to 100<br>
|
||||||
</ul>
|
</li>
|
||||||
<ul>
|
<li>
|
||||||
<code>set <name> dimUp</code><br>
|
<code>set <name> dimUp</code><br>
|
||||||
increases the pulse-width by 10%<br>
|
increases the pulse-width by 10%<br>
|
||||||
</ul>
|
</li>
|
||||||
<ul>
|
<li>
|
||||||
<code>set <name> dimDown</code><br>
|
<code>set <name> dimDown</code><br>
|
||||||
decreases the pulse-width by 10%<br>
|
decreases the pulse-width by 10%<br>
|
||||||
</ul>
|
</li>
|
||||||
|
</ul><br>
|
||||||
|
|
||||||
<a name="FRM_PWMget"></a>
|
<a name="FRM_PWMget"></a>
|
||||||
<b>Get</b><br>
|
<b>Get</b><br>
|
||||||
<ul>
|
<ul>
|
||||||
N/A
|
N/A
|
||||||
</ul><br>
|
</ul><br>
|
||||||
|
|
||||||
<a name="FRM_PWMattr"></a>
|
<a name="FRM_PWMattr"></a>
|
||||||
<b>Attributes</b><br>
|
<b>Attributes</b><br>
|
||||||
<ul>
|
<ul>
|
||||||
@ -396,9 +406,17 @@ FRM_PWM_Attr($$$$)
|
|||||||
</li>
|
</li>
|
||||||
<li><a href="#eventMap">eventMap</a><br></li>
|
<li><a href="#eventMap">eventMap</a><br></li>
|
||||||
<li><a href="#readingFnAttributes">readingFnAttributes</a><br></li>
|
<li><a href="#readingFnAttributes">readingFnAttributes</a><br></li>
|
||||||
|
</ul><br>
|
||||||
|
|
||||||
|
<a name="FRM_PWMnotes"></a>
|
||||||
|
<b>Notes</b><br>
|
||||||
|
<ul>
|
||||||
|
<li>attribute <i>stateFormat</i><br>
|
||||||
|
In most cases it is a good idea to assign "value" to the attribute <i>stateFormat</i>. This will show the
|
||||||
|
current value of the pin in the web interface.
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</ul>
|
</ul><br>
|
||||||
<br>
|
|
||||||
|
|
||||||
=end html
|
=end html
|
||||||
=cut
|
=cut
|
||||||
|
Loading…
x
Reference in New Issue
Block a user