#NEWLINE# def __init__( self , num , c_order = ChannelOrder . GRB , use_py_spi = True , dev = '/dev/spidev0.0' , SPISpeed = 2 ) : #NEWLINE# #INDENT# super ( DriverSPIBase , self ) . __init__ ( dev , c_order = c_order ) #NEWLINE# self . dev = dev #NEWLINE# self . use_py_spi = use_py_spi #NEWLINE# self . _spiSpeed = SPISpeed #NEWLINE# if self . use_py_spi : #NEWLINE# #INDENT# ( a , b ) = ( ( - 1 ) , ( - 1 ) ) #NEWLINE# d = self . dev . replace ( '/dev/spidev' , '' ) #NEWLINE# s = d . split ( '.' ) #NEWLINE# if ( len ( s ) == 2 ) : #NEWLINE# #INDENT# a = int ( s [ 0 ] ) #NEWLINE# b = int ( s [ 1 ] ) #NEWLINE# #UNINDENT# if ( ( a < 0 ) or ( b < 0 ) ) : #NEWLINE# #INDENT# error = 'When using py-spidev, the given device must be in the format /dev/spidev*.*' #NEWLINE# log . error ( error ) #NEWLINE# raise ValueError ( error ) #NEWLINE# #UNINDENT# self . _bootstrapSPIDev ( ) #NEWLINE# import spidev #NEWLINE# self . spi = spidev . SpiDev ( ) #NEWLINE# self . spi . open ( a , b ) #NEWLINE# self . spi . max_speed_hz = int ( ( self . _spiSpeed * 1000000.0 ) ) #NEWLINE# log . info ( 'py-spidev speed @ %.1f MHz' , ( float ( self . spi . max_speed_hz ) / 1000000.0 ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . _buf = bytearray ( self . _buf ) #NEWLINE# self . spi = open ( self . dev , 'wb' )