From afea0c70454249d0944260a107484b09c2ef38de Mon Sep 17 00:00:00 2001 From: matei jordache Date: Tue, 7 Nov 2023 20:02:35 -0500 Subject: [PATCH 1/2] self cal verification --- src/encoders/mt6835/MT6835.cpp | 15 +++++++++++++++ src/encoders/mt6835/MT6835.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/encoders/mt6835/MT6835.cpp b/src/encoders/mt6835/MT6835.cpp index aeaa200..4010d48 100644 --- a/src/encoders/mt6835/MT6835.cpp +++ b/src/encoders/mt6835/MT6835.cpp @@ -55,6 +55,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->startTransaction(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; diff --git a/src/encoders/mt6835/MT6835.h b/src/encoders/mt6835/MT6835.h index 5751901..8518034 100644 --- a/src/encoders/mt6835/MT6835.h +++ b/src/encoders/mt6835/MT6835.h @@ -199,6 +199,8 @@ class MT6835 { uint8_t getStatus(); + uint8_t getCalibrationStatus(); + bool setZeroFromCurrentPosition(); bool writeEEPROM(); // wait 6s after calling this method From 5daf24eec2b3cae0e81407009da630c6045eb3c1 Mon Sep 17 00:00:00 2001 From: matei jordache Date: Tue, 7 Nov 2023 20:11:33 -0500 Subject: [PATCH 2/2] oops typo --- src/encoders/mt6835/MT6835.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/encoders/mt6835/MT6835.cpp b/src/encoders/mt6835/MT6835.cpp index 4010d48..28f56bc 100644 --- a/src/encoders/mt6835/MT6835.cpp +++ b/src/encoders/mt6835/MT6835.cpp @@ -60,7 +60,7 @@ uint8_t MT6835::getCalibrationStatus(){ data[0] = MT6835_OP_READ << 4 | MT6835_REG_CAL_STATUS >> 8; data[1] = MT6835_REG_CAL_STATUS; - spi->startTransaction(settings); + spi->beginTransaction(settings); if(nCS >= 0) digitalWrite(nCS, LOW); spi->transfer(data, 3);