Skip to content

Commit fc71187

Browse files
committed
fix(as5600): correct fail logic in configureSensor()
1 parent dda19cd commit fc71187

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/components/i2c/drivers/WipperSnapper_I2C_Driver_AS5600.h

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,23 +78,19 @@ class WipperSnapper_I2C_Driver_AS5600 : public WipperSnapper_I2C_Driver {
7878
*/
7979
/*******************************************************************************/
8080
bool configureSensor() {
81-
return _as5600->enableWatchdog(false) || // Normal (high) power mode
82-
_as5600->setPowerMode(AS5600_POWER_MODE_NOM) ||
81+
return _as5600->enableWatchdog(false) &&
82+
// Normal (high) power mode
83+
_as5600->setPowerMode(AS5600_POWER_MODE_NOM) &&
8384
// No Hysteresis
84-
_as5600->setHysteresis(AS5600_HYSTERESIS_OFF) ||
85-
85+
_as5600->setHysteresis(AS5600_HYSTERESIS_OFF) &&
8686
// analog output (0-VCC for 0-360 degrees)
87-
_as5600->setOutputStage(AS5600_OUTPUT_STAGE_ANALOG_FULL) ||
88-
87+
_as5600->setOutputStage(AS5600_OUTPUT_STAGE_ANALOG_FULL) &&
8988
// setup filters
90-
_as5600->setSlowFilter(AS5600_SLOW_FILTER_16X) ||
91-
_as5600->setFastFilterThresh(AS5600_FAST_FILTER_THRESH_SLOW_ONLY) ||
92-
89+
_as5600->setSlowFilter(AS5600_SLOW_FILTER_16X) &&
90+
_as5600->setFastFilterThresh(AS5600_FAST_FILTER_THRESH_SLOW_ONLY) &&
9391
// Reset position settings to defaults
94-
_as5600->setZPosition(0) || _as5600->setMPosition(4095) ||
92+
_as5600->setZPosition(0) && _as5600->setMPosition(4095) &&
9593
_as5600->setMaxAngle(4095);
96-
97-
return true;
9894
}
9995

10096
bool readSensor() {
@@ -107,7 +103,7 @@ class WipperSnapper_I2C_Driver_AS5600 : public WipperSnapper_I2C_Driver {
107103
uint16_t rawAngle = _as5600->getRawAngle();
108104
uint16_t angle = _as5600->getAngle();
109105

110-
WS_DEBUG_PRINT("Raw: ");
106+
WS_DEBUG_PRINT("AS5600 Raw: ");
111107
WS_DEBUG_PRINT(rawAngle);
112108
WS_DEBUG_PRINT(" (0x");
113109
WS_DEBUG_PRINT(rawAngle, HEX);

0 commit comments

Comments
 (0)