Skip to content
Snippets Groups Projects
Commit ff5c1f96 authored by Rene Ebeling's avatar Rene Ebeling
Browse files

reworked the processSensorData to include Target Status

parent e3c12546
No related branches found
No related tags found
No related merge requests found
......@@ -199,7 +199,6 @@ void loop() {
VL53L7CX_ResultsData Results16;
VL53L7CX_ResultsData Results17;
// Process each sensor data and save to respective JSON arrays
processSensorData(sensor0, Results0, doc["sensor0"].to<JsonArray>(), "sensor0", LPN_PIN0);
processSensorData(sensor1, Results1, doc["sensor1"].to<JsonArray>(), "sensor1", LPN_PIN1);
......@@ -306,23 +305,23 @@ void processSensorData(VL53L7CX &sensor, VL53L7CX_ResultsData &results, const Js
// Turn LED on to indicate data processing
digitalWrite(LedPin, HIGH);
// If data is ready, get the ranging data and store it in the JSON array
if ((!status) && (NewDataReady != 0)) {
status = sensor.vl53l7cx_get_ranging_data(&results);
JsonArray sensorData = doc[sensorKey].to<JsonArray>();
// Process the results and add them to the JSON array
for (int y = imageWidth * (imageWidth - 1); y >= 0; y -= imageWidth) {
for (int x = 0; x <= imageWidth - 1; x++) {
if Results0.
sensorData.add(results.distance_mm[VL53L7CX_NB_TARGET_PER_ZONE * (x + y)]);
Results0.status
int index = VL53L7CX_NB_TARGET_PER_ZONE * (x + y);
// Neu: JsonArray via add<JsonArray>()
JsonArray measurement = sensorData.add<JsonArray>();
measurement.add(results.distance_mm[index]);
measurement.add(results.target_status[index]);
}
}
}
// Turn LED off to indicate processing is done
digitalWrite(LedPin, LOW);
}
......
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment