Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"WeatherForecastHighTemp",
"WeatherForecastLowTemp",
"WeatherUVIndex",
"WeatherApparentTemperature",
"SettingAltClockName",
"SettingAltClockOffset",
"SettingDisableAutobattery",
Expand All @@ -56,6 +57,7 @@
"SettingShowLeadingZero",
"SettingSidebarOnLeft",
"SettingSidebarTextColor",
"SettingUseApparentTemperature",
"SettingUseLargeFonts",
"SettingUseMetric",
"WeatherUseNightIcon",
Expand Down
14 changes: 13 additions & 1 deletion src/c/messaging.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ void inbox_received_callback(DictionaryIterator *iterator, void *context) {
weatherDataUpdated = true;
}

if(settings.useApparentTemperature) {
Tuple *weatherAppTemp_tuple = dict_find(iterator, MESSAGE_KEY_WeatherApparentTemperature);
if(weatherAppTemp_tuple != NULL) {
Weather_weatherInfo.currentTemp = (int)weatherAppTemp_tuple->value->int32;
weatherDataUpdated = true;
}
}

Tuple *weatherConditions_tuple = dict_find(iterator, MESSAGE_KEY_WeatherCondition);
if(weatherConditions_tuple != NULL) {
Weather_setCurrentCondition(weatherConditions_tuple->value->int32);
Expand Down Expand Up @@ -89,6 +97,7 @@ void inbox_received_callback(DictionaryIterator *iterator, void *context) {
Tuple *clockFont_tuple = dict_find(iterator, MESSAGE_KEY_SettingClockFontId);
Tuple *hourlyVibe_tuple = dict_find(iterator, MESSAGE_KEY_SettingHourlyVibe);
Tuple *useLargeFonts_tuple = dict_find(iterator, MESSAGE_KEY_SettingUseLargeFonts);
Tuple *useApparentTemperature_tuple = dict_find(iterator, MESSAGE_KEY_SettingUseApparentTemperature);

Tuple *widget0Id_tuple = dict_find(iterator, MESSAGE_KEY_SettingWidget0ID);
Tuple *widget1Id_tuple = dict_find(iterator, MESSAGE_KEY_SettingWidget1ID);
Expand All @@ -105,7 +114,6 @@ void inbox_received_callback(DictionaryIterator *iterator, void *context) {

Tuple *activateDisconnectIcon_tuple = dict_find(iterator, MESSAGE_KEY_SettingDisconnectIcon);


if(timeColor_tuple != NULL) {
settings.timeColor = GColorFromHEX(timeColor_tuple->value->int32);
}
Expand Down Expand Up @@ -155,6 +163,10 @@ void inbox_received_callback(DictionaryIterator *iterator, void *context) {
settings.useLargeFonts = (bool)useLargeFonts_tuple->value->int8;
}

if(useApparentTemperature_tuple != NULL) {
settings.useApparentTemperature = (bool)useApparentTemperature_tuple->value->int8;
}

if(hourlyVibe_tuple != NULL) {
settings.hourlyVibe = hourlyVibe_tuple->value->int8;
}
Expand Down
3 changes: 3 additions & 0 deletions src/c/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ typedef struct {
bool healthUseDistance;
bool healthUseRestfulSleep;
char decimalSeparator;

// apparent temperature option
bool useApparentTemperature;
} Settings;

// Dynamic settings (calculated at runtime based on currently-selected widgets)
Expand Down
8 changes: 8 additions & 0 deletions src/pkjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ Pebble.addEventListener('webviewclosed', function(e) {
window.localStorage.setItem('weather_loc_lng', configData.weather_loc_lng);
}

if(configData.apparent_temperature_setting) {
if(configData.apparent_temperature_setting == 'off') {
dict.SettingUseApparentTemperature = 0;
} else if(configData.apparent_temperature_setting == 'on') {
dict.SettingUseApparentTemperature = 1;
}
}

if(configData.weather_datasource) {
window.localStorage.setItem('weather_datasource', configData.weather_datasource);
window.localStorage.setItem('weather_api_key', configData.weather_api_key);
Expand Down
14 changes: 7 additions & 7 deletions src/pkjs/weather_openmeteo.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function getWeatherFromCoords(pos) {
'&current_weather=true' +
'&daily=temperature_2m_max,temperature_2m_min,uv_index_max,weathercode' +
'&hourly=uv_index' +
'&minutely_15=apparent_temperature' +
'&timezone=auto';

console.log(url);
Expand All @@ -38,11 +39,8 @@ function getAndSendWeather(url) {
var forecastLow = Math.round(json.daily.temperature_2m_min[0]);
var forecastCode = json.daily.weathercode[0];

function getCurrentUVFromHourly(json) {
function getValueFromArrays(times, values) {
var now = new Date();
var times = json.hourly.time;
var uvValues = json.hourly.uv_index;

var closestIndex = 0;
var smallestDiff = Infinity;

Expand All @@ -54,10 +52,11 @@ function getAndSendWeather(url) {
closestIndex = i;
}
}
return Math.round(uvValues[closestIndex]);
return Math.round(values[closestIndex]);
}

var uvIndex = getCurrentUVFromHourly(json);
var uvIndex = getValueFromArrays(json.hourly.time, json.hourly.uv_index);
var apparentTemperature = getValueFromArrays(json.minutely_15.time, json.minutely_15.apparent_temperature);

console.log('Forecast high/low: ' + forecastHigh + '/' + forecastLow);
console.log('Forecast condition code: ' + forecastCode);
Expand All @@ -72,7 +71,8 @@ function getAndSendWeather(url) {
'WeatherForecastHighTemp': forecastHigh,
'WeatherForecastLowTemp': forecastLow,
'WeatherForecastCondition': forecastIcon,
'WeatherUVIndex': uvIndex
'WeatherUVIndex': uvIndex,
'WeatherApparentTemperature': apparentTemperature
};

console.log(JSON.stringify(dictionary));
Expand Down