From 2393115573d2658ac84f025533fea971110d818d Mon Sep 17 00:00:00 2001 From: Kirk Benell Date: Sun, 23 Mar 2025 17:16:28 -0600 Subject: [PATCH 1/8] *deflated* the old method names - removed *Distance* from names - made the interface a little more sane --- src/sfTk/sfDevXM125Distance.cpp | 238 ++++++++++++++++---------------- src/sfTk/sfDevXM125Distance.h | 146 ++++++++++---------- 2 files changed, 192 insertions(+), 192 deletions(-) diff --git a/src/sfTk/sfDevXM125Distance.cpp b/src/sfTk/sfDevXM125Distance.cpp index 17be1d6..025e365 100644 --- a/src/sfTk/sfDevXM125Distance.cpp +++ b/src/sfTk/sfDevXM125Distance.cpp @@ -30,7 +30,7 @@ sfTkError_t sfDevXM125Distance::begin(sfTkII2C *theBus) // Check errors from device application uint32_t distanceError = 0; - retVal = getDistanceDetectorError(distanceError); + retVal = getDetectorError(distanceError); if (retVal != ksfTkErrOk) return retVal; @@ -41,19 +41,19 @@ sfTkError_t sfDevXM125Distance::begin(sfTkII2C *theBus) return ksfTkErrOk; } //------------------------------------------------------------------ -int32_t sfDevXM125Distance::distanceBegin(uint32_t startRange, uint32_t endRange) +int32_t sfDevXM125Distance::distanceSetup(uint32_t startRange, uint32_t endRange) { uint32_t errorStatus = 0; // *** Distance Sensor Setup *** // Reset sensor configuration to reapply configuration registers - setDistanceCommand(SFE_XM125_DISTANCE_RESET_MODULE); + setCommand(SFE_XM125_DISTANCE_RESET_MODULE); sftk_delay_ms(100); - distanceBusyWait(); + busyWait(); // Check error and busy bits - if (getDistanceDetectorErrorStatus(errorStatus) != 0) + if (getDetectorErrorStatus(errorStatus) != 0) { return 1; } @@ -64,24 +64,24 @@ int32_t sfDevXM125Distance::distanceBegin(uint32_t startRange, uint32_t endRange } // Set Start register - if (setDistanceStart(startRange) != 0) + if (setStart(startRange) != 0) { return 3; } sftk_delay_ms(100); // give time for command to set // Set End register - if (setDistanceEnd(endRange) != 0) + if (setEnd(endRange) != 0) { return 4; } sftk_delay_ms(100); // give time for command to set // Apply configuration and calibrate. - if (setDistanceCommand(SFE_XM125_DISTANCE_APPLY_CONFIGURATION) != 0) + if (setCommand(SFE_XM125_DISTANCE_APPLY_CONFIGURATION) != 0) { // Check for errors - getDistanceDetectorErrorStatus(errorStatus); + getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { return 5; @@ -91,13 +91,13 @@ int32_t sfDevXM125Distance::distanceBegin(uint32_t startRange, uint32_t endRange } // Poll detector status until busy bit is cleared - if (distanceBusyWait() != 0) + if (busyWait() != 0) { return 7; } // Check detector status - getDistanceDetectorErrorStatus(errorStatus); + getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { return 7; @@ -108,34 +108,34 @@ int32_t sfDevXM125Distance::distanceBegin(uint32_t startRange, uint32_t endRange } //-------------------------------------------------------------------------------- -int32_t sfDevXM125Distance::distanceDetectorReadingSetup() +int32_t sfDevXM125Distance::detectorReadingSetup() { uint32_t errorStatus = 0; uint32_t calibrateNeeded = 0; uint32_t measDistErr = 0; // Check error bits - getDistanceDetectorErrorStatus(errorStatus); + getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { return 1; } // Start detector - if (setDistanceCommand(SFE_XM125_DISTANCE_START_DETECTOR) != 0) + if (setCommand(SFE_XM125_DISTANCE_START_DETECTOR) != 0) { return 2; } sftk_delay_ms(100); // give time for command to set // Poll detector status until busy bit is cleared - CHECK ON THIS! - if (distanceBusyWait() != 0) + if (busyWait() != 0) { return 3; } // Verify that no error bits are set in the detector status register - getDistanceDetectorErrorStatus(errorStatus); + getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { return 4; @@ -143,7 +143,7 @@ int32_t sfDevXM125Distance::distanceDetectorReadingSetup() sftk_delay_ms(100); // Check MEASURE_DISTANCE_ERROR for measurement failed - getDistanceMeasureDistanceError(measDistErr); + getMeasureDistanceError(measDistErr); if (measDistErr == 1) { return 5; @@ -151,10 +151,10 @@ int32_t sfDevXM125Distance::distanceDetectorReadingSetup() sftk_delay_ms(100); // Recalibrate device if calibration error is triggered - getDistanceCalibrationNeeded(calibrateNeeded); + getCalibrationNeeded(calibrateNeeded); if (calibrateNeeded == 1) { - setDistanceCommand(SFE_XM125_DISTANCE_RECALIBRATE); + setCommand(SFE_XM125_DISTANCE_RECALIBRATE); return 6; } sftk_delay_ms(100); @@ -163,7 +163,7 @@ int32_t sfDevXM125Distance::distanceDetectorReadingSetup() } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistanceDetectorVersion(uint32_t &major, uint32_t &minor, uint32_t &patch) +sfTkError_t sfDevXM125Distance::getDetectorVersion(uint32_t &major, uint32_t &minor, uint32_t &patch) { sfTkError_t retVal; uint32_t regVal = 0; @@ -182,7 +182,7 @@ sfTkError_t sfDevXM125Distance::getDistanceDetectorVersion(uint32_t &major, uint } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistanceDetectorError(uint32_t &error) +sfTkError_t sfDevXM125Distance::getDetectorError(uint32_t &error) { // Read from 16-Bit Register size_t readBytes = 0; @@ -193,7 +193,7 @@ sfTkError_t sfDevXM125Distance::getDistanceDetectorError(uint32_t &error) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistanceDetectorErrorStatus(uint32_t &status) +sfTkError_t sfDevXM125Distance::getDetectorErrorStatus(uint32_t &status) { sfTkError_t retVal; uint32_t regVal = 0; @@ -252,7 +252,7 @@ sfTkError_t sfDevXM125Distance::getDistanceDetectorErrorStatus(uint32_t &status) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistanceMeasureCounter(uint32_t &counter) +sfTkError_t sfDevXM125Distance::getMeasureCounter(uint32_t &counter) { // Read from 16-Bit Register size_t readBytes = 0; @@ -263,7 +263,7 @@ sfTkError_t sfDevXM125Distance::getDistanceMeasureCounter(uint32_t &counter) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistanceDetectorStatus(uint32_t &status) +sfTkError_t sfDevXM125Distance::getDetectorStatus(uint32_t &status) { size_t readBytes = 0; sfTkError_t retVal = @@ -273,7 +273,7 @@ sfTkError_t sfDevXM125Distance::getDistanceDetectorStatus(uint32_t &status) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistanceNumberDistances(uint32_t &distance) +sfTkError_t sfDevXM125Distance::getNumberDistances(uint32_t &distance) { sfTkError_t retVal; uint32_t regVal = 0; @@ -290,7 +290,7 @@ sfTkError_t sfDevXM125Distance::getDistanceNumberDistances(uint32_t &distance) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistanceNearStartEdge(uint32_t &edge) +sfTkError_t sfDevXM125Distance::getNearStartEdge(uint32_t &edge) { sfTkError_t retVal; uint32_t regVal = 0; @@ -307,7 +307,7 @@ sfTkError_t sfDevXM125Distance::getDistanceNearStartEdge(uint32_t &edge) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistanceCalibrationNeeded(uint32_t &calibrate) +sfTkError_t sfDevXM125Distance::getCalibrationNeeded(uint32_t &calibrate) { sfTkError_t retVal; uint32_t regVal = 0; @@ -325,7 +325,7 @@ sfTkError_t sfDevXM125Distance::getDistanceCalibrationNeeded(uint32_t &calibrate } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistanceMeasureDistanceError(uint32_t &error) +sfTkError_t sfDevXM125Distance::getMeasureDistanceError(uint32_t &error) { sfTkError_t retVal; uint32_t regVal = 0; @@ -343,7 +343,7 @@ sfTkError_t sfDevXM125Distance::getDistanceMeasureDistanceError(uint32_t &error) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistanceTemperature(int16_t &temperature) +sfTkError_t sfDevXM125Distance::getTemperature(int16_t &temperature) { sfTkError_t retVal; uint32_t regVal = 0; @@ -365,41 +365,41 @@ sfTkError_t sfDevXM125Distance::getDistanceTemperature(int16_t &temperature) //-------------------------------------------------------------------------------- // Generic distance peak distance method -sfTkError_t sfDevXM125Distance::getDistancePeakDistance(uint8_t num, uint32_t &peak) +sfTkError_t sfDevXM125Distance::getPeakDistance(uint8_t num, uint32_t &peak) { switch (num) { case 0: - return getDistancePeak0Distance(peak); + return getPeak0Distance(peak); break; case 1: - return getDistancePeak1Distance(peak); + return getPeak1Distance(peak); break; case 2: - return getDistancePeak2Distance(peak); + return getPeak2Distance(peak); break; case 3: - return getDistancePeak3Distance(peak); + return getPeak3Distance(peak); break; case 4: - return getDistancePeak4Distance(peak); + return getPeak4Distance(peak); break; case 5: - return getDistancePeak5Distance(peak); + return getPeak5Distance(peak); break; case 6: - return getDistancePeak6Distance(peak); + return getPeak6Distance(peak); break; case 7: - return getDistancePeak7Distance(peak); + return getPeak7Distance(peak); break; case 8: - return getDistancePeak8Distance(peak); + return getPeak8Distance(peak); break; case 9: - return getDistancePeak9Distance(peak); + return getPeak9Distance(peak); break; default: return ksfTkErrFail; @@ -407,7 +407,7 @@ sfTkError_t sfDevXM125Distance::getDistancePeakDistance(uint8_t num, uint32_t &p } } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistancePeak0Distance(uint32_t &peak) +sfTkError_t sfDevXM125Distance::getPeak0Distance(uint32_t &peak) { size_t readBytes = 0; sfTkError_t retVal = @@ -417,7 +417,7 @@ sfTkError_t sfDevXM125Distance::getDistancePeak0Distance(uint32_t &peak) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistancePeak1Distance(uint32_t &peak) +sfTkError_t sfDevXM125Distance::getPeak1Distance(uint32_t &peak) { size_t readBytes = 0; sfTkError_t retVal = @@ -427,7 +427,7 @@ sfTkError_t sfDevXM125Distance::getDistancePeak1Distance(uint32_t &peak) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistancePeak2Distance(uint32_t &peak) +sfTkError_t sfDevXM125Distance::getPeak2Distance(uint32_t &peak) { size_t readBytes = 0; sfTkError_t retVal = @@ -437,7 +437,7 @@ sfTkError_t sfDevXM125Distance::getDistancePeak2Distance(uint32_t &peak) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistancePeak3Distance(uint32_t &peak) +sfTkError_t sfDevXM125Distance::getPeak3Distance(uint32_t &peak) { size_t readBytes = 0; sfTkError_t retVal = @@ -447,7 +447,7 @@ sfTkError_t sfDevXM125Distance::getDistancePeak3Distance(uint32_t &peak) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistancePeak4Distance(uint32_t &peak) +sfTkError_t sfDevXM125Distance::getPeak4Distance(uint32_t &peak) { size_t readBytes = 0; sfTkError_t retVal = @@ -457,7 +457,7 @@ sfTkError_t sfDevXM125Distance::getDistancePeak4Distance(uint32_t &peak) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistancePeak5Distance(uint32_t &peak) +sfTkError_t sfDevXM125Distance::getPeak5Distance(uint32_t &peak) { size_t readBytes = 0; sfTkError_t retVal = @@ -467,7 +467,7 @@ sfTkError_t sfDevXM125Distance::getDistancePeak5Distance(uint32_t &peak) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistancePeak6Distance(uint32_t &peak) +sfTkError_t sfDevXM125Distance::getPeak6Distance(uint32_t &peak) { size_t readBytes = 0; sfTkError_t retVal = @@ -477,7 +477,7 @@ sfTkError_t sfDevXM125Distance::getDistancePeak6Distance(uint32_t &peak) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistancePeak7Distance(uint32_t &peak) +sfTkError_t sfDevXM125Distance::getPeak7Distance(uint32_t &peak) { size_t readBytes = 0; sfTkError_t retVal = @@ -487,7 +487,7 @@ sfTkError_t sfDevXM125Distance::getDistancePeak7Distance(uint32_t &peak) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistancePeak8Distance(uint32_t &peak) +sfTkError_t sfDevXM125Distance::getPeak8Distance(uint32_t &peak) { size_t readBytes = 0; sfTkError_t retVal = @@ -497,7 +497,7 @@ sfTkError_t sfDevXM125Distance::getDistancePeak8Distance(uint32_t &peak) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistancePeak9Distance(uint32_t &peak) +sfTkError_t sfDevXM125Distance::getPeak9Distance(uint32_t &peak) { size_t readBytes = 0; sfTkError_t retVal = @@ -507,41 +507,41 @@ sfTkError_t sfDevXM125Distance::getDistancePeak9Distance(uint32_t &peak) } //-------------------------------------------------------------------------------- // Generic distance peak strength method -sfTkError_t sfDevXM125Distance::getDistancePeakStrength(uint8_t num, int32_t &peak) +sfTkError_t sfDevXM125Distance::getPeakStrength(uint8_t num, int32_t &peak) { switch (num) { case 0: - return getDistancePeak0Strength(peak); + return getPeak0Strength(peak); break; case 1: - return getDistancePeak1Strength(peak); + return getPeak1Strength(peak); break; case 2: - return getDistancePeak2Strength(peak); + return getPeak2Strength(peak); break; case 3: - return getDistancePeak3Strength(peak); + return getPeak3Strength(peak); break; case 4: - return getDistancePeak4Strength(peak); + return getPeak4Strength(peak); break; case 5: - return getDistancePeak5Strength(peak); + return getPeak5Strength(peak); break; case 6: - return getDistancePeak6Strength(peak); + return getPeak6Strength(peak); break; case 7: - return getDistancePeak7Strength(peak); + return getPeak7Strength(peak); break; case 8: - return getDistancePeak8Strength(peak); + return getPeak8Strength(peak); break; case 9: - return getDistancePeak9Strength(peak); + return getPeak9Strength(peak); break; default: return ksfTkErrFail; @@ -549,7 +549,7 @@ sfTkError_t sfDevXM125Distance::getDistancePeakStrength(uint8_t num, int32_t &pe } } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistancePeak0Strength(int32_t &peak) +sfTkError_t sfDevXM125Distance::getPeak0Strength(int32_t &peak) { size_t readBytes = 0; sfTkError_t retVal = @@ -560,7 +560,7 @@ sfTkError_t sfDevXM125Distance::getDistancePeak0Strength(int32_t &peak) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistancePeak1Strength(int32_t &peak) +sfTkError_t sfDevXM125Distance::getPeak1Strength(int32_t &peak) { size_t readBytes = 0; sfTkError_t retVal = @@ -571,7 +571,7 @@ sfTkError_t sfDevXM125Distance::getDistancePeak1Strength(int32_t &peak) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistancePeak2Strength(int32_t &peak) +sfTkError_t sfDevXM125Distance::getPeak2Strength(int32_t &peak) { size_t readBytes = 0; sfTkError_t retVal = @@ -582,7 +582,7 @@ sfTkError_t sfDevXM125Distance::getDistancePeak2Strength(int32_t &peak) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistancePeak3Strength(int32_t &peak) +sfTkError_t sfDevXM125Distance::getPeak3Strength(int32_t &peak) { size_t readBytes = 0; sfTkError_t retVal = @@ -593,7 +593,7 @@ sfTkError_t sfDevXM125Distance::getDistancePeak3Strength(int32_t &peak) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistancePeak4Strength(int32_t &peak) +sfTkError_t sfDevXM125Distance::getPeak4Strength(int32_t &peak) { size_t readBytes = 0; sfTkError_t retVal = @@ -604,7 +604,7 @@ sfTkError_t sfDevXM125Distance::getDistancePeak4Strength(int32_t &peak) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistancePeak5Strength(int32_t &peak) +sfTkError_t sfDevXM125Distance::getPeak5Strength(int32_t &peak) { size_t readBytes = 0; sfTkError_t retVal = @@ -615,7 +615,7 @@ sfTkError_t sfDevXM125Distance::getDistancePeak5Strength(int32_t &peak) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistancePeak6Strength(int32_t &peak) +sfTkError_t sfDevXM125Distance::getPeak6Strength(int32_t &peak) { size_t readBytes = 0; sfTkError_t retVal = @@ -626,7 +626,7 @@ sfTkError_t sfDevXM125Distance::getDistancePeak6Strength(int32_t &peak) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistancePeak7Strength(int32_t &peak) +sfTkError_t sfDevXM125Distance::getPeak7Strength(int32_t &peak) { size_t readBytes = 0; sfTkError_t retVal = @@ -637,7 +637,7 @@ sfTkError_t sfDevXM125Distance::getDistancePeak7Strength(int32_t &peak) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistancePeak8Strength(int32_t &peak) +sfTkError_t sfDevXM125Distance::getPeak8Strength(int32_t &peak) { size_t readBytes = 0; sfTkError_t retVal = @@ -648,7 +648,7 @@ sfTkError_t sfDevXM125Distance::getDistancePeak8Strength(int32_t &peak) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistancePeak9Strength(int32_t &peak) +sfTkError_t sfDevXM125Distance::getPeak9Strength(int32_t &peak) { size_t readBytes = 0; sfTkError_t retVal = @@ -659,7 +659,7 @@ sfTkError_t sfDevXM125Distance::getDistancePeak9Strength(int32_t &peak) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistanceStart(uint32_t &startVal) +sfTkError_t sfDevXM125Distance::getStart(uint32_t &startVal) { size_t readBytes = 0; sfTkError_t retVal = @@ -669,14 +669,14 @@ sfTkError_t sfDevXM125Distance::getDistanceStart(uint32_t &startVal) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::setDistanceStart(uint32_t start) +sfTkError_t sfDevXM125Distance::setStart(uint32_t start) { start = sftk_byte_swap(start); return _theBus->writeRegister(SFE_XM125_DISTANCE_START, (uint8_t *)&start, sizeof(uint32_t)); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistanceEnd(uint32_t &end) +sfTkError_t sfDevXM125Distance::getEnd(uint32_t &end) { size_t readBytes = 0; sfTkError_t retVal = _theBus->readRegister(SFE_XM125_DISTANCE_END, (uint8_t *)&end, sizeof(uint32_t), readBytes); @@ -685,14 +685,14 @@ sfTkError_t sfDevXM125Distance::getDistanceEnd(uint32_t &end) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::setDistanceEnd(uint32_t end) +sfTkError_t sfDevXM125Distance::setEnd(uint32_t end) { end = sftk_byte_swap(end); return _theBus->writeRegister(SFE_XM125_DISTANCE_END, (uint8_t *)&end, sizeof(uint32_t)); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistanceMaxStepLength(uint32_t &length) +sfTkError_t sfDevXM125Distance::getMaxStepLength(uint32_t &length) { size_t readBytes = 0; sfTkError_t retVal = @@ -702,14 +702,14 @@ sfTkError_t sfDevXM125Distance::getDistanceMaxStepLength(uint32_t &length) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::setDistanceMaxStepLength(uint32_t length) +sfTkError_t sfDevXM125Distance::setMaxStepLength(uint32_t length) { length = sftk_byte_swap(length); return _theBus->writeRegister(SFE_XM125_DISTANCE_MAX_STEP_LENGTH, (uint8_t *)&length, sizeof(uint32_t)); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistanceCloseRangeLeakageCancellation(bool &range) +sfTkError_t sfDevXM125Distance::getCloseRangeLeakageCancellation(bool &range) { size_t readBytes = 0; uint8_t readVal = 0; @@ -723,14 +723,14 @@ sfTkError_t sfDevXM125Distance::getDistanceCloseRangeLeakageCancellation(bool &r } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::setDistanceCloseRangeLeakageCancellation(bool range) +sfTkError_t sfDevXM125Distance::setCloseRangeLeakageCancellation(bool range) { uint8_t value = range ? 1 : 0; return _theBus->writeRegister(SFE_XM125_DISTANCE_CLOSE_RANGE_LEAKAGE, &value, sizeof(value)); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistanceSignalQuality(uint32_t &signal) +sfTkError_t sfDevXM125Distance::getSignalQuality(uint32_t &signal) { size_t readBytes = 0; sfTkError_t retVal = @@ -740,14 +740,14 @@ sfTkError_t sfDevXM125Distance::getDistanceSignalQuality(uint32_t &signal) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::setDistanceSignalQuality(uint32_t signal) +sfTkError_t sfDevXM125Distance::setSignalQuality(uint32_t signal) { signal = sftk_byte_swap(signal); return _theBus->writeRegister(SFE_XM125_DISTANCE_SIGNAL_QUALITY, (uint8_t *)&signal, sizeof(uint32_t)); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistanceMaxProfile(uint32_t &profile) +sfTkError_t sfDevXM125Distance::getMaxProfile(uint32_t &profile) { size_t readBytes = 0; sfTkError_t retVal = @@ -757,14 +757,14 @@ sfTkError_t sfDevXM125Distance::getDistanceMaxProfile(uint32_t &profile) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::setDistanceMaxProfile(uint32_t profile) +sfTkError_t sfDevXM125Distance::setMaxProfile(uint32_t profile) { profile = sftk_byte_swap(profile); return _theBus->writeRegister(SFE_XM125_DISTANCE_MAX_PROFILE, (uint8_t *)&profile, sizeof(uint32_t)); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistanceThresholdMethod(uint32_t &method) +sfTkError_t sfDevXM125Distance::getThresholdMethod(uint32_t &method) { size_t readBytes = 0; sfTkError_t retVal = @@ -774,14 +774,14 @@ sfTkError_t sfDevXM125Distance::getDistanceThresholdMethod(uint32_t &method) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::setDistanceThresholdMethod(uint32_t method) +sfTkError_t sfDevXM125Distance::setThresholdMethod(uint32_t method) { method = sftk_byte_swap(method); return _theBus->writeRegister(SFE_XM125_DISTANCE_THRESHOLD_METHOD, (uint8_t *)&method, sizeof(uint32_t)); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistancePeakSorting(uint32_t &peak) +sfTkError_t sfDevXM125Distance::getPeakSorting(uint32_t &peak) { size_t readBytes = 0; sfTkError_t retVal = @@ -791,14 +791,14 @@ sfTkError_t sfDevXM125Distance::getDistancePeakSorting(uint32_t &peak) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::setDistancePeakSorting(uint32_t peak) +sfTkError_t sfDevXM125Distance::setPeakSorting(uint32_t peak) { peak = sftk_byte_swap(peak); return _theBus->writeRegister(SFE_XM125_DISTANCE_PEAK_SORTING, (uint8_t *)&peak, sizeof(uint32_t)); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistanceNumFramesRecordedThreshold(uint32_t &thresh) +sfTkError_t sfDevXM125Distance::getNumFramesRecordedThreshold(uint32_t &thresh) { size_t readBytes = 0; sfTkError_t retVal = _theBus->readRegister(SFE_XM125_DISTANCE_NUM_FRAMES_RECORDED_THRESH, (uint8_t *)&thresh, @@ -808,14 +808,14 @@ sfTkError_t sfDevXM125Distance::getDistanceNumFramesRecordedThreshold(uint32_t & } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::setDistanceNumFramesRecordedThreshold(uint32_t thresh) +sfTkError_t sfDevXM125Distance::setNumFramesRecordedThreshold(uint32_t thresh) { thresh = sftk_byte_swap(thresh); return _theBus->writeRegister(SFE_XM125_DISTANCE_NUM_FRAMES_RECORDED_THRESH, (uint8_t *)&thresh, sizeof(uint32_t)); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistanceFixedAmpThreshold(uint32_t &thresh) +sfTkError_t sfDevXM125Distance::getFixedAmpThreshold(uint32_t &thresh) { size_t readBytes = 0; sfTkError_t retVal = _theBus->readRegister(SFE_XM125_DISTANCE_FIXED_AMPLITUDE_THRESHOLD_VAL, (uint8_t *)&thresh, @@ -825,7 +825,7 @@ sfTkError_t sfDevXM125Distance::getDistanceFixedAmpThreshold(uint32_t &thresh) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::setDistanceFixedAmpThreshold(uint32_t thresh) +sfTkError_t sfDevXM125Distance::setFixedAmpThreshold(uint32_t thresh) { thresh = sftk_byte_swap(thresh); return _theBus->writeRegister(SFE_XM125_DISTANCE_FIXED_AMPLITUDE_THRESHOLD_VAL, (uint8_t *)&thresh, @@ -833,7 +833,7 @@ sfTkError_t sfDevXM125Distance::setDistanceFixedAmpThreshold(uint32_t thresh) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistanceThresholdSensitivity(uint32_t &thresh) +sfTkError_t sfDevXM125Distance::getThresholdSensitivity(uint32_t &thresh) { size_t readBytes = 0; sfTkError_t retVal = _theBus->readRegister(SFE_XM125_DISTANCE_THREHSOLD_SENSITIVITY, (uint8_t *)&thresh, @@ -843,14 +843,14 @@ sfTkError_t sfDevXM125Distance::getDistanceThresholdSensitivity(uint32_t &thresh } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::setDistanceThresholdSensitivity(uint32_t thresh) +sfTkError_t sfDevXM125Distance::setThresholdSensitivity(uint32_t thresh) { thresh = sftk_byte_swap(thresh); return _theBus->writeRegister(SFE_XM125_DISTANCE_THREHSOLD_SENSITIVITY, (uint8_t *)&thresh, sizeof(uint32_t)); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistanceReflectorShape(uint32_t &shape) +sfTkError_t sfDevXM125Distance::getReflectorShape(uint32_t &shape) { size_t readBytes = 0; sfTkError_t retVal = @@ -860,14 +860,14 @@ sfTkError_t sfDevXM125Distance::getDistanceReflectorShape(uint32_t &shape) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::setDistanceReflectorShape(uint32_t shape) +sfTkError_t sfDevXM125Distance::setReflectorShape(uint32_t shape) { shape = sftk_byte_swap(shape); return _theBus->writeRegister(SFE_XM125_DISTANCE_REFLECTOR_SHAPE, (uint8_t *)&shape, sizeof(uint32_t)); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistanceFixedStrengthThresholdValue(int32_t &thresh) +sfTkError_t sfDevXM125Distance::getFixedStrengthThresholdValue(int32_t &thresh) { size_t readBytes = 0; sfTkError_t retVal = _theBus->readRegister(SFE_XM125_DISTANCE_FIXED_STRENGTH_THRESHOLD_VAL, (uint8_t *)&thresh, @@ -877,14 +877,14 @@ sfTkError_t sfDevXM125Distance::getDistanceFixedStrengthThresholdValue(int32_t & } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::setDistanceFixedStrengthThresholdValue(int32_t thresh) +sfTkError_t sfDevXM125Distance::setFixedStrengthThresholdValue(int32_t thresh) { thresh = sftk_byte_swap(thresh); return _theBus->writeRegister(SFE_XM125_DISTANCE_FIXED_STRENGTH_THRESHOLD_VAL, (uint8_t *)&thresh, sizeof(int32_t)); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::getDistanceMeasureOneWakeup(bool &measure) +sfTkError_t sfDevXM125Distance::getMeasureOneWakeup(bool &measure) { size_t readBytes = 0; uint8_t value; @@ -895,75 +895,75 @@ sfTkError_t sfDevXM125Distance::getDistanceMeasureOneWakeup(bool &measure) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::setDistanceMeasureOneWakeup(bool measure) +sfTkError_t sfDevXM125Distance::setMeasureOneWakeup(bool measure) { uint8_t value = static_cast(measure); return _theBus->writeRegister(SFE_XM125_DISTANCE_MEASURE_ON_WAKEUP, (uint8_t *)&value, sizeof(uint8_t)); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::setDistanceCommand(uint32_t command) +sfTkError_t sfDevXM125Distance::setCommand(uint32_t command) { command = sftk_byte_swap(command); return _theBus->writeRegister(SFE_XM125_DISTANCE_COMMAND, (uint8_t *)&command, sizeof(uint32_t)); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::distanceApplyConfiguration() +sfTkError_t sfDevXM125Distance::applyConfiguration() { - return setDistanceCommand(SFE_XM125_DISTANCE_APPLY_CONFIGURATION); + return setCommand(SFE_XM125_DISTANCE_APPLY_CONFIGURATION); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::distanceStart() +sfTkError_t sfDevXM125Distance::start() { - return setDistanceCommand(SFE_XM125_DISTANCE_START_DETECTOR); + return setCommand(SFE_XM125_DISTANCE_START_DETECTOR); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::distanceStop() +sfTkError_t sfDevXM125Distance::stop() { - return setDistanceCommand(SFE_XM125_DISTANCE_STOP_DETECTOR); + return setCommand(SFE_XM125_DISTANCE_STOP_DETECTOR); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::distanceCalibrate() +sfTkError_t sfDevXM125Distance::calibrate() { - return setDistanceCommand(SFE_XM125_DISTANCE_CALIBRATE); + return setCommand(SFE_XM125_DISTANCE_CALIBRATE); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::distanceRecalibrate() +sfTkError_t sfDevXM125Distance::recalibrate() { - return setDistanceCommand(SFE_XM125_DISTANCE_RECALIBRATE); + return setCommand(SFE_XM125_DISTANCE_RECALIBRATE); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::distanceEnableUartLogs() +sfTkError_t sfDevXM125Distance::enableUartLogs() { - return setDistanceCommand(SFE_XM125_DISTANCE_ENABLE_UART_LOGS); + return setCommand(SFE_XM125_DISTANCE_ENABLE_UART_LOGS); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::distanceDisableUartLogs() +sfTkError_t sfDevXM125Distance::disableUartLogs() { - return setDistanceCommand(SFE_XM125_DISTANCE_DISABLE_UART_LOGS); + return setCommand(SFE_XM125_DISTANCE_DISABLE_UART_LOGS); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::distanceLogConfiguration() +sfTkError_t sfDevXM125Distance::logConfiguration() { - return setDistanceCommand(SFE_XM125_DISTANCE_LOG_CONFIGURATION); + return setCommand(SFE_XM125_DISTANCE_LOG_CONFIGURATION); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::distanceReset() +sfTkError_t sfDevXM125Distance::reset() { - return setDistanceCommand(SFE_XM125_DISTANCE_RESET_MODULE); + return setCommand(SFE_XM125_DISTANCE_RESET_MODULE); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Distance::distanceBusyWait() +sfTkError_t sfDevXM125Distance::busyWait() { sfTkError_t retVal = 0; uint32_t regVal = 0; diff --git a/src/sfTk/sfDevXM125Distance.h b/src/sfTk/sfDevXM125Distance.h index 487888f..f672671 100644 --- a/src/sfTk/sfDevXM125Distance.h +++ b/src/sfTk/sfDevXM125Distance.h @@ -283,67 +283,67 @@ class sfDevXM125Distance : public sfDevXM125Core /// @brief This function sets all the beginning values for a basic I2C /// example to be run on the device for presence sensing. /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t distanceBegin(uint32_t start = sfe_xm125_distance_start_default, + sfTkError_t distanceSetup(uint32_t start = sfe_xm125_distance_start_default, uint32_t end = sfe_xm125_distance_end_default); /// @brief This function does all the required checks and busy waits to /// make sure the device is ready for distance readings. /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t distanceDetectorReadingSetup(); + sfTkError_t detectorReadingSetup(); /// @brief This function returns the version number of the device /// structure: major.minor.patch /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistanceDetectorVersion(uint32_t &major, uint32_t &minor, uint32_t &patch); + sfTkError_t getDetectorVersion(uint32_t &major, uint32_t &minor, uint32_t &patch); /// @brief This function returns if there was an error from the /// protocol status register /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistanceDetectorError(uint32_t &error); + sfTkError_t getDetectorError(uint32_t &error); /// @brief This function returns the error status according to the bit /// mask value for the distance devices errors and busy bit /// @param status Error status of device (see function for exact error) /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistanceDetectorErrorStatus(uint32_t &status); + sfTkError_t getDetectorErrorStatus(uint32_t &status); /// @brief This function returns the measure counter, the number of measurements /// performed since restart. /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistanceMeasureCounter(uint32_t &counter); + sfTkError_t getMeasureCounter(uint32_t &counter); /// @brief This function returns the status of the device if there are any issues /// with any of the status's listed defined. /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistanceDetectorStatus(uint32_t &status); + sfTkError_t getDetectorStatus(uint32_t &status); /// @brief This function returns the number of detected distances. /// @param distance Number of detected distances /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistanceNumberDistances(uint32_t &distance); + sfTkError_t getNumberDistances(uint32_t &distance); /// @brief This function returns the indication that there might be an object /// near the start point of the measured range. /// @param edge Flag to determine object in range /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistanceNearStartEdge(uint32_t &edge); + sfTkError_t getNearStartEdge(uint32_t &edge); /// @brief This function returns the indication of a sensor calibration needed. /// @param calibrate Flag to indicate calibration required /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistanceCalibrationNeeded(uint32_t &calibrate); + sfTkError_t getCalibrationNeeded(uint32_t &calibrate); /// @brief This function returns if the measure command failed. /// @param error Flag to indicate measure command error /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistanceMeasureDistanceError(uint32_t &error); + sfTkError_t getMeasureDistanceError(uint32_t &error); /// @brief This function returns the temperature in sensor during measurements /// (in degree Celsius). Note that it has poor absolute accuracy and should /// only be used for relative temperature measurements. /// @param temperature Relative temperature of device /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistanceTemperature(int16_t &temperature); + sfTkError_t getTemperature(int16_t &temperature); //-------------------------------------------------------------------------------- // Generic distance peak distance method @@ -352,57 +352,57 @@ class sfDevXM125Distance : public sfDevXM125Core /// @param num Peak number to get distance (0-9) /// @param peak Distance to peak num /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistancePeakDistance(uint8_t num, uint32_t &peak); + sfTkError_t getPeakDistance(uint8_t num, uint32_t &peak); /// @brief This function returns the distance to peak 0 /// Note: This value is a factor 1000 larger than the RSS value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistancePeak0Distance(uint32_t &peak); + sfTkError_t getPeak0Distance(uint32_t &peak); /// @brief This function returns the distance to peak 1 /// Note: This value is a factor 1000 larger than the RSS value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistancePeak1Distance(uint32_t &peak); + sfTkError_t getPeak1Distance(uint32_t &peak); /// @brief This function returns the distance to peak 2 /// Note: This value is a factor 1000 larger than the RSS value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistancePeak2Distance(uint32_t &peak); + sfTkError_t getPeak2Distance(uint32_t &peak); /// @brief This function returns the distance to peak 3 /// Note: This value is a factor 1000 larger than the RSS value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistancePeak3Distance(uint32_t &peak); + sfTkError_t getPeak3Distance(uint32_t &peak); /// @brief This function returns the distance to peak 4 /// Note: This value is a factor 1000 larger than the RSS value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistancePeak4Distance(uint32_t &peak); + sfTkError_t getPeak4Distance(uint32_t &peak); /// @brief This function returns the distance to peak 5 /// Note: This value is a factor 1000 larger than the RSS value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistancePeak5Distance(uint32_t &peak); + sfTkError_t getPeak5Distance(uint32_t &peak); /// @brief This function returns the distance to peak 6 /// Note: This value is a factor 1000 larger than the RSS value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistancePeak6Distance(uint32_t &peak); + sfTkError_t getPeak6Distance(uint32_t &peak); /// @brief This function returns the distance to peak 7 /// Note: This value is a factor 1000 larger than the RSS value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistancePeak7Distance(uint32_t &peak); + sfTkError_t getPeak7Distance(uint32_t &peak); /// @brief This function returns the distance to peak 8 /// Note: This value is a factor 1000 larger than the RSS value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistancePeak8Distance(uint32_t &peak); + sfTkError_t getPeak8Distance(uint32_t &peak); /// @brief This function returns the distance to peak 9 /// Note: This value is a factor 1000 larger than the RSS value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistancePeak9Distance(uint32_t &peak); + sfTkError_t getPeak9Distance(uint32_t &peak); //-------------------------------------------------------------------------------- // Generic distance peak strength method @@ -411,180 +411,180 @@ class sfDevXM125Distance : public sfDevXM125Core /// @param num Peak number to get strength (0-9) /// @param peak strength to peak num /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistancePeakStrength(uint8_t num, int32_t &peak); + sfTkError_t getPeakStrength(uint8_t num, int32_t &peak); /// @brief This function returns the strength of peak 0 /// Note: This value is a factor 1000 larger than the RSS value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistancePeak0Strength(int32_t &peak); + sfTkError_t getPeak0Strength(int32_t &peak); /// @brief This function returns the strength of peak 1 /// Note: This value is a factor 1000 larger than the RSS value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistancePeak1Strength(int32_t &peak); + sfTkError_t getPeak1Strength(int32_t &peak); /// @brief This function returns the strength of peak 2 /// Note: This value is a factor 1000 larger than the RSS value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistancePeak2Strength(int32_t &peak); + sfTkError_t getPeak2Strength(int32_t &peak); /// @brief This function returns the strength of peak 3 /// Note: This value is a factor 1000 larger than the RSS value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistancePeak3Strength(int32_t &peak); + sfTkError_t getPeak3Strength(int32_t &peak); /// @brief This function returns the strength of peak 4 /// Note: This value is a factor 1000 larger than the RSS value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistancePeak4Strength(int32_t &peak); + sfTkError_t getPeak4Strength(int32_t &peak); /// @brief This function returns the strength of peak 5 /// Note: This value is a factor 1000 larger than the RSS value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistancePeak5Strength(int32_t &peak); + sfTkError_t getPeak5Strength(int32_t &peak); /// @brief This function returns the strength of peak 6 /// Note: This value is a factor 1000 larger than the RSS value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistancePeak6Strength(int32_t &peak); + sfTkError_t getPeak6Strength(int32_t &peak); /// @brief This function returns the strength of peak 7 /// Note: This value is a factor 1000 larger than the RSS value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistancePeak7Strength(int32_t &peak); + sfTkError_t getPeak7Strength(int32_t &peak); /// @brief This function returns the strength of peak 8 /// Note: This value is a factor 1000 larger than the RSS value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistancePeak8Strength(int32_t &peak); + sfTkError_t getPeak8Strength(int32_t &peak); /// @brief This function returns the strength of peak 9 /// Note: This value is a factor 1000 larger than the RSS value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistancePeak9Strength(int32_t &peak); + sfTkError_t getPeak9Strength(int32_t &peak); /// @brief This function returns the start of measured interval /// in millimeters. /// Note: This value is a factor 1000 larger than the RSS value /// Default Value: 250 /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistanceStart(uint32_t &startVal); + sfTkError_t getStart(uint32_t &startVal); /// @brief This function sets the start of measured interval in /// millimeters. /// Note: This value is a factor 1000 larger than the RSS value /// Default Value: 250 /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setDistanceStart(uint32_t start); + sfTkError_t setStart(uint32_t start); /// @brief This function returns the end of measured interval /// in millimeters. /// Note: This value is a factor 1000 larger than the RSS value /// Default Value: 3000 /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistanceEnd(uint32_t &end); + sfTkError_t getEnd(uint32_t &end); /// @brief This function sets the end of measured interval /// in millimeters. /// Note: This value is a factor 1000 larger than the RSS value /// Default Value: 3000 /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setDistanceEnd(uint32_t end); + sfTkError_t setEnd(uint32_t end); /// @brief This function returns the used to limit step length. /// If set to 0 (default), the step length is calculated /// based on profile. /// Default Value: 0 /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistanceMaxStepLength(uint32_t &length); + sfTkError_t getMaxStepLength(uint32_t &length); /// @brief This function sets the used to limit step length. /// If set to 0 (default), the step length is calculated /// based on profile. /// Default Value: 0 /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setDistanceMaxStepLength(uint32_t length); + sfTkError_t setMaxStepLength(uint32_t length); /// @brief This function reads if the close range leakage /// cancellation logic is enabled. /// Default Value: true /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistanceCloseRangeLeakageCancellation(bool &range); + sfTkError_t getCloseRangeLeakageCancellation(bool &range); /// @brief This function sets the close range leakage /// cancellation logic. /// Default Value: true /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setDistanceCloseRangeLeakageCancellation(bool range); + sfTkError_t setCloseRangeLeakageCancellation(bool range); /// @brief This function returns the high signal quality in a /// better SNR (because of higher HWAAS) and higher power consumption. /// Note: This value is a factor 1000 larger than the RSS value /// Default Value: 15000 /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistanceSignalQuality(uint32_t &signal); + sfTkError_t getSignalQuality(uint32_t &signal); /// @brief This function sets the high signal quality in a /// better SNR (because of higher HWAAS) and higher power consumption. /// Note: This value is a factor 1000 larger than the RSS value /// Default Value: 15000 /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setDistanceSignalQuality(uint32_t signal); + sfTkError_t setSignalQuality(uint32_t signal); /// @brief This function returns the max profile of the device. /// Default value = PROFILE5 /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistanceMaxProfile(uint32_t &profile); + sfTkError_t getMaxProfile(uint32_t &profile); /// @brief This function sets the max profile of the device /// Default value = PROFILE5 /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setDistanceMaxProfile(uint32_t profile); + sfTkError_t setMaxProfile(uint32_t profile); /// @brief This function returns the threshold method /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistanceThresholdMethod(uint32_t &method); + sfTkError_t getThresholdMethod(uint32_t &method); /// @brief This function sets the threshold method /// @param method Threshold method (enum) /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setDistanceThresholdMethod(uint32_t method); + sfTkError_t setThresholdMethod(uint32_t method); /// @brief This function returns the peak sorting method /// @param peak Peak sorting method /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistancePeakSorting(uint32_t &peak); + sfTkError_t getPeakSorting(uint32_t &peak); /// @brief This function sets the peak sorting method /// @param peak Peak sorting method /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setDistancePeakSorting(uint32_t peak); + sfTkError_t setPeakSorting(uint32_t peak); /// @brief This function returns the number frames to use for recorded threshold. /// Default Value: 100 /// @param thresh Number of frames /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistanceNumFramesRecordedThreshold(uint32_t &thresh); + sfTkError_t getNumFramesRecordedThreshold(uint32_t &thresh); /// @brief This function sets the number frames to use for recorded threshold. /// Default Value: 100 /// @param thresh Number of frames /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setDistanceNumFramesRecordedThreshold(uint32_t thresh); + sfTkError_t setNumFramesRecordedThreshold(uint32_t thresh); /// @brief This function returns the fixed amplitude threshold value. /// Note: This value is a factor 1000 larger than the RSS value /// Default Value: 100000 /// @param thresh Fixed amplitude threshold value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistanceFixedAmpThreshold(uint32_t &thresh); + sfTkError_t getFixedAmpThreshold(uint32_t &thresh); /// @brief This function sets the fixed amplitude threshold value. /// Note: This value is a factor 1000 larger than the RSS value /// Default Value: 100000 /// @param thresh Fixed amplitude threshold value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setDistanceFixedAmpThreshold(uint32_t thresh); + sfTkError_t setFixedAmpThreshold(uint32_t thresh); /// @brief This function returns the threshold sensitivity /// (0 <= sensitivity <= 1000) @@ -592,7 +592,7 @@ class sfDevXM125Distance : public sfDevXM125Core /// Default Value: 500 /// @param thresh& Threshold sensitivity /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistanceThresholdSensitivity(uint32_t &thresh); + sfTkError_t getThresholdSensitivity(uint32_t &thresh); /// @brief This function sets the threshold sensitivity /// (0 <= sensitivity <= 1000) @@ -600,99 +600,99 @@ class sfDevXM125Distance : public sfDevXM125Core /// Default Value: 500 /// @param thresh Threshold sensitivity /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setDistanceThresholdSensitivity(uint32_t thresh); + sfTkError_t setThresholdSensitivity(uint32_t thresh); /// @brief This function returns the reflector shape /// Default Value: GENERIC /// @param shape Generic or planar reflection /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistanceReflectorShape(uint32_t &shape); + sfTkError_t getReflectorShape(uint32_t &shape); /// @brief This function sets the reflector shape /// Default Value: GENERIC /// @param shape Generic or planar reflection /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setDistanceReflectorShape(uint32_t shape); + sfTkError_t setReflectorShape(uint32_t shape); /// @brief This function returns the fixed strength threshold value. /// Default Value: 0 /// Note: This value is a factor 1000 larger than the RSS value /// @param thresh fixed threshold strength value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistanceFixedStrengthThresholdValue(int32_t &thresh); + sfTkError_t getFixedStrengthThresholdValue(int32_t &thresh); /// @brief This function sets the fixed strength threshold value. /// Default Value: 0 /// Note: This value is a factor 1000 larger than the RSS value /// @param thresh fixed threshold strength value /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setDistanceFixedStrengthThresholdValue(int32_t thresh); + sfTkError_t setFixedStrengthThresholdValue(int32_t thresh); /// @brief This function returns the measure on wakeup status. /// Default Value: false /// @param measure Measure on wakeup occurrence /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getDistanceMeasureOneWakeup(bool &measure); + sfTkError_t getMeasureOneWakeup(bool &measure); /// @brief This function sets the measure on wakeup status. /// Default Value: false /// @param measure Measure on wakeup occurrence /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setDistanceMeasureOneWakeup(bool measure); + sfTkError_t setMeasureOneWakeup(bool measure); /// @brief This function sets the specific execute command as defined in the /// datasheet on Page 25, Section 6.2.40 Command. /// @param apply Enable configuration and calibrate /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setDistanceCommand(uint32_t command); + sfTkError_t setCommand(uint32_t command); /// @brief This function applies the configuration to the device by /// writing the defined value to the distance command register /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t distanceApplyConfiguration(); + sfTkError_t applyConfiguration(); /// @brief This function starts the device by writing the defined /// start value to the distance command register /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t distanceStart(); + sfTkError_t start(); /// @brief This function stops the device by writing the defined /// stop value to the distance command register /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t distanceStop(); + sfTkError_t stop(); /// @brief This function calibrates the device by writing the defined /// calibration value to the distance command register /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t distanceCalibrate(); + sfTkError_t calibrate(); /// @brief This function recalibrates the device by writing the defined /// recalibrate value to the distance command register /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t distanceRecalibrate(); + sfTkError_t recalibrate(); /// @brief This function enables the uart logs of the device by /// writing the defined value to the distance command register /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t distanceEnableUartLogs(); + sfTkError_t enableUartLogs(); /// @brief This function disables the uart logs of the device by /// writing the defined value to the distance command register /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t distanceDisableUartLogs(); + sfTkError_t disableUartLogs(); /// @brief This function enables the configuration log of the device /// by writing the defined value to the distance command register /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t distanceLogConfiguration(); + sfTkError_t logConfiguration(); /// @brief This function resets the distance detector settings /// of the device /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t distanceReset(); + sfTkError_t reset(); /// @brief Completes a busy wait loop while the device is uploading /// information by waiting for the status /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t distanceBusyWait(); + sfTkError_t busyWait(); }; \ No newline at end of file From df1b0809c1ec20c48457ea5da1189bf53deadc03 Mon Sep 17 00:00:00 2001 From: Kirk Benell Date: Sun, 23 Mar 2025 17:16:59 -0600 Subject: [PATCH 2/8] Defines a Version one interface for the distance object -- to maintain backward compatablity --- src/sfTk/sfDevXM125DistanceV1.h | 671 ++++++++++++++++++++++++++++++++ 1 file changed, 671 insertions(+) create mode 100644 src/sfTk/sfDevXM125DistanceV1.h diff --git a/src/sfTk/sfDevXM125DistanceV1.h b/src/sfTk/sfDevXM125DistanceV1.h new file mode 100644 index 0000000..6f725c7 --- /dev/null +++ b/src/sfTk/sfDevXM125DistanceV1.h @@ -0,0 +1,671 @@ +/** + * @file sfDevXM125DistanceV1.h + * @brief Header of the SparkFun Qwiic XM125 Library. + * + * This file contains the header the Distance Application V1 API backward compatiblity + * object + * + * @author SparkFun Electronics + * @date 2024-2025 + * @copyright Copyright (c) 2024-2025, SparkFun Electronics Inc. This project is released under the MIT License. + * + * SPDX-License-Identifier: MIT + */ +#pragma once + +#include "sfDevXM125Distance.h" + +// Distance class definition + +class sfDevXM125DistanceV1 : public sfDevXM125Distance +{ + public: + /** + * @brief Initializes the distance detector device. + * + * This function sets up the I2C communication and performs initial checks + * to ensure the device is ready for operation. + * + * @param theBus Pointer to the I2C bus object. If nullptr, the default bus is used. + * @return ksfTkErrOk on success, or error code (value < -1) on failure. + */ + sfTkError_t begin(sfTkII2C *theBus = nullptr) + { + return sfDevXM125Distance::begin(theBus); + } + + /// @brief This function sets all the beginning values for a basic I2C + /// example to be run on the device for presence sensing. + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t distanceBegin(uint32_t start = sfe_xm125_distance_start_default, + uint32_t end = sfe_xm125_distance_end_default) + { + return sfDevXM125Distance::distanceSetup(start, end); +} + + /// @brief This function does all the required checks and busy waits to + /// make sure the device is ready for distance readings. + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t distanceDetectorReadingSetup() + { + return sfDevXM125Distance::detectorReadingSetup(); + } + + /// @brief This function returns the version number of the device + /// structure: major.minor.patch + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistanceDetectorVersion(uint32_t &major, uint32_t &minor, uint32_t &patch) + { + return sfDevXM125Distance::getDetectorVersion(major, minor, patch); + } + + /// @brief This function returns if there was an error from the + /// protocol status register + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistanceDetectorError(uint32_t &error) + { + return sfDevXM125Distance::getDetectorError(error); + } + + /// @brief This function returns the error status according to the bit + /// mask value for the distance devices errors and busy bit + /// @param status Error status of device (see function for exact error) + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistanceDetectorErrorStatus(uint32_t &status) + { + return sfDevXM125Distance::getDetectorErrorStatus(status); + } + + /// @brief This function returns the measure counter, the number of measurements + /// performed since restart. + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistanceMeasureCounter(uint32_t &counter) + { + return sfDevXM125Distance::getMeasureCounter(counter); + } + + /// @brief This function returns the status of the device if there are any issues + /// with any of the status's listed defined. + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistanceDetectorStatus(uint32_t &status) + { + return sfDevXM125Distance::getDetectorStatus(status); + } + + /// @brief This function returns the number of detected distances. + /// @param distance Number of detected distances + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistanceNumberDistances(uint32_t &distance) + { + return sfDevXM125Distance::getNumberDistances(distance); + } + + /// @brief This function returns the indication that there might be an object + /// near the start point of the measured range. + /// @param edge Flag to determine object in range + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistanceNearStartEdge(uint32_t &edge) + { + return sfDevXM125Distance::getNearStartEdge(edge); + } + + /// @brief This function returns the indication of a sensor calibration needed. + /// @param calibrate Flag to indicate calibration required + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistanceCalibrationNeeded(uint32_t &calibrate) + { + return sfDevXM125Distance::getCalibrationNeeded(calibrate); + } + + /// @brief This function returns if the measure command failed. + /// @param error Flag to indicate measure command error + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistanceMeasureDistanceError(uint32_t &error) + { + return sfDevXM125Distance::getMeasureDistanceError(error); + } + + /// @brief This function returns the temperature in sensor during measurements + /// (in degree Celsius). Note that it has poor absolute accuracy and should + /// only be used for relative temperature measurements. + /// @param temperature Relative temperature of device + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistanceTemperature(int16_t &temperature) + { + return sfDevXM125Distance::getTemperature(temperature); + } + + //-------------------------------------------------------------------------------- + // Generic distance peak distance method + /// @brief This function returns the distance to peak num + /// Note: This value is a factor 1000 larger than the RSS value + /// @param num Peak number to get distance (0-9) + /// @param peak Distance to peak num + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistancePeakDistance(uint8_t num, uint32_t &peak) + { + return sfDevXM125Distance::getPeakDistance(num, peak); + } + + /// @brief This function returns the distance to peak 0 + /// Note: This value is a factor 1000 larger than the RSS value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistancePeak0Distance(uint32_t &peak) + { + return sfDevXM125Distance::getPeak0Distance(peak); + } + + /// @brief This function returns the distance to peak 1 + /// Note: This value is a factor 1000 larger than the RSS value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistancePeak1Distance(uint32_t &peak) + { + return sfDevXM125Distance::getPeak1Distance(peak); + } + + /// @brief This function returns the distance to peak 2 + /// Note: This value is a factor 1000 larger than the RSS value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistancePeak2Distance(uint32_t &peak) + { + return sfDevXM125Distance::getPeak2Distance(peak); + } + + /// @brief This function returns the distance to peak 3 + /// Note: This value is a factor 1000 larger than the RSS value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistancePeak3Distance(uint32_t &peak) + { + return sfDevXM125Distance::getPeak3Distance(peak); + } + + /// @brief This function returns the distance to peak 4 + /// Note: This value is a factor 1000 larger than the RSS value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistancePeak4Distance(uint32_t &peak) + { + return sfDevXM125Distance::getPeak4Distance(peak); + } + + /// @brief This function returns the distance to peak 5 + /// Note: This value is a factor 1000 larger than the RSS value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistancePeak5Distance(uint32_t &peak) + { + return sfDevXM125Distance::getPeak5Distance(peak); + } + + /// @brief This function returns the distance to peak 6 + /// Note: This value is a factor 1000 larger than the RSS value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistancePeak6Distance(uint32_t &peak) + { + return sfDevXM125Distance::getPeak6Distance(peak); + } + + /// @brief This function returns the distance to peak 7 + /// Note: This value is a factor 1000 larger than the RSS value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistancePeak7Distance(uint32_t &peak) + { + return sfDevXM125Distance::getPeak7Distance(peak); + } + + /// @brief This function returns the distance to peak 8 + /// Note: This value is a factor 1000 larger than the RSS value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistancePeak8Distance(uint32_t &peak) + { + return sfDevXM125Distance::getPeak8Distance(peak); + } + + /// @brief This function returns the distance to peak 9 + /// Note: This value is a factor 1000 larger than the RSS value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistancePeak9Distance(uint32_t &peak) + { + return sfDevXM125Distance::getPeak9Distance(peak); + } + + //-------------------------------------------------------------------------------- + // Generic distance peak strength method + /// @brief This function returns the strength to peak num + /// Note: This value is a factor 1000 larger than the RSS value + /// @param num Peak number to get strength (0-9) + /// @param peak strength to peak num + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistancePeakStrength(uint8_t num, int32_t &peak) + { + return sfDevXM125Distance::getPeakStrength(num, peak); + } + + /// @brief This function returns the strength of peak 0 + /// Note: This value is a factor 1000 larger than the RSS value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistancePeak0Strength(int32_t &peak) + { + return sfDevXM125Distance::getPeak0Strength(peak); + } + + /// @brief This function returns the strength of peak 1 + /// Note: This value is a factor 1000 larger than the RSS value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistancePeak1Strength(int32_t &peak) + { + return sfDevXM125Distance::getPeak1Strength(peak); + } + + /// @brief This function returns the strength of peak 2 + /// Note: This value is a factor 1000 larger than the RSS value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistancePeak2Strength(int32_t &peak) + { + return sfDevXM125Distance::getPeak2Strength(peak); + } + + /// @brief This function returns the strength of peak 3 + /// Note: This value is a factor 1000 larger than the RSS value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistancePeak3Strength(int32_t &peak) + { + return sfDevXM125Distance::getPeak3Strength(peak); + } + + /// @brief This function returns the strength of peak 4 + /// Note: This value is a factor 1000 larger than the RSS value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistancePeak4Strength(int32_t &peak) + { + return sfDevXM125Distance::getPeak4Strength(peak); + } + + /// @brief This function returns the strength of peak 5 + /// Note: This value is a factor 1000 larger than the RSS value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistancePeak5Strength(int32_t &peak) + { + return sfDevXM125Distance::getPeak5Strength(peak); + } + + /// @brief This function returns the strength of peak 6 + /// Note: This value is a factor 1000 larger than the RSS value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistancePeak6Strength(int32_t &peak) + { + return sfDevXM125Distance::getPeak6Strength(peak); + } + + /// @brief This function returns the strength of peak 7 + /// Note: This value is a factor 1000 larger than the RSS value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistancePeak7Strength(int32_t &peak) + { + return sfDevXM125Distance::getPeak7Strength(peak); + } + + /// @brief This function returns the strength of peak 8 + /// Note: This value is a factor 1000 larger than the RSS value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistancePeak8Strength(int32_t &peak) + { + return sfDevXM125Distance::getPeak8Strength(peak); + } + + /// @brief This function returns the strength of peak 9 + /// Note: This value is a factor 1000 larger than the RSS value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistancePeak9Strength(int32_t &peak) + { + return sfDevXM125Distance::getPeak9Strength(peak); + } + + /// @brief This function returns the start of measured interval + /// in millimeters. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 250 + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistanceStart(uint32_t &startVal) + { + return sfDevXM125Distance::getStart(startVal); + } + + /// @brief This function sets the start of measured interval in + /// millimeters. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 250 + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setDistanceStart(uint32_t start) + { + return sfDevXM125Distance::setStart(start); + } + + /// @brief This function returns the end of measured interval + /// in millimeters. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 3000 + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistanceEnd(uint32_t &end) + { + return sfDevXM125Distance::getEnd(end); + } + + /// @brief This function sets the end of measured interval + /// in millimeters. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 3000 + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setDistanceEnd(uint32_t end) + { + return sfDevXM125Distance::setEnd(end); + } + + /// @brief This function returns the used to limit step length. + /// If set to 0 (default), the step length is calculated + /// based on profile. + /// Default Value: 0 + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistanceMaxStepLength(uint32_t &length) + { + return sfDevXM125Distance::getMaxStepLength(length); + } + + /// @brief This function sets the used to limit step length. + /// If set to 0 (default), the step length is calculated + /// based on profile. + /// Default Value: 0 + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setDistanceMaxStepLength(uint32_t length) + { + return sfDevXM125Distance::setMaxStepLength(length); + } + + /// @brief This function reads if the close range leakage + /// cancellation logic is enabled. + /// Default Value: true + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistanceCloseRangeLeakageCancellation(bool &range) + { + return sfDevXM125Distance::getCloseRangeLeakageCancellation(range); + } + + /// @brief This function sets the close range leakage + /// cancellation logic. + /// Default Value: true + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setDistanceCloseRangeLeakageCancellation(bool range) + { + return sfDevXM125Distance::setCloseRangeLeakageCancellation(range); + } + + /// @brief This function returns the high signal quality in a + /// better SNR (because of higher HWAAS) and higher power consumption. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 15000 + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistanceSignalQuality(uint32_t &signal) + { + return sfDevXM125Distance::getSignalQuality(signal); + } + + /// @brief This function sets the high signal quality in a + /// better SNR (because of higher HWAAS) and higher power consumption. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 15000 + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setDistanceSignalQuality(uint32_t signal) + { + return sfDevXM125Distance::setSignalQuality(signal); + } + + /// @brief This function returns the max profile of the device. + /// Default value = PROFILE5 + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistanceMaxProfile(uint32_t &profile) + { + return sfDevXM125Distance::getMaxProfile(profile); + } + + /// @brief This function sets the max profile of the device + /// Default value = PROFILE5 + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setDistanceMaxProfile(uint32_t profile) + { + return sfDevXM125Distance::setMaxProfile(profile); + } + + /// @brief This function returns the threshold method + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistanceThresholdMethod(uint32_t &method) + { + return sfDevXM125Distance::getThresholdMethod(method); + } + + /// @brief This function sets the threshold method + /// @param method Threshold method (enum) + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setDistanceThresholdMethod(uint32_t method) + { + return sfDevXM125Distance::setThresholdMethod(method); + } + + /// @brief This function returns the peak sorting method + /// @param peak Peak sorting method + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistancePeakSorting(uint32_t &peak) + { + return sfDevXM125Distance::getPeakSorting(peak); + } + + /// @brief This function sets the peak sorting method + /// @param peak Peak sorting method + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setDistancePeakSorting(uint32_t peak) + { + return sfDevXM125Distance::setPeakSorting(peak); + } + + /// @brief This function returns the number frames to use for recorded threshold. + /// Default Value: 100 + /// @param thresh Number of frames + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistanceNumFramesRecordedThreshold(uint32_t &thresh) + { + return sfDevXM125Distance::getNumFramesRecordedThreshold(thresh); + } + + /// @brief This function sets the number frames to use for recorded threshold. + /// Default Value: 100 + /// @param thresh Number of frames + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setDistanceNumFramesRecordedThreshold(uint32_t thresh) + { + return sfDevXM125Distance::setNumFramesRecordedThreshold(thresh); + } + + /// @brief This function returns the fixed amplitude threshold value. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 100000 + /// @param thresh Fixed amplitude threshold value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistanceFixedAmpThreshold(uint32_t &thresh) + { + return sfDevXM125Distance::getFixedAmpThreshold(thresh); + } + + /// @brief This function sets the fixed amplitude threshold value. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 100000 + /// @param thresh Fixed amplitude threshold value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setDistanceFixedAmpThreshold(uint32_t thresh) + { + return sfDevXM125Distance::setFixedAmpThreshold(thresh); + } + + /// @brief This function returns the threshold sensitivity + /// (0 <= sensitivity <= 1000) + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 500 + /// @param thresh& Threshold sensitivity + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistanceThresholdSensitivity(uint32_t &thresh) + { + return sfDevXM125Distance::getThresholdSensitivity(thresh); + } + + /// @brief This function sets the threshold sensitivity + /// (0 <= sensitivity <= 1000) + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 500 + /// @param thresh Threshold sensitivity + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setDistanceThresholdSensitivity(uint32_t thresh) + { + return sfDevXM125Distance::setThresholdSensitivity(thresh); + } + + /// @brief This function returns the reflector shape + /// Default Value: GENERIC + /// @param shape Generic or planar reflection + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistanceReflectorShape(uint32_t &shape) + { + return sfDevXM125Distance::getReflectorShape(shape); + } + + /// @brief This function sets the reflector shape + /// Default Value: GENERIC + /// @param shape Generic or planar reflection + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setDistanceReflectorShape(uint32_t shape) + { + return sfDevXM125Distance::setReflectorShape(shape); + } + + /// @brief This function returns the fixed strength threshold value. + /// Default Value: 0 + /// Note: This value is a factor 1000 larger than the RSS value + /// @param thresh fixed threshold strength value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistanceFixedStrengthThresholdValue(int32_t &thresh) + { + return sfDevXM125Distance::getFixedStrengthThresholdValue(thresh); + } + + /// @brief This function sets the fixed strength threshold value. + /// Default Value: 0 + /// Note: This value is a factor 1000 larger than the RSS value + /// @param thresh fixed threshold strength value + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setDistanceFixedStrengthThresholdValue(int32_t thresh) + { + return sfDevXM125Distance::setFixedStrengthThresholdValue(thresh); + } + + /// @brief This function returns the measure on wakeup status. + /// Default Value: false + /// @param measure Measure on wakeup occurrence + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getDistanceMeasureOneWakeup(bool &measure) + { + return sfDevXM125Distance::getMeasureOneWakeup(measure); + } + + /// @brief This function sets the measure on wakeup status. + /// Default Value: false + /// @param measure Measure on wakeup occurrence + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setDistanceMeasureOneWakeup(bool measure) + { + return sfDevXM125Distance::setMeasureOneWakeup(measure); + } + + /// @brief This function sets the specific execute command as defined in the + /// datasheet on Page 25, Section 6.2.40 Command. + /// @param apply Enable configuration and calibrate + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setDistanceCommand(uint32_t command) + { + return sfDevXM125Distance::setCommand(command); + } + + /// @brief This function applies the configuration to the device by + /// writing the defined value to the distance command register + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t distanceApplyConfiguration() + { + return sfDevXM125Distance::applyConfiguration(); + } + + /// @brief This function starts the device by writing the defined + /// start value to the distance command register + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t distanceStart() + { + return sfDevXM125Distance::start(); + } + + /// @brief This function stops the device by writing the defined + /// stop value to the distance command register + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t distanceStop() + { + return sfDevXM125Distance::stop(); + } + + /// @brief This function calibrates the device by writing the defined + /// calibration value to the distance command register + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t distanceCalibrate() + { + return sfDevXM125Distance::calibrate(); + } + + /// @brief This function recalibrates the device by writing the defined + /// recalibrate value to the distance command register + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t distanceRecalibrate() + { + return sfDevXM125Distance::recalibrate(); + } + + /// @brief This function enables the uart logs of the device by + /// writing the defined value to the distance command register + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t distanceEnableUartLogs() + { + return sfDevXM125Distance::enableUartLogs(); + } + + /// @brief This function disables the uart logs of the device by + /// writing the defined value to the distance command register + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t distanceDisableUartLogs() + { + return sfDevXM125Distance::disableUartLogs(); + } + + /// @brief This function enables the configuration log of the device + /// by writing the defined value to the distance command register + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t distanceLogConfiguration() + { + return sfDevXM125Distance::logConfiguration(); + } + + /// @brief This function resets the distance detector settings + /// of the device + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t distanceReset() + { + return sfDevXM125Distance::reset(); + } + + /// @brief Completes a busy wait loop while the device is uploading + /// information by waiting for the status + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t distanceBusyWait() + { + return sfDevXM125Distance::busyWait(); + } +}; \ No newline at end of file From b4b6a8bae3580c617492b605e3c0caea8929d36b Mon Sep 17 00:00:00 2001 From: Kirk Benell Date: Sun, 23 Mar 2025 17:17:23 -0600 Subject: [PATCH 3/8] Defines a Version one interface for the distance object -- to maintain backward compatablity --- src/SparkFun_Qwiic_XM125_Arduino_Library.h | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/SparkFun_Qwiic_XM125_Arduino_Library.h b/src/SparkFun_Qwiic_XM125_Arduino_Library.h index c79588a..6fe22f5 100644 --- a/src/SparkFun_Qwiic_XM125_Arduino_Library.h +++ b/src/SparkFun_Qwiic_XM125_Arduino_Library.h @@ -22,6 +22,9 @@ #include "sfTk/sfDevXM125Core.h" #include "sfTk/sfDevXM125Distance.h" #include "sfTk/sfDevXM125Presence.h" + +// To support version 1.* API +#include "sfTk/sfDevXM125DistanceV1.h" // clang-format on #include @@ -116,3 +119,51 @@ class SparkFunXM125Presence : public sfDevXM125Presence // I2C bus class sfTkArdI2C _i2cBus; }; + +// Version 1 - for backward compatibility +/** + * @class SparkFunXM125DistanceV1 + * @brief Arduino class for the SparkFun Pulsed Coherent Radar Sensor - Acconeer XM125 (Qwiic) for distance detection. + * + * This class is to provide Version 1 compatibility for the SparkFun Pulsed Coherent Radar Sensor - distance detection. + * + * This class provides methods for initializing the sensor, checking connection status, and configuring the device + * for distance detection using I2C communication. + */ +class SparkFunXM125DistanceV1 : public sfDevXM125DistanceV1 +{ + public: + SparkFunXM125DistanceV1() + { + } + + /** + * @brief Sets up Arduino I2C driver using the specified I2C address then calls the super class begin. + * + * @param deviceAddress Address of the I2C device. Default is SFE_XM125_I2C_ADDRESS. + * @param wirePort Wire port of the I2C device. Default is Wire. + * @return True if successful, false otherwise. + */ + bool begin(uint8_t deviceAddress = SFE_XM125_I2C_ADDRESS, TwoWire &wirePort = Wire) + { + // Give the I2C port provided by the user to the I2C bus class. + _i2cBus.init(wirePort, deviceAddress); + + // Initialize the system - return results + return this->sfDevXM125DistanceV1::begin(&_i2cBus) == ksfTkErrOk; + } + + /** + * @brief Checks if the device is connected. + * + * @return True if the sensor is connected, false otherwise. + */ + bool isConnected() + { + return _i2cBus.ping() == ksfTkErrOk; + } + + private: + // I2C bus class + sfTkArdI2C _i2cBus; +}; \ No newline at end of file From c186934c0bca6561c96a9d985b5276b1b4248437 Mon Sep 17 00:00:00 2001 From: Kirk Benell Date: Sun, 23 Mar 2025 17:20:14 -0600 Subject: [PATCH 4/8] moved examples to v2.0 interface --- .../Example06_DistanceBasicReadings.ino | 10 +-- .../Example07_DistanceThresholdSettings.ino | 48 ++++++------ .../Example08_DistanceSerialPlotter.ino | 6 +- .../Example09_DistanceAdvancedSettings.ino | 76 +++++++++---------- 4 files changed, 70 insertions(+), 70 deletions(-) diff --git a/examples/Example06_DistanceBasicReadings/Example06_DistanceBasicReadings.ino b/examples/Example06_DistanceBasicReadings/Example06_DistanceBasicReadings.ino index 2201132..5fa309d 100644 --- a/examples/Example06_DistanceBasicReadings/Example06_DistanceBasicReadings.ino +++ b/examples/Example06_DistanceBasicReadings/Example06_DistanceBasicReadings.ino @@ -56,7 +56,7 @@ void setup() Serial.println("Starting Sensor..."); Serial.println(); // Start the sensor with the specified range values - int32_t setupError = radarSensor.distanceBegin(MY_XM125_RANGE_START, MY_XM125_RANGE_END); + int32_t setupError = radarSensor.distanceSetup(MY_XM125_RANGE_START, MY_XM125_RANGE_END); if (setupError != 0) { Serial.print("Distance Detection Start Setup Error: "); @@ -79,7 +79,7 @@ void setup() void loop() { - uint32_t retCode = radarSensor.distanceDetectorReadingSetup(); + uint32_t retCode = radarSensor.detectorReadingSetup(); if (retCode != 0) { Serial.print("Distance Reading Setup Error: "); @@ -88,7 +88,7 @@ void loop() // How many distance values were detected? (0-9) uint32_t numDistances = 0; - radarSensor.getDistanceNumberDistances(numDistances); + radarSensor.getNumberDistances(numDistances); if (numDistances == 0) Serial.print("."); @@ -103,7 +103,7 @@ void loop() int32_t distanceStrength = 0; for (uint32_t i = 0; i < numDistances; i++) { - if (radarSensor.getDistancePeakDistance(i, distance) != ksfTkErrOk) + if (radarSensor.getPeakDistance(i, distance) != ksfTkErrOk) { Serial.print("Error retrieving Distance Peak "); Serial.print(i); @@ -129,7 +129,7 @@ void loop() Serial.print("m"); } - if (radarSensor.getDistancePeakStrength(i, distanceStrength) != ksfTkErrOk) + if (radarSensor.getPeakStrength(i, distanceStrength) != ksfTkErrOk) { Serial.print("Error retrieving Distance Peak Strength"); Serial.print(i); diff --git a/examples/Example07_DistanceThresholdSettings/Example07_DistanceThresholdSettings.ino b/examples/Example07_DistanceThresholdSettings/Example07_DistanceThresholdSettings.ino index bd4e1ab..15adf6f 100644 --- a/examples/Example07_DistanceThresholdSettings/Example07_DistanceThresholdSettings.ino +++ b/examples/Example07_DistanceThresholdSettings/Example07_DistanceThresholdSettings.ino @@ -68,12 +68,12 @@ void setup() // Distance Sensor Setup // Reset sensor configuration to reapply configuration registers - radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_RESET_MODULE); + radarSensor.setCommand(SFE_XM125_DISTANCE_RESET_MODULE); - radarSensor.distanceBusyWait(); + radarSensor.busyWait(); // Check error and busy bits - radarSensor.getDistanceDetectorErrorStatus(errorStatus); + radarSensor.getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { Serial.print("Detector status error: "); @@ -83,36 +83,36 @@ void setup() delay(100); // Set Start register - if (radarSensor.setDistanceStart(100) != 0) + if (radarSensor.setStart(100) != 0) { Serial.println("Distance Start Error"); } - radarSensor.getDistanceStart(startVal); + radarSensor.getStart(startVal); Serial.print("Start Val: "); Serial.println(startVal); delay(100); // Set End register - if (radarSensor.setDistanceEnd(4000) != 0) + if (radarSensor.setEnd(4000) != 0) { Serial.println("Distance End Error"); } - radarSensor.getDistanceEnd(endVal); + radarSensor.getEnd(endVal); Serial.print("End Val: "); Serial.println(endVal); delay(100); // Set Distance Threshold Settings - Threshold Sensitivity (range: 0 to 1000) - radarSensor.setDistanceThresholdSensitivity(100); + radarSensor.setThresholdSensitivity(100); // Set Fixed Amplitude Threshold - radarSensor.setDistanceFixedAmpThreshold(100); + radarSensor.setFixedAmpThreshold(100); // Apply configuration - if (radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_APPLY_CONFIGURATION) != 0) + if (radarSensor.setCommand(SFE_XM125_DISTANCE_APPLY_CONFIGURATION) != 0) { // Check for errors - radarSensor.getDistanceDetectorErrorStatus(errorStatus); + radarSensor.getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { Serial.print("Detector status error: "); @@ -123,13 +123,13 @@ void setup() } // Poll detector status until busy bit is cleared - if (radarSensor.distanceBusyWait() != 0) + if (radarSensor.busyWait() != 0) { Serial.print("Busy wait error"); } // Check detector status - radarSensor.getDistanceDetectorErrorStatus(errorStatus); + radarSensor.getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { Serial.print("Detector status error: "); @@ -144,7 +144,7 @@ void setup() void loop() { // Check error bits - radarSensor.getDistanceDetectorErrorStatus(errorStatus); + radarSensor.getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { Serial.print("Detector status error: "); @@ -152,19 +152,19 @@ void loop() } // Start detector - if (radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_START_DETECTOR) != 0) + if (radarSensor.setCommand(SFE_XM125_DISTANCE_START_DETECTOR) != 0) { Serial.println("Start detector error"); } // Poll detector status until busy bit is cleared - CHECK ON THIS! - if (radarSensor.distanceBusyWait() != 0) + if (radarSensor.busyWait() != 0) { Serial.println("Busy wait error"); } // Verify that no error bits are set in the detector status register - radarSensor.getDistanceDetectorErrorStatus(errorStatus); + radarSensor.getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { Serial.print("Detector status error: "); @@ -172,26 +172,26 @@ void loop() } // Check MEASURE_DISTANCE_ERROR for measurement failed - radarSensor.getDistanceMeasureDistanceError(measDistErr); + radarSensor.getMeasureDistanceError(measDistErr); if (measDistErr == 1) { Serial.println("Measure Distance Error"); } // Recalibrate device if calibration error is triggered - radarSensor.getDistanceCalibrationNeeded(calibrateNeeded); + radarSensor.getCalibrationNeeded(calibrateNeeded); if (calibrateNeeded == 1) { Serial.println("Calibration Needed - Recalibrating.. "); // Calibrate device (write RECALIBRATE command) - radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_RECALIBRATE); + radarSensor.setCommand(SFE_XM125_DISTANCE_RECALIBRATE); } // Read PeakX Distance and PeakX Strength registers for the number of distances detected - radarSensor.getDistancePeak0Distance(distancePeak0); - radarSensor.getDistancePeak0Strength(distancePeakStrength0); - radarSensor.getDistancePeak1Distance(distancePeak1); - radarSensor.getDistancePeak1Strength(distancePeakStrength1); + radarSensor.getPeak0Distance(distancePeak0); + radarSensor.getPeak0Strength(distancePeakStrength0); + radarSensor.getPeak1Distance(distancePeak1); + radarSensor.getPeak1Strength(distancePeakStrength1); // Read out 2 distances and peaks with threshold settings adjusted if (distancePeak0 != 0) diff --git a/examples/Example08_DistanceSerialPlotter/Example08_DistanceSerialPlotter.ino b/examples/Example08_DistanceSerialPlotter/Example08_DistanceSerialPlotter.ino index ca7bc3e..e6ca0b5 100644 --- a/examples/Example08_DistanceSerialPlotter/Example08_DistanceSerialPlotter.ino +++ b/examples/Example08_DistanceSerialPlotter/Example08_DistanceSerialPlotter.ino @@ -55,7 +55,7 @@ void setup() ; // Runs forever } - int32_t setupError = radarSensor.distanceBegin(); + int32_t setupError = radarSensor.distanceSetup(); if (setupError != 0) { Serial.print("Distance Detection Start Setup Error: "); @@ -69,7 +69,7 @@ void setup() void loop() { - distanceSetupError = radarSensor.distanceDetectorReadingSetup(); + distanceSetupError = radarSensor.detectorReadingSetup(); if (distanceSetupError != 0) { Serial.print("Distance Reading Setup Error: "); @@ -77,7 +77,7 @@ void loop() } // Read PeakX Distance and PeakX Strength registers for the number of distances detected - radarSensor.getDistancePeak0Distance(distancePeak0); + radarSensor.getPeak0Distance(distancePeak0); // If a peak distance was detected, then read out the distance and strength if (distancePeak0 != 0) diff --git a/examples/Example09_DistanceAdvancedSettings/Example09_DistanceAdvancedSettings.ino b/examples/Example09_DistanceAdvancedSettings/Example09_DistanceAdvancedSettings.ino index 4f5b255..644ca5c 100644 --- a/examples/Example09_DistanceAdvancedSettings/Example09_DistanceAdvancedSettings.ino +++ b/examples/Example09_DistanceAdvancedSettings/Example09_DistanceAdvancedSettings.ino @@ -68,12 +68,12 @@ void setup() // Distance Sensor Setup // Reset sensor configuration to reapply configuration registers - radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_RESET_MODULE); + radarSensor.setCommand(SFE_XM125_DISTANCE_RESET_MODULE); - radarSensor.distanceBusyWait(); + radarSensor.busyWait(); // Check error and busy bits - radarSensor.getDistanceDetectorErrorStatus(errorStatus); + radarSensor.getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { Serial.print("Detector status error: "); @@ -83,30 +83,30 @@ void setup() delay(100); // Set Start register - if (radarSensor.setDistanceStart(beginReading) != 0) + if (radarSensor.setStart(beginReading) != 0) { Serial.println("Distance Start Error"); } - radarSensor.getDistanceStart(startVal); + radarSensor.getStart(startVal); Serial.print("Start Val: "); Serial.println(startVal); delay(100); // Set End register - if (radarSensor.setDistanceEnd(endReading) != 0) + if (radarSensor.setEnd(endReading) != 0) { Serial.println("Distance End Error"); } - radarSensor.getDistanceEnd(endVal); + radarSensor.getEnd(endVal); Serial.print("End Val: "); Serial.println(endVal); delay(100); // Apply configuration - if (radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_APPLY_CONFIGURATION) != 0) + if (radarSensor.setCommand(SFE_XM125_DISTANCE_APPLY_CONFIGURATION) != 0) { // Check for errors - radarSensor.getDistanceDetectorErrorStatus(errorStatus); + radarSensor.getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { Serial.print("Detector status error: "); @@ -117,13 +117,13 @@ void setup() } // Poll detector status until busy bit is cleared - if (radarSensor.distanceBusyWait() != 0) + if (radarSensor.busyWait() != 0) { Serial.print("Busy wait error"); } // Check detector status - radarSensor.getDistanceDetectorErrorStatus(errorStatus); + radarSensor.getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { Serial.print("Detector status error: "); @@ -153,7 +153,7 @@ void outputResults(uint sample, uint32_t distance, int32_t strength) void loop() { // Check error bits - radarSensor.getDistanceDetectorErrorStatus(errorStatus); + radarSensor.getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { Serial.print("Detector status error: "); @@ -161,19 +161,19 @@ void loop() } // Start detector - if (radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_START_DETECTOR) != 0) + if (radarSensor.setCommand(SFE_XM125_DISTANCE_START_DETECTOR) != 0) { Serial.println("Start detector error"); } // Poll detector status until busy bit is cleared - CHECK ON THIS! - if (radarSensor.distanceBusyWait() != 0) + if (radarSensor.busyWait() != 0) { Serial.println("Busy wait error"); } // Verify that no error bits are set in the detector status register - radarSensor.getDistanceDetectorErrorStatus(errorStatus); + radarSensor.getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { Serial.print("Detector status error: "); @@ -181,60 +181,60 @@ void loop() } // Check MEASURE_DISTANCE_ERROR for measurement failed - radarSensor.getDistanceMeasureDistanceError(measDistErr); + radarSensor.getMeasureDistanceError(measDistErr); if (measDistErr == 1) { Serial.println("Measure Distance Error"); } // Recalibrate device if calibration error is triggered - radarSensor.getDistanceCalibrationNeeded(calibrateNeeded); + radarSensor.getCalibrationNeeded(calibrateNeeded); if (calibrateNeeded == 1) { Serial.println("Calibration Needed - Recalibrating.. "); // Calibrate device (write RECALIBRATE command) - radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_RECALIBRATE); + radarSensor.setCommand(SFE_XM125_DISTANCE_RECALIBRATE); } // Read PeakX Distance and PeakX Strength registers for the number of distances detected - radarSensor.getDistancePeak0Distance(distancePeak); - radarSensor.getDistancePeak0Strength(distancePeakStrength); + radarSensor.getPeak0Distance(distancePeak); + radarSensor.getPeak0Strength(distancePeakStrength); outputResults(0, distancePeak, distancePeakStrength); - radarSensor.getDistancePeak1Distance(distancePeak); - radarSensor.getDistancePeak1Strength(distancePeakStrength); + radarSensor.getPeak1Distance(distancePeak); + radarSensor.getPeak1Strength(distancePeakStrength); outputResults(1, distancePeak, distancePeakStrength); - radarSensor.getDistancePeak2Distance(distancePeak); - radarSensor.getDistancePeak2Strength(distancePeakStrength); + radarSensor.getPeak2Distance(distancePeak); + radarSensor.getPeak2Strength(distancePeakStrength); outputResults(2, distancePeak, distancePeakStrength); - radarSensor.getDistancePeak3Distance(distancePeak); - radarSensor.getDistancePeak3Strength(distancePeakStrength); + radarSensor.getPeak3Distance(distancePeak); + radarSensor.getPeak3Strength(distancePeakStrength); outputResults(3, distancePeak, distancePeakStrength); - radarSensor.getDistancePeak4Distance(distancePeak); - radarSensor.getDistancePeak4Strength(distancePeakStrength); + radarSensor.getPeak4Distance(distancePeak); + radarSensor.getPeak4Strength(distancePeakStrength); outputResults(4, distancePeak, distancePeakStrength); - radarSensor.getDistancePeak5Distance(distancePeak); - radarSensor.getDistancePeak5Strength(distancePeakStrength); + radarSensor.getPeak5Distance(distancePeak); + radarSensor.getPeak5Strength(distancePeakStrength); outputResults(5, distancePeak, distancePeakStrength); - radarSensor.getDistancePeak6Distance(distancePeak); - radarSensor.getDistancePeak6Strength(distancePeakStrength); + radarSensor.getPeak6Distance(distancePeak); + radarSensor.getPeak6Strength(distancePeakStrength); outputResults(6, distancePeak, distancePeakStrength); - radarSensor.getDistancePeak7Distance(distancePeak); - radarSensor.getDistancePeak7Strength(distancePeakStrength); + radarSensor.getPeak7Distance(distancePeak); + radarSensor.getPeak7Strength(distancePeakStrength); outputResults(7, distancePeak, distancePeakStrength); - radarSensor.getDistancePeak8Distance(distancePeak); - radarSensor.getDistancePeak8Strength(distancePeakStrength); + radarSensor.getPeak8Distance(distancePeak); + radarSensor.getPeak8Strength(distancePeakStrength); outputResults(8, distancePeak, distancePeakStrength); - radarSensor.getDistancePeak9Distance(distancePeak); - radarSensor.getDistancePeak9Strength(distancePeakStrength); + radarSensor.getPeak9Distance(distancePeak); + radarSensor.getPeak9Strength(distancePeakStrength); outputResults(9, distancePeak, distancePeakStrength); // Half a second delay for easier readings From 982cdfc6a7f814a7bc8898d642f622bb22251bd7 Mon Sep 17 00:00:00 2001 From: Kirk Benell Date: Sun, 23 Mar 2025 18:43:01 -0600 Subject: [PATCH 5/8] move to a less *bloated* method signature now that the distance and presence functions are in seperate objs --- src/sfTk/sfDevXM125Presence.cpp | 174 ++++++++++++++++---------------- src/sfTk/sfDevXM125Presence.h | 136 ++++++++++++------------- 2 files changed, 155 insertions(+), 155 deletions(-) diff --git a/src/sfTk/sfDevXM125Presence.cpp b/src/sfTk/sfDevXM125Presence.cpp index 7092457..23c799b 100644 --- a/src/sfTk/sfDevXM125Presence.cpp +++ b/src/sfTk/sfDevXM125Presence.cpp @@ -21,7 +21,7 @@ sfTkError_t sfDevXM125Presence::begin(sfTkII2C *theBus) // Check errors from device application uint32_t presenceError = 0; - retVal = getPresenceDetectorError(presenceError); + retVal = getDetectorError(presenceError); if (retVal != ksfTkErrOk) return retVal; @@ -32,52 +32,52 @@ sfTkError_t sfDevXM125Presence::begin(sfTkII2C *theBus) return ksfTkErrOk; } //------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::presenceDetectorStart(uint32_t startValue, uint32_t endValue) +sfTkError_t sfDevXM125Presence::detectorStart(uint32_t startValue, uint32_t endValue) { // *** Presence Sensor Setup *** uint32_t errorStatus = 0; // Reset sensor configuration to reapply configuration registers - if (setPresenceCommand(SFE_XM125_PRESENCE_RESET_MODULE) != ksfTkErrOk) + if (setCommand(SFE_XM125_PRESENCE_RESET_MODULE) != ksfTkErrOk) return 1; sftk_delay_ms(100); // give time for command to set // Check detector status error and busy bits - if (getPresenceDetectorErrorStatus(errorStatus) != ksfTkErrOk) + if (getDetectorErrorStatus(errorStatus) != ksfTkErrOk) return 2; if (errorStatus != 0) return 3; // Set Presence Start register - if (setPresenceStart(startValue) != ksfTkErrOk) + if (setStart(startValue) != ksfTkErrOk) return 4; sftk_delay_ms(100); // give time for command to set // Set End register - if (setPresenceEnd(endValue) != ksfTkErrOk) + if (setEnd(endValue) != ksfTkErrOk) return 5; sftk_delay_ms(100); // give time for command to set // Apply configuration - if (setPresenceCommand(SFE_XM125_PRESENCE_APPLY_CONFIGURATION) != ksfTkErrOk) + if (setCommand(SFE_XM125_PRESENCE_APPLY_CONFIGURATION) != ksfTkErrOk) { // Check for errors - getPresenceDetectorErrorStatus(errorStatus); + getDetectorErrorStatus(errorStatus); return errorStatus != 0 ? 6 : 7; } sftk_delay_ms(100); // give time for command to set // Poll detector status until busy bit is cleared - if (presenceBusyWait() != ksfTkErrOk) + if (busyWait() != ksfTkErrOk) return 8; // Check detector error status - sfTkError_t retVal = getPresenceDetectorErrorStatus(errorStatus); + sfTkError_t retVal = getDetectorErrorStatus(errorStatus); if (retVal != ksfTkErrOk || errorStatus != 0) return 9; @@ -86,28 +86,28 @@ sfTkError_t sfDevXM125Presence::presenceDetectorStart(uint32_t startValue, uint3 } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceDistanceValuemm(uint32_t &presenceVal) +sfTkError_t sfDevXM125Presence::getDistanceValuemm(uint32_t &presenceVal) { // Check error bits uint32_t errorStatus = 0; uint32_t presenceStatus = 0; - sfTkError_t retVal = getPresenceDetectorErrorStatus(errorStatus); + sfTkError_t retVal = getDetectorErrorStatus(errorStatus); if (retVal != ksfTkErrOk || errorStatus != 0) return ksfTkErrFail; // Start detector - if (setPresenceCommand(SFE_XM125_PRESENCE_START_DETECTOR) != ksfTkErrOk) + if (setCommand(SFE_XM125_PRESENCE_START_DETECTOR) != ksfTkErrOk) return ksfTkErrFail; sftk_delay_ms(100); // Poll detector status until busy bit is cleared - if (presenceBusyWait() != ksfTkErrOk) + if (busyWait() != ksfTkErrOk) return ksfTkErrFail; // Verify that no error bits are set in the detector status register - retVal = getPresenceDetectorErrorStatus(errorStatus); + retVal = getDetectorErrorStatus(errorStatus); if (retVal != ksfTkErrOk || errorStatus != 0) return ksfTkErrFail; @@ -121,7 +121,7 @@ sfTkError_t sfDevXM125Presence::getPresenceDistanceValuemm(uint32_t &presenceVal // If presence or a sticky presence is detected, get the distance and return if (bPresenceDetected) - return getPresenceDistance(presenceVal); + return getDistance(presenceVal); // If no presence detected, return 0 presenceVal = 0; @@ -129,7 +129,7 @@ sfTkError_t sfDevXM125Presence::getPresenceDistanceValuemm(uint32_t &presenceVal } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceDetectorVersion(uint32_t &major, uint32_t &minor, uint32_t &patch) +sfTkError_t sfDevXM125Presence::getDetectorVersion(uint32_t &major, uint32_t &minor, uint32_t &patch) { sfTkError_t retVal; uint32_t regVal = 0; @@ -146,22 +146,22 @@ sfTkError_t sfDevXM125Presence::getPresenceDetectorVersion(uint32_t &major, uint return retVal; } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceDetectorError(uint32_t &error) +sfTkError_t sfDevXM125Presence::getDetectorError(uint32_t &error) { return _theBus->readRegister(SFE_XM125_PRESENCE_PROTOCOL_STATUS, error); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceMeasureCounter(uint32_t &counter) +sfTkError_t sfDevXM125Presence::getMeasureCounter(uint32_t &counter) { return _theBus->readRegister(SFE_XM125_PRESENCE_MEASURE_COUNTER, counter); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceDetectorStatus(uint32_t &status) +sfTkError_t sfDevXM125Presence::getDetectorStatus(uint32_t &status) { return _theBus->readRegister(SFE_XM125_PRESENCE_DETECTOR_STATUS, status); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceDetectorErrorStatus(uint32_t &status) +sfTkError_t sfDevXM125Presence::getDetectorErrorStatus(uint32_t &status) { sfTkError_t retVal = 0; uint32_t regVal = 0; @@ -215,7 +215,7 @@ sfTkError_t sfDevXM125Presence::getPresenceDetectorErrorStatus(uint32_t &status) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceDetectorPresenceDetected(uint32_t &detected) +sfTkError_t sfDevXM125Presence::getDetectorPresenceDetected(uint32_t &detected) { // Read from 16-Bit Register sfTkError_t retVal = _theBus->readRegister(SFE_XM125_PRESENCE_RESULT, detected); @@ -227,7 +227,7 @@ sfTkError_t sfDevXM125Presence::getPresenceDetectorPresenceDetected(uint32_t &de return retVal; } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceDetectorPresenceStickyDetected(uint32_t &sticky) +sfTkError_t sfDevXM125Presence::getDetectorPresenceStickyDetected(uint32_t &sticky) { // Read from 16-Bit Register @@ -240,7 +240,7 @@ sfTkError_t sfDevXM125Presence::getPresenceDetectorPresenceStickyDetected(uint32 return retVal; } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceDetectorRegError(uint32_t &error) +sfTkError_t sfDevXM125Presence::getDetectorRegError(uint32_t &error) { sfTkError_t retVal = _theBus->readRegister(SFE_XM125_PRESENCE_RESULT, error); @@ -251,7 +251,7 @@ sfTkError_t sfDevXM125Presence::getPresenceDetectorRegError(uint32_t &error) return retVal; } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceTemperature(uint32_t &temp) +sfTkError_t sfDevXM125Presence::getTemperature(uint32_t &temp) { sfTkError_t retVal = _theBus->readRegister(SFE_XM125_PRESENCE_DISTANCE, temp); @@ -261,45 +261,45 @@ sfTkError_t sfDevXM125Presence::getPresenceTemperature(uint32_t &temp) return retVal; } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceDistance(uint32_t &distance) +sfTkError_t sfDevXM125Presence::getDistance(uint32_t &distance) { return _theBus->readRegister(SFE_XM125_PRESENCE_DISTANCE, distance); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceIntraPresenceScore(uint32_t &intra) +sfTkError_t sfDevXM125Presence::getIntraPresenceScore(uint32_t &intra) { return _theBus->readRegister(SFE_XM125_INTRA_PRESENCE_SCORE, intra); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceInterPresenceScore(uint32_t &inter) +sfTkError_t sfDevXM125Presence::getInterPresenceScore(uint32_t &inter) { return _theBus->readRegister(SFE_XM125_INTER_PRESENCE, inter); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceSweepsPerFrame(uint32_t &sweeps) +sfTkError_t sfDevXM125Presence::getSweepsPerFrame(uint32_t &sweeps) { return _theBus->readRegister(SFE_XM125_PRESENCE_SWEEPS_PER_FRAME, sweeps); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::setPresenceSweepsPerFrame(uint32_t sweeps) +sfTkError_t sfDevXM125Presence::setSweepsPerFrame(uint32_t sweeps) { return _theBus->writeRegister(SFE_XM125_PRESENCE_SWEEPS_PER_FRAME, sweeps); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceInterFramePresenceTimeout(uint32_t &time) +sfTkError_t sfDevXM125Presence::getInterFramePresenceTimeout(uint32_t &time) { return _theBus->readRegister(SFE_XM125_PRESENCE_INTER_FRAME_TIMEOUT, time); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::setPresenceInterFramePresenceTimeout(uint32_t time) +sfTkError_t sfDevXM125Presence::setInterFramePresenceTimeout(uint32_t time) { return _theBus->writeRegister(SFE_XM125_PRESENCE_INTER_FRAME_TIMEOUT, time); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceInterPhaseBoostEnabled(bool &en) +sfTkError_t sfDevXM125Presence::getInterPhaseBoostEnabled(bool &en) { size_t readBytes = 0; uint8_t value; @@ -310,14 +310,14 @@ sfTkError_t sfDevXM125Presence::getPresenceInterPhaseBoostEnabled(bool &en) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::setPresenceInterPhaseBoostEnabled(bool en) +sfTkError_t sfDevXM125Presence::setInterPhaseBoostEnabled(bool en) { uint8_t value = en ? 1 : 0; return _theBus->writeRegisterUInt8(SFE_XM125_PRESENCE_INTER_PHASE_BOOST_ENABLED, value); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceIntraDetectionEnabled(bool &en) +sfTkError_t sfDevXM125Presence::getIntraDetectionEnabled(bool &en) { uint8_t value; sfTkError_t retVal = _theBus->readRegisterUInt8(SFE_XM125_PRESENCE_INTRA_DETECTION_ENABLED, value); @@ -327,122 +327,122 @@ sfTkError_t sfDevXM125Presence::getPresenceIntraDetectionEnabled(bool &en) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::setPresenceInterDetectionEnabled(bool en) +sfTkError_t sfDevXM125Presence::setInterDetectionEnabled(bool en) { uint8_t value = en ? 1 : 0; return _theBus->writeRegister(SFE_XM125_PRESENCE_INTRA_DETECTION_ENABLED, (uint8_t *)&value, sizeof(uint8_t)); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceFrameRate(uint32_t &rate) +sfTkError_t sfDevXM125Presence::getFrameRate(uint32_t &rate) { return _theBus->readRegister(SFE_XM125_PRESENCE_FRAME_RATE, rate); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::setPresenceFrameRate(uint32_t rate) +sfTkError_t sfDevXM125Presence::setFrameRate(uint32_t rate) { return _theBus->writeRegister(SFE_XM125_PRESENCE_FRAME_RATE, rate); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceIntraDetectionThreshold(uint32_t &thresh) +sfTkError_t sfDevXM125Presence::getIntraDetectionThreshold(uint32_t &thresh) { return _theBus->readRegister(SFE_XM125_PRESENCE_INTRA_DETECTION_THRESHOLD, thresh); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::setPresenceIntraDetectionThreshold(uint32_t thresh) +sfTkError_t sfDevXM125Presence::setIntraDetectionThreshold(uint32_t thresh) { return _theBus->writeRegister(SFE_XM125_PRESENCE_INTRA_DETECTION_THRESHOLD, thresh); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceInterDetectionThreshold(uint32_t &thresh) +sfTkError_t sfDevXM125Presence::getInterDetectionThreshold(uint32_t &thresh) { return _theBus->readRegister(SFE_XM125_PRESENCE_INTER_DETECTION_THRESHOLD, thresh); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::setPresenceInterDetectionThreshold(uint32_t thresh) +sfTkError_t sfDevXM125Presence::setInterDetectionThreshold(uint32_t thresh) { return _theBus->writeRegister(SFE_XM125_PRESENCE_INTER_DETECTION_THRESHOLD, thresh); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceInterFrameDeviationTime(uint32_t &time) +sfTkError_t sfDevXM125Presence::getInterFrameDeviationTime(uint32_t &time) { return _theBus->readRegister(SFE_XM125_PRESENCE_INTER_FRAME_DEVIATION, time); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::setPresenceInterFrameDeviationTime(uint32_t time) +sfTkError_t sfDevXM125Presence::setInterFrameDeviationTime(uint32_t time) { return _theBus->writeRegister(SFE_XM125_PRESENCE_INTER_FRAME_DEVIATION, time); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceInterFrameFastCutoff(uint32_t &cut) +sfTkError_t sfDevXM125Presence::getInterFrameFastCutoff(uint32_t &cut) { return _theBus->readRegister(SFE_XM125_PRESENCE_INTER_FRAME_FAST_CUTOFF, cut); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::setPresenceInterFrameFastCutoff(uint32_t cut) +sfTkError_t sfDevXM125Presence::setInterFrameFastCutoff(uint32_t cut) { return _theBus->writeRegister(SFE_XM125_PRESENCE_INTER_FRAME_FAST_CUTOFF, cut); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceInterFrameSlowCutoff(uint32_t &cut) +sfTkError_t sfDevXM125Presence::getInterFrameSlowCutoff(uint32_t &cut) { return _theBus->readRegister(SFE_XM125_PRESENCE_INTER_FRAME_SLOW_CUTOFF, cut); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::setPresenceInterFrameSlowCutoff(uint32_t cut) +sfTkError_t sfDevXM125Presence::setInterFrameSlowCutoff(uint32_t cut) { return _theBus->writeRegister(SFE_XM125_PRESENCE_INTER_FRAME_SLOW_CUTOFF, cut); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceIntraFrameTimeConst(uint32_t &time) +sfTkError_t sfDevXM125Presence::getIntraFrameTimeConst(uint32_t &time) { return _theBus->readRegister(SFE_XM125_PRESENCE_INTRA_FRAME_TIME_CONST, time); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::setPresenceIntraFrameTimeConst(uint32_t time) +sfTkError_t sfDevXM125Presence::setIntraFrameTimeConst(uint32_t time) { return _theBus->writeRegister(SFE_XM125_PRESENCE_INTRA_FRAME_TIME_CONST, time); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceIntraOutputTimeConst(uint32_t &time) +sfTkError_t sfDevXM125Presence::getIntraOutputTimeConst(uint32_t &time) { return _theBus->readRegister(SFE_XM125_PRESENCE_INTRA_OUTPUT_TIME_CONST, time); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::setPresenceIntraOutputTimeConst(uint32_t time) +sfTkError_t sfDevXM125Presence::setIntraOutputTimeConst(uint32_t time) { return _theBus->writeRegister(SFE_XM125_PRESENCE_INTRA_OUTPUT_TIME_CONST, time); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceInterOutputTimeConst(uint32_t &time) +sfTkError_t sfDevXM125Presence::getInterOutputTimeConst(uint32_t &time) { return _theBus->readRegister(SFE_XM125_PRESENCE_INTER_OUTPUT_TIME_CONST, time); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::setPresenceInterOutputTimeConst(uint32_t time) +sfTkError_t sfDevXM125Presence::setInterOutputTimeConst(uint32_t time) { return _theBus->writeRegister(SFE_XM125_PRESENCE_INTER_OUTPUT_TIME_CONST, time); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceAutoProfileEn(bool &en) +sfTkError_t sfDevXM125Presence::getAutoProfileEn(bool &en) { size_t readBytes = 0; uint8_t value; @@ -453,14 +453,14 @@ sfTkError_t sfDevXM125Presence::getPresenceAutoProfileEn(bool &en) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::setPresenceAutoProfileEn(bool en) +sfTkError_t sfDevXM125Presence::setAutoProfileEn(bool en) { uint8_t value = en ? 1 : 0; return _theBus->writeRegister(SFE_XM125_PRESENCE_AUTO_PROFILE_ENABLED, (uint8_t *)&value, sizeof(uint8_t)); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceAutoStepLengthEn(bool &en) +sfTkError_t sfDevXM125Presence::getAutoStepLengthEn(bool &en) { size_t readBytes = 0; uint8_t value; @@ -471,62 +471,62 @@ sfTkError_t sfDevXM125Presence::getPresenceAutoStepLengthEn(bool &en) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::setPresenceAutoStepLengthEn(bool en) +sfTkError_t sfDevXM125Presence::setAutoStepLengthEn(bool en) { uint8_t value = en ? 1 : 0; return _theBus->writeRegister(SFE_XM125_PRESENCE_AUTO_STEP_LENGTH_ENABLED, (uint8_t *)&value, sizeof(uint8_t)); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceManualProfile(uint32_t &prof) +sfTkError_t sfDevXM125Presence::getManualProfile(uint32_t &prof) { return _theBus->readRegister(SFE_XM125_PRESENCE_MANUAL_PROFILE, prof); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::setPresenceManualProfile(uint32_t prof) +sfTkError_t sfDevXM125Presence::setManualProfile(uint32_t prof) { return _theBus->writeRegister(SFE_XM125_PRESENCE_MANUAL_PROFILE, prof); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceManualStepLength(uint32_t &length) +sfTkError_t sfDevXM125Presence::getManualStepLength(uint32_t &length) { return _theBus->readRegister(SFE_XM125_PRESENCE_MANUAL_STEP_LENGTH, length); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::setPresenceManualStepLength(uint32_t length) +sfTkError_t sfDevXM125Presence::setManualStepLength(uint32_t length) { return _theBus->writeRegister(SFE_XM125_PRESENCE_MANUAL_STEP_LENGTH, length); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceStart(uint32_t &start) +sfTkError_t sfDevXM125Presence::getStart(uint32_t &start) { return _theBus->readRegister(SFE_XM125_PRESENCE_START, start); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::setPresenceStart(uint32_t start) +sfTkError_t sfDevXM125Presence::setStart(uint32_t start) { return _theBus->writeRegister(SFE_XM125_PRESENCE_START, start); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceEnd(uint32_t &end) +sfTkError_t sfDevXM125Presence::getEnd(uint32_t &end) { return _theBus->readRegister(SFE_XM125_PRESENCE_END, end); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::setPresenceEnd(uint32_t end) +sfTkError_t sfDevXM125Presence::setEnd(uint32_t end) { return _theBus->writeRegister(SFE_XM125_PRESENCE_END, end); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceResetFilters(bool &reset) +sfTkError_t sfDevXM125Presence::getResetFilters(bool &reset) { size_t readBytes = 0; @@ -538,79 +538,79 @@ sfTkError_t sfDevXM125Presence::getPresenceResetFilters(bool &reset) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::setPresenceResetFilters(bool reset) +sfTkError_t sfDevXM125Presence::setResetFilters(bool reset) { uint8_t value = reset ? 1 : 0; return _theBus->writeRegister(SFE_XM125_PRESENCE_RESET_FILTERS_ON_PREPARE, &value, sizeof(uint8_t)); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceHWAAS(uint32_t &avg) +sfTkError_t sfDevXM125Presence::getHWAAS(uint32_t &avg) { return _theBus->readRegister(SFE_XM125_PRESENCE_HWAAS, avg); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::setPresenceHWAAS(uint32_t avg) +sfTkError_t sfDevXM125Presence::setHWAAS(uint32_t avg) { return _theBus->writeRegister(SFE_XM125_PRESENCE_HWAAS, avg); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceDetectionOnGPIO(uint32_t &detected) +sfTkError_t sfDevXM125Presence::getDetectionOnGPIO(uint32_t &detected) { return _theBus->readRegister(SFE_XM125_PRESENCE_DETECTION_ON_GPIO, detected); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::setPresenceDetectionOnGPIO(uint32_t detected) +sfTkError_t sfDevXM125Presence::setDetectionOnGPIO(uint32_t detected) { return _theBus->writeRegister(SFE_XM125_PRESENCE_DETECTION_ON_GPIO, detected); } -sfTkError_t sfDevXM125Presence::setPresenceCommand(uint32_t cmd) +sfTkError_t sfDevXM125Presence::setCommand(uint32_t cmd) { return _theBus->writeRegister(SFE_XM125_PRESENCE_COMMAND, cmd); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::presenceApplyConfiguration() +sfTkError_t sfDevXM125Presence::applyConfiguration() { - return setPresenceCommand(SFE_XM125_PRESENCE_START_DETECTOR); + return setCommand(SFE_XM125_PRESENCE_START_DETECTOR); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::presenceStart() +sfTkError_t sfDevXM125Presence::start() { - return setPresenceCommand(SFE_XM125_PRESENCE_START_DETECTOR); + return setCommand(SFE_XM125_PRESENCE_START_DETECTOR); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::presenceStop() +sfTkError_t sfDevXM125Presence::stop() { - return setPresenceCommand(SFE_XM125_PRESENCE_STOP_DETECTOR); + return setCommand(SFE_XM125_PRESENCE_STOP_DETECTOR); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::presenceEnableUartLogs() +sfTkError_t sfDevXM125Presence::enableUartLogs() { - return setPresenceCommand(SFE_XM125_PRESENCE_ENABLE_UART_LOGS); + return setCommand(SFE_XM125_PRESENCE_ENABLE_UART_LOGS); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::presenceDisableUartLogs() +sfTkError_t sfDevXM125Presence::disableUartLogs() { - return setPresenceCommand(SFE_XM125_PRESENCE_DISABLE_UART_LOGS); + return setCommand(SFE_XM125_PRESENCE_DISABLE_UART_LOGS); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::presenceLogConfiguration() +sfTkError_t sfDevXM125Presence::logConfiguration() { - return setPresenceCommand(SFE_XM125_PRESENCE_LOG_CONFIGURATION); + return setCommand(SFE_XM125_PRESENCE_LOG_CONFIGURATION); } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::getPresenceBusy(uint32_t &busy) +sfTkError_t sfDevXM125Presence::getBusy(uint32_t &busy) { // Read from 16-Bit Register @@ -623,7 +623,7 @@ sfTkError_t sfDevXM125Presence::getPresenceBusy(uint32_t &busy) } //-------------------------------------------------------------------------------- -sfTkError_t sfDevXM125Presence::presenceBusyWait() +sfTkError_t sfDevXM125Presence::busyWait() { uint32_t regVal = 0; diff --git a/src/sfTk/sfDevXM125Presence.h b/src/sfTk/sfDevXM125Presence.h index 41fa9a0..48dda1c 100644 --- a/src/sfTk/sfDevXM125Presence.h +++ b/src/sfTk/sfDevXM125Presence.h @@ -249,18 +249,18 @@ class sfDevXM125Presence : public sfDevXM125Core /// @param start Start value for presence sensing in mm - default value is 1000 /// @param end End value for presence sensing in mm - default value is 5000 /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t presenceDetectorStart(uint32_t start = 1000, uint32_t end = 5000); + sfTkError_t detectorStart(uint32_t start = 1000, uint32_t end = 5000); /// @brief This function returns the presence value of the register /// with all the checks in place as per the I2C Datasheet. /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceDistanceValuemm(uint32_t &presenceVal); + sfTkError_t getDistanceValuemm(uint32_t &presenceVal); /// @brief This function returns the RSS version number /// @param version Version number /// @param patch Patch version number /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceDetectorVersion(uint32_t &major, uint32_t &minor, uint32_t &patch); + sfTkError_t getDetectorVersion(uint32_t &major, uint32_t &minor, uint32_t &patch); /// @brief This function returns the protocol state erorr /// @param state Error code for device @@ -270,79 +270,79 @@ class sfDevXM125Presence : public sfDevXM125Core /// 3 = Write failed /// 4 = Write to read only /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceDetectorError(uint32_t &error); + sfTkError_t getDetectorError(uint32_t &error); /// @brief This function returns the measure counter; the number of /// measurements performed since restart. /// @param counter number of measurements /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceMeasureCounter(uint32_t &counter); + sfTkError_t getMeasureCounter(uint32_t &counter); /// @brief This function returns the detector status flags. See page 17, section /// 6.2.4 Detector Status /// @param status Status detector flag /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceDetectorStatus(uint32_t &status); + sfTkError_t getDetectorStatus(uint32_t &status); /// @brief This function returns the error status according to the bit /// mask value for the presence devices errors and busy bit /// @param status Error status of device (see function for exact error) /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceDetectorErrorStatus(uint32_t &status); + sfTkError_t getDetectorErrorStatus(uint32_t &status); /// @brief This function returns if there was presence detected /// @param detected Presence Detected /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceDetectorPresenceDetected(uint32_t &detected); + sfTkError_t getDetectorPresenceDetected(uint32_t &detected); /// @brief This function returns if there was presence detected, sticky bit with /// clear on read. /// @param sticky Sticky Presence Detected /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceDetectorPresenceStickyDetected(uint32_t &sticky); + sfTkError_t getDetectorPresenceStickyDetected(uint32_t &sticky); /// @brief This function returns the indication that the presence detector /// failed. /// @param calibrate Indication of sensor calibration /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceDetectorRegError(uint32_t &error); + sfTkError_t getDetectorRegError(uint32_t &error); /// @brief This function returns the temperature in sensor during measurement (in /// degree Celsius). Note that it has poor absolute accuracy and should only /// be used for relative temperature measurements. /// @param temp Relative temperature /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceTemperature(uint32_t &temp); + sfTkError_t getTemperature(uint32_t &temp); /// @brief This function returns the distance, in millimeters, for the detected /// presence. /// @param distance distance in mm /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceDistance(uint32_t &distance); + sfTkError_t getDistance(uint32_t &distance); /// @brief This function returns the measure of amount of fast motion detected. /// @param intra Measure of fast motion /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceIntraPresenceScore(uint32_t &intra); + sfTkError_t getIntraPresenceScore(uint32_t &intra); /// @brief This function returns the measure of amount of slow motion detected. /// @param inter Measure of slow motion /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceInterPresenceScore(uint32_t &inter); + sfTkError_t getInterPresenceScore(uint32_t &inter); /// @brief This function returns the number of sweeps that will be /// captured in each frame (measurement). /// Default Value: 16 seconds /// @param sweeps Number of sweeps /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceSweepsPerFrame(uint32_t &sweeps); + sfTkError_t getSweepsPerFrame(uint32_t &sweeps); /// @brief This function sets the number of sweeps that will be /// captured in each frame (measurement). /// Default Value: 16 seconds /// @param sweeps Number of sweeps /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setPresenceSweepsPerFrame(uint32_t sweeps); + sfTkError_t setSweepsPerFrame(uint32_t sweeps); /// @brief Returns the number of seconds the inter-frame presence score needs to decrease before /// exponential scaling starts for faster decline. Should be between 0 and 30 where 0 @@ -350,7 +350,7 @@ class sfDevXM125Presence : public sfDevXM125Core /// Default Value: 3 seconds /// @param time Number of seconds /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceInterFramePresenceTimeout(uint32_t &time); + sfTkError_t getInterFramePresenceTimeout(uint32_t &time); /// @brief Sets the number of seconds the inter-frame presence score needs to decrease before /// exponential scaling starts for faster decline. Should be between 0 and 30 where 0 @@ -358,49 +358,49 @@ class sfDevXM125Presence : public sfDevXM125Core /// Default Value: 3 seconds /// @param time Number of seconds /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setPresenceInterFramePresenceTimeout(uint32_t time); + sfTkError_t setInterFramePresenceTimeout(uint32_t time); /// @brief This function returns the enable to increase detection of slow /// motions by utilizing the phase information in the Sparse IQ data /// @param en Enables increased detection /// Default Value: false /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceInterPhaseBoostEnabled(bool &en); + sfTkError_t getInterPhaseBoostEnabled(bool &en); /// @brief This function sets the enable to increase detection of slow /// motions by utilizing the phase information in the Sparse IQ data /// @param en Enables increased detection /// Default Value: false /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setPresenceInterPhaseBoostEnabled(bool en); + sfTkError_t setInterPhaseBoostEnabled(bool en); /// @brief This function returns the bit to enable to detect faster /// movements inside frames. /// Default Value: true /// @param en Enables faster detection /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceIntraDetectionEnabled(bool &en); + sfTkError_t getIntraDetectionEnabled(bool &en); /// @brief This function returns the bit to enable to detect slower /// movements between frames. /// Default Value: true /// @param en Enables faster detection /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setPresenceInterDetectionEnabled(bool en); + sfTkError_t setInterDetectionEnabled(bool en); /// @brief This function returns the presence detector frame rate. /// Note: This value is a factor 1000 larger than the RSS value /// Default Value: 12000 mHz /// @param rate Frame rate, in mHz /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceFrameRate(uint32_t &rate); + sfTkError_t getFrameRate(uint32_t &rate); /// @brief This function sets the presence detector frame rate. /// Note: This value is a factor 1000 larger than the RSS value /// Default Value: 12000 mHz /// @param rate Frame rate, in mHz /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setPresenceFrameRate(uint32_t rate); + sfTkError_t setFrameRate(uint32_t rate); /// @brief This function returns the threshold for detecting faster /// movements inside frames. @@ -408,7 +408,7 @@ class sfDevXM125Presence : public sfDevXM125Core /// Default Value: 1300 /// @param thresh threshold for faster movements /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceIntraDetectionThreshold(uint32_t &thresh); + sfTkError_t getIntraDetectionThreshold(uint32_t &thresh); /// @brief This function sets the threshold for detecting faster /// movements inside frames. @@ -416,7 +416,7 @@ class sfDevXM125Presence : public sfDevXM125Core /// Default Value: 1300 /// @param thresh threshold for faster movements /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setPresenceIntraDetectionThreshold(uint32_t thresh); + sfTkError_t setIntraDetectionThreshold(uint32_t thresh); /// @brief This function returns the threshold for detecting slower /// movements inside frames. @@ -424,7 +424,7 @@ class sfDevXM125Presence : public sfDevXM125Core /// Default Value: 1000 /// @param thresh threshold for faster movements /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceInterDetectionThreshold(uint32_t &thresh); + sfTkError_t getInterDetectionThreshold(uint32_t &thresh); /// @brief This function sets the threshold for detecting slower /// movements inside frames. @@ -432,7 +432,7 @@ class sfDevXM125Presence : public sfDevXM125Core /// Default Value: 1000 /// @param thresh threshold for faster movements /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setPresenceInterDetectionThreshold(uint32_t thresh); + sfTkError_t setInterDetectionThreshold(uint32_t thresh); /// @brief This function returns the time constant of the low pass /// filter for the inter-frame deviation between fast and slow. @@ -440,7 +440,7 @@ class sfDevXM125Presence : public sfDevXM125Core /// Default Value: 500 ms /// @param time time in ms /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceInterFrameDeviationTime(uint32_t &time); + sfTkError_t getInterFrameDeviationTime(uint32_t &time); /// @brief This function sets the time constant of the low pass /// filter for the inter-frame deviation between fast and slow. @@ -448,7 +448,7 @@ class sfDevXM125Presence : public sfDevXM125Core /// Default Value: 500 ms /// @param time time in ms /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setPresenceInterFrameDeviationTime(uint32_t time); + sfTkError_t setInterFrameDeviationTime(uint32_t time); /// @brief This function returns the cutoff frequency of the low pass /// filter for the fast filtered absolute sweep mean. @@ -456,7 +456,7 @@ class sfDevXM125Presence : public sfDevXM125Core /// Default Value: 6000 mHz /// @param cut cutoff frequency in mHz /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceInterFrameFastCutoff(uint32_t &cut); + sfTkError_t getInterFrameFastCutoff(uint32_t &cut); /// @brief This function sets the cutoff frequency of the low pass /// filter for the fast filtered absolute sweep mean. @@ -464,7 +464,7 @@ class sfDevXM125Presence : public sfDevXM125Core /// Default Value: 6000 mHz /// @param cut cutoff frequency in mHz /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setPresenceInterFrameFastCutoff(uint32_t cut); + sfTkError_t setInterFrameFastCutoff(uint32_t cut); /// @brief This function returns the cutoff frequency of the low pass /// filter for the slow filtered absolute sweep mean. @@ -472,7 +472,7 @@ class sfDevXM125Presence : public sfDevXM125Core /// Default Value: 200 mHz /// @param cut cutoff frequency in mHz /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceInterFrameSlowCutoff(uint32_t &cut); + sfTkError_t getInterFrameSlowCutoff(uint32_t &cut); /// @brief This function sets the cutoff frequency of the low pass /// filter for the slow filtered absolute sweep mean. @@ -480,7 +480,7 @@ class sfDevXM125Presence : public sfDevXM125Core /// Default Value: 200 mHz /// @param cut cutoff frequency in mHz /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setPresenceInterFrameSlowCutoff(uint32_t cut); + sfTkError_t setInterFrameSlowCutoff(uint32_t cut); /// @brief This functions returns time constant for the depthwise /// filtering in the intra-frame part @@ -488,7 +488,7 @@ class sfDevXM125Presence : public sfDevXM125Core /// Default Value: 150ms /// @param time time const in ms /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceIntraFrameTimeConst(uint32_t &time); + sfTkError_t getIntraFrameTimeConst(uint32_t &time); /// @brief This functions sets time constant for the depthwise /// filtering in the intra-frame part @@ -496,7 +496,7 @@ class sfDevXM125Presence : public sfDevXM125Core /// Default Value: 150ms /// @param time time const in ms /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setPresenceIntraFrameTimeConst(uint32_t time); + sfTkError_t setIntraFrameTimeConst(uint32_t time); /// @brief This function returns time constant for the output in /// the intra-frame part @@ -504,7 +504,7 @@ class sfDevXM125Presence : public sfDevXM125Core /// Default Value: 300ms /// @param time time const in ms /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceIntraOutputTimeConst(uint32_t &time); + sfTkError_t getIntraOutputTimeConst(uint32_t &time); /// @brief This function sets the time constant for the output in /// the intra-frame part @@ -512,7 +512,7 @@ class sfDevXM125Presence : public sfDevXM125Core /// Default Value: 300ms /// @param time time const in ms /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setPresenceIntraOutputTimeConst(uint32_t time); + sfTkError_t setIntraOutputTimeConst(uint32_t time); /// @brief This function returns time constant for the output in /// the inter-frame part @@ -520,7 +520,7 @@ class sfDevXM125Presence : public sfDevXM125Core /// Default Value: 2000ms /// @param time time const in ms /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceInterOutputTimeConst(uint32_t &time); + sfTkError_t getInterOutputTimeConst(uint32_t &time); /// @brief This function sets the time constant for the output in /// the inter-frame part @@ -528,45 +528,45 @@ class sfDevXM125Presence : public sfDevXM125Core /// Default Value: 2000ms /// @param time time const in ms /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setPresenceInterOutputTimeConst(uint32_t time); + sfTkError_t setInterOutputTimeConst(uint32_t time); /// @brief This function returns if enable/disable for the automatic /// selection of profile based on start point of measurement. /// Default Value: true /// @param en enable/disable selection /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceAutoProfileEn(bool &en); + sfTkError_t getAutoProfileEn(bool &en); /// @brief This function enables/disables the automatic selection /// of profile based on start point of measurement. /// Default Value: true /// @param en enable/disable selection /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setPresenceAutoProfileEn(bool en); + sfTkError_t setAutoProfileEn(bool en); /// @brief This function returns the Enable/Disable /// automatic selection of step length based on the profile. /// @param en Enable/disable selection /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceAutoStepLengthEn(bool &en); + sfTkError_t getAutoStepLengthEn(bool &en); /// @brief This function Enables/Disables automatic selection /// of step length based on the profile. /// @param en Enable/disable selection /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setPresenceAutoStepLengthEn(bool en); + sfTkError_t setAutoStepLengthEn(bool en); /// @brief This function returns the profile in use. The profile will only /// be used if profile auto selection was disabled. /// @param prof Profile to use (enum) /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceManualProfile(uint32_t &prof); + sfTkError_t getManualProfile(uint32_t &prof); /// @brief This function sets the profile to use. The profile will only /// be used if profile auto selection was disabled. /// @param prof Profile to use (enum) /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setPresenceManualProfile(uint32_t prof); + sfTkError_t setManualProfile(uint32_t prof); /// @brief THis function returns the number of steps between each data point. /// NOTE: The manual step length will only be used if step length auto selection @@ -574,7 +574,7 @@ class sfDevXM125Presence : public sfDevXM125Core /// Default Value: 72 /// @param length number of steps /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceManualStepLength(uint32_t &length); + sfTkError_t getManualStepLength(uint32_t &length); /// @brief THis function returns the number of steps between each data point. /// NOTE: The manual step length will only be used if step length auto selection @@ -582,21 +582,21 @@ class sfDevXM125Presence : public sfDevXM125Core /// Default Value: 72 /// @param length number of steps /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setPresenceManualStepLength(uint32_t length); + sfTkError_t setManualStepLength(uint32_t length); /// @brief This function returns the start of measured interval in mm. /// Note: This value is a factor 1000 larger than the RSS value /// Default Value: 300mm /// @param start measured start interval in mm /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceStart(uint32_t &start); + sfTkError_t getStart(uint32_t &start); /// @brief This function sets the start of measured interval in mm. /// Note: This value is a factor 1000 larger than the RSS value /// Default Value: 300mm /// @param start measured start interval in mm /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setPresenceStart(uint32_t start); + sfTkError_t setStart(uint32_t start); /// @brief This function returns the end point of measurement /// interval in millimeters. @@ -604,7 +604,7 @@ class sfDevXM125Presence : public sfDevXM125Core /// Default Value: 2500 /// @param end End point of measurement in mm /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceEnd(uint32_t &end); + sfTkError_t getEnd(uint32_t &end); /// @brief This function returns the end point of measurement /// interval in millimeters. @@ -612,96 +612,96 @@ class sfDevXM125Presence : public sfDevXM125Core /// Default Value: 2500 /// @param end End point of measurement in mm /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setPresenceEnd(uint32_t end); + sfTkError_t setEnd(uint32_t end); /// @brief This function returns if the device is enabled/disabled /// for the reset of the presence filters during start/restart. /// Default Value: true /// @param reset enabled/disabled /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceResetFilters(bool &reset); + sfTkError_t getResetFilters(bool &reset); /// @brief This function sets if the device is enabled/disabled /// for the reset of the presence filters during start/restart . /// Default Value: true /// @param reset enabled/disabled /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setPresenceResetFilters(bool reset); + sfTkError_t setResetFilters(bool reset); /// @brief This function returns the hardware accelerated average /// sampled (HWAAS). /// Default Value: 32 /// @param avg average samples /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceHWAAS(uint32_t &avg); + sfTkError_t getHWAAS(uint32_t &avg); /// @brief This function sets the hardware accelerated average /// sampled (HWAAS). /// Default Value: 32 /// @param avg average samples /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setPresenceHWAAS(uint32_t avg); + sfTkError_t setHWAAS(uint32_t avg); /// @brief This function returns the output presence detection on /// generic GPIO. /// @param detected Output presence detected /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceDetectionOnGPIO(uint32_t &detected); + sfTkError_t getDetectionOnGPIO(uint32_t &detected); /// @brief This function returns the output presence detection on /// generic GPIO. /// @param detected Output presence detected /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setPresenceDetectionOnGPIO(uint32_t detected); + sfTkError_t setDetectionOnGPIO(uint32_t detected); /// @brief This function sets the execute command /// @param cmd command to send to device /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t setPresenceCommand(uint32_t cmd); + sfTkError_t setCommand(uint32_t cmd); /// @brief This function applies the configuration to the device by /// writing the defined value to the presence command register /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t presenceApplyConfiguration(); + sfTkError_t applyConfiguration(); /// @brief This function starts the device by writing the defined /// start value to the presence command register /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t presenceStart(); + sfTkError_t start(); /// @brief This function stops the device by writing the defined /// stop value to the presence command register /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t presenceStop(); + sfTkError_t stop(); /// @brief This function enables the uart logs of the device by /// writing the defined value to the presence command register /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t presenceEnableUartLogs(); + sfTkError_t enableUartLogs(); /// @brief This function disables the uart logs of the device by /// writing the defined value to the presence command register /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t presenceDisableUartLogs(); + sfTkError_t disableUartLogs(); /// @brief This function enables the configuration log of the device /// by writing the defined value to the presence command register /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t presenceLogConfiguration(); + sfTkError_t logConfiguration(); /// @brief This function resets the presence detector settings /// of the device /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t presenceReset(); + sfTkError_t reset(); /// @brief This function returns the busy bit of the presence status register /// @param busy Device busy or not /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t getPresenceBusy(uint32_t &busy); + sfTkError_t getBusy(uint32_t &busy); /// @brief Completes a busy wait loop while the device is uploading /// information by waiting for the status. Checks the error status register /// to wait until errors are completed/gone /// @return ksfTkErrOk on success, or error code (value < -1) - sfTkError_t presenceBusyWait(); + sfTkError_t busyWait(); }; \ No newline at end of file From 74cc750ad705942fe01bc337e8994af4571b5b33 Mon Sep 17 00:00:00 2001 From: Kirk Benell Date: Sun, 23 Mar 2025 18:43:21 -0600 Subject: [PATCH 6/8] class to support V1 api sigs --- src/sfTk/sfDevXM125PresenceV1.h | 700 ++++++++++++++++++++++++++++++++ 1 file changed, 700 insertions(+) create mode 100644 src/sfTk/sfDevXM125PresenceV1.h diff --git a/src/sfTk/sfDevXM125PresenceV1.h b/src/sfTk/sfDevXM125PresenceV1.h new file mode 100644 index 0000000..eb1df9f --- /dev/null +++ b/src/sfTk/sfDevXM125PresenceV1.h @@ -0,0 +1,700 @@ +/** + * @file sfDevXM125Presence.h + * @brief Header of the SparkFun Qwiic XM125 Library. + * + * This file contains the header the Presence Application object + * + * @author SparkFun Electronics + * @date 2024-2025 + * @copyright Copyright (c) 2024-2025, SparkFun Electronics Inc. This project is released under the MIT License. + * + * SPDX-License-Identifier: MIT + */ +#pragma once + +#include "sfDevXM125Presence.h" + + +// Presence class definition + +class sfDevXM125PresenceV1 : public sfDevXM125Presence +{ + public: + /** + * @brief Initializes the Presence detector device. + * + * This function sets up the I2C communication and performs initial checks + * to ensure the device is ready for operation. + * + * @param theBus Pointer to the I2C bus object. If nullptr, the default bus is used. + * @return ksfTkErrOk on success, or error code (value < -1) on failure. + */ + sfTkError_t begin(sfTkII2C *theBus = nullptr) + { + return sfDevXM125Presence::begin(theBus); + } + /// @brief This function sets all the beginning values for a basic I2C + /// example to be run on the device for presence sensing. + /// @param start Start value for presence sensing in mm - default value is 1000 + /// @param end End value for presence sensing in mm - default value is 5000 + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t presenceDetectorStart(uint32_t start = 1000, uint32_t end = 5000) + { + return sfDevXM125Presence::detectorStart(start, end); + } + + /// @brief This function returns the presence value of the register + /// with all the checks in place as per the I2C Datasheet. + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceDistanceValuemm(uint32_t &presenceVal) + { + return sfDevXM125Presence::getDistanceValuemm(presenceVal); + } + + /// @brief This function returns the RSS version number + /// @param version Version number + /// @param patch Patch version number + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceDetectorVersion(uint32_t &major, uint32_t &minor, uint32_t &patch) + { + return sfDevXM125Presence::getDetectorVersion(major, minor, patch); + } + + /// @brief This function returns the protocol state error + /// @param state Error code for device + /// 0 = Protocol state error + /// 1 = Packet length error + /// 2 = Address error + /// 3 = Write failed + /// 4 = Write to read only + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceDetectorError(uint32_t &error) + { + return sfDevXM125Presence::getDetectorError(error); + } + + /// @brief This function returns the measure counter; the number of + /// measurements performed since restart. + /// @param counter number of measurements + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceMeasureCounter(uint32_t &counter) + { + return sfDevXM125Presence::getMeasureCounter(counter); + } + + /// @brief This function returns the detector status flags. See page 17, section + /// 6.2.4 Detector Status + /// @param status Status detector flag + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceDetectorStatus(uint32_t &status) + { + return sfDevXM125Presence::getDetectorStatus(status); + } + + /// @brief This function returns the error status according to the bit + /// mask value for the presence devices errors and busy bit + /// @param status Error status of device (see function for exact error) + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceDetectorErrorStatus(uint32_t &status) + { + return sfDevXM125Presence::getDetectorErrorStatus(status); + } + + /// @brief This function returns if there was presence detected + /// @param detected Presence Detected + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceDetectorPresenceDetected(uint32_t &detected) + { + return sfDevXM125Presence::getDetectorPresenceDetected(detected); + } + + /// @brief This function returns if there was presence detected, sticky bit with + /// clear on read. + /// @param sticky Sticky Presence Detected + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceDetectorPresenceStickyDetected(uint32_t &sticky) + { + return sfDevXM125Presence::getDetectorPresenceStickyDetected(sticky); + } + + /// @brief This function returns the indication that the presence detector + /// failed. + /// @param calibrate Indication of sensor calibration + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceDetectorRegError(uint32_t &error) + { + return sfDevXM125Presence::getDetectorRegError(error); + } + + /// @brief This function returns the temperature in sensor during measurement (in + /// degree Celsius). Note that it has poor absolute accuracy and should only + /// be used for relative temperature measurements. + /// @param temp Relative temperature + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceTemperature(uint32_t &temp) + { + return sfDevXM125Presence::getTemperature(temp); + } + + /// @brief This function returns the distance, in millimeters, for the detected + /// presence. + /// @param distance distance in mm + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceDistance(uint32_t &distance) + { + return sfDevXM125Presence::getDistance(distance); + } + + /// @brief This function returns the measure of amount of fast motion detected. + /// @param intra Measure of fast motion + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceIntraPresenceScore(uint32_t &intra) + { + return sfDevXM125Presence::getIntraPresenceScore(intra); + } + + /// @brief This function returns the measure of amount of slow motion detected. + /// @param inter Measure of slow motion + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceInterPresenceScore(uint32_t &inter) + { + return sfDevXM125Presence::getInterPresenceScore(inter); + } + + /// @brief This function returns the number of sweeps that will be + /// captured in each frame (measurement). + /// Default Value: 16 seconds + /// @param sweeps Number of sweeps + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceSweepsPerFrame(uint32_t &sweeps) + { + return sfDevXM125Presence::getSweepsPerFrame(sweeps); + } + + /// @brief This function sets the number of sweeps that will be + /// captured in each frame (measurement). + /// Default Value: 16 seconds + /// @param sweeps Number of sweeps + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setPresenceSweepsPerFrame(uint32_t sweeps) + { + return sfDevXM125Presence::setSweepsPerFrame(sweeps); + } + + /// @brief Returns the number of seconds the inter-frame presence score needs to decrease before + /// exponential scaling starts for faster decline. Should be between 0 and 30 where 0 + /// means no timeout. + /// Default Value: 3 seconds + /// @param time Number of seconds + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceInterFramePresenceTimeout(uint32_t &time) + { + return sfDevXM125Presence::getInterFramePresenceTimeout(time); + } + + /// @brief Sets the number of seconds the inter-frame presence score needs to decrease before + /// exponential scaling starts for faster decline. Should be between 0 and 30 where 0 + /// means no timeout. + /// Default Value: 3 seconds + /// @param time Number of seconds + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setPresenceInterFramePresenceTimeout(uint32_t time) + { + return sfDevXM125Presence::setInterFramePresenceTimeout(time); + } + + /// @brief This function returns the enable to increase detection of slow + /// motions by utilizing the phase information in the Sparse IQ data + /// @param en Enables increased detection + /// Default Value: false + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceInterPhaseBoostEnabled(bool &en) + { + return sfDevXM125Presence::getInterPhaseBoostEnabled(en); + } + + /// @brief This function sets the enable to increase detection of slow + /// motions by utilizing the phase information in the Sparse IQ data + /// @param en Enables increased detection + /// Default Value: false + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setPresenceInterPhaseBoostEnabled(bool en) + { + return sfDevXM125Presence::setInterPhaseBoostEnabled(en); + } + + /// @brief This function returns the bit to enable to detect faster + /// movements inside frames. + /// Default Value: true + /// @param en Enables faster detection + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceIntraDetectionEnabled(bool &en) + { + return sfDevXM125Presence::getIntraDetectionEnabled(en); + } + + /// @brief This function returns the bit to enable to detect slower + /// movements between frames. + /// Default Value: true + /// @param en Enables faster detection + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setPresenceInterDetectionEnabled(bool en) + { + return sfDevXM125Presence::setInterDetectionEnabled(en); + } + + /// @brief This function returns the presence detector frame rate. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 12000 mHz + /// @param rate Frame rate, in mHz + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceFrameRate(uint32_t &rate) + { + return sfDevXM125Presence::getFrameRate(rate); + } + + /// @brief This function sets the presence detector frame rate. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 12000 mHz + /// @param rate Frame rate, in mHz + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setPresenceFrameRate(uint32_t rate) + { + return sfDevXM125Presence::setFrameRate(rate); + } + + /// @brief This function returns the threshold for detecting faster + /// movements inside frames. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 1300 + /// @param thresh threshold for faster movements + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceIntraDetectionThreshold(uint32_t &thresh) + { + return sfDevXM125Presence::getIntraDetectionThreshold(thresh); + } + + /// @brief This function sets the threshold for detecting faster + /// movements inside frames. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 1300 + /// @param thresh threshold for faster movements + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setPresenceIntraDetectionThreshold(uint32_t thresh) + { + return sfDevXM125Presence::setIntraDetectionThreshold(thresh); + } + + /// @brief This function returns the threshold for detecting slower + /// movements inside frames. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 1000 + /// @param thresh threshold for faster movements + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceInterDetectionThreshold(uint32_t &thresh) + { + return sfDevXM125Presence::getInterDetectionThreshold(thresh); + } + + /// @brief This function sets the threshold for detecting slower + /// movements inside frames. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 1000 + /// @param thresh threshold for faster movements + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setPresenceInterDetectionThreshold(uint32_t thresh) + { + return sfDevXM125Presence::setInterDetectionThreshold(thresh); + } + + /// @brief This function returns the time constant of the low pass + /// filter for the inter-frame deviation between fast and slow. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 500 ms + /// @param time time in ms + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceInterFrameDeviationTime(uint32_t &time) + { + return sfDevXM125Presence::getInterFrameDeviationTime(time); + } + + /// @brief This function sets the time constant of the low pass + /// filter for the inter-frame deviation between fast and slow. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 500 ms + /// @param time time in ms + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setPresenceInterFrameDeviationTime(uint32_t time) + { + return sfDevXM125Presence::setInterFrameDeviationTime(time); + } + + /// @brief This function returns the cutoff frequency of the low pass + /// filter for the fast filtered absolute sweep mean. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 6000 mHz + /// @param cut cutoff frequency in mHz + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceInterFrameFastCutoff(uint32_t &cut) + { + return sfDevXM125Presence::getInterFrameFastCutoff(cut); + } + + /// @brief This function sets the cutoff frequency of the low pass + /// filter for the fast filtered absolute sweep mean. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 6000 mHz + /// @param cut cutoff frequency in mHz + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setPresenceInterFrameFastCutoff(uint32_t cut) + { + return sfDevXM125Presence::setInterFrameFastCutoff(cut); + } + + /// @brief This function returns the cutoff frequency of the low pass + /// filter for the slow filtered absolute sweep mean. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 200 mHz + /// @param cut cutoff frequency in mHz + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceInterFrameSlowCutoff(uint32_t &cut) + { + return sfDevXM125Presence::getInterFrameSlowCutoff(cut); + } + + /// @brief This function sets the cutoff frequency of the low pass + /// filter for the slow filtered absolute sweep mean. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 200 mHz + /// @param cut cutoff frequency in mHz + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setPresenceInterFrameSlowCutoff(uint32_t cut) + { + return sfDevXM125Presence::setInterFrameSlowCutoff(cut); + } + + /// @brief This functions returns time constant for the depthwise + /// filtering in the intra-frame part + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 150ms + /// @param time time const in ms + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceIntraFrameTimeConst(uint32_t &time) + { + return sfDevXM125Presence::getIntraFrameTimeConst(time); + } + + /// @brief This functions sets time constant for the depthwise + /// filtering in the intra-frame part + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 150ms + /// @param time time const in ms + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setPresenceIntraFrameTimeConst(uint32_t time) + { + return sfDevXM125Presence::setIntraFrameTimeConst(time); + } + + /// @brief This function returns time constant for the output in + /// the intra-frame part + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 300ms + /// @param time time const in ms + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceIntraOutputTimeConst(uint32_t &time) + { + return sfDevXM125Presence::getIntraOutputTimeConst(time); + } + + /// @brief This function sets the time constant for the output in + /// the intra-frame part + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 300ms + /// @param time time const in ms + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setPresenceIntraOutputTimeConst(uint32_t time) + { + return sfDevXM125Presence::setIntraOutputTimeConst(time); + } + + /// @brief This function returns time constant for the output in + /// the inter-frame part + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 2000ms + /// @param time time const in ms + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceInterOutputTimeConst(uint32_t &time) + { + return sfDevXM125Presence::getInterOutputTimeConst(time); + } + + /// @brief This function sets the time constant for the output in + /// the inter-frame part + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 2000ms + /// @param time time const in ms + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setPresenceInterOutputTimeConst(uint32_t time) + { + return sfDevXM125Presence::setInterOutputTimeConst(time); + } + + /// @brief This function returns if enable/disable for the automatic + /// selection of profile based on start point of measurement. + /// Default Value: true + /// @param en enable/disable selection + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceAutoProfileEn(bool &en) + { + return sfDevXM125Presence::getAutoProfileEn(en); + } + + /// @brief This function enables/disables the automatic selection + /// of profile based on start point of measurement. + /// Default Value: true + /// @param en enable/disable selection + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setPresenceAutoProfileEn(bool en) + { + return sfDevXM125Presence::setAutoProfileEn(en); + } + + /// @brief This function returns the Enable/Disable + /// automatic selection of step length based on the profile. + /// @param en Enable/disable selection + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceAutoStepLengthEn(bool &en) + { + return sfDevXM125Presence::getAutoStepLengthEn(en); + } + + /// @brief This function Enables/Disables automatic selection + /// of step length based on the profile. + /// @param en Enable/disable selection + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setPresenceAutoStepLengthEn(bool en) + { + return sfDevXM125Presence::setAutoStepLengthEn(en); + } + + /// @brief This function returns the profile in use. The profile will only + /// be used if profile auto selection was disabled. + /// @param prof Profile to use (enum) + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceManualProfile(uint32_t &prof) + { + return sfDevXM125Presence::getManualProfile(prof); + } + + /// @brief This function sets the profile to use. The profile will only + /// be used if profile auto selection was disabled. + /// @param prof Profile to use (enum) + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setPresenceManualProfile(uint32_t prof) + { + return sfDevXM125Presence::setManualProfile(prof); + } + + /// @brief THis function returns the number of steps between each data point. + /// NOTE: The manual step length will only be used if step length auto selection + /// was disabled + /// Default Value: 72 + /// @param length number of steps + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceManualStepLength(uint32_t &length) + { + return sfDevXM125Presence::getManualStepLength(length); + } + + /// @brief THis function returns the number of steps between each data point. + /// NOTE: The manual step length will only be used if step length auto selection + /// was disabled + /// Default Value: 72 + /// @param length number of steps + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setPresenceManualStepLength(uint32_t length) + { + return sfDevXM125Presence::setManualStepLength(length); + } + + /// @brief This function returns the start of measured interval in mm. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 300mm + /// @param start measured start interval in mm + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceStart(uint32_t &start) + { + return sfDevXM125Presence::getStart(start); + } + + /// @brief This function sets the start of measured interval in mm. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 300mm + /// @param start measured start interval in mm + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setPresenceStart(uint32_t start) + { + return sfDevXM125Presence::setStart(start); + } + + /// @brief This function returns the end point of measurement + /// interval in millimeters. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 2500 + /// @param end End point of measurement in mm + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceEnd(uint32_t &end) + { + return sfDevXM125Presence::getEnd(end); + } + + /// @brief This function returns the end point of measurement + /// interval in millimeters. + /// Note: This value is a factor 1000 larger than the RSS value + /// Default Value: 2500 + /// @param end End point of measurement in mm + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setPresenceEnd(uint32_t end) + { + return sfDevXM125Presence::setEnd(end); + } + + /// @brief This function returns if the device is enabled/disabled + /// for the reset of the presence filters during start/restart. + /// Default Value: true + /// @param reset enabled/disabled + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceResetFilters(bool &reset) + { + return sfDevXM125Presence::getResetFilters(reset); + } + + /// @brief This function sets if the device is enabled/disabled + /// for the reset of the presence filters during start/restart . + /// Default Value: true + /// @param reset enabled/disabled + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setPresenceResetFilters(bool reset) + { + return sfDevXM125Presence::setResetFilters(reset); + } + + /// @brief This function returns the hardware accelerated average + /// sampled (HWAAS). + /// Default Value: 32 + /// @param avg average samples + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceHWAAS(uint32_t &avg) + { + return sfDevXM125Presence::getHWAAS(avg); + } + + /// @brief This function sets the hardware accelerated average + /// sampled (HWAAS). + /// Default Value: 32 + /// @param avg average samples + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setPresenceHWAAS(uint32_t avg) + { + return sfDevXM125Presence::setHWAAS(avg); + } + + /// @brief This function returns the output presence detection on + /// generic GPIO. + /// @param detected Output presence detected + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceDetectionOnGPIO(uint32_t &detected) + { + return sfDevXM125Presence::getDetectionOnGPIO(detected); + } + + /// @brief This function sets the output presence detection on + /// generic GPIO. + /// @param detected Output presence detected + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setPresenceDetectionOnGPIO(uint32_t detected) + { + return sfDevXM125Presence::setDetectionOnGPIO(detected); + } + + /// @brief This function sets the execute command + /// @param cmd command to send to device + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t setPresenceCommand(uint32_t cmd) + { + return sfDevXM125Presence::setCommand(cmd); + } + + /// @brief This function applies the configuration to the device by + /// writing the defined value to the presence command register + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t presenceApplyConfiguration() + { + return sfDevXM125Presence::applyConfiguration(); + } + + /// @brief This function starts the device by writing the defined + /// start value to the presence command register + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t presenceStart() + { + return sfDevXM125Presence::start(); + } + + /// @brief This function stops the device by writing the defined + /// stop value to the presence command register + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t presenceStop() + { + return sfDevXM125Presence::stop(); + } + + /// @brief This function enables the uart logs of the device by + /// writing the defined value to the presence command register + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t presenceEnableUartLogs() + { + return sfDevXM125Presence::enableUartLogs(); + } + + /// @brief This function disables the uart logs of the device by + /// writing the defined value to the presence command register + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t presenceDisableUartLogs() + { + return sfDevXM125Presence::disableUartLogs(); + } + + /// @brief This function enables the configuration log of the device + /// by writing the defined value to the presence command register + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t presenceLogConfiguration() + { + return sfDevXM125Presence::logConfiguration(); + } + + /// @brief This function resets the presence detector settings + /// of the device + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t presenceReset() + { + return sfDevXM125Presence::reset(); + } + + /// @brief This function returns the busy bit of the presence status register + /// @param busy Device busy or not + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t getPresenceBusy(uint32_t &busy) + { + return sfDevXM125Presence::getBusy(busy); + } + + /// @brief Completes a busy wait loop while the device is uploading + /// information by waiting for the status. Checks the error status register + /// to wait until errors are completed/gone + /// @return ksfTkErrOk on success, or error code (value < -1) + sfTkError_t presenceBusyWait() + { + return sfDevXM125Presence::busyWait(); + } +}; \ No newline at end of file From f3c19b8284e0b643b4ddaad95765964475fdab78 Mon Sep 17 00:00:00 2001 From: Kirk Benell Date: Sun, 23 Mar 2025 18:43:51 -0600 Subject: [PATCH 7/8] add V1 Presence class for backward compat --- src/SparkFun_Qwiic_XM125_Arduino_Library.h | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/SparkFun_Qwiic_XM125_Arduino_Library.h b/src/SparkFun_Qwiic_XM125_Arduino_Library.h index 6fe22f5..2f0dfea 100644 --- a/src/SparkFun_Qwiic_XM125_Arduino_Library.h +++ b/src/SparkFun_Qwiic_XM125_Arduino_Library.h @@ -25,6 +25,7 @@ // To support version 1.* API #include "sfTk/sfDevXM125DistanceV1.h" +#include "sfTk/sfDevXM125PresenceV1.h" // clang-format on #include @@ -163,6 +164,53 @@ class SparkFunXM125DistanceV1 : public sfDevXM125DistanceV1 return _i2cBus.ping() == ksfTkErrOk; } + private: + // I2C bus class + sfTkArdI2C _i2cBus; +}; + +/** + * @class SparkFunXM125Presence + * @brief Arduino class for the SparkFun Pulsed Coherent Radar Sensor - Acconeer XM125 (Qwiic) for presence detection. + * + * This class is to provide Version 1 compatibility for the SparkFun Pulsed Coherent Radar Sensor - presence detection. + * + * This class provides methods for initializing the sensor, checking connection status, and configuring the device + * for presence detection using I2C communication. + */ +class SparkFunXM125PresenceV1 : public sfDevXM125PresenceV1 +{ + public: + SparkFunXM125PresenceV1() + { + } + + /** + * @brief Sets up Arduino I2C driver using the specified I2C address then calls the super class begin. + * + * @param deviceAddress Address of the I2C device. Default is SFE_XM125_I2C_ADDRESS. + * @param wirePort Wire port of the I2C device. Default is Wire. + * @return True if successful, false otherwise. + */ + bool begin(uint8_t deviceAddress = SFE_XM125_I2C_ADDRESS, TwoWire &wirePort = Wire) + { + // Give the I2C port provided by the user to the I2C bus class. + _i2cBus.init(wirePort, deviceAddress); + + // Initialize the system - return results + return this->sfDevXM125PresenceV1::begin(&_i2cBus) == ksfTkErrOk; + } + + /** + * @brief Checks if the device is connected. + * + * @return True if the sensor is connected, false otherwise. + */ + bool isConnected() + { + return _i2cBus.ping() == ksfTkErrOk; + } + private: // I2C bus class sfTkArdI2C _i2cBus; From 5f5de1f08636e7a64868cf05c973631b54405fb4 Mon Sep 17 00:00:00 2001 From: Kirk Benell Date: Sun, 23 Mar 2025 18:46:00 -0600 Subject: [PATCH 8/8] updated Examples to new API for v2.0 --- .../Example01_PresenceBasicReadings.ino | 8 ++--- .../Example02_PresenceGPIO0Usage.ino | 20 +++++------ .../Example03_PresenceSerialPlotter.ino | 8 ++--- .../Example04_PresenceAdvancedReadings.ino | 20 +++++------ .../Example05_PresenceAdvancedSettings.ino | 34 +++++++++---------- 5 files changed, 45 insertions(+), 45 deletions(-) diff --git a/examples/Example01_PresenceBasicReadings/Example01_PresenceBasicReadings.ino b/examples/Example01_PresenceBasicReadings/Example01_PresenceBasicReadings.ino index 705e75f..a23cc4c 100644 --- a/examples/Example01_PresenceBasicReadings/Example01_PresenceBasicReadings.ino +++ b/examples/Example01_PresenceBasicReadings/Example01_PresenceBasicReadings.ino @@ -65,7 +65,7 @@ void setup() } // Start the sensor with default register values - int32_t setupError = radarSensor.presenceDetectorStart(MY_XM125_RANGE_START, MY_XM125_RANGE_END); + int32_t setupError = radarSensor.detectorStart(MY_XM125_RANGE_START, MY_XM125_RANGE_END); if (setupError != 0) { Serial.print("Presence Detection Start Setup Error: "); @@ -84,11 +84,11 @@ void setup() void loop() { // Busy wait loop until data is ready - radarSensor.presenceBusyWait(); + radarSensor.busyWait(); // Get the presence distance value and print out if no errors. - // Note - this returns if Presense is detected now, or since last check (sticky) - presValError = radarSensor.getPresenceDistanceValuemm(distance); + // Note - this returns if Presence is detected now, or since last check (sticky) + presValError = radarSensor.getDistanceValuemm(distance); if (presValError == 0) { diff --git a/examples/Example02_PresenceGPIO0Usage/Example02_PresenceGPIO0Usage.ino b/examples/Example02_PresenceGPIO0Usage/Example02_PresenceGPIO0Usage.ino index 71c993a..bd2dc56 100644 --- a/examples/Example02_PresenceGPIO0Usage/Example02_PresenceGPIO0Usage.ino +++ b/examples/Example02_PresenceGPIO0Usage/Example02_PresenceGPIO0Usage.ino @@ -70,10 +70,10 @@ void setup() // Presence Sensor Setup // Reset sensor configuration to reapply configuration registers - radarSensor.setPresenceCommand(SFE_XM125_PRESENCE_RESET_MODULE); + radarSensor.setCommand(SFE_XM125_PRESENCE_RESET_MODULE); // Check error and busy bits - radarSensor.getPresenceDetectorErrorStatus(errorStatus); + radarSensor.getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { Serial.print("Detector status error: "); @@ -83,19 +83,19 @@ void setup() delay(100); // Turn presence detection on GPIO0 on - if (radarSensor.setPresenceDetectionOnGPIO(1) != 0) + if (radarSensor.setDetectionOnGPIO(1) != 0) { Serial.println("GPIO0 Pin Setup Error"); } - radarSensor.getPresenceDetectionOnGPIO(gpioUsage); + radarSensor.getDetectionOnGPIO(gpioUsage); Serial.print("GPIO0 Detection Status: "); Serial.println(gpioUsage); // Apply configuration - if (radarSensor.setPresenceCommand(SFE_XM125_PRESENCE_APPLY_CONFIGURATION) != 0) + if (radarSensor.setCommand(SFE_XM125_PRESENCE_APPLY_CONFIGURATION) != 0) { // Check for errors - radarSensor.getPresenceDetectorErrorStatus(errorStatus); + radarSensor.getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { Serial.print("Detector status error: "); @@ -106,13 +106,13 @@ void setup() } // Poll detector status until busy bit is cleared - if (radarSensor.presenceBusyWait() != 0) + if (radarSensor.busyWait() != 0) { Serial.print("Busy wait error"); } // Check detector status - radarSensor.getPresenceDetectorErrorStatus(errorStatus); + radarSensor.getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { Serial.print("Detector status error: "); @@ -127,10 +127,10 @@ void setup() void loop() { // Busy wait loop until data is ready - radarSensor.presenceBusyWait(); + radarSensor.busyWait(); // Get the presence distance value and print out if no errors - presValError = radarSensor.getPresenceDistanceValuemm(distance); + presValError = radarSensor.getDistanceValuemm(distance); if (presValError == 0) { diff --git a/examples/Example03_PresenceSerialPlotter/Example03_PresenceSerialPlotter.ino b/examples/Example03_PresenceSerialPlotter/Example03_PresenceSerialPlotter.ino index 319ace7..b4c218a 100644 --- a/examples/Example03_PresenceSerialPlotter/Example03_PresenceSerialPlotter.ino +++ b/examples/Example03_PresenceSerialPlotter/Example03_PresenceSerialPlotter.ino @@ -68,7 +68,7 @@ void setup() delay(200); // Start the sensor with default register values - int32_t setupError = radarSensor.presenceDetectorStart(); + int32_t setupError = radarSensor.detectorStart(); if (setupError != 0) { Serial.print("Presence Detection Start Setup Error: "); @@ -83,14 +83,14 @@ void setup() void loop() { // Busy wait loop until data is ready - radarSensor.presenceBusyWait(); + radarSensor.busyWait(); // Get the presence distance value and print out if no errors - presValError = radarSensor.getPresenceDistanceValuemm(distance); + presValError = radarSensor.getDistanceValuemm(distance); if (presValError == 0) { - radarSensor.getPresenceDistance(distance); + radarSensor.getDistance(distance); Serial.println(distance); } diff --git a/examples/Example04_PresenceAdvancedReadings/Example04_PresenceAdvancedReadings.ino b/examples/Example04_PresenceAdvancedReadings/Example04_PresenceAdvancedReadings.ino index 512f80d..a6b230e 100644 --- a/examples/Example04_PresenceAdvancedReadings/Example04_PresenceAdvancedReadings.ino +++ b/examples/Example04_PresenceAdvancedReadings/Example04_PresenceAdvancedReadings.ino @@ -69,7 +69,7 @@ void setup() delay(200); // Start the sensor with default register values - int32_t setupError = radarSensor.presenceDetectorStart(); + int32_t setupError = radarSensor.detectorStart(); if (setupError != 0) { Serial.print("Presence Detection Start Setup Error: "); @@ -84,7 +84,7 @@ void setup() void loop() { // Check error bits - radarSensor.getPresenceDetectorErrorStatus(errorStatus); + radarSensor.getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { Serial.print("Detector status error: "); @@ -92,19 +92,19 @@ void loop() } // Start detector - if (radarSensor.setPresenceCommand(SFE_XM125_PRESENCE_START_DETECTOR) != 0) + if (radarSensor.setCommand(SFE_XM125_PRESENCE_START_DETECTOR) != 0) { Serial.println("Start detector error"); } // Poll detector status until busy bit is cleared - CHECK ON THIS! - if (radarSensor.presenceBusyWait() != 0) + if (radarSensor.busyWait() != 0) { Serial.println("Busy wait error"); } // Verify that no error bits are set in the detector status register - radarSensor.getPresenceDetectorErrorStatus(errorStatus); + radarSensor.getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { Serial.print("Detector status error: "); @@ -112,18 +112,18 @@ void loop() } // Read detector result register and determine detection status - radarSensor.getPresenceDetectorPresenceDetected(presenceDetected); - radarSensor.getPresenceDetectorPresenceStickyDetected(presenceDetectedSticky); + radarSensor.getDetectorPresenceDetected(presenceDetected); + radarSensor.getDetectorPresenceStickyDetected(presenceDetectedSticky); if ((presenceDetected == 1) || (presenceDetectedSticky == 1)) { - radarSensor.getPresenceDistance(distance); + radarSensor.getDistance(distance); Serial.print("Presence Detected: "); Serial.print(distance); Serial.println("mm"); - radarSensor.getPresenceIntraPresenceScore(intraScore); - radarSensor.getPresenceInterPresenceScore(interScore); + radarSensor.getIntraPresenceScore(intraScore); + radarSensor.getInterPresenceScore(interScore); Serial.print("Intra-Presence Score: "); Serial.println(intraScore); diff --git a/examples/Example05_PresenceAdvancedSettings/Example05_PresenceAdvancedSettings.ino b/examples/Example05_PresenceAdvancedSettings/Example05_PresenceAdvancedSettings.ino index 3988041..53c2833 100644 --- a/examples/Example05_PresenceAdvancedSettings/Example05_PresenceAdvancedSettings.ino +++ b/examples/Example05_PresenceAdvancedSettings/Example05_PresenceAdvancedSettings.ino @@ -72,10 +72,10 @@ void setup() // *** Presence Sensor Setup *** // Reset sensor configuration to reapply configuration registers - radarSensor.setPresenceCommand(SFE_XM125_PRESENCE_RESET_MODULE); + radarSensor.setCommand(SFE_XM125_PRESENCE_RESET_MODULE); // Check error and busy bits - radarSensor.getPresenceDetectorErrorStatus(errorStatus); + radarSensor.getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { Serial.print("Detector status error: "); @@ -85,30 +85,30 @@ void setup() delay(100); // Set Start register - if (radarSensor.setPresenceStart(beginReading) != 0) + if (radarSensor.setStart(beginReading) != 0) { Serial.println("Presence Start Error"); } - radarSensor.getPresenceStart(startVal); + radarSensor.getStart(startVal); Serial.print("Start Val: "); Serial.println(startVal); delay(100); // Set End register - if (radarSensor.setPresenceEnd(endReading) != 0) + if (radarSensor.setEnd(endReading) != 0) { Serial.println("Presence End Error"); } - radarSensor.getPresenceEnd(endVal); + radarSensor.getEnd(endVal); Serial.print("End Val: "); Serial.println(endVal); delay(100); // Apply configuration - if (radarSensor.setPresenceCommand(SFE_XM125_PRESENCE_APPLY_CONFIGURATION) != 0) + if (radarSensor.setCommand(SFE_XM125_PRESENCE_APPLY_CONFIGURATION) != 0) { // Check for errors - radarSensor.getPresenceDetectorErrorStatus(errorStatus); + radarSensor.getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { Serial.print("Detector status error: "); @@ -119,13 +119,13 @@ void setup() } // Poll detector status until busy bit is cleared - if (radarSensor.presenceBusyWait() != 0) + if (radarSensor.busyWait() != 0) { Serial.print("Busy wait error"); } // Check detector status - radarSensor.getPresenceDetectorErrorStatus(errorStatus); + radarSensor.getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { Serial.print("Detector status error: "); @@ -140,7 +140,7 @@ void setup() void loop() { // Check error bits - radarSensor.getPresenceDetectorErrorStatus(errorStatus); + radarSensor.getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { Serial.print("Detector status error: "); @@ -148,19 +148,19 @@ void loop() } // Start detector - if (radarSensor.setPresenceCommand(SFE_XM125_PRESENCE_START_DETECTOR) != 0) + if (radarSensor.setCommand(SFE_XM125_PRESENCE_START_DETECTOR) != 0) { Serial.println("Start detector error"); } // Poll detector status until busy bit is cleared - CHECK ON THIS! - if (radarSensor.presenceBusyWait() != 0) + if (radarSensor.busyWait() != 0) { Serial.println("Busy wait error"); } // Verify that no error bits are set in the detector status register - radarSensor.getPresenceDetectorErrorStatus(errorStatus); + radarSensor.getDetectorErrorStatus(errorStatus); if (errorStatus != 0) { Serial.print("Detector status error: "); @@ -168,12 +168,12 @@ void loop() } // Read detector result register and determine detection status - radarSensor.getPresenceDetectorPresenceDetected(presenceDetected); - radarSensor.getPresenceDetectorPresenceStickyDetected(presenceDetectedSticky); + radarSensor.getDetectorPresenceDetected(presenceDetected); + radarSensor.getDetectorPresenceStickyDetected(presenceDetectedSticky); if ((presenceDetected == 1) | (presenceDetectedSticky == 1)) { - radarSensor.getPresenceDistance(distance); + radarSensor.getDistance(distance); Serial.print("Presence Detected: "); Serial.print(distance); Serial.println("mm");