############################################# package main; use strict; use warnings; use Device::Firmata; use Device::Firmata::Constants qw/ :all /; ##################################### sub FRM_I2C_Initialize($) { my ($hash) = @_; $hash->{DefFn} = "FRM_Client_Define"; $hash->{InitFn} = "FRM_I2C_Init"; $hash->{UndefFn} = "FRM_I2C_Undef"; $hash->{AttrFn} = "FRM_I2C_Attr"; $hash->{AttrList} = "IODev loglevel:0,1,2,3,4,5 $main::readingFnAttributes"; } sub FRM_I2C_Init($) { my ($hash,$args) = @_; my $u = "wrong syntax: define FRM_I2C address register numbytes"; return $u if(int(@$args) < 5); $hash->{"i2c-address"} = @$args[2]; $hash->{"i2c-register"} = @$args[3]; $hash->{"i2c-bytestoread"} = @$args[4]; if (defined $hash->{IODev}) { my $firmata = $hash->{IODev}->{FirmataDevice}; if (defined $firmata) { $firmata->i2c_read(@$args[2],@$args[3],@$args[4]); } return undef; } return 1; } sub FRM_I2C_Attr(@) { my ($command,$name,$attribute,$value) = @_; my $hash = $main::defs{$name}; if ($command eq "set") { $main::attr{$name}{$attribute}=$value; } } sub FRM_I2C_Undef($$) { my ($hash, $name) = @_; } 1; =pod =begin html

FRM_I2C


=end html =cut