#NEWLINE# def i2cReg( self , wr , addr = 0 , data = 0 ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# if ( wr == 'w' ) : #NEWLINE# #INDENT# tmp = ( ( ( wr & 255 ) << 8 ) | ( ( data & 65280 ) >> 8 ) ) #NEWLINE# return bus . write_word_data ( self . I2C_ADDR , addr , tmp ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( wr == 'r' ) : #NEWLINE# #INDENT# tmp = bus . read_word_data ( self . I2C_ADDR , addr ) #NEWLINE# tmp = ( ( ( tmp & 255 ) << 8 ) | ( ( tmp & 65280 ) >> 8 ) ) #NEWLINE# return tmp #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( - 1 ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except IOError as err : #NEWLINE# #INDENT# print ( 'No ACK!' ) #NEWLINE# time . sleep ( 0.1 ) #NEWLINE# self . i2cReg ( wr , addr , data )