Skip to content

Commit 73c232c

Browse files
author
Yury Starkov
committed
use software I2C, apply PR tockn#30
Change code to use software I2C to improve stability; PR#30: Update header to use forward declaration for SoftWire and move SoftWire.h to .cpp file
1 parent 89ffd68 commit 73c232c

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Diff for: src/MPU6050_tockn.cpp

100755100644
+3-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#include "MPU6050_tockn.h"
22
#include "Arduino.h"
3+
#include "SoftWire.h"
34

4-
MPU6050::MPU6050(TwoWire &w){
5+
MPU6050::MPU6050(SoftWire &w){
56
wire = &w;
67
accCoef = 0.02f;
78
gyroCoef = 0.98f;
89
}
910

10-
MPU6050::MPU6050(TwoWire &w, float aC, float gC){
11+
MPU6050::MPU6050(SoftWire &w, float aC, float gC){
1112
wire = &w;
1213
accCoef = aC;
1314
gyroCoef = gC;

Diff for: src/MPU6050_tockn.h

100755100644
+5-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#define MPU6050_TOCKN_H
33

44
#include "Arduino.h"
5-
#include "Wire.h"
65

76
#define MPU6050_ADDR 0x68
87
#define MPU6050_SMPLRT_DIV 0x19
@@ -14,11 +13,13 @@
1413
#define MPU6050_TEMP_H 0x41
1514
#define MPU6050_TEMP_L 0x42
1615

16+
class SoftWire;
17+
1718
class MPU6050{
1819
public:
1920

20-
MPU6050(TwoWire &w);
21-
MPU6050(TwoWire &w, float aC, float gC);
21+
MPU6050(SoftWire &w);
22+
MPU6050(SoftWire &w, float aC, float gC);
2223

2324
void begin();
2425

@@ -68,7 +69,7 @@ class MPU6050{
6869

6970
private:
7071

71-
TwoWire *wire;
72+
SoftWire *wire;
7273

7374
int16_t rawAccX, rawAccY, rawAccZ, rawTemp,
7475
rawGyroX, rawGyroY, rawGyroZ;

0 commit comments

Comments
 (0)