Skip to content

Commit

Permalink
Finishing up in prep for first release
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachBenz committed Feb 8, 2014
1 parent 1de27dc commit 1b13db9
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 24 deletions.
Binary file added appstore_image_assets/indigo_remote_header.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified appstore_image_assets/screenshot-a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified appstore_image_assets/screenshot-b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified appstore_image_assets/screenshot-c.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added appstore_image_assets/screenshot-d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added appstore_image_assets/screenshot-e.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 8 additions & 11 deletions src/js/pebble-js-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function toggleDeviceOnOff(deviceNumber) {
sendDeviceInfo(deviceNumber, devices[deviceNumber]);
localStorage.setItem("devices", JSON.stringify(devices));
} else {
// TODO - inform pebble that toggle failed
// TODO: inform pebble that toggle failed
console.log("Request returned error code " + req.status.toString());
}
}
Expand Down Expand Up @@ -257,33 +257,30 @@ function executeAction(actionNumber) {
if (req.readyState == 4) {
// 200 - HTTP OK
if (req.status == 200) {
// TODO - inform pebble that action was succesful
// var actionInfo = JSON.parse(req.responseText);
// sendActionInfo(actionNumber, actions[actionNumber]);
// localStorage.setItem("actions", JSON.stringify(actions));
sendActionInfo(actionNumber, actions[actionNumber]);
} else {
// TODO - inform pebble that action failed
// TODO: inform pebble that action failed
console.log("Request returned error code " + req.status.toString());
}
}
}
req.send(null);
}

function dimDevice(deviceInfo) {
function dimDevice(dimRequest) {
var req = new XMLHttpRequest();
// TODO: Support Digest Authentication
req.open('GET', prefixForGet + devices[deviceInfo.device_dim].device_rest_url + "?brightness=" + deviceInfo.device_dim_level + "&_method=put", true); // `true` makes the request asynchronous
req.open('GET', prefixForGet + devices[dimRequest.device_dim].device_rest_url + "?brightness=" + dimRequest.device_dim_level + "&_method=put", true); // `true` makes the request asynchronous
req.onload = function(e) {
if (req.readyState == 4) {
// 200 - HTTP OK
if(req.status == 200) {
var deviceInfo = JSON.parse(req.responseText);
devices[deviceNumber].device_on = deviceInfo.isOn;
sendDeviceInfo(deviceNumber, devices[deviceNumber]);
devices[dimRequest.device_dim].device_on = deviceInfo.isOn;
sendDeviceInfo(dimRequest.device_dim, devices[dimRequest.device_dim]);
localStorage.setItem("devices", JSON.stringify(devices));
} else {
// TODO - inform pebble that dim failed
// TODO: inform pebble that dim failed
console.log("Request returned error code " + req.status.toString());
}
}
Expand Down
39 changes: 26 additions & 13 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ static void in_received_handler(DictionaryIterator *iter, void *context) {
}

gotDeviceCount = STATUS_LOADED;
layer_mark_dirty(menu_layer_get_layer(top_menu_layer));
if (window_stack_get_top_window() == top_window) {
layer_mark_dirty(menu_layer_get_layer(top_menu_layer));
}
}

if (device_tuple) {
Expand All @@ -128,12 +130,12 @@ static void in_received_handler(DictionaryIterator *iter, void *context) {
if (on) {
device_data_list[deviceNumber->value->uint8].on = on->value->uint8;
}

if (window_stack_get_top_window() == devices_window) {
layer_mark_dirty(menu_layer_get_layer(devices_menu_layer));
}
}
}

if (window_stack_get_top_window() == devices_window) {
layer_mark_dirty(menu_layer_get_layer(devices_menu_layer));
}
}

if (action_count_tuple) {
Expand All @@ -151,26 +153,33 @@ static void in_received_handler(DictionaryIterator *iter, void *context) {
}

gotActionCount = STATUS_LOADED;
layer_mark_dirty(menu_layer_get_layer(top_menu_layer));
if (window_stack_get_top_window() == top_window) {
layer_mark_dirty(menu_layer_get_layer(top_menu_layer));
}
}

if (action_tuple) {
// Add the action info to our list
Tuple *actionNumber = dict_find(iter, INDIGO_REMOTE_KEY_ACTION_NUMBER);
Tuple *name = dict_find(iter, INDIGO_REMOTE_KEY_ACTION_NAME);
APP_LOG(APP_LOG_LEVEL_DEBUG, "1");

if (actionNumber) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "2");
if (actionNumber->value->uint8 < MAX_NUMBER_OF_ACTIONS) {
if (name) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "3");
strncpy(action_data_list[actionNumber->value->uint8].name, name->value->cstring, MAX_ACTION_NAME_LENGTH);
}
APP_LOG(APP_LOG_LEVEL_DEBUG, "4");
action_data_list[actionNumber->value->uint8].status = STATUS_NONE;

if (window_stack_get_top_window() == actions_window) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "5");
layer_mark_dirty(menu_layer_get_layer(actions_menu_layer));
}
}
}

if (window_stack_get_top_window() == actions_window) {
layer_mark_dirty(menu_layer_get_layer(actions_menu_layer));
}
}
}

Expand Down Expand Up @@ -456,11 +465,15 @@ static void loading_timer_callback(void *data) {
static void loading_timeout_callback(void *data) {
if (gotDeviceCount == STATUS_LOADING) {
gotDeviceCount = STATUS_COULD_NOT_CONNECT;
layer_mark_dirty(menu_layer_get_layer(top_menu_layer));
if (window_stack_get_top_window() == top_window) {
layer_mark_dirty(menu_layer_get_layer(top_menu_layer));
}
}
if (gotActionCount == STATUS_LOADING) {
gotActionCount = STATUS_COULD_NOT_CONNECT;
layer_mark_dirty(menu_layer_get_layer(top_menu_layer));
if (window_stack_get_top_window() == top_window) {
layer_mark_dirty(menu_layer_get_layer(top_menu_layer));
}
}
}

Expand Down Expand Up @@ -643,7 +656,7 @@ static void dim_window_load(Window *window) {
Layer *window_layer = window_get_root_layer(window);
const int16_t width = layer_get_frame(window_layer).size.w - ACTION_BAR_WIDTH - 3;

dim_header_text_layer = text_layer_create(GRect(4, 0, width, 60));
dim_header_text_layer = text_layer_create(GRect(4, 4, width, 60));
text_layer_set_font(dim_header_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
text_layer_set_background_color(dim_header_text_layer, GColorClear);
text_layer_set_text(dim_header_text_layer, "Set dim level to:");
Expand Down

0 comments on commit 1b13db9

Please sign in to comment.