Skip to content

Commit

Permalink
Merge pull request #33 from VIPQualityPost/mt6835-selfcal
Browse files Browse the repository at this point in the history
MT6835 Calibration register check
  • Loading branch information
runger1101001 authored Nov 8, 2023
2 parents ad05d2f + 5daf24e commit 9c93bd4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/encoders/mt6835/MT6835.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,21 @@ uint8_t MT6835::getStatus(){
return laststatus;
};

uint8_t MT6835::getCalibrationStatus(){
uint8_t data[3] = {0};
data[0] = MT6835_OP_READ << 4 | MT6835_REG_CAL_STATUS >> 8;
data[1] = MT6835_REG_CAL_STATUS;

spi->beginTransaction(settings);
if(nCS >= 0)
digitalWrite(nCS, LOW);
spi->transfer(data, 3);
if(nCS >= 0)
digitalWrite(nCS, HIGH);
spi->endTransaction();

return data[2] >> 6;
}

bool MT6835::setZeroFromCurrentPosition(){
MT6835Command cmd;
Expand Down
2 changes: 2 additions & 0 deletions src/encoders/mt6835/MT6835.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ class MT6835 {

uint8_t getStatus();

uint8_t getCalibrationStatus();

bool setZeroFromCurrentPosition();
bool writeEEPROM(); // wait 6s after calling this method

Expand Down

0 comments on commit 9c93bd4

Please sign in to comment.