Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import smbus
- bus = smbus.SMBus(1)
- v = bus.read_byte_data(0x57, 0xff)
- if v != 17:
- print "wrong part ID"
- exit(1)
- bus.write_byte_data(0x57, 0x06, 0x03)
- p = bus.read_byte_data(0x57, 0x07)
- bus.write_byte_data(0x57, 0x07, (p & 0xfc) | 0x03)
- p = bus.read_byte_data(0x57, 0x07)
- bus.write_byte_data(0x57, 0x07, (p & 0xe3) | (0x01 << 2))
- bus.write_byte_data(0x57, 0x09, 0x0f << 4 | 0x0f)
- p = bus.read_byte_data(0x57, 0x07)
- bus.write_byte_data(0x57, 0x07, p | (1 << 6))
- alpha = 0.95
- dcw = 0.0
- lpf = [ 0.0, 0.0 ]
- while True:
- buffer = bus.read_i2c_block_data(0x57, 0x05, 4)
- rawIRValue = (buffer[0] << 8) | buffer[1]
- rawRedValue = (buffer[2] << 8) | buffer[3]
- olddcw = dcw
- dcw = rawIRValue + alpha * dcw
- irACValue = dcw - olddcw
- lpf[0] = lpf[1]
- lpf[1] = (2.452372752527856026e-1 * (-irACValue)) + (0.50952544949442879485 * lpf[0])
- print (lpf[0] + lpf[1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement