Skip to content

Instantly share code, notes, and snippets.

@DCRichards
Created January 22, 2015 21:19
Show Gist options
  • Save DCRichards/d3bc4f3b610074f0db5f to your computer and use it in GitHub Desktop.
Save DCRichards/d3bc4f3b610074f0db5f to your computer and use it in GitHub Desktop.
Data logging in a Pebble Background Worker
#include <pebble_worker.h>
DataLoggingSessionRef data_logger;
int num_samples = 1;
static void data_handler(AccelData *data, uint32_t samples) {
data_logging_log(data_logger, data, samples);
}
static void worker_init() {
accel_data_service_subscribe(num_samples, data_handler);
accel_service_set_sampling_rate(ACCEL_SAMPLING_10HZ);
data_logger = data_logging_create(1, DATA_LOGGING_BYTE_ARRAY, sizeof(AccelData), true);
}
static void worker_deinit() {
data_logging_finish(data_logger);
accel_data_service_unsubscribe();
}
int main(void) {
worker_init();
worker_event_loop();
worker_deinit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment