activity_logging_state_t *state = (activity_logging_state_t *)context;
state->display_index = 0;
state->ts_ticks = 0;
+ state->data_dump_idx = -1;
}
bool activity_logging_face_loop(movement_event_t event, void *context) {
activity_logging_state_t *state = (activity_logging_state_t *)context;
switch (event.event_type) {
case EVENT_TIMEOUT:
- movement_move_to_face(0);
+ if (state->data_dump_idx == -1) movement_move_to_face(0);
break;
case EVENT_LIGHT_LONG_PRESS:
// light button shows the timestamp, but if you need the light, long press it.
case EVENT_ACTIVATE:
_activity_logging_face_update_display(state, movement_clock_mode_24h());
break;
+ case EVENT_ALARM_LONG_PRESS:
+ state->data_dump_idx = 0;
+ /// FIXME: Battery indicator is now Arrows indicator.
+ watch_set_indicator(WATCH_INDICATOR_BATTERY);
+ movement_request_tick_frequency(4);
+ watch_set_decimal_if_available();
+ // fall through
case EVENT_TICK:
if (state->ts_ticks && --state->ts_ticks == 0) {
_activity_logging_face_update_display(state, movement_clock_mode_24h());
}
+ if (state->data_dump_idx != -1) {
+ // dance through the full buffer
+ char buf[8];
+ uint32_t count = 0;
+ movement_activity_data_point *data_points = movement_get_data_log(&count);
+ int32_t pos = ((int32_t)count - 1 - (int32_t)state->data_dump_idx) % MOVEMENT_NUM_DATA_POINTS;
+
+ sprintf(buf, "%03d ", state->data_dump_idx);
+ watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, buf, buf + 2);
+ sprintf(buf, "%3d%3d", data_points[pos].bit.measured_temperature - 300, data_points[pos].bit.orientation_changes > 999 ? 999 : data_points[pos].bit.orientation_changes);
+ buf[6] = 0;
+ watch_display_text(WATCH_POSITION_BOTTOM, buf);
+ sprintf(buf, "%2d", data_points[pos].bit.stationary_minutes);
+ watch_display_text(WATCH_POSITION_TOP_RIGHT, buf);
+
+ state->data_dump_idx++;
+ if (state->data_dump_idx >= MOVEMENT_NUM_DATA_POINTS) {
+ state->data_dump_idx = -1;
+ /// FIXME: Battery indicator is now Arrows indicator.
+ watch_clear_indicator(WATCH_INDICATOR_BATTERY);
+ watch_clear_decimal_if_available();
+ movement_request_tick_frequency(1);
+ state->display_index = 0;
+ _activity_logging_face_update_display(state, movement_clock_mode_24h());
+ }
+ }
break;
default:
movement_default_loop_handler(event);
* ACTIVITY LOGGING
*
* This watch face works with Movement's built-in count of accelerometer
- * waekeups to log activity over time. It is very much a work in progress,
- * and these notes will expand as the functionality is fleshed out.
+ * waekeups to log activity over time.
+ *
+ * Default behavior is to show the last 100 data points. Format is:
+ * - Top left is display title (LOG or AC for Activity)
+ * - Top right is index backwards in the data log.
+ * - Bottom left is the number of orientation changes in the five minutes logged.
+ * - Bottom right is number of stationary minutes (0 to 5)
+ *
+ * A short press of the Light button reveals the time (bottom row) and date (top right) of the data point.
+ * The display will update to say "AT" the time and date, or "T+D" on custom LCD.
+ *
+ * A short press of the Alarm button moves backwards in the data log.
+ *
+ * A long press of the Alarm button initiates a rapid dump of the full activity log buffer. Works best on custom LCD:
+ * - Top left is the index backwards in the data log.
+ * - Top right is the number of stationary minutes (0 to 5)
+ * - Bottom row should be viewed as two three digit numbers:
+ * - Positions 0, 1 and 2 contain the number of orientation changes in the five minutes logged.
+ * - Positions 3, 4 and 5 contain the temperature (256 = 25.6 degrees C)
*/
#include "movement.h"
typedef struct {
uint8_t display_index; // the index we are displaying on screen
uint8_t ts_ticks; // when the user taps the LIGHT button, we show the timestamp for a few ticks.
+ int16_t data_dump_idx; // for dumping the full activity log on long press of Alarm
} activity_logging_state_t;
void activity_logging_face_setup(uint8_t watch_face_index, void ** context_ptr);