Commit 99b41894 authored by Zachary Seguin's avatar Zachary Seguin

Various updates & fixes

parent 00e9a958
......@@ -12,7 +12,8 @@
"icon": 0,
"temperature": 1,
"conditions": 2,
"message": 3
"message": 3,
"location": 4
},
"capabilities" : [ "location" ],
"resources": {
......
......@@ -16,7 +16,8 @@ enum /* MESSAGE KEYS */
KEY_WEATHER_ICON,
KEY_WEATHER_TEMPERATURE,
KEY_WEATHER_CONDITIONS,
KEY_MESSAGE
KEY_MESSAGE,
KEY_LOCATION
};
// Structs
......@@ -41,6 +42,7 @@ TextLayer *date_text_layer;
TextLayer *weather_icon_layer;
TextLayer *weather_text_layer;
TextLayer *message_layer;
TextLayer *location_layer;
// Fonts
GFont icons_font;
......@@ -61,6 +63,7 @@ static char date_text[] = "Xxx., Xxx. ##, ####";
static char weather_icon_text[] = DEFAULT_WEATHER_ICON;
static char weather_text[50];
static char message_text[40];
static char location_text[20];
static Weather current_weather_conditions;
......@@ -123,6 +126,7 @@ static void handle_message_received(DictionaryIterator *message, void *context)
Tuple *weather_icon_tuple = dict_find(message, KEY_WEATHER_ICON);
Tuple *temperature_tuple = dict_find(message, KEY_WEATHER_TEMPERATURE);
Tuple *conditions_tuple = dict_find(message, KEY_WEATHER_CONDITIONS);
Tuple *location_tuple = dict_find(message, KEY_LOCATION);
Tuple *message_tuple = dict_find(message, KEY_MESSAGE);
if (weather_icon_tuple && conditions_tuple && temperature_tuple)
......@@ -132,8 +136,6 @@ static void handle_message_received(DictionaryIterator *message, void *context)
current_weather_conditions.icon = weather_icon_tuple->value->cstring;
current_weather_conditions.temperature = temperature_tuple->value->int16;
current_weather_conditions.conditions = conditions_tuple->value->cstring;
set_weather_conditions(&current_weather_conditions);
}// End of if
else
{
......@@ -142,24 +144,39 @@ static void handle_message_received(DictionaryIterator *message, void *context)
current_weather_conditions.icon = DEFAULT_WEATHER_ICON;
current_weather_conditions.temperature = 0;
current_weather_conditions.conditions = "Weather Unavailable";
set_weather_conditions(&current_weather_conditions);
}// End of else
set_weather_conditions(&current_weather_conditions);
if (message_tuple)
{
APP_LOG(APP_LOG_LEVEL_DEBUG, "Message received");
snprintf(message_text, sizeof(message_text), message_tuple->value->cstring);
text_layer_set_text(message_layer, message_text);
}// End of if
else
{
APP_LOG(APP_LOG_LEVEL_DEBUG, "Message not received");
snprintf(message_text, sizeof(message_text), "Message Unavailable");
text_layer_set_text(message_layer, message_text);
}// End of else
text_layer_set_text(message_layer, message_text);
if (location_tuple)
{
APP_LOG(APP_LOG_LEVEL_DEBUG, "Location received");
snprintf(location_text, sizeof(location_text), location_tuple->value->cstring);
}// End of if
else
{
APP_LOG(APP_LOG_LEVEL_DEBUG, "Location not received");
snprintf(location_text, sizeof(location_text), "No Location");
}// End of else
text_layer_set_text(location_layer, location_text);
}// End of handle_message_received method
/*
......@@ -383,13 +400,24 @@ static void window_load(Window *window)
text_layer_set_text(bluetooth_status_layer, BLUETOOTH_STATUS_TEXT);
text_layer_set_font(bluetooth_status_layer, BLUETOOTH_STATUS_FONT);
text_layer_set_text_alignment(battery_percentage_layer, BLUETOOTH_STATUS_ALIGNMENT);
text_layer_set_text_alignment(bluetooth_status_layer, BLUETOOTH_STATUS_ALIGNMENT);
text_layer_set_background_color(bluetooth_status_layer, BLUETOOTH_STATUS_BACKGROUND_COLOUR);
text_layer_set_text_color(bluetooth_status_layer, BLUETOOTH_STATUS_FOREGROUND_COLOUR);
layer_add_child(window_layer, text_layer_get_layer(bluetooth_status_layer));
location_layer = text_layer_create((GRect) { .origin = { LOCATION_ORIGIN }, .size = { LOCATION_SIZE } });
text_layer_set_text(location_layer, LOCATION_TEXT);
text_layer_set_font(location_layer, LOCATION_FONT);
text_layer_set_text_alignment(location_layer, LOCATION_ALIGNMENT);
text_layer_set_background_color(location_layer, LOCATION_BACKGROUND_COLOUR);
text_layer_set_text_color(location_layer, LOCATION_FOREGROUND_COLOUR);
layer_add_child(window_layer, text_layer_get_layer(location_layer));
// Date & Time
time_text_layer = text_layer_create((GRect) { .origin = { TIME_TEXT_ORIGIN }, .size = { TIME_TEXT_SIZE } });
......@@ -526,6 +554,7 @@ static void window_unload(Window *window)
text_layer_destroy(weather_icon_layer);
text_layer_destroy(weather_text_layer);
text_layer_destroy(message_layer);
text_layer_destroy(location_layer);
APP_LOG(APP_LOG_LEVEL_DEBUG_VERBOSE, "Done removing window events");
......
......@@ -30,7 +30,7 @@
#define BATTERY_PERCENTAGE_SIZE_HEIGHT 25
#define BATTERY_PERCENTAGE_SIZE BATTERY_PERCENTAGE_SIZE_WIDTH, BATTERY_PERCENTAGE_SIZE_HEIGHT
#define BATTERY_PERCENTAGE_ORIGIN_X BATTERY_STATUS_SIZE_WIDTH
#define BATTERY_PERCENTAGE_ORIGIN_X BATTERY_STATUS_SIZE_WIDTH + 8
#define BATTERY_PERCENTAGE_ORIGIN_Y 2
#define BATTERY_PERCENTAGE_ORIGIN BATTERY_PERCENTAGE_ORIGIN_X, BATTERY_PERCENTAGE_ORIGIN_Y
......@@ -57,6 +57,22 @@
#define BLUETOOTH_STATUS_FONT icons_font
#define BLUETOOTH_STATUS_ALIGNMENT GTextAlignmentRight
// Location
#define LOCATION_SIZE_X bounds.size.w - BLUETOOTH_STATUS_SIZE_WIDTH - BATTERY_PERCENTAGE_SIZE_WIDTH - BATTERY_STATUS_SIZE_WIDTH - 8
#define LOCATION_SIZE_Y 25
#define LOCATION_SIZE LOCATION_SIZE_X, LOCATION_SIZE_Y
#define LOCATION_ORIGIN_X BATTERY_STATUS_SIZE_WIDTH + BATTERY_PERCENTAGE_SIZE_WIDTH + 4
#define LOCATION_ORIGIN_Y 2
#define LOCATION_ORIGIN LOCATION_ORIGIN_X, LOCATION_ORIGIN_Y
#define LOCATION_BACKGROUND_COLOUR background_colour
#define LOCATION_FOREGROUND_COLOUR foreground_colour
#define LOCATION_TEXT location_text
#define LOCATION_FONT fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD)
#define LOCATION_ALIGNMENT GTextAlignmentCenter
// Time
#define TIME_TEXT_SIZE_X bounds.size.w
#define TIME_TEXT_SIZE_Y 55
......
......@@ -133,6 +133,7 @@ function sendUpdate() {
data.temperature = response.temperature;
data.conditions = response.conditions;
data.message = response.message;
data.location = response.location;
sendData(data);
} else if (http.readyState == 4) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment