Skip to content

Commit afea0c7

Browse files
self cal verification
1 parent b6c0c7d commit afea0c7

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
@@ -55,6 +55,21 @@ uint8_t MT6835::getStatus(){
5555
return laststatus;
5656
};
5757

58+
uint8_t MT6835::getCalibrationStatus(){
59+
uint8_t data[3] = {0};
60+
data[0] = MT6835_OP_READ << 4 | MT6835_REG_CAL_STATUS >> 8;
61+
data[1] = MT6835_REG_CAL_STATUS;
62+
63+
spi->startTransaction(settings);
64+
if(nCS >= 0)
65+
digitalWrite(nCS, LOW);
66+
spi->transfer(data, 3);
67+
if(nCS >= 0)
68+
digitalWrite(nCS, HIGH);
69+
spi->endTransaction();
70+
71+
return data[2] >> 6;
72+
}
5873

5974
bool MT6835::setZeroFromCurrentPosition(){
6075
MT6835Command cmd;

src/encoders/mt6835/MT6835.h

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

200200
uint8_t getStatus();
201201

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

0 commit comments

Comments
 (0)