diff --git a/FHEM/lib/Device/Firmata.pm b/FHEM/lib/Device/Firmata.pm index b3185daa9..5867ba89e 100644 --- a/FHEM/lib/Device/Firmata.pm +++ b/FHEM/lib/Device/Firmata.pm @@ -15,11 +15,11 @@ Device::Firmata - Perl interface to Firmata for the arduino platform. =head1 VERSION -Version 0.63 +Version 0.64 =cut -our $VERSION = '0.63'; +our $VERSION = '0.64'; our $DEBUG = 0; diff --git a/FHEM/lib/Device/Firmata/Changes b/FHEM/lib/Device/Firmata/Changes index 71f834ac2..ad310d6a2 100644 --- a/FHEM/lib/Device/Firmata/Changes +++ b/FHEM/lib/Device/Firmata/Changes @@ -1,59 +1,62 @@ -Revision history for Device-Firmata - -0.63 2016.03.19 - Jens Beyer - supported protocol version detection modified (Protocol) - -0.62 2016.02.22 - Jens Beyer - added software serial support (Platform, Protocol) - -0.61 2016.01.09 - Jens Beyer - added serial pin support (Platform, Protocol, Constants) - added protocol version query (Platform) - fixed messages_handle: REPORT_VERSION returns protocol version (Platform) - added method get_max_compatible_protocol_version (Protocol) - -0.60 2014.06.28 - Norbert Truchsess - Fixed formating of Firmata.pm as Windows line-endings break automatic install from CPAN - -0.59 2014.06.26 - Norbert Truchsess - Fix a bug in the parser incorrectly skipping single 0x30 bytes - -0.58 2014.06.26 - Yanick Champoux - cosmetic change to POD for CPAN - -0.57 2014.06.12 - Norbert Truchsess - Fixed building dist for cpan - -0.56 2014.06.04 - Norbert Truchsess - add generic method sysex_send to Platform.pl - -0.55 2014.04.17 - Norbert Truchsess - fix digital-input message interference with output pins on same port - -0.54 2014.03.04 - Norbert Truchsess - add stepper-motor protocol - -0.53 2014.03.03 - Norbert Truchsess - add rotary-encoder protocol - -0.52 2013.11.22 - Norbert Truchsess - add Firmata over Ethernet - -0.51 2013.09.10/23:00 - Brett Carroll - Changed IO.pm to use Win32::SerialPort instead of Win32::Serialport on Windows platforms - Norbert Truchsess: fix handle onewire in capability-response - -0.50 2012.12.13-2013.08.11 - Norbert Truchsess - adding all missing protocol-features (1-Wire, I2C, Servo ...) - adding observers for all suitable protocols - - Valdas Kondrotas: various bugfixes and enhancements. - - 2011.03.23 - Chris Fedde - reorganizing as CPAN ready module - - 2011.02.16 Aki Mimoto - implementig all protocol basics and releasing Device::Firmata on Github - - 2010.08.31 Aki Mimoto +Revision history for Device-Firmata + +0.64 2018.01.03 - Jens Beyer + support Firmata protocol version 2.5 feature PIN_PULLUP (Constants, Platform, Protocol) + +0.63 2016.03.19 - Jens Beyer + supported protocol version detection modified (Protocol) + +0.62 2016.02.22 - Jens Beyer + added software serial support (Platform, Protocol) + +0.61 2016.01.09 - Jens Beyer + added serial pin support (Platform, Protocol, Constants) + added protocol version query (Platform) + fixed messages_handle: REPORT_VERSION returns protocol version (Platform) + added method get_max_compatible_protocol_version (Protocol) + +0.60 2014.06.28 - Norbert Truchsess + Fixed formating of Firmata.pm as Windows line-endings break automatic install from CPAN + +0.59 2014.06.26 - Norbert Truchsess + Fix a bug in the parser incorrectly skipping single 0x30 bytes + +0.58 2014.06.26 - Yanick Champoux + cosmetic change to POD for CPAN + +0.57 2014.06.12 - Norbert Truchsess + Fixed building dist for cpan + +0.56 2014.06.04 - Norbert Truchsess + add generic method sysex_send to Platform.pl + +0.55 2014.04.17 - Norbert Truchsess + fix digital-input message interference with output pins on same port + +0.54 2014.03.04 - Norbert Truchsess + add stepper-motor protocol + +0.53 2014.03.03 - Norbert Truchsess + add rotary-encoder protocol + +0.52 2013.11.22 - Norbert Truchsess + add Firmata over Ethernet + +0.51 2013.09.10/23:00 - Brett Carroll + Changed IO.pm to use Win32::SerialPort instead of Win32::Serialport on Windows platforms + Norbert Truchsess: fix handle onewire in capability-response + +0.50 2012.12.13-2013.08.11 - Norbert Truchsess + adding all missing protocol-features (1-Wire, I2C, Servo ...) + adding observers for all suitable protocols + + Valdas Kondrotas: various bugfixes and enhancements. + + 2011.03.23 - Chris Fedde + reorganizing as CPAN ready module + + 2011.02.16 Aki Mimoto + implementig all protocol basics and releasing Device::Firmata on Github + + 2010.08.31 Aki Mimoto start of development \ No newline at end of file diff --git a/FHEM/lib/Device/Firmata/Constants.pm b/FHEM/lib/Device/Firmata/Constants.pm index f2e01082f..beabbfdab 100644 --- a/FHEM/lib/Device/Firmata/Constants.pm +++ b/FHEM/lib/Device/Firmata/Constants.pm @@ -30,6 +30,7 @@ use constant ( PIN_STEPPER => 8, PIN_ENCODER => 9, PIN_SERIAL => 10, + PIN_PULLUP => 11, PIN_LOW => 0, PIN_HIGH => 1, } @@ -295,6 +296,7 @@ use constant ( ONEWIRE => 0x07, # pin configured for 1-Wire commuication STEPPER => 0x08, # pin configured for stepper motor SERIAL => 0x0A, # pin configured for serial port + PULLUP => 0x0B, # digital pin in digitalInput mode with pullup # Deprecated entries deprecated => [ @@ -355,6 +357,7 @@ use constant ( STEPPER => 0x08, # pin configured for stepper motor ENCODER => 0x09, # pin configured for rotary-encoders SERIAL => 0x0A, # pin configured for serial port + PULLUP => 0x0B, # digital pin in digitalInput mode with pullup # Deprecated entries deprecated => [ diff --git a/FHEM/lib/Device/Firmata/Platform.pm b/FHEM/lib/Device/Firmata/Platform.pm index 2e205fb60..0ed53ffc9 100644 --- a/FHEM/lib/Device/Firmata/Platform.pm +++ b/FHEM/lib/Device/Firmata/Platform.pm @@ -256,6 +256,7 @@ sub sysex_handle { my @stepperpins; my @encoderpins; my @serialpins; + my @pulluppins; foreach my $pin (keys %$capabilities) { if (defined $capabilities->{$pin}) { @@ -298,6 +299,9 @@ sub sysex_handle { push @serialpins, $pin; $self->{metadata}{serial_resolutions}{$pin} = $capabilities->{$pin}->{PIN_SERIAL+0}->{resolution}; } + if ($capabilities->{$pin}->{PIN_PULLUP+0}) { + push @pulluppins, $pin; + } } } $self->{metadata}{input_pins} = \@inputpins; @@ -311,6 +315,7 @@ sub sysex_handle { $self->{metadata}{stepper_pins} = \@stepperpins; $self->{metadata}{encoder_pins} = \@encoderpins; $self->{metadata}{serial_pins} = \@serialpins; + $self->{metadata}{pullup_pins} = \@pulluppins; last; }; @@ -455,7 +460,7 @@ sub pin_mode { PIN_MODE_HANDLER: { - ( $mode == PIN_INPUT ) and do { + ( $mode == PIN_INPUT or $mode == PIN_PULLUP ) and do { my $port_number = $pin >> 3; $self->{io}->data_write($self->{protocol}->message_prepare( SET_PIN_MODE => 0, $pin, $mode )); $self->{io}->data_write($self->{protocol}->message_prepare( REPORT_DIGITAL => $port_number, 1 )); @@ -479,13 +484,17 @@ sub pin_mode { Analogous to the digitalWrite function on the arduino +Deprecation Warning: +Writing to pin with mode "INPUT" is only supported for backward compatibility +to switch pullup on and off. Use sub pin_mode with $mode=PIN_PULLUP instead. + =cut sub digital_write { # -------------------------------------------------- my ( $self, $pin, $state ) = @_; - die "pin '".$pin."' is not configured for mode 'INPUT' or 'OUTPUT'" unless ($self->is_configured_mode($pin,PIN_OUTPUT) or $self->is_configured_mode($pin,PIN_INPUT)); + die "pin '".$pin."' is not configured for mode 'INPUT', 'PULLUP' or 'OUTPUT'" unless ($self->is_configured_mode($pin,PIN_OUTPUT) or $self->is_configured_mode($pin,PIN_INPUT) or $self->is_configured_mode($pin,PIN_PULLUP)); my $port_number = $pin >> 3; my $pin_offset = $pin % 8; @@ -514,7 +523,7 @@ sub digital_read { # -------------------------------------------------- my ( $self, $pin ) = @_; - die "pin '".$pin."' is not configured for mode 'INPUT'" unless $self->is_configured_mode($pin,PIN_INPUT); + die "pin '".$pin."' is not configured for mode 'INPUT' or 'PULLUP'" unless ($self->is_configured_mode($pin,PIN_INPUT) or $self->is_configured_mode($pin,PIN_PULLUP)); my $port_number = $pin >> 3; my $pin_offset = $pin % 8; my $pin_mask = 1 << $pin_offset; diff --git a/FHEM/lib/Device/Firmata/Protocol.pm b/FHEM/lib/Device/Firmata/Protocol.pm index 6ab4814ce..21803ead3 100644 --- a/FHEM/lib/Device/Firmata/Protocol.pm +++ b/FHEM/lib/Device/Firmata/Protocol.pm @@ -114,6 +114,7 @@ our $MODENAMES = { 8 => 'STEPPER', 9 => 'ENCODER', 10 => 'SERIAL', + 11 => 'PULLUP', }; =head1 DESCRIPTION