diff options
author | davejacobs: David Jacobs <davejacobs@google.com> | 2021-09-10 20:15:12 -0400 |
---|---|---|
committer | David Jacobs <davejacobs@google.com> | 2021-09-16 21:12:35 +0000 |
commit | 577dd4467313d30a947abcff8f4be70230da085a (patch) | |
tree | 6c85511b97069707da6bded8c5fb6885e4256220 | |
parent | 6acf8258cc566b3938600abee061d306c0304a6e (diff) | |
download | contexthub-577dd4467313d30a947abcff8f4be70230da085a.tar.gz |
[DO NOT MERGE] Support ImuCal hinge-angle integration
- These changes provide support for using hinge-angle to detect foldable
physical state changes and respond with changes to calibration values.
Bug: 197029853
Test: Compiled and tested on device.
PiperOrigin-RevId: 396038420
Change-Id: I9a3324f6074f87dbfdc475f737a0484d5c539a5d
3 files changed, 18 insertions, 1 deletions
diff --git a/firmware/os/algos/calibration/online_calibration/common_data/calibration_quality.h b/firmware/os/algos/calibration/online_calibration/common_data/calibration_quality.h index d6475c78..6b146f49 100644 --- a/firmware/os/algos/calibration/online_calibration/common_data/calibration_quality.h +++ b/firmware/os/algos/calibration/online_calibration/common_data/calibration_quality.h @@ -65,7 +65,7 @@ enum class CalibrationQualityLevel : uint8_t { // Sets the calibration quality value when this metric is either not // implemented, or has not yet been determined (e.g., a calibration hasn't // occurred). -constexpr float kUndeterminedCalibrationQuality = -1.0f; +constexpr float kUndeterminedCalibrationQuality = FLT_MAX; /* * Calibration quality structure that contains a quantitative (float) and diff --git a/firmware/os/algos/calibration/online_calibration/common_data/online_calibration.h b/firmware/os/algos/calibration/online_calibration/common_data/online_calibration.h index 8c95f9ba..710c442c 100644 --- a/firmware/os/algos/calibration/online_calibration/common_data/online_calibration.h +++ b/firmware/os/algos/calibration/online_calibration/common_data/online_calibration.h @@ -26,6 +26,14 @@ namespace online_calibration { +// Device physical state change types. +enum class PhysicalStateType : uint8_t { + kUnknownPhysicalState = 0, + kFoldableOpen, + kFoldableClosed, + kNumPhysicalStateTypes, +}; + /* * This abstract base class provides a set of general interface functions for * calibration algorithms. The data structures used are intended to be lean and @@ -130,6 +138,13 @@ class OnlineCalibration { // Returns the sensor-type this calibration algorithm provides updates for. virtual SensorType get_sensor_type() const = 0; + // Tells the calibrator that the device's physical state has changed. This is + // useful, for example, if there is a need for the calibration algorithm to be + // aware of and take some sort of internal action in response to a physical + // state change (e.g., for foldable devices, MagCal may adjust internal states + // to implement specific transition behavior between open/closed states). + virtual void UpdatePhysicalState(PhysicalStateType physical_state) {} + protected: // Helper function that activates the registered callback. void OnNotifyCalibrationUpdate(CalibrationTypeFlags cal_update_flags) const { diff --git a/firmware/os/algos/calibration/online_calibration/common_data/sensor_data.h b/firmware/os/algos/calibration/online_calibration/common_data/sensor_data.h index 23b63c9b..b6d6eb37 100644 --- a/firmware/os/algos/calibration/online_calibration/common_data/sensor_data.h +++ b/firmware/os/algos/calibration/online_calibration/common_data/sensor_data.h @@ -48,6 +48,8 @@ enum class SensorType : int8_t { kBarometerHpa = 5, // 1-axis sensor (units = hecto-Pascal). kWifiM = 6, // 3-axis sensor (units = meter). kProximity = 7, // 1-axis sensor (units = ?). + kHallEffect = 8, // 1-axis sensor (units = ?). + kHingeAngle = 9, // 1-axis sensor (units = degrees). }; // Helper function for determining if a sensor type is 3-axis, otherwise it's |