summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--microcopter.cfg2
-rw-r--r--sensors/compass/Makefile6
-rw-r--r--sensors/compass/hmc5883l.vala (renamed from sensors/compass/hmc5843.vala)14
3 files changed, 12 insertions, 10 deletions
diff --git a/microcopter.cfg b/microcopter.cfg
index 3d47a7d..a820b68 100644
--- a/microcopter.cfg
+++ b/microcopter.cfg
@@ -18,7 +18,7 @@ i2c-adapter = 0
#i2c-address = 0x53
i2c-address = 83
-[HMC5843]
+[HMC5883L]
i2c-adapter = 0
#i2c-address = 0x1e
i2c-address = 30
diff --git a/sensors/compass/Makefile b/sensors/compass/Makefile
index 178ae55..5cecef4 100644
--- a/sensors/compass/Makefile
+++ b/sensors/compass/Makefile
@@ -1,14 +1,14 @@
include ../../config.mk
-all: HMC5843.so
+all: HMC5883L.so
clean:
rm -f *.c *.so
-hmc5843.c: hmc5843.vala
+hmc5883l.c: hmc5883l.vala
$(VALAC) --pkg gmodule-2.0 --pkg posix --pkg linux -C $< ../compass.vala ../../hw/i2c-device.vala ../../hw/device.vala
-HMC5843.so: hmc5843.c
+HMC5883l.so: hmc5883l.c
$(CC) -shared -fPIC `pkg-config --cflags --libs glib-2.0 gobject-2.0 gmodule-2.0` -o $@ $<
.PHONY: all clean
diff --git a/sensors/compass/hmc5843.vala b/sensors/compass/hmc5883l.vala
index 147a730..b30a243 100644
--- a/sensors/compass/hmc5843.vala
+++ b/sensors/compass/hmc5883l.vala
@@ -13,7 +13,9 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-public class HMC5843 : I2CDevice, Compass {
+public class HMC5883L : I2CDevice, Compass {
+ public static const int COUNTS_PER_MGAUSS = 1090;
+
public HMC5843(uint8 dev, uint8 addr = 0x1e) throws I2CError {
setup(dev, addr);
devsetup();
@@ -21,18 +23,18 @@ public class HMC5843 : I2CDevice, Compass {
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");
+ log("HMC5883L", LogLevelFlags.LEVEL_ERROR, @"invalid device id");
else
- log("HMC5843", LogLevelFlags.LEVEL_DEBUG, @"HMC5843: correct device id");
+ log("HMC5883L", LogLevelFlags.LEVEL_DEBUG, @"correct device id");
set_byte(0x00, 0x10); /* default mode */
- set_byte(0x01, 0x20); /* set gain: +/- 1.0Ga (default) */
+ set_byte(0x01, 0x20); /* set gain: +/- 1.3Ga (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");
+ var adapter = cfg.get_uint64("HMC5883L", "i2c-adapter");
+ var address = cfg.get_uint64("HMC5883L", "i2c-address");
setup((uint8) adapter, (uint8) address);
devsetup();
}