Skip to content

Commit 5f5de1f

Browse files
committed
updated Examples to new API for v2.0
1 parent f3c19b8 commit 5f5de1f

File tree

5 files changed

+45
-45
lines changed

5 files changed

+45
-45
lines changed

examples/Example01_PresenceBasicReadings/Example01_PresenceBasicReadings.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void setup()
6565
}
6666

6767
// Start the sensor with default register values
68-
int32_t setupError = radarSensor.presenceDetectorStart(MY_XM125_RANGE_START, MY_XM125_RANGE_END);
68+
int32_t setupError = radarSensor.detectorStart(MY_XM125_RANGE_START, MY_XM125_RANGE_END);
6969
if (setupError != 0)
7070
{
7171
Serial.print("Presence Detection Start Setup Error: ");
@@ -84,11 +84,11 @@ void setup()
8484
void loop()
8585
{
8686
// Busy wait loop until data is ready
87-
radarSensor.presenceBusyWait();
87+
radarSensor.busyWait();
8888

8989
// Get the presence distance value and print out if no errors.
90-
// Note - this returns if Presense is detected now, or since last check (sticky)
91-
presValError = radarSensor.getPresenceDistanceValuemm(distance);
90+
// Note - this returns if Presence is detected now, or since last check (sticky)
91+
presValError = radarSensor.getDistanceValuemm(distance);
9292

9393
if (presValError == 0)
9494
{

examples/Example02_PresenceGPIO0Usage/Example02_PresenceGPIO0Usage.ino

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ void setup()
7070

7171
// Presence Sensor Setup
7272
// Reset sensor configuration to reapply configuration registers
73-
radarSensor.setPresenceCommand(SFE_XM125_PRESENCE_RESET_MODULE);
73+
radarSensor.setCommand(SFE_XM125_PRESENCE_RESET_MODULE);
7474

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

8585
// Turn presence detection on GPIO0 on
86-
if (radarSensor.setPresenceDetectionOnGPIO(1) != 0)
86+
if (radarSensor.setDetectionOnGPIO(1) != 0)
8787
{
8888
Serial.println("GPIO0 Pin Setup Error");
8989
}
90-
radarSensor.getPresenceDetectionOnGPIO(gpioUsage);
90+
radarSensor.getDetectionOnGPIO(gpioUsage);
9191
Serial.print("GPIO0 Detection Status: ");
9292
Serial.println(gpioUsage);
9393

9494
// Apply configuration
95-
if (radarSensor.setPresenceCommand(SFE_XM125_PRESENCE_APPLY_CONFIGURATION) != 0)
95+
if (radarSensor.setCommand(SFE_XM125_PRESENCE_APPLY_CONFIGURATION) != 0)
9696
{
9797
// Check for errors
98-
radarSensor.getPresenceDetectorErrorStatus(errorStatus);
98+
radarSensor.getDetectorErrorStatus(errorStatus);
9999
if (errorStatus != 0)
100100
{
101101
Serial.print("Detector status error: ");
@@ -106,13 +106,13 @@ void setup()
106106
}
107107

108108
// Poll detector status until busy bit is cleared
109-
if (radarSensor.presenceBusyWait() != 0)
109+
if (radarSensor.busyWait() != 0)
110110
{
111111
Serial.print("Busy wait error");
112112
}
113113

114114
// Check detector status
115-
radarSensor.getPresenceDetectorErrorStatus(errorStatus);
115+
radarSensor.getDetectorErrorStatus(errorStatus);
116116
if (errorStatus != 0)
117117
{
118118
Serial.print("Detector status error: ");
@@ -127,10 +127,10 @@ void setup()
127127
void loop()
128128
{
129129
// Busy wait loop until data is ready
130-
radarSensor.presenceBusyWait();
130+
radarSensor.busyWait();
131131

132132
// Get the presence distance value and print out if no errors
133-
presValError = radarSensor.getPresenceDistanceValuemm(distance);
133+
presValError = radarSensor.getDistanceValuemm(distance);
134134

135135
if (presValError == 0)
136136
{

examples/Example03_PresenceSerialPlotter/Example03_PresenceSerialPlotter.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void setup()
6868
delay(200);
6969

7070
// Start the sensor with default register values
71-
int32_t setupError = radarSensor.presenceDetectorStart();
71+
int32_t setupError = radarSensor.detectorStart();
7272
if (setupError != 0)
7373
{
7474
Serial.print("Presence Detection Start Setup Error: ");
@@ -83,14 +83,14 @@ void setup()
8383
void loop()
8484
{
8585
// Busy wait loop until data is ready
86-
radarSensor.presenceBusyWait();
86+
radarSensor.busyWait();
8787

8888
// Get the presence distance value and print out if no errors
89-
presValError = radarSensor.getPresenceDistanceValuemm(distance);
89+
presValError = radarSensor.getDistanceValuemm(distance);
9090

9191
if (presValError == 0)
9292
{
93-
radarSensor.getPresenceDistance(distance);
93+
radarSensor.getDistance(distance);
9494
Serial.println(distance);
9595
}
9696

examples/Example04_PresenceAdvancedReadings/Example04_PresenceAdvancedReadings.ino

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void setup()
6969
delay(200);
7070

7171
// Start the sensor with default register values
72-
int32_t setupError = radarSensor.presenceDetectorStart();
72+
int32_t setupError = radarSensor.detectorStart();
7373
if (setupError != 0)
7474
{
7575
Serial.print("Presence Detection Start Setup Error: ");
@@ -84,46 +84,46 @@ void setup()
8484
void loop()
8585
{
8686
// Check error bits
87-
radarSensor.getPresenceDetectorErrorStatus(errorStatus);
87+
radarSensor.getDetectorErrorStatus(errorStatus);
8888
if (errorStatus != 0)
8989
{
9090
Serial.print("Detector status error: ");
9191
Serial.println(errorStatus);
9292
}
9393

9494
// Start detector
95-
if (radarSensor.setPresenceCommand(SFE_XM125_PRESENCE_START_DETECTOR) != 0)
95+
if (radarSensor.setCommand(SFE_XM125_PRESENCE_START_DETECTOR) != 0)
9696
{
9797
Serial.println("Start detector error");
9898
}
9999

100100
// Poll detector status until busy bit is cleared - CHECK ON THIS!
101-
if (radarSensor.presenceBusyWait() != 0)
101+
if (radarSensor.busyWait() != 0)
102102
{
103103
Serial.println("Busy wait error");
104104
}
105105

106106
// Verify that no error bits are set in the detector status register
107-
radarSensor.getPresenceDetectorErrorStatus(errorStatus);
107+
radarSensor.getDetectorErrorStatus(errorStatus);
108108
if (errorStatus != 0)
109109
{
110110
Serial.print("Detector status error: ");
111111
Serial.println(errorStatus);
112112
}
113113

114114
// Read detector result register and determine detection status
115-
radarSensor.getPresenceDetectorPresenceDetected(presenceDetected);
116-
radarSensor.getPresenceDetectorPresenceStickyDetected(presenceDetectedSticky);
115+
radarSensor.getDetectorPresenceDetected(presenceDetected);
116+
radarSensor.getDetectorPresenceStickyDetected(presenceDetectedSticky);
117117

118118
if ((presenceDetected == 1) || (presenceDetectedSticky == 1))
119119
{
120-
radarSensor.getPresenceDistance(distance);
120+
radarSensor.getDistance(distance);
121121
Serial.print("Presence Detected: ");
122122
Serial.print(distance);
123123
Serial.println("mm");
124124

125-
radarSensor.getPresenceIntraPresenceScore(intraScore);
126-
radarSensor.getPresenceInterPresenceScore(interScore);
125+
radarSensor.getIntraPresenceScore(intraScore);
126+
radarSensor.getInterPresenceScore(interScore);
127127

128128
Serial.print("Intra-Presence Score: ");
129129
Serial.println(intraScore);

examples/Example05_PresenceAdvancedSettings/Example05_PresenceAdvancedSettings.ino

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ void setup()
7272

7373
// *** Presence Sensor Setup ***
7474
// Reset sensor configuration to reapply configuration registers
75-
radarSensor.setPresenceCommand(SFE_XM125_PRESENCE_RESET_MODULE);
75+
radarSensor.setCommand(SFE_XM125_PRESENCE_RESET_MODULE);
7676

7777
// Check error and busy bits
78-
radarSensor.getPresenceDetectorErrorStatus(errorStatus);
78+
radarSensor.getDetectorErrorStatus(errorStatus);
7979
if (errorStatus != 0)
8080
{
8181
Serial.print("Detector status error: ");
@@ -85,30 +85,30 @@ void setup()
8585
delay(100);
8686

8787
// Set Start register
88-
if (radarSensor.setPresenceStart(beginReading) != 0)
88+
if (radarSensor.setStart(beginReading) != 0)
8989
{
9090
Serial.println("Presence Start Error");
9191
}
92-
radarSensor.getPresenceStart(startVal);
92+
radarSensor.getStart(startVal);
9393
Serial.print("Start Val: ");
9494
Serial.println(startVal);
9595

9696
delay(100);
9797
// Set End register
98-
if (radarSensor.setPresenceEnd(endReading) != 0)
98+
if (radarSensor.setEnd(endReading) != 0)
9999
{
100100
Serial.println("Presence End Error");
101101
}
102-
radarSensor.getPresenceEnd(endVal);
102+
radarSensor.getEnd(endVal);
103103
Serial.print("End Val: ");
104104
Serial.println(endVal);
105105
delay(100);
106106

107107
// Apply configuration
108-
if (radarSensor.setPresenceCommand(SFE_XM125_PRESENCE_APPLY_CONFIGURATION) != 0)
108+
if (radarSensor.setCommand(SFE_XM125_PRESENCE_APPLY_CONFIGURATION) != 0)
109109
{
110110
// Check for errors
111-
radarSensor.getPresenceDetectorErrorStatus(errorStatus);
111+
radarSensor.getDetectorErrorStatus(errorStatus);
112112
if (errorStatus != 0)
113113
{
114114
Serial.print("Detector status error: ");
@@ -119,13 +119,13 @@ void setup()
119119
}
120120

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

127127
// Check detector status
128-
radarSensor.getPresenceDetectorErrorStatus(errorStatus);
128+
radarSensor.getDetectorErrorStatus(errorStatus);
129129
if (errorStatus != 0)
130130
{
131131
Serial.print("Detector status error: ");
@@ -140,40 +140,40 @@ void setup()
140140
void loop()
141141
{
142142
// Check error bits
143-
radarSensor.getPresenceDetectorErrorStatus(errorStatus);
143+
radarSensor.getDetectorErrorStatus(errorStatus);
144144
if (errorStatus != 0)
145145
{
146146
Serial.print("Detector status error: ");
147147
Serial.println(errorStatus);
148148
}
149149

150150
// Start detector
151-
if (radarSensor.setPresenceCommand(SFE_XM125_PRESENCE_START_DETECTOR) != 0)
151+
if (radarSensor.setCommand(SFE_XM125_PRESENCE_START_DETECTOR) != 0)
152152
{
153153
Serial.println("Start detector error");
154154
}
155155

156156
// Poll detector status until busy bit is cleared - CHECK ON THIS!
157-
if (radarSensor.presenceBusyWait() != 0)
157+
if (radarSensor.busyWait() != 0)
158158
{
159159
Serial.println("Busy wait error");
160160
}
161161

162162
// Verify that no error bits are set in the detector status register
163-
radarSensor.getPresenceDetectorErrorStatus(errorStatus);
163+
radarSensor.getDetectorErrorStatus(errorStatus);
164164
if (errorStatus != 0)
165165
{
166166
Serial.print("Detector status error: ");
167167
Serial.println(errorStatus);
168168
}
169169

170170
// Read detector result register and determine detection status
171-
radarSensor.getPresenceDetectorPresenceDetected(presenceDetected);
172-
radarSensor.getPresenceDetectorPresenceStickyDetected(presenceDetectedSticky);
171+
radarSensor.getDetectorPresenceDetected(presenceDetected);
172+
radarSensor.getDetectorPresenceStickyDetected(presenceDetectedSticky);
173173

174174
if ((presenceDetected == 1) | (presenceDetectedSticky == 1))
175175
{
176-
radarSensor.getPresenceDistance(distance);
176+
radarSensor.getDistance(distance);
177177
Serial.print("Presence Detected: ");
178178
Serial.print(distance);
179179
Serial.println("mm");

0 commit comments

Comments
 (0)