Skip to content

Commit db83f54

Browse files
committed
feat: add precipitation bars setting
1 parent 13caeb0 commit db83f54

8 files changed

Lines changed: 23 additions & 6 deletions

File tree

package.template.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@
8989
"CLAY_COLOR_SUNDAY",
9090
"CLAY_COLOR_US_FEDERAL",
9191
"CLAY_COLOR_TIME",
92-
"CLAY_DAY_NIGHT_SHADING"
92+
"CLAY_DAY_NIGHT_SHADING",
93+
"CLAY_PRECIP_AMOUNT_BARS"
9394
]
9495
}
9596
}

src/c/appendix/app_message.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ static void inbox_received_callback(DictionaryIterator *iterator, void *context)
3939
Tuple *clay_color_us_federal_tuple = dict_find(iterator, MESSAGE_KEY_CLAY_COLOR_US_FEDERAL);
4040
Tuple *clay_color_time_tuple = dict_find(iterator, MESSAGE_KEY_CLAY_COLOR_TIME);
4141
Tuple *clay_day_night_shading_tuple = dict_find(iterator, MESSAGE_KEY_CLAY_DAY_NIGHT_SHADING);
42+
Tuple *clay_precip_amount_bars_tuple = dict_find(iterator, MESSAGE_KEY_CLAY_PRECIP_AMOUNT_BARS);
4243

4344
if(temp_trend_tuple && precip_trend_tuple && precip_amount_trend_tuple && forecast_start_tuple && num_entries_tuple && city_tuple && sun_events_tuple) {
4445
// Weather data received
@@ -76,7 +77,7 @@ static void inbox_received_callback(DictionaryIterator *iterator, void *context)
7677
else if (clay_celsius_tuple && clay_time_lead_zero_tuple && clay_axis_12h_tuple && clay_start_mon_tuple && clay_prev_week_tuple
7778
&& clay_color_today_tuple && clay_time_font_tuple && clay_vibe_tuple && clay_show_qt_tuple && clay_show_bt_tuple
7879
&& clay_show_bt_disconnect_tuple && clay_show_am_pm_tuple && clay_color_saturday_tuple && clay_color_sunday_tuple
79-
&& clay_color_us_federal_tuple && clay_color_time_tuple && clay_day_night_shading_tuple) {
80+
&& clay_color_us_federal_tuple && clay_color_time_tuple && clay_day_night_shading_tuple && clay_precip_amount_bars_tuple) {
8081
// Clay config data received
8182
bool clay_celsius = (bool) (clay_celsius_tuple->value->int16);
8283
bool time_lead_zero = (bool) (clay_time_lead_zero_tuple->value->int16);
@@ -89,6 +90,7 @@ static void inbox_received_callback(DictionaryIterator *iterator, void *context)
8990
bool show_bt_disconnect = (bool) (clay_show_bt_disconnect_tuple->value->int16);
9091
bool show_am_pm = (bool) (clay_show_am_pm_tuple->value->int16);
9192
bool day_night_shading = (bool) (clay_day_night_shading_tuple->value->int16);
93+
bool precip_amount_bars = (bool) (clay_precip_amount_bars_tuple->value->int16);
9294
int16_t time_font = clay_time_font_tuple->value->int16;
9395
GColor color_today = GColorFromHEX(clay_color_today_tuple->value->int32);
9496
GColor color_saturday = GColorFromHEX(clay_color_saturday_tuple->value->int32);
@@ -112,7 +114,8 @@ static void inbox_received_callback(DictionaryIterator *iterator, void *context)
112114
.color_sunday = color_sunday,
113115
.color_us_federal = color_us_federal,
114116
.color_time = color_time,
115-
.day_night_shading = day_night_shading
117+
.day_night_shading = day_night_shading,
118+
.precip_amount_bars = precip_amount_bars
116119
};
117120
persist_set_config(config);
118121
main_window_refresh();

src/c/appendix/config.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ static Config config_defaults(void) {
2828
.color_sunday = GColorFolly,
2929
.color_us_federal = GColorFolly,
3030
.color_time = GColorWhite,
31-
.day_night_shading = true
31+
.day_night_shading = true,
32+
.precip_amount_bars = true
3233
};
3334
}
3435

src/c/appendix/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ typedef struct {
2626
GColor color_us_federal;
2727
GColor color_time;
2828
bool day_night_shading;
29+
bool precip_amount_bars;
2930
} Config;
3031

3132
extern Config *g_config;

src/c/appendix/persist.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ void persist_init() {
6262
.color_sunday = GColorFolly,
6363
.color_us_federal = GColorFolly,
6464
.color_time = GColorWhite,
65-
.day_night_shading = true
65+
.day_night_shading = true,
66+
.precip_amount_bars = true
6667
};
6768
persist_set_config(config);
6869
}

src/c/layers/forecast_layer.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ typedef struct
5858
typedef struct
5959
{
6060
bool draw_night_overlay;
61+
bool draw_precip_amount_bars;
6162
GColor axis_color;
6263
} RenderSpec;
6364

@@ -84,6 +85,7 @@ static RenderSpec make_render_spec()
8485
{
8586
RenderSpec spec = {
8687
.draw_night_overlay = g_config->day_night_shading,
88+
.draw_precip_amount_bars = g_config->precip_amount_bars,
8789
.axis_color = PBL_IF_COLOR_ELSE(GColorOrange, GColorWhite)};
8890

8991
if (spec.draw_night_overlay)
@@ -628,7 +630,7 @@ static void forecast_update_proc(Layer *layer, GContext *ctx)
628630
MEMORY_HEAP_PROBE_SAMPLE("after_precip_top_draw", &redraw_probe);
629631

630632
// Draw absolute precipitation intensity bars above the probability area and outline.
631-
if (num_entries > 0)
633+
if (render_spec.draw_precip_amount_bars && num_entries > 0)
632634
{
633635
const int amount_plot_h = graph_plot_rect.size.h;
634636
graphics_context_set_fill_color(ctx, PRECIP_AMOUNT_FILL_COLOR);

src/pkjs/clay/config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ module.exports = [
179179
"defaultValue": true,
180180
"description": "Show hatch shading between sunset and sunrise to distinguish day and night on the forecast graph."
181181
},
182+
{
183+
"type": "toggle",
184+
"label": "Precipitation amount bars",
185+
"messageKey": "precipAmountBars",
186+
"defaultValue": true
187+
},
182188
{
183189
"type": "radiogroup",
184190
"label": "Provider",

src/pkjs/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ function sendClaySettings(onSuccess, onFailure) {
495495
"CLAY_COLOR_US_FEDERAL": app.settings.hasOwnProperty('colorUSFederal') ? app.settings.colorUSFederal : DEFAULT_COLOR_FOLLY,
496496
"CLAY_COLOR_TIME": app.settings.hasOwnProperty('colorTime') ? app.settings.colorTime : DEFAULT_COLOR_WHITE,
497497
"CLAY_DAY_NIGHT_SHADING": app.settings.hasOwnProperty('dayNightShading') ? app.settings.dayNightShading : true,
498+
"CLAY_PRECIP_AMOUNT_BARS": app.settings.hasOwnProperty('precipAmountBars') ? app.settings.precipAmountBars : true,
498499
}
499500
Pebble.sendAppMessage(payload, function() {
500501
console.log('Message sent successfully: ' + JSON.stringify(payload));
@@ -585,6 +586,7 @@ function getDefaultClaySettings() {
585586
location: '',
586587
temperatureUnits: 'f',
587588
dayNightShading: true,
589+
precipAmountBars: true,
588590
timeLeadingZero: false,
589591
timeShowAmPm: false,
590592
axisTimeFormat: '24h',

0 commit comments

Comments
 (0)