1212#define KEY_SUNSET MESSAGE_KEY_SUNSET
1313#define KEY_WIND_MAX MESSAGE_KEY_WIND_MAX
1414#define KEY_AQI MESSAGE_KEY_AQI
15+ #define KEY_PRECIPITATION_PROBABILITY MESSAGE_KEY_PRECIPITATION_PROBABILITY
1516#define KEY_TIDE_NEXT_TIME MESSAGE_KEY_TIDE_NEXT_TIME
1617#define KEY_TIDE_NEXT_TYPE MESSAGE_KEY_TIDE_NEXT_TYPE
1718#define KEY_TIDE_NEXT_HEIGHT MESSAGE_KEY_TIDE_NEXT_HEIGHT
6869#define PERSIST_KEY_POLLEN_TREE 18
6970#define PERSIST_KEY_POLLEN_GRASS 19
7071#define PERSIST_KEY_POLLEN_WEED 20
72+ #define PERSIST_KEY_PRECIPITATION_PROBABILITY 25
7173
7274// Configuration persistence
7375#define PERSIST_KEY_CONFIG_TEMP_UNIT 50
@@ -112,9 +114,12 @@ static GBitmap *s_temp_arrow_high_bitmap;
112114// MUNI bus tracking (top-left grid cell)
113115static TextLayer * s_muni_layer ;
114116
115- // Pollen display (bottom-left of time box )
117+ // Pollen display (top right of header )
116118static TextLayer * s_pollen_layer ;
117119
120+ // Precipitation probability (top left of header)
121+ static TextLayer * s_precip_layer ;
122+
118123// Footer
119124static TextLayer * s_tide_layer ;
120125static TextLayer * s_sunrise_layer ;
@@ -136,6 +141,7 @@ typedef struct {
136141 int temp_max ;
137142 int temp_min ;
138143 int aqi ;
144+ int precipitation_probability ; // 0-100%
139145 int tide_time ;
140146 int tide_type ; // 0 = low, 1 = high
141147 int sunrise ;
@@ -367,7 +373,16 @@ static void update_weather_display() {
367373 // MUNI bus countdown updated separately (recalculated every minute)
368374 update_muni_display ();
369375
370- // Pollen display (bottom-left of time box) - show worst type + level
376+ // Precipitation probability display (top left corner) - show as 2-digit percentage
377+ static char precip_buffer [8 ];
378+ if (s_weather_data .precipitation_probability >= 0 ) {
379+ snprintf (precip_buffer , sizeof (precip_buffer ), "%02d" , s_weather_data .precipitation_probability );
380+ text_layer_set_text (s_precip_layer , precip_buffer );
381+ } else {
382+ text_layer_set_text (s_precip_layer , "" );
383+ }
384+
385+ // Pollen display (top right corner) - show worst type + level
371386 static char pollen_buffer [8 ];
372387 if (s_weather_data .pollen_tree >= 0 || s_weather_data .pollen_grass >= 0 || s_weather_data .pollen_weed >= 0 ) {
373388 // Find highest pollen count
@@ -543,6 +558,8 @@ static void load_persisted_data() {
543558 persist_read_int (PERSIST_KEY_POLLEN_GRASS ) : -1 ;
544559 s_weather_data .pollen_weed = persist_exists (PERSIST_KEY_POLLEN_WEED ) ?
545560 persist_read_int (PERSIST_KEY_POLLEN_WEED ) : -1 ;
561+ s_weather_data .precipitation_probability = persist_exists (PERSIST_KEY_PRECIPITATION_PROBABILITY ) ?
562+ persist_read_int (PERSIST_KEY_PRECIPITATION_PROBABILITY ) : 0 ;
546563 } else {
547564 // Default values
548565 s_weather_data .temperature = 0 ;
@@ -599,6 +616,7 @@ static void save_weather_data() {
599616 persist_write_int (PERSIST_KEY_POLLEN_TREE , s_weather_data .pollen_tree );
600617 persist_write_int (PERSIST_KEY_POLLEN_GRASS , s_weather_data .pollen_grass );
601618 persist_write_int (PERSIST_KEY_POLLEN_WEED , s_weather_data .pollen_weed );
619+ persist_write_int (PERSIST_KEY_PRECIPITATION_PROBABILITY , s_weather_data .precipitation_probability );
602620}
603621
604622// Load configuration
@@ -639,6 +657,7 @@ static void inbox_received_callback(DictionaryIterator *iterator, void *context)
639657 Tuple * weather_code_tuple = dict_find (iterator , KEY_WEATHER_CODE );
640658 Tuple * weather_code_tomorrow_tuple = dict_find (iterator , KEY_WEATHER_CODE_TOMORROW );
641659 Tuple * aqi_tuple = dict_find (iterator , KEY_AQI );
660+ Tuple * precip_prob_tuple = dict_find (iterator , KEY_PRECIPITATION_PROBABILITY );
642661 Tuple * temp_max_tuple = dict_find (iterator , KEY_TEMP_MAX );
643662 Tuple * temp_min_tuple = dict_find (iterator , KEY_TEMP_MIN );
644663 Tuple * tide_time_tuple = dict_find (iterator , KEY_TIDE_NEXT_TIME );
@@ -674,6 +693,7 @@ static void inbox_received_callback(DictionaryIterator *iterator, void *context)
674693 if (weather_code_tuple ) s_weather_data .weather_code = (int )weather_code_tuple -> value -> int32 ;
675694 if (weather_code_tomorrow_tuple ) s_weather_data .weather_code_tomorrow = (int )weather_code_tomorrow_tuple -> value -> int32 ;
676695 if (aqi_tuple ) s_weather_data .aqi = (int )aqi_tuple -> value -> int32 ;
696+ if (precip_prob_tuple ) s_weather_data .precipitation_probability = (int )precip_prob_tuple -> value -> int32 ;
677697 if (temp_max_tuple ) s_weather_data .temp_max = (int )temp_max_tuple -> value -> int32 ;
678698 if (temp_min_tuple ) s_weather_data .temp_min = (int )temp_min_tuple -> value -> int32 ;
679699 if (tide_time_tuple ) s_weather_data .tide_time = (int )tide_time_tuple -> value -> int32 ;
@@ -822,7 +842,8 @@ static void apply_color_theme() {
822842 text_layer_set_text_color (s_uv_layer , get_foreground_color ());
823843 text_layer_set_text_color (s_aqi_layer , get_foreground_color ());
824844 text_layer_set_text_color (s_tide_layer , get_foreground_color ());
825- text_layer_set_text_color (s_pollen_layer , get_foreground_color ());
845+ text_layer_set_text_color (s_pollen_layer , get_background_color ()); // Inverted for header
846+ text_layer_set_text_color (s_precip_layer , get_background_color ()); // Inverted for header
826847 text_layer_set_text_color (s_sunrise_layer , get_foreground_color ());
827848 text_layer_set_text_color (s_sunset_layer , get_foreground_color ());
828849
@@ -899,6 +920,17 @@ static void main_window_load(Window *window) {
899920 );
900921 layer_add_child (window_layer , text_layer_get_layer (s_location_layer ));
901922
923+ // Precipitation probability (top left corner of header) - inverted colors for black header
924+ s_precip_layer = create_text_layer_colored (
925+ GRect (4 , 3 , 30 , 14 ),
926+ GTextAlignmentLeft ,
927+ fonts_get_system_font (FONT_KEY_GOTHIC_14_BOLD ),
928+ get_background_color (), // Inverted: white text on black header, or black on white header
929+ GColorClear
930+ );
931+ layer_add_child (window_layer , text_layer_get_layer (s_precip_layer ));
932+ text_layer_set_text (s_precip_layer , "" ); // Empty by default
933+
902934 // === TIME SECTION (26-80) ===
903935 // Date (centered) - smaller, above time (add this FIRST so icons appear on top)
904936 s_date_layer = create_text_layer (
@@ -928,11 +960,13 @@ static void main_window_load(Window *window) {
928960 );
929961 layer_add_child (window_layer , text_layer_get_layer (s_time_layer ));
930962
931- // Pollen display (bottom-left of time box)
932- s_pollen_layer = create_text_layer (
933- GRect (11 , 64 , 30 , 14 ),
934- GTextAlignmentLeft ,
935- fonts_get_system_font (FONT_KEY_GOTHIC_14 )
963+ // Pollen display (top right corner, next to city name) - inverted colors for black header
964+ s_pollen_layer = create_text_layer_colored (
965+ GRect (110 , 3 , 30 , 14 ),
966+ GTextAlignmentRight ,
967+ fonts_get_system_font (FONT_KEY_GOTHIC_14_BOLD ),
968+ get_background_color (), // Inverted: white text on black header, or black on white header
969+ GColorClear
936970 );
937971 layer_add_child (window_layer , text_layer_get_layer (s_pollen_layer ));
938972 text_layer_set_text (s_pollen_layer , "" ); // Empty by default
@@ -1127,6 +1161,7 @@ static void main_window_unload(Window *window) {
11271161 text_layer_destroy (s_aqi_layer );
11281162 text_layer_destroy (s_tide_layer );
11291163 text_layer_destroy (s_pollen_layer );
1164+ text_layer_destroy (s_precip_layer );
11301165 text_layer_destroy (s_sunrise_layer );
11311166 text_layer_destroy (s_sunset_layer );
11321167}
0 commit comments