Skip to content
This repository has been archived by the owner on Feb 5, 2022. It is now read-only.

Commit

Permalink
Remove logging and fix small config issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohan Robert committed Apr 10, 2016
1 parent 8e4ba0a commit 180bdbc
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 46 deletions.
74 changes: 38 additions & 36 deletions src/js/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,44 +45,46 @@ Pebble.addEventListener('showConfiguration', function() {
platform: Pebble.getActiveWatchInfo().platform
};
url += toQueryString(params);
console.log('Showing configuration page: ' + url);
// console.log('Showing configuration page: ' + url);
Pebble.openURL(url);
});

Pebble.addEventListener('webviewclosed', function(e) {
var saveColor = function(dict, attr, color){
color = color.replace('#', '').replace('0x','');
localStorage.setItem(attr + '_color', color);
dict['AppKey' + attr + 'Color'] = parseInt(color, 16);
};
var saveBool = function(dict, attr, bool){
localStorage.setItem(attr + '_bool', bool);
dict['AppKey' + attr] = bool;
};
var saveInt = function(dict, attr, int){
localStorage.setItem(attr + '_int', int);
dict['AppKey' + attr] = int;
};
var configData = JSON.parse(decodeURIComponent(e.response));
console.log('Configuration page returned: ' + JSON.stringify(configData));
var dict = {};
saveColor(dict, 'MinuteHand', configData.minute_hand_color);
saveColor(dict, 'HourHand', configData.hour_hand_color);
saveColor(dict, 'Background', configData.background_color);
saveColor(dict, 'Date', configData.date_color);
saveColor(dict, 'Time', configData.time_color);
saveColor(dict, 'Info', configData.info_color);
saveBool(dict, 'DateDisplayed', configData.date_displayed);
saveInt(dict, 'WeatherEnabled', configData.weather_enabled);
saveInt(dict, 'BluetoothIcon', configData.bluetooth_icon);
saveInt(dict, 'TemperatureUnit', configData.temperature_unit);
saveInt(dict, 'RefreshRate', configData.refresh_rate);
saveBool(dict, 'RainbowMode', configData.rainbow_mode);
dict['AppKeyConfig'] = 1;
localStorage.setItem("Location", configData.location);
Pebble.sendAppMessage(dict, function() {
console.log('Send successful: ' + JSON.stringify(dict));
}, function() {
console.log('Send failed!');
});
if(e.response){
var saveColor = function(dict, attr, color){
color = color.replace('#', '').replace('0x','');
localStorage.setItem(attr + '_color', color);
dict['AppKey' + attr + 'Color'] = parseInt(color, 16);
};
var saveBool = function(dict, attr, bool){
localStorage.setItem(attr + '_bool', bool);
dict['AppKey' + attr] = bool;
};
var saveInt = function(dict, attr, int){
localStorage.setItem(attr + '_int', int);
dict['AppKey' + attr] = int;
};
var configData = JSON.parse(decodeURIComponent(e.response));
// console.log('Configuration page returned: ' + JSON.stringify(configData));
var dict = {};
saveColor(dict, 'MinuteHand', configData.minute_hand_color);
saveColor(dict, 'HourHand', configData.hour_hand_color);
saveColor(dict, 'Background', configData.background_color);
saveColor(dict, 'Date', configData.date_color);
saveColor(dict, 'Time', configData.time_color);
saveColor(dict, 'Info', configData.info_color);
saveBool(dict, 'DateDisplayed', configData.date_displayed);
saveInt(dict, 'WeatherEnabled', configData.weather_enabled);
saveInt(dict, 'BluetoothIcon', configData.bluetooth_icon);
saveInt(dict, 'TemperatureUnit', configData.temperature_unit);
saveInt(dict, 'RefreshRate', configData.refresh_rate);
saveBool(dict, 'RainbowMode', configData.rainbow_mode);
dict['AppKeyConfig'] = 1;
localStorage.setItem("Location", configData.location);
Pebble.sendAppMessage(dict, function() {
// console.log('Send successful: ' + JSON.stringify(dict));
}, function() {
// console.log('Send failed!');
});
}
});
6 changes: 3 additions & 3 deletions src/js/weather.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ function fetchWeather(query) {
"AppKeyWeatherIcon": icon,
"AppKeyWeatherTemperature": temperature
};
console.log("weather sent: " + JSON.stringify(data));
// console.log("weather sent: " + JSON.stringify(data));
Pebble.sendAppMessage(data);
} else {
console.warn("weather error (" + req.code + ")");
// console.warn("weather error (" + req.code + ")");
Pebble.sendAppMessage({
"AppKeyWeatherFailed": 1
});
Expand All @@ -69,7 +69,7 @@ function locationSuccess(pos) {
}

function locationError(err) {
console.warn("location error (" + err.code + "): " + err.message);
// console.warn("location error (" + err.code + "): " + err.message);
Pebble.sendAppMessage({
"AppKeyWeatherFailed": 0
});
Expand Down
14 changes: 7 additions & 7 deletions src/minimalin.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include "messenger.h"

#define HOUR_HAND_COLOR GColorRed
#define d(string, ...) APP_LOG (APP_LOG_LEVEL_DEBUG, string, ##__VA_ARGS__)
#define e(string, ...) APP_LOG (APP_LOG_LEVEL_ERROR, string, ##__VA_ARGS__)
#define i(string, ...) APP_LOG (APP_LOG_LEVEL_INFO, string, ##__VA_ARGS__)
// #define d(string, ...) APP_LOG (APP_LOG_LEVEL_DEBUG, string, ##__VA_ARGS__)
// #define e(string, ...) APP_LOG (APP_LOG_LEVEL_ERROR, string, ##__VA_ARGS__)
// #define i(string, ...) APP_LOG (APP_LOG_LEVEL_INFO, string, ##__VA_ARGS__)

#ifdef PBL_ROUND
static GPoint ticks_points[12][2] = {
Expand Down Expand Up @@ -243,24 +243,25 @@ static void send_weather_request_callback(void * context){
result = app_message_outbox_send();
if(result != APP_MSG_OK) {
schedule_weather_request(5000);
e("Error sending the outbox: %d", (int)result);
// e("Error sending the outbox: %d", (int)result);
}
} else {
schedule_weather_request(5000);
e("Error preparing the outbox: %d", (int)result);
// e("Error preparing the outbox: %d", (int)result);
}
}
}
}

static void schedule_weather_request(int timeout){
int expiration = time(NULL) + timeout;
if(s_weather_request_timer){
int expiration = time(NULL) + timeout;
if(expiration < s_weather_request_timeout){
s_weather_request_timeout = expiration;
app_timer_reschedule(s_weather_request_timer, timeout);
}
}else{
s_weather_request_timeout = expiration;
s_weather_request_timer = app_timer_register(timeout, send_weather_request_callback, NULL);
}
}
Expand Down Expand Up @@ -337,7 +338,6 @@ static void weather_failed_callback(DictionaryIterator * iter, Tuple * tuple){
static void weather_requested_callback(DictionaryIterator * iter, Tuple * tuple){
Tuple * icon_tuple = dict_find(iter, AppKeyWeatherIcon);;
Tuple * temp_tuple = dict_find(iter, AppKeyWeatherTemperature);;
schedule_weather_request(60000);
if(icon_tuple && temp_tuple){
s_weather.timestamp = time(NULL);
s_weather.icon = icon_tuple->value->int8;
Expand Down

0 comments on commit 180bdbc

Please sign in to comment.