This repository has been archived by the owner on Apr 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The top half of the text now displays the number of steps taken today.
- Loading branch information
1 parent
8579b97
commit e7698b9
Showing
7 changed files
with
155 additions
and
62 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include <pebble.h> | ||
#include "data.h" | ||
|
||
static int s_current_steps; | ||
static char s_current_steps_buffer[19]; | ||
|
||
void data_update_steps_buffer() { | ||
int thousands = s_current_steps / 1000; | ||
int hundreds = s_current_steps % 1000; | ||
if(thousands > 0) { | ||
snprintf(s_current_steps_buffer, sizeof(s_current_steps_buffer), "%d,%03d STEPS TODAY", thousands, hundreds); | ||
} else { | ||
snprintf(s_current_steps_buffer, sizeof(s_current_steps_buffer), "%d STEPS TODAY", hundreds); | ||
} | ||
} | ||
|
||
static void load_health_data_handler() { | ||
s_current_steps = health_service_sum_today(HealthMetricStepCount); | ||
data_update_steps_buffer(); | ||
} | ||
|
||
void data_init() { | ||
app_timer_register(500, load_health_data_handler, NULL); | ||
} | ||
|
||
int data_get_current_steps() { | ||
return s_current_steps; | ||
} | ||
|
||
void data_set_current_steps(int value) { | ||
s_current_steps = value; | ||
} | ||
|
||
char* data_get_current_steps_buffer() { | ||
return s_current_steps_buffer; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
#include "src/c/breathe_window.h" | ||
|
||
void data_init(); | ||
|
||
void data_set_current_steps(int value); | ||
int data_get_current_steps(); | ||
|
||
void data_update_steps_buffer(); | ||
|
||
char* data_get_current_steps_buffer(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <pebble.h> | ||
#include "health.h" | ||
|
||
static void health_handler(HealthEventType event, void *context) { | ||
data_set_current_steps((int)health_service_sum_today(HealthMetricStepCount)); | ||
data_update_steps_buffer(); | ||
} | ||
|
||
void health_init() { | ||
health_service_events_subscribe(health_handler, NULL); | ||
} | ||
|
||
bool health_is_available() { | ||
#if defined(PBL_HEALTH) | ||
return true; | ||
#else | ||
return false; | ||
#endif | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
#include "src/c/data.h" | ||
|
||
void health_init(); | ||
|
||
bool health_is_available(); | ||
|
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