diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2011-04-11 05:44:51 +0200 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2011-04-11 05:44:51 +0200 |
commit | c6ac90fc731d8411380f582be3b91ce4e93f61fc (patch) | |
tree | e5fc2017a6e27e3669a81f595df551cc91af7549 /itg3200.h | |
parent | 14f24f2a98a63a5c5525fd196df46100b4ef626d (diff) |
Create I2CSensor class and subclasses for each sensor.
Diffstat (limited to 'itg3200.h')
-rw-r--r-- | itg3200.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/itg3200.h b/itg3200.h new file mode 100644 index 0000000..f03b6f3 --- /dev/null +++ b/itg3200.h @@ -0,0 +1,24 @@ +#ifndef ITG3200_H +#define ITG3200_H + +#include "i2csensor.h" + +class ITG3200 : public I2CSensor { + public: + int16_t x, y, z; + + void init() { + i2c_address = 0x68; + write(0x3e, 0x03); // Select clock reference. + write(0x16, 0x18 | 0x05); // 2000 deg/sec range, 10 Hz bandwidth. + } + + void update() { + read(0x1d, 6); + x = (rxdata[0] << 8 | rxdata[1]) - -50; + y = (rxdata[2] << 8 | rxdata[3]) - 36; + z = (rxdata[4] << 8 | rxdata[5]) - 2; + } +}; + +#endif |