more accelerometer work
This commit is contained in:
@@ -31,6 +31,10 @@
|
||||
|
||||
#ifdef HAS_ACCELEROMETER
|
||||
|
||||
// hacky: we're just tapping into Movement's orientation changes.
|
||||
// we should make better API for this.
|
||||
extern uint32_t orientation_changes;
|
||||
|
||||
static void _accel_interrupt_count_face_update_display(accel_interrupt_count_state_t *state) {
|
||||
(void) state;
|
||||
char buf[7];
|
||||
@@ -38,8 +42,7 @@ static void _accel_interrupt_count_face_update_display(accel_interrupt_count_sta
|
||||
// "AC"celerometer "IN"terrupts
|
||||
watch_display_text(WATCH_POSITION_TOP_LEFT, "AC");
|
||||
watch_display_text(WATCH_POSITION_TOP_RIGHT, "1N");
|
||||
uint16_t count = tc_count16_get_count(2);
|
||||
snprintf(buf, 7, "%6d", count);
|
||||
snprintf(buf, 7, "%6lu", orientation_changes);
|
||||
watch_display_text(WATCH_POSITION_BOTTOM, buf);
|
||||
printf("%s\n", buf);
|
||||
}
|
||||
@@ -90,10 +93,6 @@ bool accel_interrupt_count_face_loop(movement_event_t event, void *context) {
|
||||
}
|
||||
} else {
|
||||
switch (event.event_type) {
|
||||
case EVENT_ALARM_BUTTON_UP:
|
||||
// reset the counter
|
||||
tc_count16_set_count(2, 0);
|
||||
// fall through
|
||||
case EVENT_ACTIVATE:
|
||||
case EVENT_TICK:
|
||||
_accel_interrupt_count_face_update_display(state);
|
||||
|
||||
@@ -29,20 +29,26 @@
|
||||
|
||||
#ifdef HAS_ACCELEROMETER
|
||||
|
||||
// hacky: we're just tapping into Movement's orientation changes.
|
||||
// we should make better API for this.
|
||||
extern uint32_t orientation_changes;
|
||||
|
||||
static void _activity_logging_face_log_data(activity_logging_state_t *state) {
|
||||
watch_date_time_t date_time = watch_rtc_get_date_time();
|
||||
size_t pos = state->data_points % ACTIVITY_LOGGING_NUM_DATA_POINTS;
|
||||
|
||||
state->data[pos].timestamp.reg = date_time.reg;
|
||||
state->data[pos].active_minutes = state->active_minutes;
|
||||
state->data[pos].orientation_changes = orientation_changes;
|
||||
state->active_minutes = 0;
|
||||
orientation_changes = 0;
|
||||
|
||||
state->data_points++;
|
||||
}
|
||||
|
||||
static void _activity_logging_face_update_display(activity_logging_state_t *state, bool clock_mode_24h) {
|
||||
int8_t pos = (state->data_points - 1 - state->display_index) % ACTIVITY_LOGGING_NUM_DATA_POINTS;
|
||||
char buf[7];
|
||||
char buf[16];
|
||||
|
||||
watch_clear_indicator(WATCH_INDICATOR_24H);
|
||||
watch_clear_indicator(WATCH_INDICATOR_PM);
|
||||
@@ -71,11 +77,11 @@ static void _activity_logging_face_update_display(activity_logging_state_t *stat
|
||||
sprintf(buf, "%2d%02d%02d", date_time.unit.hour, date_time.unit.minute, date_time.unit.second);
|
||||
watch_display_text(WATCH_POSITION_BOTTOM, buf);
|
||||
} else {
|
||||
// we are displaying the number of accelerometer wakeups
|
||||
watch_display_text_with_fallback(WATCH_POSITION_TOP, "ACT L", "AC");
|
||||
// we are displaying the number of accelerometer wakeups and orientation changes
|
||||
watch_display_text(WATCH_POSITION_TOP, "WO");
|
||||
sprintf(buf, "%2d", state->display_index);
|
||||
watch_display_text(WATCH_POSITION_TOP_RIGHT, buf);
|
||||
sprintf(buf, "%d", state->data[pos].active_minutes);
|
||||
sprintf(buf, "%2d=%lu", state->data[pos].active_minutes, state->data[pos].orientation_changes);
|
||||
watch_display_text(WATCH_POSITION_BOTTOM, buf);
|
||||
}
|
||||
}
|
||||
@@ -139,7 +145,7 @@ movement_watch_face_advisory_t activity_logging_face_advise(void *context) {
|
||||
activity_logging_state_t *state = (activity_logging_state_t *)context;
|
||||
movement_watch_face_advisory_t retval = { 0 };
|
||||
|
||||
// every minute, we want to log whether the accelerometer is alseeep or awake.
|
||||
// every minute, we want to log whether the accelerometer is asleep or awake.
|
||||
if (!HAL_GPIO_A3_read()) {
|
||||
state->active_minutes++;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
typedef struct {
|
||||
watch_date_time_t timestamp;
|
||||
uint8_t active_minutes;
|
||||
uint32_t orientation_changes;
|
||||
} activity_logging_data_point_t;
|
||||
|
||||
typedef struct {
|
||||
|
||||
Reference in New Issue
Block a user