summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2014-07-04 17:49:26 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2014-07-04 17:49:26 +0100
commit1ad08f012ad0a17fbaad1a85a0a02818f5b62b5a (patch)
tree7406f25e1ad8122b8ce3295df1fc1ef24c834bb4
parent1990514d536050e7b05a30ce7bb7c80a4f450584 (diff)
downloadaskel-ja-uni-1ad08f012ad0a17fbaad1a85a0a02818f5b62b5a.tar.bz2
Icons and other updates
-rw-r--r--watchapp/appinfo.json58
-rw-r--r--watchapp/resources/icons/README3
-rw-r--r--watchapp/resources/icons/alarm.pngbin0 -> 211 bytes
-rw-r--r--watchapp/resources/icons/battery-charged.pngbin0 -> 238 bytes
-rw-r--r--watchapp/resources/icons/battery-charging.pngbin0 -> 233 bytes
-rw-r--r--watchapp/resources/icons/battery-critical.pngbin0 -> 224 bytes
-rw-r--r--watchapp/resources/icons/battery-full.pngbin0 -> 202 bytes
-rw-r--r--watchapp/resources/icons/battery-mid.pngbin0 -> 205 bytes
-rw-r--r--watchapp/resources/icons/connected-to-app.pngbin0 -> 222 bytes
-rw-r--r--watchapp/resources/icons/connected.pngbin0 -> 216 bytes
-rw-r--r--watchapp/resources/icons/icons.xcfbin0 -> 6707 bytes
-rw-r--r--watchapp/resources/icons/logging.pngbin0 -> 201 bytes
-rw-r--r--watchapp/resources/icons/sleep.pngbin0 -> 206 bytes
-rw-r--r--watchapp/resources/icons/steps.pngbin0 -> 193 bytes
-rw-r--r--watchapp/src/actimon.c74
-rw-r--r--watchapp/src/actimon.h2
-rw-r--r--watchapp/src/watchapp.c4
17 files changed, 118 insertions, 23 deletions
diff --git a/watchapp/appinfo.json b/watchapp/appinfo.json
index 3064eed..e0d6828 100644
--- a/watchapp/appinfo.json
+++ b/watchapp/appinfo.json
@@ -12,6 +12,62 @@
"dummy": 0
},
"resources": {
- "media": []
+ "media": [
+ {
+ "type": "png",
+ "name": "ICON_BATTERY_CRITICAL",
+ "file": "icons/battery-critical.png"
+ },
+ {
+ "type": "png",
+ "name": "ICON_BATTERY_MID",
+ "file": "icons/battery-mid.png"
+ },
+ {
+ "type": "png",
+ "name": "ICON_BATTERY_FULL",
+ "file": "icons/battery-full.png"
+ },
+ {
+ "type": "png",
+ "name": "ICON_BATTERY_CHARGING",
+ "file": "icons/battery-charging.png"
+ },
+ {
+ "type": "png",
+ "name": "ICON_BATTERY_CHARGED",
+ "file": "icons/battery-charged.png"
+ },
+ {
+ "type": "png",
+ "name": "ICON_CONNECTED",
+ "file": "icons/connected.png"
+ },
+ {
+ "type": "png",
+ "name": "ICON_CONNECTED_TO_APP",
+ "file": "icons/connected-to-app.png"
+ },
+ {
+ "type": "png",
+ "name": "ICON_ALARM",
+ "file": "icons/alarm.png"
+ },
+ {
+ "type": "png",
+ "name": "ICON_LOGGING",
+ "file": "icons/logging.png"
+ },
+ {
+ "type": "png",
+ "name": "ICON_SLEEP",
+ "file": "icons/sleep.png"
+ },
+ {
+ "type": "png",
+ "name": "ICON_STEPS",
+ "file": "icons/steps.png"
+ }
+ ]
}
}
diff --git a/watchapp/resources/icons/README b/watchapp/resources/icons/README
new file mode 100644
index 0000000..ddfedbe
--- /dev/null
+++ b/watchapp/resources/icons/README
@@ -0,0 +1,3 @@
+All the PNGs here are created from icons.xcf.
+
+Edit that file and re-export the layers you change.
diff --git a/watchapp/resources/icons/alarm.png b/watchapp/resources/icons/alarm.png
new file mode 100644
index 0000000..e9f50e6
--- /dev/null
+++ b/watchapp/resources/icons/alarm.png
Binary files differ
diff --git a/watchapp/resources/icons/battery-charged.png b/watchapp/resources/icons/battery-charged.png
new file mode 100644
index 0000000..c68be49
--- /dev/null
+++ b/watchapp/resources/icons/battery-charged.png
Binary files differ
diff --git a/watchapp/resources/icons/battery-charging.png b/watchapp/resources/icons/battery-charging.png
new file mode 100644
index 0000000..499db2c
--- /dev/null
+++ b/watchapp/resources/icons/battery-charging.png
Binary files differ
diff --git a/watchapp/resources/icons/battery-critical.png b/watchapp/resources/icons/battery-critical.png
new file mode 100644
index 0000000..b2cd889
--- /dev/null
+++ b/watchapp/resources/icons/battery-critical.png
Binary files differ
diff --git a/watchapp/resources/icons/battery-full.png b/watchapp/resources/icons/battery-full.png
new file mode 100644
index 0000000..20fd8f0
--- /dev/null
+++ b/watchapp/resources/icons/battery-full.png
Binary files differ
diff --git a/watchapp/resources/icons/battery-mid.png b/watchapp/resources/icons/battery-mid.png
new file mode 100644
index 0000000..b909bc7
--- /dev/null
+++ b/watchapp/resources/icons/battery-mid.png
Binary files differ
diff --git a/watchapp/resources/icons/connected-to-app.png b/watchapp/resources/icons/connected-to-app.png
new file mode 100644
index 0000000..cbeb356
--- /dev/null
+++ b/watchapp/resources/icons/connected-to-app.png
Binary files differ
diff --git a/watchapp/resources/icons/connected.png b/watchapp/resources/icons/connected.png
new file mode 100644
index 0000000..b4c837b
--- /dev/null
+++ b/watchapp/resources/icons/connected.png
Binary files differ
diff --git a/watchapp/resources/icons/icons.xcf b/watchapp/resources/icons/icons.xcf
new file mode 100644
index 0000000..b6e3ae8
--- /dev/null
+++ b/watchapp/resources/icons/icons.xcf
Binary files differ
diff --git a/watchapp/resources/icons/logging.png b/watchapp/resources/icons/logging.png
new file mode 100644
index 0000000..9ab951d
--- /dev/null
+++ b/watchapp/resources/icons/logging.png
Binary files differ
diff --git a/watchapp/resources/icons/sleep.png b/watchapp/resources/icons/sleep.png
new file mode 100644
index 0000000..7902252
--- /dev/null
+++ b/watchapp/resources/icons/sleep.png
Binary files differ
diff --git a/watchapp/resources/icons/steps.png b/watchapp/resources/icons/steps.png
new file mode 100644
index 0000000..62029d4
--- /dev/null
+++ b/watchapp/resources/icons/steps.png
Binary files differ
diff --git a/watchapp/src/actimon.c b/watchapp/src/actimon.c
index 1002672..1530ef5 100644
--- a/watchapp/src/actimon.c
+++ b/watchapp/src/actimon.c
@@ -4,11 +4,11 @@
/* Since the user just launched us, we're likely to be stepcounting */
monitor_mode_e monitor_mode = mmSteps;
static monitor_mode_e last_monitor_mode = mmSleep;
-uint32_t step_total_today = 0;
+uint32_t step_total_this_period = 0;
-static int8_t strunc(int16_t samp)
+static int16_t strunc(int16_t samp)
{
- return (int8_t)(samp >> 5);
+ return (samp >> 4);
}
#define iter1(N) \
@@ -43,37 +43,73 @@ static uint32_t runiir(uint32_t m)
static uint64_t now;
-static uint8_t step_last_mag;
+static uint16_t step_last_mag;
static int16_t step_last_delta;
static uint64_t step_last_event;
-static bool step_last_event_was_step;
+static uint8_t step_last_n_steps;
+static uint8_t step_last_n_counted_steps;
+static bool step_last_event_was_counted;
static uint16_t step_current_gap;
+static uint16_t step_total_delta;
static void init_steps()
{
step_last_mag = 0;
step_last_delta = 0;
step_last_event = 0;
- step_last_event_was_step = false;
+ step_last_n_steps = 0;
+ step_last_n_counted_steps = 0;
+ step_last_event_was_counted = false;
+ step_current_gap = 500;
+ step_total_delta = 0;
}
-static void log_step_point(uint8_t since, uint8_t mag)
+static void log_step_point(uint8_t since, uint16_t mag)
{
int32_t delta = mag - step_last_mag;
bool maybeevent = (step_last_delta > 0) && (delta <= 0);
step_last_mag = mag;
step_last_delta = delta;
- if (maybeevent) {
+ if (delta > 0)
+ step_total_delta += delta;
+ if (maybeevent /* && step_total_delta > 1 */) {
uint32_t steptime = (uint32_t)(now - step_last_event);
- if (steptime >= (uint32_t)(step_current_gap - 150) &&
- steptime <= (uint32_t)(step_current_gap + 150)) {
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "Maybe step: %d <= %ld <= %d ?.",
+ // step_current_gap - 200, steptime, step_current_gap + 200);
+ if (steptime >= (uint32_t)(step_current_gap - 200) &&
+ steptime <= (uint32_t)(step_current_gap + 200)) {
/* Event detected */
- step_total_today++;
- if (!step_last_event_was_step)
- step_total_today++;
- step_last_event_was_step = true;
+ if (step_last_n_steps == 5 && !step_last_event_was_counted) {
+ APP_LOG(APP_LOG_LEVEL_DEBUG, "Logging %d-%d more steps",
+ step_last_n_steps, step_last_n_counted_steps);
+ step_total_this_period += step_last_n_steps - step_last_n_counted_steps;
+ step_last_event_was_counted = true;
+ step_last_n_counted_steps = step_last_n_steps;
+ }
+ if (!step_last_event_was_counted) {
+ step_last_n_steps++;
+ APP_LOG(APP_LOG_LEVEL_DEBUG, "maybe step, counters now %d-%d",
+ step_last_n_steps, step_last_n_counted_steps);
+ } else {
+ APP_LOG(APP_LOG_LEVEL_DEBUG, "Logging a real step");
+ step_total_this_period++;
+ }
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "last_n_steps=%d was_counted=%s!",
+ // step_last_n_steps, step_last_event_was_counted ? "YES" : "NO");
} else {
- step_last_event_was_step = false;
+ if (steptime > 2000) {
+ APP_LOG(APP_LOG_LEVEL_DEBUG, "Resetting step counters");
+ step_last_n_steps = step_last_n_counted_steps = 0;
+ } else {
+ if (step_last_n_counted_steps != 0) {
+ step_last_n_counted_steps--;
+ }
+ step_last_n_steps = step_last_n_counted_steps;
+ }
+ step_last_event_was_counted = false;
+ APP_LOG(APP_LOG_LEVEL_DEBUG, "Not-step %d %ld %d. Counters now %d-%d",
+ step_current_gap - 200, steptime, step_current_gap + 200,
+ step_last_n_steps, step_last_n_counted_steps);
}
step_last_event = now;
if (steptime < 2000) {
@@ -82,9 +118,11 @@ static void log_step_point(uint8_t since, uint8_t mag)
if (step_current_gap > 675) step_current_gap = 675;
}
}
+ if (delta < 0)
+ step_total_delta = 0;
}
-static void log_sleep_point(uint8_t since, uint8_t mag)
+static void log_sleep_point(uint8_t since, uint16_t mag)
{
}
@@ -92,7 +130,7 @@ static void init_sleep(void)
{
}
-static void log_data_point(uint64_t when, uint8_t mag)
+static void log_data_point(uint64_t when, uint16_t mag)
{
uint8_t since = (uint8_t)(when-now);
if (when-now > 255) since = 255;
@@ -119,7 +157,7 @@ static void accel_handler(AccelData *data, uint32_t num_samples)
int16_t x = data->x, y = data->y, z = data->z;
int8_t tx = strunc(x), ty = strunc(y), tz = strunc(z);
uint32_t tmag = mag(tx,ty,tz);
- uint8_t smooth = (uint8_t)runiir(tmag);
+ uint16_t smooth = (uint16_t)runiir(tmag);
log_data_point(data->timestamp, smooth);
}
}
diff --git a/watchapp/src/actimon.h b/watchapp/src/actimon.h
index fe4dcf2..bc822ca 100644
--- a/watchapp/src/actimon.h
+++ b/watchapp/src/actimon.h
@@ -11,7 +11,7 @@ typedef enum {
} monitor_mode_e;
extern monitor_mode_e monitor_mode;
-extern uint32_t step_total_today;
+extern uint32_t step_total_this_period;
void init_activity_monitor(void);
void fini_activity_monitor(void);
diff --git a/watchapp/src/watchapp.c b/watchapp/src/watchapp.c
index 995ab80..63e693f 100644
--- a/watchapp/src/watchapp.c
+++ b/watchapp/src/watchapp.c
@@ -23,7 +23,7 @@ static void handle_second_tick(struct tm* tick_time, TimeUnits units_changed)
strftime(time_text, sizeof(time_text), "%k:%M", tick_time);
strftime(date_text, sizeof(date_text), "%B %d", tick_time);
if (monitor_mode == mmSteps)
- snprintf(step_text, sizeof(step_text), "%lu steps", step_total_today);
+ snprintf(step_text, sizeof(step_text), "%lu steps", step_total_this_period);
else
snprintf(step_text, sizeof(step_text), "Sleeping");
text_layer_set_text(time_layer, time_text);
@@ -61,8 +61,6 @@ static void window_load(Window *window)
window_set_fullscreen(window, true);
window_set_background_color(window, GColorBlack);
GRect full = layer_get_bounds(window_get_root_layer(window));
- APP_LOG(APP_LOG_LEVEL_DEBUG, "{.origin={.x=%d,.y=%d},.size={.w=%d,.h=%d}}\n",
- full.origin.x, full.origin.y, full.size.w, full.size.h);
full.size.h += 16; /* Account for status bar no longer shown */
layer_set_bounds(window_get_root_layer(window), full);
// Init the text layer used to show the time