getSonarReflections method
Implementation
SonarReflections? getSonarReflections() {
final distances = calloc<Uint32>(8);
final amplitudes = calloc<Uint32>(8);
final count = calloc<Uint32>();
try {
final result = bindings.distanceSensorGetSonarReflections(
_handle!, distances, amplitudes, count);
if (result != 0) return null;
final validCount = count.value;
return SonarReflections(distances.asTypedList(8).sublist(0, validCount),
amplitudes.asTypedList(8).sublist(0, validCount));
} catch (e) {
throw PhidgetException('An error occurred getting the sonar reflections: $e');
} finally {
calloc.free(distances);
calloc.free(amplitudes);
calloc.free(count);
}
}