1212#include <pbdrv/bluetooth.h>
1313
1414#include <pbio/error.h>
15+ #include <pbio/imu.h>
1516#include <pbsys/status.h>
1617#include <pbsys/storage_settings.h>
1718
2324 *
2425 * @param [in] settings Settings to populate.
2526 */
26- void pbsys_storage_set_default_settings (pbsys_storage_settings_t * settings ) {
27+ void pbsys_storage_settings_set_defaults (pbsys_storage_settings_t * settings ) {
2728 #if PBSYS_CONFIG_BLUETOOTH_TOGGLE
2829 settings -> flags |= PBSYS_STORAGE_SETTINGS_FLAGS_BLUETOOTH_ENABLED ;
2930 #endif
31+ #if PBIO_CONFIG_IMU
32+ settings -> gyro_stationary_threshold = 5 ;
33+ settings -> accel_stationary_threshold = 2500 ;
34+ #endif // PBIO_CONFIG_IMU
35+ }
36+
37+ /**
38+ * Applies the loaded settings and preferences after boot.
39+ *
40+ * @param [in] settings Settings to populate.
41+ */
42+ void pbsys_storage_settings_apply_loaded_settings (pbsys_storage_settings_t * settings ) {
43+ #if PBIO_CONFIG_IMU
44+ pbio_imu_set_stationary_thresholds (settings -> gyro_stationary_threshold , settings -> accel_stationary_threshold );
45+ #endif // PBIO_CONFIG_IMU
46+ }
47+
48+ /**
49+ * Copies the configured IMU settings to storage and requests them to be saved.
50+ *
51+ * @param [in] settings Settings to populate.
52+ */
53+ void pbsys_storage_settings_save_imu_settings (void ) {
54+ pbsys_storage_settings_t * settings = pbsys_storage_settings_get_settings ();
55+ if (!settings ) {
56+ return ;
57+ }
58+ #if PBIO_CONFIG_IMU
59+ pbio_imu_get_stationary_thresholds (& settings -> gyro_stationary_threshold , & settings -> accel_stationary_threshold );
60+ pbsys_storage_request_write ();
61+ #endif // PBIO_CONFIG_IMU
3062}
3163
3264bool pbsys_storage_settings_bluetooth_enabled (void ) {
3365 #if PBSYS_CONFIG_BLUETOOTH_TOGGLE
34- pbsys_storage_settings_t * settings = pbsys_storage_get_settings ();
66+ pbsys_storage_settings_t * settings = pbsys_storage_settings_get_settings ();
3567 if (!settings ) {
3668 return true;
3769 }
@@ -43,7 +75,7 @@ bool pbsys_storage_settings_bluetooth_enabled(void) {
4375
4476void pbsys_storage_settings_bluetooth_enabled_request_toggle (void ) {
4577 #if PBSYS_CONFIG_BLUETOOTH_TOGGLE
46- pbsys_storage_settings_t * settings = pbsys_storage_get_settings ();
78+ pbsys_storage_settings_t * settings = pbsys_storage_settings_get_settings ();
4779
4880 // Ignore toggle request in all but idle system status.
4981 if (!settings
0 commit comments