File tree 1 file changed +33
-3
lines changed 1 file changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -310,8 +310,23 @@ class ImageSensor {
310
310
}
311
311
};
312
312
313
- template <typename T> class ScanResults {
313
+
314
+ /* *
315
+ * @class ScanResults
316
+ * @brief A template class used to store the results from an I2C scan.
317
+ *
318
+ * @param T Data type for the device address (e.g. uint8_t)
319
+ */
320
+ template <typename T>
321
+ class ScanResults {
314
322
public:
323
+ /* *
324
+ * @brief Equality operator to check if a given device address is found in the ScanResults.
325
+ *
326
+ * @param toBeFound The device address to be checked
327
+ * @return true If the device address is found in the ScanResults
328
+ * @return false Otherwise
329
+ */
315
330
bool operator ==(T toBeFound) {
316
331
for (int i = 0 ; i < howMany; i++) {
317
332
if (toBeFound == data[i]) {
@@ -320,15 +335,30 @@ template <typename T> class ScanResults {
320
335
}
321
336
return false ;
322
337
}
338
+
339
+ /* *
340
+ * @brief Inequality operator to check if a given device address is not found in the ScanResults.
341
+ *
342
+ * @param toBeFound The device address to be checked
343
+ * @return true If the device address is not found in the ScanResults
344
+ * @return false Otherwise
345
+ */
323
346
bool operator !=(T toBeFound) {
324
347
return !(*this == toBeFound);
325
348
}
349
+
350
+ /* *
351
+ * @brief Add a device address to the ScanResults.
352
+ *
353
+ * @param obj The device address to be added
354
+ */
326
355
void push (T obj) {
327
356
data[howMany++] = obj;
328
357
}
358
+
329
359
private:
330
- T data[20 ];
331
- int howMany = 0 ;
360
+ T data[20 ]; // / Array to store the device addresses (max 20).
361
+ int howMany = 0 ; // / Number of device addresses in the ScanResults
332
362
};
333
363
334
364
You can’t perform that action at this time.
0 commit comments