Check for null screen

This commit is contained in:
Jonathan Bennett
2025-05-17 22:03:23 -05:00
parent 212005bfe9
commit f1440a27d7
14 changed files with 85 additions and 60 deletions

View File

@@ -37,7 +37,8 @@ int32_t BMX160Sensor::runOnce()
if (!showingScreen) {
powerFSM.trigger(EVENT_PRESS); // keep screen alive during calibration
showingScreen = true;
screen->startAlert((FrameCallback)drawFrameCalibration);
if (screen)
screen->startAlert((FrameCallback)drawFrameCalibration);
}
if (magAccel.x > highestX)
@@ -58,7 +59,8 @@ int32_t BMX160Sensor::runOnce()
doCalibration = false;
endCalibrationAt = 0;
showingScreen = false;
screen->endAlert();
if (screen)
screen->endAlert();
}
// LOG_DEBUG("BMX160 min_x: %.4f, max_X: %.4f, min_Y: %.4f, max_Y: %.4f, min_Z: %.4f, max_Z: %.4f", lowestX, highestX,
@@ -103,8 +105,8 @@ int32_t BMX160Sensor::runOnce()
heading += 270;
break;
}
screen->setHeading(heading);
if (screen)
screen->setHeading(heading);
#endif
return MOTION_SENSOR_CHECK_INTERVAL_MS;
@@ -118,7 +120,8 @@ void BMX160Sensor::calibrate(uint16_t forSeconds)
doCalibration = true;
uint16_t calibrateFor = forSeconds * 1000; // calibrate for seconds provided
endCalibrationAt = millis() + calibrateFor;
screen->setEndCalibration(endCalibrationAt);
if (screen)
screen->setEndCalibration(endCalibrationAt);
#endif
}

View File

@@ -60,7 +60,8 @@ int32_t ICM20948Sensor::runOnce()
if (!showingScreen) {
powerFSM.trigger(EVENT_PRESS); // keep screen alive during calibration
showingScreen = true;
screen->startAlert((FrameCallback)drawFrameCalibration);
if (screen)
screen->startAlert((FrameCallback)drawFrameCalibration);
}
if (magX > highestX)
@@ -81,7 +82,8 @@ int32_t ICM20948Sensor::runOnce()
doCalibration = false;
endCalibrationAt = 0;
showingScreen = false;
screen->endAlert();
if (screen)
screen->endAlert();
}
// LOG_DEBUG("ICM20948 min_x: %.4f, max_X: %.4f, min_Y: %.4f, max_Y: %.4f, min_Z: %.4f, max_Z: %.4f", lowestX, highestX,
@@ -124,8 +126,8 @@ int32_t ICM20948Sensor::runOnce()
heading += 270;
break;
}
screen->setHeading(heading);
if (screen)
screen->setHeading(heading);
#endif
// Wake on motion using polling - this is not as efficient as using hardware interrupt pin (see above)
@@ -159,7 +161,8 @@ void ICM20948Sensor::calibrate(uint16_t forSeconds)
doCalibration = true;
uint16_t calibrateFor = forSeconds * 1000; // calibrate for seconds provided
endCalibrationAt = millis() + calibrateFor;
screen->setEndCalibration(endCalibrationAt);
if (screen)
screen->setEndCalibration(endCalibrationAt);
#endif
}
// ----------------------------------------------------------------------