return false;
}
+uint8_t movement_get_accelerometer_motion_threshold(void) {
+ if (movement_state.has_lis2dw) return movement_state.accelerometer_motion_threshold;
+ else return 0;
+}
+
+bool movement_set_accelerometer_motion_threshold(uint8_t new_threshold) {
+ if (movement_state.has_lis2dw) {
+ if (movement_state.accelerometer_motion_threshold != new_threshold) {
+ lis2dw_configure_wakeup_threshold(new_threshold);
+ movement_state.accelerometer_motion_threshold = new_threshold;
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
float movement_get_temperature(void) {
float temperature_c = (float)0xFFFFFFFF;
watch_rtc_set_date_time(date_time);
}
+ if (movement_state.accelerometer_motion_threshold == 0) movement_state.accelerometer_motion_threshold = 32;
movement_state.light_ticks = -1;
movement_state.alarm_ticks = -1;
lis2dw_enable_stationary_motion_detection(); // stationary/motion detection mode keeps the data rate at 1.6 Hz even in sleep
lis2dw_set_range(LIS2DW_RANGE_2_G); // Application note AN5038 recommends 2g range
lis2dw_enable_sleep(); // allow acceleromter to sleep and wake on activity
- lis2dw_configure_wakeup_threshold(32); // g threshold to wake up: (THS * FS / 64) where FS is "full scale" of ±2g.
+ lis2dw_configure_wakeup_threshold(movement_state.accelerometer_motion_threshold); // g threshold to wake up: (THS * FS / 64) where FS is "full scale" of ±2g.
lis2dw_configure_6d_threshold(3); // 0-3 is 80, 70, 60, or 50 degrees. 50 is least precise, hopefully most sensitive?
// set up interrupts:
bool has_lis2dw;
// data rate for background accelerometer sensing
lis2dw_data_rate_t accelerometer_background_rate;
+ // threshold for considering the wearer is in motion
+ uint8_t accelerometer_motion_threshold;
} movement_state_t;
void movement_move_to_face(uint8_t watch_face_index);
lis2dw_data_rate_t movement_get_accelerometer_background_rate(void);
bool movement_set_accelerometer_background_rate(lis2dw_data_rate_t new_rate);
+// gets and sets the accelerometer motion threshold
+uint8_t movement_get_accelerometer_motion_threshold(void);
+bool movement_set_accelerometer_motion_threshold(uint8_t new_threshold);
+
// If the board has a temperature sensor, this function will give you the temperature in degrees celsius.
// If the board has multiple temperature sensors, it will use the most accurate one available.
// If the board has no temperature sensors, it will return 0xFFFFFFFF.
movement_request_tick_frequency(4);
// fetch current threshold from accelerometer
- state->threshold = lis2dw_get_wakeup_threshold();
+ state->threshold = movement_get_accelerometer_motion_threshold();
}
bool accelerometer_status_face_loop(movement_event_t event, void *context) {
}
break;
case EVENT_ALARM_BUTTON_UP:
- lis2dw_configure_wakeup_threshold(state->new_threshold);
+ movement_set_accelerometer_motion_threshold(state->new_threshold);
state->threshold = state->new_threshold;
watch_clear_decimal_if_available();
state->is_setting = false;