diff options
author | Sebastian Reichel <sre@ring0.de> | 2012-10-29 16:49:57 +0100 |
---|---|---|
committer | Sebastian Reichel <sre@ring0.de> | 2012-10-29 16:49:57 +0100 |
commit | 305dc06de590e4319f782d058e3199435a424218 (patch) | |
tree | bc5c8beefbdbf08b3cb2da70c93340d52ab56e9e /sensors/compass/hmc5843.vala | |
parent | 05ede46c5f16b9a30c5c6cc86ddcd494d7517fbc (diff) | |
download | microcopterd-305dc06de590e4319f782d058e3199435a424218.tar.bz2 |
HMC5843 -> HMC5883L
Diffstat (limited to 'sensors/compass/hmc5843.vala')
-rw-r--r-- | sensors/compass/hmc5843.vala | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/sensors/compass/hmc5843.vala b/sensors/compass/hmc5843.vala deleted file mode 100644 index 147a730..0000000 --- a/sensors/compass/hmc5843.vala +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright 2012, Sebastian Reichel <sre@ring0.de> - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -public class HMC5843 : I2CDevice, Compass { - public HMC5843(uint8 dev, uint8 addr = 0x1e) throws I2CError { - setup(dev, addr); - devsetup(); - } - - private void devsetup() throws I2CError { - if(get_byte(0x0a) != 'H' || get_byte(0x0b) != '4' || get_byte(0x0c) != '3') - log("HMC5843", LogLevelFlags.LEVEL_ERROR, @"HMC5843: invalid device id"); - else - log("HMC5843", LogLevelFlags.LEVEL_DEBUG, @"HMC5843: correct device id"); - - set_byte(0x00, 0x10); /* default mode */ - set_byte(0x01, 0x20); /* set gain: +/- 1.0Ga (default) */ - set_byte(0x02, 0x00); /* continous conversion */ - } - - public void init(KeyFile cfg) throws KeyFileError, I2CError { - var adapter = cfg.get_uint64("HMC5843", "i2c-adapter"); - var address = cfg.get_uint64("HMC5843", "i2c-address"); - setup((uint8) adapter, (uint8) address); - devsetup(); - } - - public void get_data(out int16 x, out int16 y, out int16 z) throws I2CError { - var data = get_block(0x03, 6); - x = data[0] << 8 | data[1]; - y = data[2] << 8 | data[3]; - z = data[4] << 8 | data[5]; - } -} - -public Type register_plugin(Module module) { - // types are registered automatically - return typeof(HMC5843); -} |