diff --git a/fhem/CHANGED b/fhem/CHANGED index 58353766a..09b02a597 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,10 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - feature: 20_FRM_PWM: new attribute "restoreOnStartup" + - feature: 20_FRM_OUT: new attributes "activeLow" and "valueMode" + - feature: 10_FRM: SerialFirmata support + - update: 10_FRM: OWX IODev assignment + - update: 10_FRM: Firmata 2.7+ support - bugfix: 98_weekprofile: fix "error restore topic" - change: 14_CUL_TCM97001: Fix Logoutput, Fix device output with multiple sensors diff --git a/fhem/FHEM/20_FRM_PWM.pm b/fhem/FHEM/20_FRM_PWM.pm index a7f3bd985..f20a31183 100755 --- a/fhem/FHEM/20_FRM_PWM.pm +++ b/fhem/FHEM/20_FRM_PWM.pm @@ -1,6 +1,37 @@ -############################################## +######################################################################################## +# # $Id$ -############################################## +# +# FHEM module for one Firmata PWM output pin +# +######################################################################################## +# +# LICENSE AND COPYRIGHT +# +# Copyright (C) 2013 ntruchess +# Copyright (C) 2016 jensb +# +# All rights reserved +# +# This script is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# The GNU General Public License can be found at +# http://www.gnu.org/copyleft/gpl.html. +# A copy is found in the textfile GPL.txt and important notices to the license +# from the author is found in LICENSE.txt distributed with these scripts. +# +# This script is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# This copyright notice MUST APPEAR in all copies of the script! +# +######################################################################################## + package main; use strict; @@ -71,7 +102,7 @@ FRM_PWM_Init($$) } my $value = ReadingsVal($name,"value",undef); if (defined $value and AttrVal($hash->{NAME},"restoreOnReconnect","on") eq "on") { - FRM_PWM_Set($hash,$name,$value); + FRM_PWM_Set($hash,$name,"value",$value); } main::readingsSingleUpdate($hash,"state","Initialized",1); return undef; @@ -239,9 +270,21 @@ sub FRM_PWM_State($$$$) { my ($hash, $tim, $sname, $sval) = @_; + my $name = $hash->{NAME}; if ($sname eq "value") { - FRM_PWM_Set($hash,$hash->{NAME},$sname,$sval); + # depending on the FHEM startup timing and the Arduino connection type, FHEM statefile restore and Arduino connect take place in arbitrary order + if (AttrVal($name, "restoreOnStartup", "on") eq "on") { + $hash->{READINGS}{$sname}{VAL} = $sval; + $hash->{READINGS}{$sname}{TIME} = $tim; + if (defined($hash->{IODev}) && defined($hash->{IODev}->{FirmataDevice} && $hash->{IODev}->{FirmataDevice}->{state} eq "Initialized")) { + FRM_PWM_Set($hash, $name, "value", $sval); + } + } else { + $hash->{READINGS}{$sname}{VAL} = undef; + $hash->{READINGS}{$sname}{TIME} = gettimeofday(); + } } + return 0; # default processing by fhem.pl } sub @@ -272,6 +315,18 @@ FRM_PWM_Attr($$$$) 1; =pod + + CHANGES + + 2016 jensb + o modified subs FRM_PWM_Init and FRM_PWM_State to support attribute "restoreOnStartup" + +=cut + +=pod +=item device +=item summary Firmata: PWM output +=item summary_DE Firmata: PWM Ausgang =begin html diff --git a/fhem/MAINTAINER.txt b/fhem/MAINTAINER.txt index daf9915c7..9d182dbc6 100644 --- a/fhem/MAINTAINER.txt +++ b/fhem/MAINTAINER.txt @@ -106,7 +106,7 @@ FHEM/20_FRM_I2C.pm ntruchsess Sonstige Systeme FHEM/20_FRM_IN.pm ntruchsess Sonstige Systeme FHEM/20_FRM_LCD.pm ntruchsess Sonstige Systeme (deprecated) FHEM/20_FRM_OUT.pm jensb Sonstige Systeme -FHEM/20_FRM_PWM.pm ntruchsess Sonstige Systeme +FHEM/20_FRM_PWM.pm jensb Sonstige Systeme FHEM/20_FRM_RBG.pm ntruchsess Sonstige Systeme FHEM/20_FRM_SERVO.pm ntruchsess Sonstige Systeme FHEM/20_FRM_STEPPER.pm ntruchsess Sonstige Systeme