MakeBlock Drive Updated Updated library for MakeBlock Ranger

Loading...
Searching...
No Matches
MeGyro.h
Go to the documentation of this file.
1
51/* Define to prevent recursive inclusion -------------------------------------*/
52#ifndef MeGyro_H
53#define MeGyro_H
54
55/* Includes ------------------------------------------------------------------*/
56#include <stdint.h>
57#include <stdbool.h>
58#include <Arduino.h>
59#include "MeConfig.h"
60#ifdef ME_PORT_DEFINED
61#include "MePort.h"
62#endif // ME_PORT_DEFINED
63
64/* Exported macro ------------------------------------------------------------*/
65#define I2C_ERROR (-1)
66
67#define GYRO_DEFAULT_ADDRESS (0x68)
68
74#ifndef ME_PORT_DEFINED
75 class MeGyro
76#else // !ME_PORT_DEFINED
77class MeGyro : public MePort
78#endif // !ME_PORT_DEFINED
79{
80 public:
81#ifdef ME_PORT_DEFINED
86 MeGyro(void);
87
94 MeGyro(uint8_t port);
95
105 MeGyro(uint8_t port, uint8_t address);
106#else
115 MeGyro(uint8_t AD0, uint8_t INT);
116
127 MeGyro(uint8_t AD0, uint8_t INT, uint8_t address);
128#endif // ME_PORT_DEFINED
145 void setpin(uint8_t AD0, uint8_t INT);
146
161 void begin();
162
179 void update(void);
180
197 void fast_update(void);
198
213 uint8_t getDevAddr(void) const;
214
229 double getAngleX(void) const;
230
245 double getAngleY(void) const;
246
261 double getAngleZ(void) const;
262
277 double getGyroX(void) const;
278
293 double getGyroY(void) const;
294
309 double getGyroZ(void) const;
310
325 double getAngle(uint8_t index) const;
326
343 void resetData(void);
344
345 private:
346 volatile uint8_t _AD0;
347 volatile uint8_t _INT;
348 double gSensitivity; /* for 500 deg/s, check data sheet */
349 double gx, gy, gz;
350 double gyrX, gyrY, gyrZ;
351 int16_t accX, accY, accZ;
352 double gyrXoffs, gyrYoffs, gyrZoffs;
353 uint8_t i2cData[14];
354 uint8_t Device_Address;
355
371 void deviceCalibration(void);
372
396 int8_t writeReg(int16_t reg, uint8_t data);
397
423 int8_t readData(uint8_t start, uint8_t *buffer, uint8_t size);
424
450 int8_t writeData(uint8_t start, const uint8_t *pData, uint8_t size);
451};
452#endif // MeGyro_H
MeConfig.h
Configuration file of library.
MePort.h
Header for MePort.cpp module.
MeGyro
Driver for MeGyro module.
Definition MeGyro.h:79
MeGyro::fast_update
void fast_update(void)
Definition MeGyro.cpp:276
MeGyro::getDevAddr
uint8_t getDevAddr(void) const
Definition MeGyro.cpp:339
MeGyro::resetData
void resetData(void)
Definition MeGyro.cpp:661
MeGyro::getAngleX
double getAngleX(void) const
Definition MeGyro.cpp:358
MeGyro::getGyroY
double getGyroY(void) const
Definition MeGyro.cpp:434
MeGyro::getAngleY
double getAngleY(void) const
Definition MeGyro.cpp:377
MeGyro::MeGyro
MeGyro(void)
Definition MeGyro.cpp:63
MeGyro::getAngle
double getAngle(uint8_t index) const
Definition MeGyro.cpp:472
MeGyro::update
void update(void)
Definition MeGyro.cpp:207
MeGyro::getGyroZ
double getGyroZ(void) const
Definition MeGyro.cpp:453
MeGyro::getGyroX
double getGyroX(void) const
Definition MeGyro.cpp:415
MeGyro::begin
void begin()
Definition MeGyro.cpp:166
MeGyro::getAngleZ
double getAngleZ(void) const
Definition MeGyro.cpp:396
MePort
Port Mapping for RJ25.
Definition MePort.h:128