Skip to content

Commit

Permalink
bugfix for fair & partly cloudly yahoo weather logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredbiehler committed May 4, 2014
1 parent 37b7277 commit c4d4bff
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This is my attempt at both learning about the Pebble SDK by adjusting an app for

I make no claims about the icons nor the design of this app, all credit for that goes to those listed below.

Give it a shot and let me know what you think! [Download pbw here](https://github.com/jaredbiehler/weather-my-way/releases/download/1.0.1/weather-my-way.pbw)
Give it a shot and let me know what you think! [Download pbw here](https://github.com/jaredbiehler/weather-my-way/releases/download/1.0.2/weather-my-way.pbw)

![pebble screen1](https://raw.githubusercontent.com/jaredbiehler/weather-my-way/master/screenshots/pebble-screenshot1.png) 
![pebble screen2](https://raw.githubusercontent.com/jaredbiehler/weather-my-way/master/screenshots/pebble-screenshot2.png) 
Expand Down
Binary file modified screenshots/weather-my-way-config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 4 additions & 5 deletions src/js/pebble-js-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ Pebble.addEventListener("appmessage", function(data) {
* for the latest config settings. So I persist them in a rather ugly Global variable.
*/
Pebble.addEventListener("showConfiguration", function (e) {

var options = {
's': Global.latestConfig.weatherService,
'd': Global.latestConfig.debugEnabled,
Expand All @@ -75,7 +74,7 @@ Pebble.addEventListener("webviewclosed", function(e) {
var settings = JSON.parse(decodeURIComponent(e.response));

var config = {};
config.weatherService = settings.service === SERVICE_YAHOO_WEATHER ? SERVICE_YAHOO_WEATHER : SERVICE_OPEN_WEATHER
config.weatherService = settings.service === SERVICE_YAHOO_WEATHER ? SERVICE_YAHOO_WEATHER : SERVICE_OPEN_WEATHER;
config.weatherScale = settings.scale === 'F' ? 'F' : 'C';
config.debugEnabled = settings.debug === 'true';
config.batteryEnabled = settings.battery === 'on';
Expand Down Expand Up @@ -108,7 +107,7 @@ var nack = function (data, retry) {
var updateWeather = function () {
if (Global.updateInProgress &&
new Date().getTime() < Global.lastUpdateAttempt.getTime() + Global.updateWaitTimeout) {
console.log("Upadte already progress in the last "+(Global.updateWaitTimeout/60000)+" minutes");
console.log("Update already started in the last "+(Global.updateWaitTimeout/60000)+" minutes");
return;
}
Global.updateInProgress = true;
Expand Down Expand Up @@ -145,7 +144,7 @@ var fetchYahooWeather = function(latitude, longitude) {
neighbor = 'SELECT neighborhood FROM geo.placefinder WHERE text="'+latitude+','+longitude+'" AND gflags="R";';
query = 'SELECT * FROM weather.forecast WHERE woeid IN ('+subselect+') AND u="'+Global.latestConfig.weatherScale.toLowerCase()+'";';
multi = "SELECT * FROM yql.query.multi WHERE queries='"+query+" "+neighbor+"'";
options.url = "https://query.yahooapis.com/v1/public/yql?format=json&q=" + encodeURIComponent(multi);
options.url = "https://query.yahooapis.com/v1/public/yql?format=json&q="+encodeURIComponent(multi)+"&nocache="+new Date().getTime();

options.parse = function(response) {
var sunrise, sunset, pubdate, neighborhood;
Expand Down Expand Up @@ -214,7 +213,7 @@ var fetchOpenWeather = function(latitude, longitude) {

var fetchWeather = function(options) {

//console.log('URL: ' + options.url);
console.log('URL: ' + options.url);

getJson(options.url, function(err, response) {

Expand Down
4 changes: 2 additions & 2 deletions src/weather_layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,14 +378,14 @@ uint8_t yahoo_weather_icon_for_condition(int c, bool night_time)
return WEATHER_ICON_CLOUDY;
}
// Cloudly Night and` Cloudly Day
else if (c >= 27 || c <= 30) {
else if (c >= 27 && c <= 30) {
if (night_time)
return WEATHER_ICON_PARTLY_CLOUDY_NIGHT;
else
return WEATHER_ICON_PARTLY_CLOUDY_DAY;
}
// Clear / Fair Night && Sunny / Fair Day
else if (c >= 31 || c <= 34) {
else if (c >= 31 && c <= 34) {
if (night_time)
return WEATHER_ICON_CLEAR_NIGHT;
else
Expand Down

0 comments on commit c4d4bff

Please sign in to comment.