Skip to content

Commit e5b63c2

Browse files
tildenhellcp
andcommitted
fw/apps/system/health: improved appearance for health screen
The rotated 4-point square now renders properly, and the heart icon has a white background. Co-Authored-By: Stasia Michalska <hel@lcp.world> Signed-off-by: Dan Tilden <freakified@gmail.com>
1 parent 09543e1 commit e5b63c2

File tree

6 files changed

+88
-17
lines changed

6 files changed

+88
-17
lines changed
1 Byte
Binary file not shown.

src/fw/apps/system_apps/health/health_hr_summary_card.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
/* SPDX-License-Identifier: Apache-2.0 */
33

44
#include "health_hr_summary_card.h"
5+
#include "health_hr_summary_card_segments.h"
56
#include "health_hr_detail_card.h"
7+
#include "health_progress.h"
68
#include "services/normal/activity/health_util.h"
79

8-
#include "applib/graphics/graphics_circle.h"
910
#include "applib/pbl_std/pbl_std.h"
1011
#include "applib/ui/kino/kino_reel.h"
1112
#include "applib/ui/text_layer.h"
@@ -18,14 +19,14 @@
1819
#include "system/logging.h"
1920
#include "util/size.h"
2021
#include "util/string.h"
21-
#include "util/trig.h"
2222

2323
// Compile-time display offset calculations
2424
#define HEALTH_X_OFFSET ((DISP_COLS - LEGACY_2X_DISP_COLS) / 2)
2525
#define HEALTH_Y_OFFSET ((DISP_ROWS - LEGACY_2X_DISP_ROWS) / 2)
2626

2727
typedef struct HealthHrSummaryCardData {
2828
HealthData *health_data;
29+
HealthProgressBar progress_bar;
2930
GDrawCommandSequence *pulsing_heart;
3031
uint32_t pulsing_heart_frame_index;
3132
AppTimer *pulsing_heart_timer;
@@ -40,13 +41,8 @@ typedef struct HealthHrSummaryCardData {
4041

4142
#define PULSING_HEART_TIMEOUT (30 * MS_PER_SECOND)
4243

43-
#define CIRCLE_COLOR (PBL_IF_COLOR_ELSE(GColorDarkCandyAppleRed, GColorBlack))
44-
// Outer radius, inner radius and center of the ring around the heart icon.
45-
// The center is in layer coordinates (legacy 144x168 base, before display offset).
46-
#define CIRCLE_RADIUS_OUTER 43
47-
#define CIRCLE_RADIUS_INNER 33
48-
#define CIRCLE_CENTER_X (71 + HEALTH_X_OFFSET)
49-
#define CIRCLE_CENTER_Y (58 + HEALTH_Y_OFFSET)
44+
#define PROGRESS_BACKGROUND_COLOR (PBL_IF_COLOR_ELSE(GColorDarkCandyAppleRed, GColorBlack))
45+
#define PROGRESS_OUTLINE_COLOR (PBL_IF_COLOR_ELSE(GColorClear, GColorBlack))
5046

5147
#define TEXT_COLOR (PBL_IF_COLOR_ELSE(GColorBulgarianRose, GColorBlack))
5248
#define CARD_BACKGROUND_COLOR (PBL_IF_COLOR_ELSE(GColorWhite, GColorWhite))
@@ -77,12 +73,11 @@ static void prv_pulsing_heart_timer_cb(void *context) {
7773
layer_mark_dirty(base_layer);
7874
}
7975

80-
static void prv_render_circle(GContext *ctx) {
81-
graphics_context_set_fill_color(ctx, CIRCLE_COLOR);
82-
graphics_fill_radial_internal(ctx,
83-
GPoint(CIRCLE_CENTER_X, CIRCLE_CENTER_Y),
84-
CIRCLE_RADIUS_INNER, CIRCLE_RADIUS_OUTER,
85-
0, TRIG_MAX_ANGLE);
76+
static void prv_render_progress_bar(GContext *ctx, Layer *base_layer) {
77+
HealthHrSummaryCardData *data = layer_get_data(base_layer);
78+
79+
health_progress_bar_fill(ctx, &data->progress_bar, PROGRESS_BACKGROUND_COLOR,
80+
0, HEALTH_PROGRESS_BAR_MAX_VALUE);
8681
}
8782

8883
static void prv_render_icon(GContext *ctx, Layer *base_layer) {
@@ -175,10 +170,10 @@ static void prv_base_layer_update_proc(Layer *base_layer, GContext *ctx) {
175170
data->now_bpm = health_data_hr_get_current_bpm(data->health_data);
176171
data->last_updated = health_data_hr_get_last_updated_timestamp(data->health_data);
177172

178-
prv_render_circle(ctx);
179-
180173
prv_render_icon(ctx, base_layer);
181174

175+
prv_render_progress_bar(ctx, base_layer);
176+
182177
if (!activity_prefs_heart_rate_is_enabled()) {
183178
prv_render_hrm_disabled(ctx, base_layer);
184179
return;
@@ -207,6 +202,10 @@ Layer *health_hr_summary_card_create(HealthData *health_data) {
207202
.health_data = health_data,
208203
.pulsing_heart =
209204
gdraw_command_sequence_create_with_resource(RESOURCE_ID_HEALTH_APP_PULSING_HEART),
205+
.progress_bar = {
206+
.num_segments = ARRAY_LENGTH(s_hr_summary_progress_segments),
207+
.segments = s_hr_summary_progress_segments,
208+
},
210209
.now_bpm = health_data_hr_get_current_bpm(health_data),
211210
.resting_bpm = health_data_hr_get_resting_bpm(health_data),
212211
.last_updated = health_data_hr_get_last_updated_timestamp(health_data),
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/* SPDX-FileCopyrightText: 2024 Google LLC */
2+
/* SPDX-License-Identifier: Apache-2.0 */
3+
4+
#pragma once
5+
6+
#include "board/display.h"
7+
#include "health_progress.h"
8+
9+
//! 4 main segments + 4 real corners
10+
//! Each of the 4 non-corener segments get 25% of the total
11+
#define AMOUNT_PER_SEGMENT (HEALTH_PROGRESS_BAR_MAX_VALUE * 25 / 100)
12+
13+
// The shape is the same, but the offsets are different
14+
// Dynamically center based on display size vs legacy 144x168 base
15+
// Round displays need additional adjustment for the bezel
16+
#define X_SHIFT (((DISP_COLS - LEGACY_2X_DISP_COLS) / 2) + PBL_IF_ROUND_ELSE(18, 0))
17+
#define Y_SHIFT (((DISP_ROWS - LEGACY_2X_DISP_ROWS) / 2) + PBL_IF_ROUND_ELSE(6, 0))
18+
19+
static HealthProgressSegment s_hr_summary_progress_segments[] = {
20+
{
21+
// Bottom corner
22+
.type = HealthProgressSegmentType_Corner,
23+
.points = {{72 + X_SHIFT, 87 + Y_SHIFT}, {65 + X_SHIFT, 94 + Y_SHIFT},
24+
{72 + X_SHIFT, 101 + Y_SHIFT}, {79 + X_SHIFT, 94 + Y_SHIFT}},
25+
},
26+
{
27+
// Left side bottom
28+
.amount_of_total = AMOUNT_PER_SEGMENT,
29+
.type = HealthProgressSegmentType_Vertical,
30+
.points = {{66 + X_SHIFT, 95 + Y_SHIFT}, {73 + X_SHIFT, 88 + Y_SHIFT},
31+
{42 + X_SHIFT, 57 + Y_SHIFT}, {35 + X_SHIFT, 64 + Y_SHIFT}},
32+
},
33+
{
34+
// Left corner
35+
.type = HealthProgressSegmentType_Corner,
36+
.points = {{43 + X_SHIFT, 58 + Y_SHIFT}, {36 + X_SHIFT, 51 + Y_SHIFT},
37+
{29 + X_SHIFT, 58 + Y_SHIFT}, {36 + X_SHIFT, 65 + Y_SHIFT}},
38+
},
39+
{
40+
// Left side top
41+
.amount_of_total = AMOUNT_PER_SEGMENT,
42+
.type = HealthProgressSegmentType_Vertical,
43+
.points = {{35 + X_SHIFT, 52 + Y_SHIFT}, {42 + X_SHIFT, 59 + Y_SHIFT},
44+
{73 + X_SHIFT, 28 + Y_SHIFT}, {66 + X_SHIFT, 21 + Y_SHIFT}},
45+
},
46+
{
47+
// Top corner
48+
.type = HealthProgressSegmentType_Corner,
49+
.points = {{72 + X_SHIFT, 29 + Y_SHIFT}, {79 + X_SHIFT, 22 + Y_SHIFT},
50+
{72 + X_SHIFT, 15 + Y_SHIFT}, {65 + X_SHIFT, 22 + Y_SHIFT}},
51+
},
52+
{
53+
// Right side top
54+
.amount_of_total = AMOUNT_PER_SEGMENT,
55+
.type = HealthProgressSegmentType_Vertical,
56+
.points = {{78 + X_SHIFT, 21 + Y_SHIFT}, {71 + X_SHIFT, 28 + Y_SHIFT},
57+
{102 + X_SHIFT, 59 + Y_SHIFT}, {109 + X_SHIFT, 52 + Y_SHIFT}},
58+
},
59+
{
60+
// Right corner
61+
.type = HealthProgressSegmentType_Corner,
62+
.points = {{101 + X_SHIFT, 58 + Y_SHIFT}, {108 + X_SHIFT, 65 + Y_SHIFT},
63+
{115 + X_SHIFT, 58 + Y_SHIFT}, {108 + X_SHIFT, 51 + Y_SHIFT}},
64+
},
65+
{
66+
// Right side bottom
67+
.amount_of_total = AMOUNT_PER_SEGMENT,
68+
.type = HealthProgressSegmentType_Vertical,
69+
.points = {{102 + X_SHIFT, 57 + Y_SHIFT}, {109 + X_SHIFT, 64 + Y_SHIFT},
70+
{78 + X_SHIFT, 95 + Y_SHIFT}, {71 + X_SHIFT, 88 + Y_SHIFT}},
71+
},
72+
};
-55 Bytes
Loading
-62 Bytes
Loading
-46 Bytes
Loading

0 commit comments

Comments
 (0)