Upload files to "src/c"
This commit is contained in:
86
src/c/constants.h
Normal file
86
src/c/constants.h
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define DEBUG 0
|
||||||
|
|
||||||
|
#define KEY_TEMPERATURE_IN_C 1
|
||||||
|
#define KEY_CONDITIONS 2
|
||||||
|
#define KEY_BACKGROUND_COLOR 3
|
||||||
|
#define KEY_TEXT_COLOR 4
|
||||||
|
#define KEY_WEATHER_FREQUENCY 5
|
||||||
|
#define KEY_USE_CELSIUS 6
|
||||||
|
#define KEY_DISPLAY_WEATHER 7
|
||||||
|
#define KEY_MIN_SINCE_WEATHER_UPDATE 8
|
||||||
|
#define KEY_GET_WEATHER 9
|
||||||
|
#define KEY_TEMPERATURE 10
|
||||||
|
#define KEY_READABILITY 11
|
||||||
|
#define KEY_TEMPERATURE_LO 12
|
||||||
|
#define KEY_TEMPERATURE_HI 13
|
||||||
|
#define KEY_TEMPERATURE_IN_C_LO 14
|
||||||
|
#define KEY_TEMPERATURE_IN_C_HI 15
|
||||||
|
#define KEY_CONDITION_CODE 16
|
||||||
|
#define KEY_SHAKE_FOR_LOHI 17
|
||||||
|
#define KEY_DISPLAY_DIGITAL_TIME 18
|
||||||
|
#define KEY_DISPLAY_DATE 19
|
||||||
|
#define KEY_DISPLAY_MONTH 20
|
||||||
|
#define KEY_VIBBRATE_BT_STATUS 22
|
||||||
|
#define KEY_WEATHER_USE_GPS 23
|
||||||
|
#define KEY_WEATHER_LOCATION 24
|
||||||
|
#define KEY_USE_THIN_HANDS 25
|
||||||
|
#define KEY_DISPLAY_BATTERY 26
|
||||||
|
#define KEY_JS_READY 28
|
||||||
|
#define KEY_HOUR_HAND_COLOR 29
|
||||||
|
#define KEY_MINUTE_HAND_COLOR 30
|
||||||
|
#define KEY_HOUR_MARKERS_COLOR 31
|
||||||
|
#define KEY_MINOR_MARKERS_COLOR 32
|
||||||
|
#define KEY_DISPLAY_HOUR_DIGITS 33
|
||||||
|
#define KEY_DISPLAY_SECONDS_HAND 34
|
||||||
|
#define KEY_SECONDS_HAND_COLOR 35
|
||||||
|
#define KEY_OPTIONS 99
|
||||||
|
|
||||||
|
extern const int DEFAULT_SHAKE_FOR_LOHI;
|
||||||
|
extern const int DEFAULT_DISPLAY_LOHI_TIMER;
|
||||||
|
extern const int DEFAULT_MIN_SINCE_WEATHER_UPDATE;
|
||||||
|
extern const char DEFAULT_LAST_WEATHER_UPDATE[16];
|
||||||
|
extern const char DEFAULT_ERROR_WEATHER_UPDATE[16];
|
||||||
|
extern const int DEFAULT_CONDITION_CODE;
|
||||||
|
extern const int DEFAULT_DISPLAY_WEATHER;
|
||||||
|
extern const int DEFAULT_WEATHER_FREQUENCY;
|
||||||
|
extern const int DEFAULT_WEATHER_USE_GPS;
|
||||||
|
extern const int DEFAULT_USE_CELSIUS;
|
||||||
|
extern const int DEFAULT_BACKGROUND_COLOR;
|
||||||
|
extern const int DEFAULT_TEXT_COLOR;
|
||||||
|
extern const int DEFAULT_HOUR_HAND_COLOR;
|
||||||
|
extern const int DEFAULT_MINUTE_HAND_COLOR;
|
||||||
|
extern const int DEFAULT_SECONDS_HAND_COLOR;
|
||||||
|
extern const int DEFAULT_HOUR_MARKERS_COLOR;
|
||||||
|
extern const int DEFAULT_MINOR_MARKERS_COLOR;
|
||||||
|
extern const int DEFAULT_DISPLAY_HOUR_DIGITS;
|
||||||
|
extern const int DEFAULT_READABILITY;
|
||||||
|
|
||||||
|
extern const int DEFAULT_DIGITAL_TIME_Y_OFFSET_READABILITY;
|
||||||
|
extern const int DEFAULT_DISPLAY_DIGITAL_TIME;
|
||||||
|
extern const int DEFAULT_DISPLAY_DATE;
|
||||||
|
extern const int DEFAULT_VIBRATE_BT_STATUS;
|
||||||
|
extern const int DEFAULT_USE_THIN_HANDS;
|
||||||
|
extern const int DEFAULT_DISPLAY_BATTERY;
|
||||||
|
extern const int DEFAULT_DISPLAY_SECONDS_HAND;
|
||||||
|
|
||||||
|
extern const int DEFAULT_MAX_WEATHER_RETRY_COUNT;
|
||||||
|
extern const uint MAX_CHALK_SINGLE_LINE_CONDITIONS_LEN;
|
||||||
|
extern const int DEFAULT_WEATHER_Y_OFFSET_READABILITY;
|
||||||
|
extern const int DEFAULT_WEATHER_Y_OFFSET_HOUR_DIGITS;
|
||||||
|
extern const int DEFAULT_DATE_Y_OFFSET_READABILITY;
|
||||||
|
extern const int DEFAULT_DATE_X_OFFSET_READABILITY;
|
||||||
|
extern const int DEFAULT_DATE_X_OFFSET_HOUR_DIGITS;
|
||||||
|
extern const int DEFAULT_CHALK_TIME_X_OFFSET;
|
||||||
|
extern const int DEFAULT_CHALK_WEATHER1_Y_OFFSET;
|
||||||
|
extern const int DEFAULT_CHALK_WEATHER2_Y_OFFSET;
|
||||||
|
extern const int DEFAULT_CHALK_WEATHER_CENTER_Y_OFFSET;
|
||||||
|
extern const int DEFAULT_CHALK_TIME_Y_OFFSET;
|
||||||
|
extern const int DEFAULT_CHALK_DIGITAL_TIME_Y_OFFSET;
|
||||||
|
extern const int DEFAULT_DIGITAL_TIME_Y_OFFSET_HOUR_DIGITS;
|
||||||
|
extern const int DEFAULT_MARKERS_Y_OFFSET;
|
||||||
|
extern const int DEFAULT_MARKERS_X_OFFSET;
|
||||||
|
extern const int DEFAULT_CHALK_BATTERY_X_OFFSET;
|
||||||
|
extern const int DEFAULT_BATTERY_OFFSET_READABILITY;
|
||||||
|
extern const int DEFAULT_BATTERY_OFFSET_HOUR_DIGITS;
|
||||||
86
src/c/date.c
Normal file
86
src/c/date.c
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
#include <pebble.h>
|
||||||
|
#include "date.h"
|
||||||
|
#include "constants.h"
|
||||||
|
#include "analog_wd.h"
|
||||||
|
|
||||||
|
#define DEBUG_DAY_DATE "Sun 03"
|
||||||
|
#define DEBUG_MONTH "Jan"
|
||||||
|
|
||||||
|
extern TextLayer *date_layer1, *date_layer2;
|
||||||
|
|
||||||
|
extern Options s_options;
|
||||||
|
|
||||||
|
//adds/configures date display lines
|
||||||
|
void add_date_layers(Layer *window_layer, int16_t width, int16_t height) {
|
||||||
|
|
||||||
|
GFont date_font;
|
||||||
|
int date_Y_readability_offset = 0;
|
||||||
|
int date_X_readability_offset = 0;
|
||||||
|
int date_X_hour_digits_offset = 0;
|
||||||
|
|
||||||
|
if (s_options.readability) {
|
||||||
|
date_X_readability_offset = DEFAULT_DATE_X_OFFSET_READABILITY;
|
||||||
|
date_Y_readability_offset = DEFAULT_DATE_Y_OFFSET_READABILITY;
|
||||||
|
date_font = fonts_get_system_font(FONT_KEY_GOTHIC_24);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
date_font = fonts_get_system_font(FONT_KEY_GOTHIC_18);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s_options.display_hour_digits) {
|
||||||
|
date_X_hour_digits_offset = DEFAULT_DATE_X_OFFSET_HOUR_DIGITS;
|
||||||
|
}
|
||||||
|
|
||||||
|
//date layers
|
||||||
|
date_layer1 = text_layer_create(GRect(55 - date_X_hour_digits_offset - date_X_readability_offset, (height / 2) - 20 - date_Y_readability_offset, width, 28));
|
||||||
|
text_layer_set_text_alignment(date_layer1, GTextAlignmentCenter);
|
||||||
|
init_static_row(date_layer1, date_font);
|
||||||
|
layer_add_child(window_layer, text_layer_get_layer(date_layer1));
|
||||||
|
|
||||||
|
date_layer2 = text_layer_create(GRect(55 - date_X_hour_digits_offset - date_X_readability_offset, (height / 2) - 5 - date_Y_readability_offset, width, 28));
|
||||||
|
text_layer_set_text_alignment(date_layer2, GTextAlignmentCenter);
|
||||||
|
init_static_row(date_layer2, date_font);
|
||||||
|
layer_add_child(window_layer, text_layer_get_layer(date_layer2));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//checks/updates date display line
|
||||||
|
void update_date_layer() {
|
||||||
|
static char date1_buffer[16], date2_buffer[16];
|
||||||
|
const char *current_date1_layer, *current_date2_layer;
|
||||||
|
|
||||||
|
//if displaying date
|
||||||
|
if (s_options.display_date) {
|
||||||
|
|
||||||
|
//get current from date layers
|
||||||
|
current_date1_layer = text_layer_get_text(date_layer1);
|
||||||
|
current_date2_layer = text_layer_get_text(date_layer2);
|
||||||
|
|
||||||
|
//get current date
|
||||||
|
time_t temp = time(NULL);
|
||||||
|
struct tm *tick_time = localtime(&temp);
|
||||||
|
if (s_options.display_date) {
|
||||||
|
strftime(date1_buffer, sizeof(date1_buffer), "%a %d", tick_time); //Week Day Day#
|
||||||
|
strftime(date2_buffer, sizeof(date2_buffer), "%b", tick_time); //month
|
||||||
|
#if DEBUG
|
||||||
|
strftime(date1_buffer, sizeof(date1_buffer), DEBUG_DAY_DATE, tick_time); //for screen shots
|
||||||
|
strftime(date2_buffer, sizeof(date2_buffer), DEBUG_MONTH, tick_time);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (current_date1_layer != date1_buffer ||
|
||||||
|
current_date2_layer != date2_buffer) {
|
||||||
|
text_layer_set_text(date_layer1, date1_buffer);
|
||||||
|
text_layer_set_text(date_layer2, date2_buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
text_layer_set_text(date_layer1, "");
|
||||||
|
text_layer_set_text(date_layer2, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
APP_LOG(APP_LOG_LEVEL_DEBUG, "update_date_layer: text_layer_set_text date_layer1: %s", date1_buffer);
|
||||||
|
APP_LOG(APP_LOG_LEVEL_DEBUG, "update_date_layer: text_layer_set_text date_layer2: %s", date2_buffer);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
4
src/c/date.h
Normal file
4
src/c/date.h
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
void add_date_layers(Layer *window_layer, int16_t width, int16_t height); //adds/configures weather/date display lines
|
||||||
|
void update_date_layer(); //checks/updates date display line
|
||||||
70
src/c/digital_time.c
Normal file
70
src/c/digital_time.c
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
#include <pebble.h>
|
||||||
|
#include "digital_time.h"
|
||||||
|
#include "constants.h"
|
||||||
|
#include "analog_wd.h"
|
||||||
|
|
||||||
|
#define SCREEN_SHOT_HR 18
|
||||||
|
#define SCREEN_SHOT_MIN 22
|
||||||
|
|
||||||
|
extern Options s_options;
|
||||||
|
|
||||||
|
//adds/configures display digital time line
|
||||||
|
void add_digital_time_layer(Layer *window_layer, int16_t width, int16_t height) {
|
||||||
|
|
||||||
|
GFont digital_time_font;
|
||||||
|
int digital_time_Y_readability_offset = 0;
|
||||||
|
int digital_time_X_hour_digits_offset = 0;
|
||||||
|
|
||||||
|
if (s_options.readability) {
|
||||||
|
digital_time_Y_readability_offset = DEFAULT_DIGITAL_TIME_Y_OFFSET_READABILITY;
|
||||||
|
digital_time_font = fonts_get_system_font(FONT_KEY_GOTHIC_24);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
digital_time_font = fonts_get_system_font(FONT_KEY_GOTHIC_18);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s_options.display_hour_digits) {
|
||||||
|
digital_time_X_hour_digits_offset = DEFAULT_DIGITAL_TIME_Y_OFFSET_HOUR_DIGITS;
|
||||||
|
}
|
||||||
|
|
||||||
|
digital_time_layer = text_layer_create(GRect(0, 142 - digital_time_Y_readability_offset - digital_time_X_hour_digits_offset, width, 28));
|
||||||
|
text_layer_set_text_alignment(digital_time_layer, GTextAlignmentCenter);
|
||||||
|
init_static_row(digital_time_layer, digital_time_font);
|
||||||
|
layer_add_child(window_layer, text_layer_get_layer(digital_time_layer));
|
||||||
|
}
|
||||||
|
|
||||||
|
//checks/updates date display line
|
||||||
|
void update_digital_time_layer() {
|
||||||
|
static char digital_time_buffer[16];
|
||||||
|
const char *current_digital_time_layer;
|
||||||
|
|
||||||
|
//if displaying digital time
|
||||||
|
if (s_options.display_digital_time) {
|
||||||
|
|
||||||
|
//get current date_layer text
|
||||||
|
current_digital_time_layer = text_layer_get_text(digital_time_layer);
|
||||||
|
|
||||||
|
//get digital time
|
||||||
|
time_t temp = time(NULL);
|
||||||
|
struct tm *tick_time = localtime(&temp);
|
||||||
|
#if DEBUG
|
||||||
|
tick_time->tm_hour = SCREEN_SHOT_HR; //for screen shots
|
||||||
|
tick_time->tm_min = SCREEN_SHOT_MIN;
|
||||||
|
#endif
|
||||||
|
if (clock_is_24h_style()) {
|
||||||
|
strftime(digital_time_buffer, sizeof(digital_time_buffer), "%H:%M", tick_time);
|
||||||
|
} else {
|
||||||
|
strftime(digital_time_buffer, sizeof(digital_time_buffer), "%l:%M %P", tick_time);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (current_digital_time_layer != digital_time_buffer) {
|
||||||
|
text_layer_set_text(digital_time_layer, digital_time_buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
text_layer_set_text(digital_time_layer, "");
|
||||||
|
}
|
||||||
|
#if DEBUG
|
||||||
|
APP_LOG(APP_LOG_LEVEL_DEBUG, "update_digital_time_layer: text_layer_set_text digital_time_layer: %s", digital_time_buffer);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
4
src/c/digital_time.h
Normal file
4
src/c/digital_time.h
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
void update_digital_time_layer();
|
||||||
|
void add_digital_time_layer(Layer *window_layer, int16_t width, int16_t height);
|
||||||
Reference in New Issue
Block a user