Skip to content

Commit c186934

Browse files
committed
moved examples to v2.0 interface
1 parent b4b6a8b commit c186934

File tree

4 files changed

+70
-70
lines changed

4 files changed

+70
-70
lines changed

examples/Example06_DistanceBasicReadings/Example06_DistanceBasicReadings.ino

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void setup()
5656
Serial.println("Starting Sensor...");
5757
Serial.println();
5858
// Start the sensor with the specified range values
59-
int32_t setupError = radarSensor.distanceBegin(MY_XM125_RANGE_START, MY_XM125_RANGE_END);
59+
int32_t setupError = radarSensor.distanceSetup(MY_XM125_RANGE_START, MY_XM125_RANGE_END);
6060
if (setupError != 0)
6161
{
6262
Serial.print("Distance Detection Start Setup Error: ");
@@ -79,7 +79,7 @@ void setup()
7979

8080
void loop()
8181
{
82-
uint32_t retCode = radarSensor.distanceDetectorReadingSetup();
82+
uint32_t retCode = radarSensor.detectorReadingSetup();
8383
if (retCode != 0)
8484
{
8585
Serial.print("Distance Reading Setup Error: ");
@@ -88,7 +88,7 @@ void loop()
8888

8989
// How many distance values were detected? (0-9)
9090
uint32_t numDistances = 0;
91-
radarSensor.getDistanceNumberDistances(numDistances);
91+
radarSensor.getNumberDistances(numDistances);
9292

9393
if (numDistances == 0)
9494
Serial.print(".");
@@ -103,7 +103,7 @@ void loop()
103103
int32_t distanceStrength = 0;
104104
for (uint32_t i = 0; i < numDistances; i++)
105105
{
106-
if (radarSensor.getDistancePeakDistance(i, distance) != ksfTkErrOk)
106+
if (radarSensor.getPeakDistance(i, distance) != ksfTkErrOk)
107107
{
108108
Serial.print("Error retrieving Distance Peak ");
109109
Serial.print(i);
@@ -129,7 +129,7 @@ void loop()
129129
Serial.print("m");
130130
}
131131

132-
if (radarSensor.getDistancePeakStrength(i, distanceStrength) != ksfTkErrOk)
132+
if (radarSensor.getPeakStrength(i, distanceStrength) != ksfTkErrOk)
133133
{
134134
Serial.print("Error retrieving Distance Peak Strength");
135135
Serial.print(i);

examples/Example07_DistanceThresholdSettings/Example07_DistanceThresholdSettings.ino

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ void setup()
6868

6969
// Distance Sensor Setup
7070
// Reset sensor configuration to reapply configuration registers
71-
radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_RESET_MODULE);
71+
radarSensor.setCommand(SFE_XM125_DISTANCE_RESET_MODULE);
7272

73-
radarSensor.distanceBusyWait();
73+
radarSensor.busyWait();
7474

7575
// Check error and busy bits
76-
radarSensor.getDistanceDetectorErrorStatus(errorStatus);
76+
radarSensor.getDetectorErrorStatus(errorStatus);
7777
if (errorStatus != 0)
7878
{
7979
Serial.print("Detector status error: ");
@@ -83,36 +83,36 @@ void setup()
8383
delay(100);
8484

8585
// Set Start register
86-
if (radarSensor.setDistanceStart(100) != 0)
86+
if (radarSensor.setStart(100) != 0)
8787
{
8888
Serial.println("Distance Start Error");
8989
}
90-
radarSensor.getDistanceStart(startVal);
90+
radarSensor.getStart(startVal);
9191
Serial.print("Start Val: ");
9292
Serial.println(startVal);
9393

9494
delay(100);
9595
// Set End register
96-
if (radarSensor.setDistanceEnd(4000) != 0)
96+
if (radarSensor.setEnd(4000) != 0)
9797
{
9898
Serial.println("Distance End Error");
9999
}
100-
radarSensor.getDistanceEnd(endVal);
100+
radarSensor.getEnd(endVal);
101101
Serial.print("End Val: ");
102102
Serial.println(endVal);
103103
delay(100);
104104

105105
// Set Distance Threshold Settings - Threshold Sensitivity (range: 0 to 1000)
106-
radarSensor.setDistanceThresholdSensitivity(100);
106+
radarSensor.setThresholdSensitivity(100);
107107

108108
// Set Fixed Amplitude Threshold
109-
radarSensor.setDistanceFixedAmpThreshold(100);
109+
radarSensor.setFixedAmpThreshold(100);
110110

111111
// Apply configuration
112-
if (radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_APPLY_CONFIGURATION) != 0)
112+
if (radarSensor.setCommand(SFE_XM125_DISTANCE_APPLY_CONFIGURATION) != 0)
113113
{
114114
// Check for errors
115-
radarSensor.getDistanceDetectorErrorStatus(errorStatus);
115+
radarSensor.getDetectorErrorStatus(errorStatus);
116116
if (errorStatus != 0)
117117
{
118118
Serial.print("Detector status error: ");
@@ -123,13 +123,13 @@ void setup()
123123
}
124124

125125
// Poll detector status until busy bit is cleared
126-
if (radarSensor.distanceBusyWait() != 0)
126+
if (radarSensor.busyWait() != 0)
127127
{
128128
Serial.print("Busy wait error");
129129
}
130130

131131
// Check detector status
132-
radarSensor.getDistanceDetectorErrorStatus(errorStatus);
132+
radarSensor.getDetectorErrorStatus(errorStatus);
133133
if (errorStatus != 0)
134134
{
135135
Serial.print("Detector status error: ");
@@ -144,54 +144,54 @@ void setup()
144144
void loop()
145145
{
146146
// Check error bits
147-
radarSensor.getDistanceDetectorErrorStatus(errorStatus);
147+
radarSensor.getDetectorErrorStatus(errorStatus);
148148
if (errorStatus != 0)
149149
{
150150
Serial.print("Detector status error: ");
151151
Serial.println(errorStatus);
152152
}
153153

154154
// Start detector
155-
if (radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_START_DETECTOR) != 0)
155+
if (radarSensor.setCommand(SFE_XM125_DISTANCE_START_DETECTOR) != 0)
156156
{
157157
Serial.println("Start detector error");
158158
}
159159

160160
// Poll detector status until busy bit is cleared - CHECK ON THIS!
161-
if (radarSensor.distanceBusyWait() != 0)
161+
if (radarSensor.busyWait() != 0)
162162
{
163163
Serial.println("Busy wait error");
164164
}
165165

166166
// Verify that no error bits are set in the detector status register
167-
radarSensor.getDistanceDetectorErrorStatus(errorStatus);
167+
radarSensor.getDetectorErrorStatus(errorStatus);
168168
if (errorStatus != 0)
169169
{
170170
Serial.print("Detector status error: ");
171171
Serial.println(errorStatus);
172172
}
173173

174174
// Check MEASURE_DISTANCE_ERROR for measurement failed
175-
radarSensor.getDistanceMeasureDistanceError(measDistErr);
175+
radarSensor.getMeasureDistanceError(measDistErr);
176176
if (measDistErr == 1)
177177
{
178178
Serial.println("Measure Distance Error");
179179
}
180180

181181
// Recalibrate device if calibration error is triggered
182-
radarSensor.getDistanceCalibrationNeeded(calibrateNeeded);
182+
radarSensor.getCalibrationNeeded(calibrateNeeded);
183183
if (calibrateNeeded == 1)
184184
{
185185
Serial.println("Calibration Needed - Recalibrating.. ");
186186
// Calibrate device (write RECALIBRATE command)
187-
radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_RECALIBRATE);
187+
radarSensor.setCommand(SFE_XM125_DISTANCE_RECALIBRATE);
188188
}
189189

190190
// Read PeakX Distance and PeakX Strength registers for the number of distances detected
191-
radarSensor.getDistancePeak0Distance(distancePeak0);
192-
radarSensor.getDistancePeak0Strength(distancePeakStrength0);
193-
radarSensor.getDistancePeak1Distance(distancePeak1);
194-
radarSensor.getDistancePeak1Strength(distancePeakStrength1);
191+
radarSensor.getPeak0Distance(distancePeak0);
192+
radarSensor.getPeak0Strength(distancePeakStrength0);
193+
radarSensor.getPeak1Distance(distancePeak1);
194+
radarSensor.getPeak1Strength(distancePeakStrength1);
195195

196196
// Read out 2 distances and peaks with threshold settings adjusted
197197
if (distancePeak0 != 0)

examples/Example08_DistanceSerialPlotter/Example08_DistanceSerialPlotter.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void setup()
5555
; // Runs forever
5656
}
5757

58-
int32_t setupError = radarSensor.distanceBegin();
58+
int32_t setupError = radarSensor.distanceSetup();
5959
if (setupError != 0)
6060
{
6161
Serial.print("Distance Detection Start Setup Error: ");
@@ -69,15 +69,15 @@ void setup()
6969

7070
void loop()
7171
{
72-
distanceSetupError = radarSensor.distanceDetectorReadingSetup();
72+
distanceSetupError = radarSensor.detectorReadingSetup();
7373
if (distanceSetupError != 0)
7474
{
7575
Serial.print("Distance Reading Setup Error: ");
7676
Serial.println(distanceSetupError);
7777
}
7878

7979
// Read PeakX Distance and PeakX Strength registers for the number of distances detected
80-
radarSensor.getDistancePeak0Distance(distancePeak0);
80+
radarSensor.getPeak0Distance(distancePeak0);
8181

8282
// If a peak distance was detected, then read out the distance and strength
8383
if (distancePeak0 != 0)

examples/Example09_DistanceAdvancedSettings/Example09_DistanceAdvancedSettings.ino

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ void setup()
6868

6969
// Distance Sensor Setup
7070
// Reset sensor configuration to reapply configuration registers
71-
radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_RESET_MODULE);
71+
radarSensor.setCommand(SFE_XM125_DISTANCE_RESET_MODULE);
7272

73-
radarSensor.distanceBusyWait();
73+
radarSensor.busyWait();
7474

7575
// Check error and busy bits
76-
radarSensor.getDistanceDetectorErrorStatus(errorStatus);
76+
radarSensor.getDetectorErrorStatus(errorStatus);
7777
if (errorStatus != 0)
7878
{
7979
Serial.print("Detector status error: ");
@@ -83,30 +83,30 @@ void setup()
8383
delay(100);
8484

8585
// Set Start register
86-
if (radarSensor.setDistanceStart(beginReading) != 0)
86+
if (radarSensor.setStart(beginReading) != 0)
8787
{
8888
Serial.println("Distance Start Error");
8989
}
90-
radarSensor.getDistanceStart(startVal);
90+
radarSensor.getStart(startVal);
9191
Serial.print("Start Val: ");
9292
Serial.println(startVal);
9393

9494
delay(100);
9595
// Set End register
96-
if (radarSensor.setDistanceEnd(endReading) != 0)
96+
if (radarSensor.setEnd(endReading) != 0)
9797
{
9898
Serial.println("Distance End Error");
9999
}
100-
radarSensor.getDistanceEnd(endVal);
100+
radarSensor.getEnd(endVal);
101101
Serial.print("End Val: ");
102102
Serial.println(endVal);
103103
delay(100);
104104

105105
// Apply configuration
106-
if (radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_APPLY_CONFIGURATION) != 0)
106+
if (radarSensor.setCommand(SFE_XM125_DISTANCE_APPLY_CONFIGURATION) != 0)
107107
{
108108
// Check for errors
109-
radarSensor.getDistanceDetectorErrorStatus(errorStatus);
109+
radarSensor.getDetectorErrorStatus(errorStatus);
110110
if (errorStatus != 0)
111111
{
112112
Serial.print("Detector status error: ");
@@ -117,13 +117,13 @@ void setup()
117117
}
118118

119119
// Poll detector status until busy bit is cleared
120-
if (radarSensor.distanceBusyWait() != 0)
120+
if (radarSensor.busyWait() != 0)
121121
{
122122
Serial.print("Busy wait error");
123123
}
124124

125125
// Check detector status
126-
radarSensor.getDistanceDetectorErrorStatus(errorStatus);
126+
radarSensor.getDetectorErrorStatus(errorStatus);
127127
if (errorStatus != 0)
128128
{
129129
Serial.print("Detector status error: ");
@@ -153,88 +153,88 @@ void outputResults(uint sample, uint32_t distance, int32_t strength)
153153
void loop()
154154
{
155155
// Check error bits
156-
radarSensor.getDistanceDetectorErrorStatus(errorStatus);
156+
radarSensor.getDetectorErrorStatus(errorStatus);
157157
if (errorStatus != 0)
158158
{
159159
Serial.print("Detector status error: ");
160160
Serial.println(errorStatus);
161161
}
162162

163163
// Start detector
164-
if (radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_START_DETECTOR) != 0)
164+
if (radarSensor.setCommand(SFE_XM125_DISTANCE_START_DETECTOR) != 0)
165165
{
166166
Serial.println("Start detector error");
167167
}
168168

169169
// Poll detector status until busy bit is cleared - CHECK ON THIS!
170-
if (radarSensor.distanceBusyWait() != 0)
170+
if (radarSensor.busyWait() != 0)
171171
{
172172
Serial.println("Busy wait error");
173173
}
174174

175175
// Verify that no error bits are set in the detector status register
176-
radarSensor.getDistanceDetectorErrorStatus(errorStatus);
176+
radarSensor.getDetectorErrorStatus(errorStatus);
177177
if (errorStatus != 0)
178178
{
179179
Serial.print("Detector status error: ");
180180
Serial.println(errorStatus);
181181
}
182182

183183
// Check MEASURE_DISTANCE_ERROR for measurement failed
184-
radarSensor.getDistanceMeasureDistanceError(measDistErr);
184+
radarSensor.getMeasureDistanceError(measDistErr);
185185
if (measDistErr == 1)
186186
{
187187
Serial.println("Measure Distance Error");
188188
}
189189

190190
// Recalibrate device if calibration error is triggered
191-
radarSensor.getDistanceCalibrationNeeded(calibrateNeeded);
191+
radarSensor.getCalibrationNeeded(calibrateNeeded);
192192
if (calibrateNeeded == 1)
193193
{
194194
Serial.println("Calibration Needed - Recalibrating.. ");
195195
// Calibrate device (write RECALIBRATE command)
196-
radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_RECALIBRATE);
196+
radarSensor.setCommand(SFE_XM125_DISTANCE_RECALIBRATE);
197197
}
198198

199199
// Read PeakX Distance and PeakX Strength registers for the number of distances detected
200-
radarSensor.getDistancePeak0Distance(distancePeak);
201-
radarSensor.getDistancePeak0Strength(distancePeakStrength);
200+
radarSensor.getPeak0Distance(distancePeak);
201+
radarSensor.getPeak0Strength(distancePeakStrength);
202202
outputResults(0, distancePeak, distancePeakStrength);
203203

204-
radarSensor.getDistancePeak1Distance(distancePeak);
205-
radarSensor.getDistancePeak1Strength(distancePeakStrength);
204+
radarSensor.getPeak1Distance(distancePeak);
205+
radarSensor.getPeak1Strength(distancePeakStrength);
206206
outputResults(1, distancePeak, distancePeakStrength);
207207

208-
radarSensor.getDistancePeak2Distance(distancePeak);
209-
radarSensor.getDistancePeak2Strength(distancePeakStrength);
208+
radarSensor.getPeak2Distance(distancePeak);
209+
radarSensor.getPeak2Strength(distancePeakStrength);
210210
outputResults(2, distancePeak, distancePeakStrength);
211211

212-
radarSensor.getDistancePeak3Distance(distancePeak);
213-
radarSensor.getDistancePeak3Strength(distancePeakStrength);
212+
radarSensor.getPeak3Distance(distancePeak);
213+
radarSensor.getPeak3Strength(distancePeakStrength);
214214
outputResults(3, distancePeak, distancePeakStrength);
215215

216-
radarSensor.getDistancePeak4Distance(distancePeak);
217-
radarSensor.getDistancePeak4Strength(distancePeakStrength);
216+
radarSensor.getPeak4Distance(distancePeak);
217+
radarSensor.getPeak4Strength(distancePeakStrength);
218218
outputResults(4, distancePeak, distancePeakStrength);
219219

220-
radarSensor.getDistancePeak5Distance(distancePeak);
221-
radarSensor.getDistancePeak5Strength(distancePeakStrength);
220+
radarSensor.getPeak5Distance(distancePeak);
221+
radarSensor.getPeak5Strength(distancePeakStrength);
222222
outputResults(5, distancePeak, distancePeakStrength);
223223

224-
radarSensor.getDistancePeak6Distance(distancePeak);
225-
radarSensor.getDistancePeak6Strength(distancePeakStrength);
224+
radarSensor.getPeak6Distance(distancePeak);
225+
radarSensor.getPeak6Strength(distancePeakStrength);
226226
outputResults(6, distancePeak, distancePeakStrength);
227227

228-
radarSensor.getDistancePeak7Distance(distancePeak);
229-
radarSensor.getDistancePeak7Strength(distancePeakStrength);
228+
radarSensor.getPeak7Distance(distancePeak);
229+
radarSensor.getPeak7Strength(distancePeakStrength);
230230
outputResults(7, distancePeak, distancePeakStrength);
231231

232-
radarSensor.getDistancePeak8Distance(distancePeak);
233-
radarSensor.getDistancePeak8Strength(distancePeakStrength);
232+
radarSensor.getPeak8Distance(distancePeak);
233+
radarSensor.getPeak8Strength(distancePeakStrength);
234234
outputResults(8, distancePeak, distancePeakStrength);
235235

236-
radarSensor.getDistancePeak9Distance(distancePeak);
237-
radarSensor.getDistancePeak9Strength(distancePeakStrength);
236+
radarSensor.getPeak9Distance(distancePeak);
237+
radarSensor.getPeak9Strength(distancePeakStrength);
238238
outputResults(9, distancePeak, distancePeakStrength);
239239

240240
// Half a second delay for easier readings

0 commit comments

Comments
 (0)