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


+ Set
- - - - - - - +
  • 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
    + +
    =end html =cut