33#if defined(PLUGIN_WEATHER) && PLUGIN_WEATHER && defined(HAS_MESSAGE_KEY_WEATHER_PROVIDER)
34#define PLUGIN_SOURCE_KEEPS_WEATHER 1
36#define PLUGIN_SOURCE_KEEPS_WEATHER 0
40#if defined(PLUGIN_CALENDAR) && PLUGIN_CALENDAR && defined(HAS_MESSAGE_KEY_CALENDAR_SOURCE)
41#define PLUGIN_SOURCE_KEEPS_CALENDAR 1
43#define PLUGIN_SOURCE_KEEPS_CALENDAR 0
47#if defined(PLUGIN_STOCKS) && PLUGIN_STOCKS && defined(HAS_MESSAGE_KEY_STOCK_PROVIDER)
48#define PLUGIN_SOURCE_KEEPS_STOCK 1
50#define PLUGIN_SOURCE_KEEPS_STOCK 0
54#define PLUGIN_SOURCE_KEEPS_ANY (PLUGIN_SOURCE_KEEPS_WEATHER || PLUGIN_SOURCE_KEEPS_CALENDAR || PLUGIN_SOURCE_KEEPS_STOCK)
60#define PLUGIN_SOURCE_WEATHER_LEN 12
66#define PLUGIN_SOURCE_CALENDAR_LEN 8
72#define PLUGIN_SOURCE_STOCK_LEN 14
74#define PLUGIN_SOURCE_VERSION 2
75#define PLUGIN_SOURCE_FIRST_SIZE 21
95_Static_assert(offsetof(
PluginSourceSettings, weather) == 1,
"the weather source moved, so older saves would read wrong");
96_Static_assert(offsetof(
PluginSourceSettings, calendar) == 13,
"the calendar source moved, so older saves would read wrong");
99#if PLUGIN_SOURCE_KEEPS_WEATHER
100#ifndef PLUGIN_SOURCE_WEATHER_DEFAULT
101#error "PLUGIN_WEATHER keeps the weather source on the watch, so it needs PLUGIN_SOURCE_WEATHER_DEFAULT. Build the face with paf build, which writes it from the providers list"
104_Static_assert(
sizeof(
"" PLUGIN_SOURCE_WEATHER_DEFAULT) > 1 &&
sizeof(
"" PLUGIN_SOURCE_WEATHER_DEFAULT) <=
PLUGIN_SOURCE_WEATHER_LEN,
105 "the default weather source has to be 1 to 11 characters, which is as much as the watch keeps");
108#if PLUGIN_SOURCE_KEEPS_CALENDAR
109#ifndef PLUGIN_SOURCE_CALENDAR_DEFAULT
110#error "PLUGIN_CALENDAR keeps the calendar source on the watch, so it needs PLUGIN_SOURCE_CALENDAR_DEFAULT. Build the face with paf build, which writes it from the providers list"
112_Static_assert(
sizeof(
"" PLUGIN_SOURCE_CALENDAR_DEFAULT) > 1 &&
sizeof(
"" PLUGIN_SOURCE_CALENDAR_DEFAULT) <=
PLUGIN_SOURCE_CALENDAR_LEN,
113 "the default calendar source has to be 1 to 7 characters, which is as much as the watch keeps");
116#if PLUGIN_SOURCE_KEEPS_STOCK
117#ifndef PLUGIN_SOURCE_STOCK_DEFAULT
118#error "PLUGIN_STOCKS keeps the stock source on the watch, so it needs PLUGIN_SOURCE_STOCK_DEFAULT. Build the face with paf build, which writes it from the providers list"
120_Static_assert(
sizeof(
"" PLUGIN_SOURCE_STOCK_DEFAULT) > 1 &&
sizeof(
"" PLUGIN_SOURCE_STOCK_DEFAULT) <=
PLUGIN_SOURCE_STOCK_LEN,
121 "the default stock source has to be 1 to 13 characters, which is as much as the watch keeps");
132#if PLUGIN_SOURCE_KEEPS_WEATHER
133#define PLUGIN_SOURCE_WEATHER_FIELD \
134 { .id = SETTING_COUNT, .message_key = &MESSAGE_KEY_WEATHER_PROVIDER, .type = SETTING_CSTRING, \
135 .offset = offsetof(PluginSourceSettings, weather), .size = PLUGIN_SOURCE_WEATHER_LEN, \
136 .default_str = PLUGIN_SOURCE_WEATHER_DEFAULT },
138#define PLUGIN_SOURCE_WEATHER_FIELD
145#if PLUGIN_SOURCE_KEEPS_CALENDAR
146#define PLUGIN_SOURCE_CALENDAR_FIELD \
147 { .id = SETTING_COUNT, .message_key = &MESSAGE_KEY_CALENDAR_SOURCE, .type = SETTING_CSTRING, \
148 .offset = offsetof(PluginSourceSettings, calendar), .size = PLUGIN_SOURCE_CALENDAR_LEN, \
149 .default_str = PLUGIN_SOURCE_CALENDAR_DEFAULT },
151#define PLUGIN_SOURCE_CALENDAR_FIELD
158#if PLUGIN_SOURCE_KEEPS_STOCK
159#define PLUGIN_SOURCE_STOCK_FIELD { .id = SETTING_COUNT, .message_key = &MESSAGE_KEY_STOCK_PROVIDER, .type = SETTING_CSTRING, .offset = offsetof(PluginSourceSettings, stock), .size = PLUGIN_SOURCE_STOCK_LEN, .default_str = PLUGIN_SOURCE_STOCK_DEFAULT },
161#define PLUGIN_SOURCE_STOCK_FIELD
165#define PLUGIN_SOURCE_FIELDS PLUGIN_SOURCE_WEATHER_FIELD PLUGIN_SOURCE_CALENDAR_FIELD PLUGIN_SOURCE_STOCK_FIELD
184 return !on_flash_known || memcmp(now, on_flash,
sizeof(*now)) != 0;
static bool plugin_source_write_needed(const PluginSourceSettings *now, const PluginSourceSettings *on_flash, bool on_flash_known)
Whether a save has to write the choices to flash.
Definition plugin_source.h:181
#define PLUGIN_SOURCE_WEATHER_LEN
The size of the weather source buffer. weatherapi is the longest value the settings page saves,...
Definition plugin_source.h:60
#define PLUGIN_SOURCE_CALENDAR_LEN
The size of the calendar source buffer. plugin is the longest value the settings page saves,...
Definition plugin_source.h:66
#define PLUGIN_SOURCE_STOCK_LEN
The size of the stock source buffer. alphavantage is the longest value the settings page saves,...
Definition plugin_source.h:72
#define PLUGIN_SOURCE_FIRST_SIZE
The struct's size in its first release, which never changes.
Definition plugin_source.h:75
The persist API. A per-face SettingField table drives versioned load and save, sanitizing,...
The saved choices, version byte first.
Definition plugin_source.h:86
char stock[PLUGIN_SOURCE_STOCK_LEN]
What the stocks' Data Source select saved.
Definition plugin_source.h:90
char weather[PLUGIN_SOURCE_WEATHER_LEN]
What the weather's Data Source select saved.
Definition plugin_source.h:88
uint8_t version
The schema version this blob was saved at.
Definition plugin_source.h:87
char calendar[PLUGIN_SOURCE_CALENDAR_LEN]
What the Calendar Source select saved.
Definition plugin_source.h:89