TLI493D  2.0.1
With this Sensor, you can detect the position of a Joystick etc. without any additional mechanical components. You just have to provide a magnet that is fixed to a movable component.
Tli493d.h
Go to the documentation of this file.
1 
34 #ifndef TLI493D_H_INCLUDED
35 #define TLI493D_H_INCLUDED
36 
37 #include <Arduino.h>
38 #include <Wire.h>
39 #include "./util/BusInterface.h"
40 #include "./util/Tli493d_conf.h"
41 
42 #define NO_POWER_PIN -1
43 
44 typedef enum Tli493d_Error
45 {
50 
51 class Tli493d
52 {
53  public:
55  {
56  TLI493D_A0 = 0x35,
57  TLI493D_A1 = 0x22,
58  TLI493D_A2 = 0x78,
59  TLI493D_A3 = 0x44
60  };
61 
68  {
71  FASTMODE = 3,
72  };
82  enum Range_e
83  {
84  FULL = 0,
85  SHORT = 1,
87  };
102  TypeAddress_e productType = TLI493D_A0,
103  int resetPin = NO_POWER_PIN,
104  bool powerLevel = HIGH);
105 
111  Tli493d(int resetPin,
112  bool powerLevel = HIGH,
114  TypeAddress_e productType = TLI493D_A0);
115 
119  ~Tli493d(void);
123  void begin(void);
124 
128  void begin(bool);
129 
137  void begin(TwoWire &bus, TypeAddress_e slaveAddress, bool reset,
138  uint8_t oneByteRead);
139 
145  bool setAccessMode(AccessMode_e mode);
146 
151  void setTrigger(uint8_t trigger);
152 
156  void enableTemp(void);
157 
161  void disableTemp(void);
162 
166  void enableBz(void);
167 
171  void disableBz(void);
172 
188  bool setWakeUpThreshold(float xh, float xl, float yh, float yl, float zh,
189  float zl);
190 
206  bool setWakeUpThresholdLSB(int16_t xh, int16_t xl, int16_t yh, int16_t yl, int16_t zh,
207  int16_t zl);
208 
224  bool setWakeUpThresholdMT(float xh, float xl, float yh, float yl, float zh,
225  float zl);
226 
230  bool wakeUpEnabled(void);
231 
239  void enableWakeUp(void);
240 
244  void disableWakeUp(void);
245 
250  void setUpdateRate(uint8_t updateRate);
251 
259  bool setMeasurementRange(Range_e range);
260 
265 
269  float getX(void);
273  float getY(void);
277  float getZ(void);
278 
282  float getNorm(void);
283 
287  float getAzimuth(void);
288 
292  float getPolar(void);
293 
297  float getTemp(void);
298 
302  void resetSensor(void);
303 
304  void readDiagnosis(uint8_t (&diag)[7]);
305 
309  void enableInterrupt(void);
310 
314  void disableInterrupt(void);
315 
320  void enableCollisionAvoidance(void);
321 
325  void disableCollisionAvoidance(void);
326 
327 
328  protected:
335  void setRegBits(uint8_t regMaskIndex, uint8_t data);
336 
341  uint8_t getRegBits(uint8_t regMaskIndex);
342 
343  private:
344  const TypeAddress_e mProductType;
345  AccessMode_e mMode;
346  int mPowerPin;
347  bool mPowerLevel;
348  int16_t mXdata;
349  int16_t mYdata;
350  int16_t mZdata;
351  int16_t mTempdata;
352  float mBMult = TLI493D_B_MULT_FULL;
353 
357  void calcParity(uint8_t regMaskIndex);
358 
362  int16_t concatResults(uint8_t upperByte, uint8_t lowerByte, bool isB);
363 };
364 
365 #endif /* TLI493D_H_INCLUDED */
float getTemp(void)
Definition: Tli493d.cpp:446
uint8_t getRegBits(uint8_t regMaskIndex)
Returns the value of a register field.
Definition: Tli493d.cpp:503
void begin(void)
Starts the sensor.
Definition: Tli493d.cpp:35
void resetSensor(void)
Resets the sensor.
Definition: Tli493d.cpp:469
AccessMode_e
Definition: Tli493d.h:67
float getNorm(void)
Definition: Tli493d.cpp:451
Definition: Tli493d.h:70
void enableWakeUp(void)
Enables the Wake Up functionality of the sensor. Following conditions must be fulfilled: ...
Definition: Tli493d.cpp:366
void enableInterrupt(void)
Enables interrupts.
Definition: Tli493d.cpp:162
void disableTemp(void)
Disables temperature measurement to reduce power consumption.
Definition: Tli493d.cpp:197
bool setMeasurementRange(Range_e range)
Sets the magnetic range that can be measured. The smaller the range, the higher the sensitivity...
Definition: Tli493d.cpp:388
Definition: Tli493d.h:71
Definition: Tli493d.h:59
float getX(void)
Definition: Tli493d.cpp:431
Definition: Tli493d.h:51
Definition: Tli493d.h:69
~Tli493d(void)
Destructor.
Definition: Tli493d.cpp:30
bool wakeUpEnabled(void)
Checks if WA bit is set. When not interrupt configuration is as specified by the CA and INT bits...
Definition: Tli493d.cpp:361
Definition: Tli493d.h:57
Definition: BusInterface.h:12
void enableCollisionAvoidance(void)
Enables collision avoidance. When Interrupt is deactivated, clock stretching is active. For clock stretching: SCL and INT pins must be shorted.
Definition: Tli493d.cpp:176
bool setWakeUpThresholdMT(float xh, float xl, float yh, float yl, float zh, float zl)
The Wake Up threshold range disabling /INT pulses between upper threshold and lower threshold is limi...
Definition: Tli493d.cpp:313
Definition: Tli493d.h:85
void disableInterrupt(void)
Disables interrupts; When Collision Avoidance is activated, Sensor read-outs are suppressed during on...
Definition: Tli493d.cpp:169
Definition: Tli493d.h:47
Range_e
Definition: Tli493d.h:82
tli493d::BusInterface_t mInterface
Definition: Tli493d.h:329
Tli493d_Error
Definition: Tli493d.h:44
void disableWakeUp(void)
Disables the Wake Up functionality of the sensor.
Definition: Tli493d.cpp:373
float getY(void)
Definition: Tli493d.cpp:436
Definition: Tli493d.h:46
void setUpdateRate(uint8_t updateRate)
Sets the update rate in low power mode.
Definition: Tli493d.cpp:380
float getPolar(void)
Definition: Tli493d.cpp:461
Tli493d_Error updateData(void)
Reads measurement results from sensor.
Definition: Tli493d.cpp:414
bool setWakeUpThresholdLSB(int16_t xh, int16_t xl, int16_t yh, int16_t yl, int16_t zh, int16_t zl)
The Wake Up threshold range disabling /INT pulses between upper threshold and lower threshold is limi...
Definition: Tli493d.cpp:265
void readDiagnosis(uint8_t(&diag)[7])
Definition: Tli493d.cpp:484
void setRegBits(uint8_t regMaskIndex, uint8_t data)
Stores new values into the bus interface; for this function to take effect the function writeOut() sh...
Definition: Tli493d.cpp:495
Definition: Tli493d.h:58
bool setWakeUpThreshold(float xh, float xl, float yh, float yl, float zh, float zl)
The Wake Up threshold range disabling /INT pulses between upper threshold and lower threshold is limi...
Definition: Tli493d.cpp:218
float getAzimuth(void)
Definition: Tli493d.cpp:456
Definition: Tli493d.h:48
Definition: Tli493d.h:56
float getZ(void)
Definition: Tli493d.cpp:441
TypeAddress_e
Definition: Tli493d.h:54
void disableCollisionAvoidance(void)
Disables collision avoidance; readouts may collide with ADC conversion.
Definition: Tli493d.cpp:183
enum Tli493d_Error Tli493d_Error_t
bool setAccessMode(AccessMode_e mode)
Sets the operating mode of the sensor.
Definition: Tli493d.cpp:114
Definition: Tli493d.h:86
void enableBz(void)
Enables BZ measurement; by default already enabled.
Definition: Tli493d.cpp:204
void disableBz(void)
Disables Bz measurement to reduce power consumption. This only works, when temperature measurement is...
Definition: Tli493d.cpp:211
Tli493d(AccessMode_e mode=MASTERCONTROLLEDMODE, TypeAddress_e productType=TLI493D_A0, int resetPin=NO_POWER_PIN, bool powerLevel=HIGH)
Constructor of the sensor class.
Definition: Tli493d.cpp:14
Definition: Tli493d.h:84
void setTrigger(uint8_t trigger)
Sets when new measurements are triggered in MASTERCONTROLLEDMODE. If invalid argument or sensor mode ...
Definition: Tli493d.cpp:145
void enableTemp(void)
Enables temperature measurement; by default already enabled.
Definition: Tli493d.cpp:190