DUDS
Distributed Update of Data from Something
FXOS8700CQ.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of the DUDS project. It is subject to the BSD-style
3  * license terms in the LICENSE file found in the top-level directory of this
4  * distribution and at https://github.com/jjackowski/duds/blob/master/LICENSE.
5  * No part of DUDS, including this file, may be copied, modified, propagated,
6  * or distributed except according to the terms contained in the LICENSE file.
7  *
8  * Copyright (C) 2017 Jeff Jackowski
9  */
14 
15 namespace duds { namespace hardware { namespace devices { namespace instruments {
16 
34 
35 typedef boost::error_info<struct Info_UpdateRate, float> RequestedUpdateRate;
36 
56 class FXOS8700CQ : boost::noncopyable {
57 public:
62  union RawSample {
63  std::int16_t vals[3];
64  struct {
65  std::int16_t x;
66  std::int16_t y;
67  std::int16_t z;
68  };
69  };
79  enum Magnitude {
92  Magnitude8g
93  };
98  LowPower
99  };
104  struct Settings {
109  unsigned int accelerometer : 1;
114  unsigned int magnetometer : 1;
119  unsigned int accelLowNoise : 1;
123  unsigned int highPassFilter : 1;
127  unsigned int highPassLowCutoff : 1;
147  unsigned int oversampleRatio : 3;
153  unsigned int threadedSample : 1;
154  };
155 private:
159  std::unique_ptr<duds::hardware::interface::I2c> com;
176  float datarate;
184  std::int8_t drval;
185 public:
197  FXOS8700CQ(std::unique_ptr<duds::hardware::interface::I2c> &i2ccom);
201  ~FXOS8700CQ();
216  void configure(float freq, Settings settings);
221  void start();
227  void suspend();
235  void resume() {
236  start();
237  }
242  bool sample();
247  float sampleRate() const {
248  return datarate;
249  }
258  const RawSample &rawAccelerometer() const {
259  return accl;
260  }
266  const RawSample &rawMagnetometer() const {
267  return magn;
268  }
269 };
270 
271 } } } }
The various settings for the device packed into an integer to avoid passing a lot of parameters...
Definition: FXOS8700CQ.hpp:104
void resume()
Resumes operation after a call to suspend().
Definition: FXOS8700CQ.hpp:235
unsigned int accelLowNoise
Use the low-noise mode of the accelerometer.
Definition: FXOS8700CQ.hpp:119
unsigned int highPassLowCutoff
Adjusts the cut-off frequency of the high-pass filter to be lower.
Definition: FXOS8700CQ.hpp:127
unsigned int accelerometer
Flag to use the accelerometer.
Definition: FXOS8700CQ.hpp:109
Magnitude maxMagnitude
The maximum magnetude for the accelerometer.
Definition: FXOS8700CQ.hpp:131
boost::error_info< struct Info_UpdateRate, float > RequestedUpdateRate
Definition: FXOS8700CQ.hpp:35
duds::hardware::interface::Conversation initialize
The conversation used to initialize the device.
Definition: FXOS8700CQ.hpp:164
OversampleMode oversampleSleepMode
The oversample mode to use when in the sleep state.
Definition: FXOS8700CQ.hpp:140
unsigned int threadedSample
Uses a thread to periodically read samples from the device.
Definition: FXOS8700CQ.hpp:153
duds::data::QuantityXyz ConvertedSample
The sample data converted to known units.
Definition: FXOS8700CQ.hpp:75
Base class for all FXOS8700CQ specific errors.
Definition: FXOS8700CQ.hpp:20
std::int8_t drval
The data rate value given to the device.
Definition: FXOS8700CQ.hpp:184
duds::hardware::interface::Conversation input
The conversation used to read in samples from the device.
Definition: FXOS8700CQ.hpp:168
const RawSample & rawMagnetometer() const
Returns the magnetometer data as read from the device.
Definition: FXOS8700CQ.hpp:266
unsigned int magnetometer
Flag to use the magnetometer.
Definition: FXOS8700CQ.hpp:114
Initial support of the FXOS8700CQ; a combined triple axis accelerometer and magnetometer.
Definition: FXOS8700CQ.hpp:56
Settings cfg
The current various configuration options.
Definition: FXOS8700CQ.hpp:180
unsigned int oversampleRatio
Affects how many samples are taken by the magnetometer to produce a single output sample...
Definition: FXOS8700CQ.hpp:147
The requested maximum magnitude is either unsupported or an invalid value.
Definition: FXOS8700CQ.hpp:28
const RawSample & rawAccelerometer() const
Returns the accelerometer data as read from the device.
Definition: FXOS8700CQ.hpp:258
std::unique_ptr< duds::hardware::interface::I2c > com
The I2C communication interface.
Definition: FXOS8700CQ.hpp:159
Header for Conversarion; includes ConversationVector.hpp and ConversationExternal.hpp.
A QuantityArray for the common usage of a three dimentional coordinate or a triple axis sample...
The base type for errors from devices.
float datarate
The currently configured sample rate.
Definition: FXOS8700CQ.hpp:176
Magnitude
The magnitude options for the accelerometer.
Definition: FXOS8700CQ.hpp:79
The configuration requested that neither the accelerometer or magnetometer be used.
Definition: FXOS8700CQ.hpp:33
unsigned int highPassFilter
Enables the high-pass filter.
Definition: FXOS8700CQ.hpp:123
The requested data rate is unsupported.
Definition: FXOS8700CQ.hpp:24
OversampleMode oversampleMode
The oversample mode to use when in the active non-sleep state.
Definition: FXOS8700CQ.hpp:135
float sampleRate() const
Returns the confiured sampling rate.
Definition: FXOS8700CQ.hpp:247
Stores the sample data as reported by the device.
Definition: FXOS8700CQ.hpp:62
Represents a two-way conversation with a device.