Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/pebble-my-data.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbahbka <bahbka@gmail.com>2014-07-13 15:58:08 +0400
committerbahbka <bahbka@gmail.com>2014-07-13 15:58:08 +0400
commit89e76572868b95d655ca709e3784af3cf5bbd516 (patch)
treee4dbe546b4f7a39dbcb5dba82c46e4810df7bb10
parent16d647d76ec15e56148f39b230e2e71eba055e53 (diff)
Scroll to defined offset.
-rw-r--r--README.md9
-rw-r--r--appinfo.json4
-rw-r--r--resources/configuration.html2
-rw-r--r--src/pebble-my-data.c28
4 files changed, 26 insertions, 17 deletions
diff --git a/README.md b/README.md
index b6e4d44..60dfe11 100644
--- a/README.md
+++ b/README.md
@@ -25,7 +25,7 @@ Inspired by [Pebble Cards](http://keanulee.com/pebblecards).
* Black/white theme switched from JSON
* Turn on light from JSON
* Blink content from JSON
-* Scroll-up content after update from JSON
+* Define scroll offset in percent after update from JSON
* Vibrate on bluetooth connection loss (configurable)
* Watches battery charge status
* Digital clock (12h/24h support), seconds dots blinking (configurable)
@@ -78,7 +78,7 @@ JSON output example (some fields are optional):
"vibrate": 0,
"font": 4,
"theme": 0,
- "scroll": 1,
+ "scroll": 33,
"light": 1,
"blink": 3,
"updown": 1,
@@ -117,9 +117,8 @@ Next update delay in seconds.
- 1 - White
### scroll
-
-- 0 - Keep position
-- 1 - Scroll up
+Scroll content to offset (in percent 0..100).
+If param not defined or >100 - position will be kept.
### light
diff --git a/appinfo.json b/appinfo.json
index 67125dd..5bd8763 100644
--- a/appinfo.json
+++ b/appinfo.json
@@ -3,8 +3,8 @@
"shortName": "My Data",
"longName": "My Data",
"companyName": "bahbka",
- "versionCode": 230,
- "versionLabel": "2.3.0",
+ "versionCode": 231,
+ "versionLabel": "2.3.1",
"watchapp": {
"watchface": false
},
diff --git a/resources/configuration.html b/resources/configuration.html
index 331537d..7a7f663 100644
--- a/resources/configuration.html
+++ b/resources/configuration.html
@@ -63,7 +63,7 @@ vim: sw=2 ts=2 expandtab ai
</head>
<body onload="put_config();">
<h1>My Data</h1>
- <small>v2.3.0, by bahbka</small>
+ <small>v2.3.1, by bahbka</small>
<hr size="1" />
<form action="javascript: get_config();" id="config_form">
diff --git a/src/pebble-my-data.c b/src/pebble-my-data.c
index 32e8c89..ed03b39 100644
--- a/src/pebble-my-data.c
+++ b/src/pebble-my-data.c
@@ -59,6 +59,8 @@ bool updown = false;
#define CONTENT_SIZE 1024
+#define DONT_SCROLL 255
+
static char content[CONTENT_SIZE];
enum { // AppMessage keys
@@ -115,7 +117,7 @@ static void handle_shake(AccelAxisType axis, int32_t direction);
static void change_info_theme(uint8_t theme);
static void blink_info();
-static void update_info_layer(char *content, uint8_t font, bool scroll_up, bool new_updown);
+static void update_info_layer(char *content, uint8_t font, uint8_t scroll_offset, bool new_updown);
static void change_theme(uint8_t t);
static void select_click_handler(ClickRecognizerRef recognizer, void *context);
@@ -273,7 +275,7 @@ static void handle_shake(AccelAxisType axis, int32_t direction) {
}
// update data in main layer (content, font)
-static void update_info_layer(char *content, uint8_t font, bool scroll_up, bool new_updown) {
+static void update_info_layer(char *content, uint8_t font, uint8_t scroll_offset, bool new_updown) {
// change font
switch (font) {
case 1:
@@ -330,8 +332,14 @@ static void update_info_layer(char *content, uint8_t font, bool scroll_up, bool
}
text_layer_set_size(text_info_layer, max_size); // resize layer
scroll_layer_set_content_size(scroll_layer, GSize(144, max_size.h)); // resize scroll layer
- if (scroll_up) {
- scroll_layer_set_content_offset(scroll_layer, GPoint(0, 0), true); // scroll to beginning with animation
+
+ if (scroll_offset != DONT_SCROLL) {
+ GPoint offset;
+ offset.x = 0;
+
+ offset.y = -(int)((float)max_size.h / 100.0 * scroll_offset);
+
+ scroll_layer_set_content_offset(scroll_layer, offset, true); // scroll to beginning with animation
}
}
@@ -532,10 +540,12 @@ void in_received_handler(DictionaryIterator *received, void *context) {
if (content_tuple) {
memcpy(content, content_tuple->value->cstring, strlen(content_tuple->value->cstring) + 1);
- Tuple *scroll_up_tuple = dict_find(received, KEY_SCROLL);
- bool scroll_up = false;
- if (scroll_up_tuple && scroll_up_tuple->value->uint8 == 1) {
- scroll_up = true;
+ Tuple *scroll_offset_tuple = dict_find(received, KEY_SCROLL);
+ uint8_t scroll_offset = DONT_SCROLL;
+ if (scroll_offset_tuple) {
+ scroll_offset = scroll_offset_tuple->value->uint8;
+ if (scroll_offset > 100)
+ scroll_offset = DONT_SCROLL;
}
Tuple *updown_tuple = dict_find(received, KEY_UPDOWN);
@@ -550,7 +560,7 @@ void in_received_handler(DictionaryIterator *received, void *context) {
font = font_tuple->value->uint8;
}
- update_info_layer(content, font, scroll_up, updown_beh);
+ update_info_layer(content, font, scroll_offset, updown_beh);
}
// maybe need to vibrate?