anilvadnala
New Member
Hi frens,
Here I am writing a python program with not knowing some instructions so I hope you would help me.
Here "handle" is constant and aa is stand for "ardwark adaptor"I have to understand /, %d, q\n,
aa_i2c_write(handle,DEVICE,0,array('B',[CTRL_REGB, 0])) syntaxs
Here I am writing a python program with not knowing some instructions so I hope you would help me.
Here "handle" is constant and aa is stand for "ardwark adaptor"I have to understand /, %d, q\n,
aa_i2c_write(handle,DEVICE,0,array('B',[CTRL_REGB, 0])) syntaxs
Code:
[\code]
# Set the bitrate
bitrate = aa_i2c_bitrate(handle, bitrate)
print "Bitrate set to %d kHz" % bitrate
# Configure the device
aa_i2c_write(handle,DEVICE,0,array('B',[CTRL_REGC, 0]))
aa_i2c_write(handle,DEVICE,0,array('B',[CTRL_REGB, 0]))
aa_i2c_write(handle,DEVICE,0,array('B',[CTRL_REGB, FFIen | MOTIen]))
aa_i2c_write(handle,DEVICE,0,array('B',[FF_DELAY, FF_Delay]))
aa_i2c_write(handle,DEVICE,0,array('B',[MOT_DELAY, MOT_Delay]))
aa_i2c_write(handle,DEVICE,0,array('B',[FF_INT, int(FF_Threshold)]))
aa_i2c_write(handle,DEVICE,0,array('B',[MOT_INT, int(MOT_Threshold)]))
print "Ready..."
while (1):
aa_i2c_write(handle,DEVICE,0,array('B',[CTRL_REGA]))
(ret, data, count) = aa_i2c_read_ext(handle,DEVICE,0,1)
if len(data) < 1:
sys.stdout.write("SENSOR READ ERROR. Park drive head.\n(Press Enter to resume
sampling or Q followed by Enter to quit.) ")
userinput = sys.stdin.readline()
if (userinput == "q\n" or userinput == "Q\n"):
aa_close(handle)
sys.exit()
elif data[0] & FFI:
sys.stdout.write("Freefall started. Park drive head.\n(Press Enter to resume
sampling or Q followed by Enter to quit.) ")
userinput = sys.stdin.readline()
if (userinput == "q\n" or userinput == "Q\n"):
aa_close(handle)
sys.exit()
aa_i2c_write(handle,DEVICE,0,array('B',[CTRL_REGB, 0]))
aa_i2c_write(handle,DEVICE,0,array('B',[CTRL_REGB, FFIen | MOTIen]))
elif data[0] & MOTI:
sys.stdout.write("High-g motion detected. Park drive head.\n(Press Enter to
resume sampling or Q followed by Enter to quit.) ")
userinput = sys.stdin.readline()
if (userinput == "q\n" or userinput == "Q\n"):
aa_close(handle)
sys.exit()
aa_i2c_write(handle,DEVICE,0,array('B',[CTRL_REGB, 0]))
aa_i2c_write(handle,DEVICE,0,array('B',[CTRL_REGB, FFIen | MOTIen]))
aa_close(handle)