Created
November 6, 2016 03:09
-
-
Save sunpazed/88e45ecb44758a3332485ee68eb4faa3 to your computer and use it in GitHub Desktop.
Pebble HR handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -- init and handle health data ------------------------------------------ | |
static void handler_health_hr(HealthEventType type, void *context) { | |
// if the update was from the Heart Rate Monitor, query it | |
if (type == HealthEventHeartRateUpdate) { | |
field_hr_value = health_service_peek_current_value(HealthMetricHeartRateBPM); | |
//field_hr_value = (uint32_t) 0x0000008F; // debug HR | |
} | |
if (state_is == STATE_RUN || state_is == STATE_PAUSE) { | |
if (mode_is == MODE_HR) { | |
snprintf(hr_placeholder, sizeof(hr_placeholder), "%lu", (uint32_t)field_hr_value); | |
text_layer_set_text(layer_big_field, hr_placeholder ); | |
} | |
} | |
} | |
static void init_health_hr(void) { | |
bool success = health_service_set_heart_rate_sample_period(2); | |
// Subscribe to health event handler | |
health_service_events_subscribe(handler_health_hr, NULL); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment