Upload files to "src/c"

This commit is contained in:
2024-10-06 20:41:32 +00:00
parent f0d2ed4702
commit a16d7921e5
5 changed files with 1262 additions and 0 deletions

24
src/c/constants.c Normal file
View File

@@ -0,0 +1,24 @@
#include <pebble.h>
#include "constants.h"
const int DEFAULT_WEATHER_USE_GPS = 1; //true
const int DEFAULT_SHAKE_FOR_LOHI = 1; //True - shake to show Lo Hi Temps
const int DEFAULT_DISPLAY_LOHI_TIMER = 5000; //length time (milliseconds) to display Lo Hi Temps
const int DEFAULT_MIN_SINCE_WEATHER_UPDATE = 0; //weather just updated
const char DEFAULT_LAST_WEATHER_UPDATE[16] = "--:--"; //default last update "time" display
const char DEFAULT_ERROR_WEATHER_UPDATE[16] = "---"; //default text display upon weather update error
const int DEFAULT_CONDITION_CODE = -99; //Invalid condition code to force weather update
const int DEFAULT_DISPLAY_WEATHER = 1; //true
const int DEFAULT_WEATHER_FREQUENCY = 30; //minutes
const int DEFAULT_USE_CELSIUS = 0; //false
const int DEFAULT_BLINK_COLON = 0; //false
const int DEFAULT_INVERT = 0; //false
const int DEFAULT_VIBBRATE_BT_STATUS = 1; //true
const int DEFAULT_DISPLAY_SECONDS = 0; //false
const int DEFAULT_HIDE_BATTERY = 0; //false
const int DEFAULT_WEATHER_READABILITY = 1; //use original size
const int DEFAULT_WEATHER_Y_OFFSET_READABILITY = 4; //Y-axis adjustment for increased readability font options
const int DEFAULT_BACKGROUND_COLOR = 0x000000; //black
const int DEFAULT_WD_COLOR = 0xFFFFFF; //white
const int DEFAULT_MAX_WEATHER_RETRY_COUNT = 5; //max (seconds) weather retry counts

53
src/c/constants.h Normal file
View File

@@ -0,0 +1,53 @@
#pragma once
#define DEBUG 0
#define KEY_BLINK_COLON 1
#define KEY_VIBBRATE_BT_STATUS 2
#define KEY_HOURLY_VIBRATE 3
#define KEY_HIDE_BATTERY 4
#define KEY_DISPLAY_SECONDS 5
#define KEY_TEMPERATURE_IN_C 6
#define KEY_CONDITIONS 7
#define KEY_BACKGROUND_COLOR 8
#define KEY_TIME_COLOR 9
#define KEY_WEATHER_FREQUENCY 10
#define KEY_USE_CELSIUS 11
#define KEY_DISPLAY_WEATHER 12
#define KEY_GET_WEATHER 13
#define KEY_TEMPERATURE 14
#define KEY_WEATHER_READABILITY 15
#define KEY_TEMPERATURE_LO 16
#define KEY_TEMPERATURE_HI 17
#define KEY_TEMPERATURE_IN_C_LO 18
#define KEY_TEMPERATURE_IN_C_HI 19
#define KEY_CONDITION_CODE 20
#define KEY_SHAKE_FOR_LOHI 21
#define KEY_WEATHER_USE_GPS 22
#define KEY_WEATHER_LOCATION 23
#define KEY_JS_READY 24
#define KEY_WD_COLOR 25
#define KEY_MIN_SINCE_WEATHER_UPDATE 26
#define KEY_INVERT 27
#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_BLINK_COLON;
extern const int DEFAULT_INVERT;
extern const int DEFAULT_DISPLAY_SECONDS;
extern const int DEFAULT_BACKGROUND_COLOR;
extern const int DEFAULT_WEATHER_READABILITY;
extern const int DEFAULT_WEATHER_Y_OFFSET_READABILITY;
extern const int DEFAULT_VIBRATE_BT_STATUS;
extern const int DEFAULT_WD_COLOR;
extern const int DEFAULT_MAX_WEATHER_RETRY_COUNT;

1080
src/c/ninety_one_dub.c Normal file

File diff suppressed because it is too large Load Diff

42
src/c/ninety_one_dub.h Normal file
View File

@@ -0,0 +1,42 @@
#include <pebble.h>
TextLayer *weather_layer1;
AppTimer *lohi_display_timer;
void init_static_row(TextLayer *label, GFont font); //creates/configures static (weather/date) display lines
GTextAlignment row_alignment(int alignment); //accepts int alignement and sets row GTextAlignment (0 left, 1 center, 2 right)
void set_wd_layers_color(GColor textColor);
typedef struct {
int shake_for_lohi;
int tempF;
int tempFLo;
int tempFHi;
int tempC;
int tempCLo;
int tempCHi;
int weather_alignment;
int display_weather;
int weather_use_GPS;
char weather_location[64];
int use_celsius;
int weather_frequency;
int min_since_last_forecast;
int wd_color;
int background_color;
int weather_readability;
int condition_code;
int pebble_js_ready;
int vibrate_bt_status;
int hourly_vibe;
int display_seconds;
int hide_battery;
int blink_colon;
int invert;
bool bluetooth_state;
char conditions[32];
time_t last_update;
char last_weather_update12hr[16];
char last_weather_update24hr[16];
} Options;

63
src/c/options.c Normal file
View File

@@ -0,0 +1,63 @@
#include <pebble.h>
#include "options.h"
#include "constants.h"
#include "ninety_one_dub.h"
extern Options s_options;
void init_options() {
if (persist_exists(KEY_OPTIONS)) {
persist_read_data(KEY_OPTIONS, &s_options, sizeof(s_options));
}
else {
s_options.weather_use_GPS = DEFAULT_WEATHER_USE_GPS;
s_options.shake_for_lohi = DEFAULT_SHAKE_FOR_LOHI;
s_options.display_weather = DEFAULT_DISPLAY_WEATHER;
s_options.use_celsius = DEFAULT_USE_CELSIUS;
memset(s_options.weather_location, 0,sizeof(s_options.weather_location));
s_options.weather_frequency = DEFAULT_WEATHER_FREQUENCY;
s_options.min_since_last_forecast = DEFAULT_MIN_SINCE_WEATHER_UPDATE;
s_options.background_color = DEFAULT_BACKGROUND_COLOR;
s_options.invert = DEFAULT_INVERT;
s_options.blink_colon = DEFAULT_BLINK_COLON;
s_options.display_seconds = DEFAULT_DISPLAY_SECONDS;
s_options.wd_color = DEFAULT_WD_COLOR;
s_options.weather_readability = DEFAULT_WEATHER_READABILITY;
s_options.condition_code = DEFAULT_CONDITION_CODE;
memset(s_options.conditions, 0,sizeof(s_options.conditions));
snprintf(s_options.last_weather_update12hr, sizeof(s_options.last_weather_update12hr), DEFAULT_LAST_WEATHER_UPDATE);
snprintf(s_options.last_weather_update24hr, sizeof(s_options.last_weather_update24hr), DEFAULT_LAST_WEATHER_UPDATE);
//persist_write_data(KEY_OPTIONS, &s_options, sizeof(s_options));
}
#if DEBUG
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.shake_for_lohi: %d", s_options.shake_for_lohi);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.tempF: %d", s_options.tempF);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.tempFLo: %d", s_options.tempFLo);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.tempFHi: %d", s_options.tempFHi);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.tempC: %d", s_options.tempC);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.tempCLo: %d", s_options.tempCLo);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.tempCHi: %d", s_options.tempCHi);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.weather_alignment: %d", s_options.weather_alignment);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.display_weather: %d", s_options.display_weather);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.use_celsius: %d", s_options.use_celsius);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.weather_use_GPS: %d", s_options.weather_use_GPS);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.weather_location: %s", s_options.weather_location);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.weather_frequency: %d", s_options.weather_frequency);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.min_since_last_forecast: %d", s_options.min_since_last_forecast);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.background_color: %d", s_options.background_color);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.wd_color: %d", s_options.wd_color);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.invert: %d", s_options.invert);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.blink_colon: %d", s_options.blink_colon);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.display_seconds: %d", s_options.display_seconds);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.weather_readability: %d", s_options.weather_readability);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.condition_code: %d", s_options.condition_code);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.bluetooth_state: %d", s_options.bluetooth_state);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.vibrate_bt_status: %d", s_options.vibrate_bt_status);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.conditions: %s", s_options.conditions);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.last_weather_update12hr: %s", s_options.last_weather_update12hr);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: s_options.last_weather_update24hr: %s", s_options.last_weather_update24hr);
APP_LOG(APP_LOG_LEVEL_DEBUG, "init_options: options sizeof(s_options) %zu", sizeof(s_options));
#endif
}