code:compas2osc
no way to compare when less than two revisions
Différences
Ci-dessous, les différences entre deux révisions de la page.
— | code:compas2osc [2024/02/09 17:26] (Version actuelle) – créée - modification externe 127.0.0.1 | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ====== compas2OSC.py ====== | ||
+ | ===== CMPS10 - Tilt Compensated Compass Module ===== | ||
+ | * [[http:// | ||
+ | * http:// | ||
+ | |||
+ | ** Registre de 23 bytes :** | ||
+ | * 0 Software version | ||
+ | * 1 Compass Bearing as a byte, i.e. 0-255 for a full circle | ||
+ | * 2,3 Compass Bearing as a word, i.e. 0-3599 for a full circle, representing 0-359.9 degrees. | ||
+ | * 4 Pitch angle - signed byte giving angle in degrees from the horizontal plane | ||
+ | * 5 Roll angle - signed byte giving angle in degrees from the horizontal plane | ||
+ | * 6,,7,8,9 Unused | ||
+ | * 10,11 Magnetometer X axis raw output, 16 bit signed integer with register 10 being the upper 8 bits | ||
+ | * 12,13 Magnetometer Y axis raw output, 16 bit signed integer with register 12 being the upper 8 bits | ||
+ | * 14,15 Magnetometer Z axis raw output, 16 bit signed integer with register 14 being the upper 8 bits | ||
+ | * 16,17 Accelerometer | ||
+ | * 18,19 Accelerometer | ||
+ | * 20,21 Accelerometer | ||
+ | * 22 Command register | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ===== HMC6352 ===== | ||
+ | |||
+ | |||
+ | la boussole HMC6352 est sur un bus i2c. | ||
+ | Donne l' | ||
+ | Mais pas de compensation en fonction de l' | ||
+ | d'ou pas d' | ||
+ | |||
+ | < | ||
+ | # | ||
+ | # -*- coding: utf-8 -*- | ||
+ | |||
+ | import sys, | ||
+ | from smbus import SMBus | ||
+ | |||
+ | BUS_NUMBER = 2 | ||
+ | IP=' | ||
+ | PORT=9001 | ||
+ | ADRS=33 # 0x21 - compass | ||
+ | osc_path='/ | ||
+ | |||
+ | b = SMBus(BUS_NUMBER) # 0 indicates /dev/i2c-0 | ||
+ | data = {} | ||
+ | |||
+ | try: | ||
+ | target = liblo.Address(' | ||
+ | except liblo.AddressError, | ||
+ | print str(err) | ||
+ | sys.exit() | ||
+ | |||
+ | while True: | ||
+ | try: | ||
+ | b.write_byte(0x21, | ||
+ | time.sleep(0.02) | ||
+ | data_block = b.read_i2c_block_data(0x21, | ||
+ | heading = (data_block[0] * 2**8 + data_block[1]) / 10 | ||
+ | time.sleep(0.02) | ||
+ | # | ||
+ | liblo.send(target, | ||
+ | except KeyError: | ||
+ | pass | ||
+ | except KeyboardInterrupt: | ||
+ | quit() | ||
+ | except StopIteration: | ||
+ | session = None | ||
+ | print " | ||
+ | except: | ||
+ | # | ||
+ | continue | ||
+ | |||
+ | </ |
code/compas2osc.txt · Dernière modification : 2024/02/09 17:26 de 127.0.0.1