Skip to content

Commit 9c93bd4

Browse files
Merge pull request #33 from VIPQualityPost/mt6835-selfcal
MT6835 Calibration register check
2 parents ad05d2f + 5daf24e commit 9c93bd4

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/encoders/mt6835/MT6835.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,21 @@ uint8_t MT6835::getStatus(){
8888
return laststatus;
8989
};
9090

91+
uint8_t MT6835::getCalibrationStatus(){
92+
uint8_t data[3] = {0};
93+
data[0] = MT6835_OP_READ << 4 | MT6835_REG_CAL_STATUS >> 8;
94+
data[1] = MT6835_REG_CAL_STATUS;
95+
96+
spi->beginTransaction(settings);
97+
if(nCS >= 0)
98+
digitalWrite(nCS, LOW);
99+
spi->transfer(data, 3);
100+
if(nCS >= 0)
101+
digitalWrite(nCS, HIGH);
102+
spi->endTransaction();
103+
104+
return data[2] >> 6;
105+
}
91106

92107
bool MT6835::setZeroFromCurrentPosition(){
93108
MT6835Command cmd;

src/encoders/mt6835/MT6835.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ class MT6835 {
200200

201201
uint8_t getStatus();
202202

203+
uint8_t getCalibrationStatus();
204+
203205
bool setZeroFromCurrentPosition();
204206
bool writeEEPROM(); // wait 6s after calling this method
205207

0 commit comments

Comments
 (0)