Skip to content

Commit

Permalink
Change display appearance
Browse files Browse the repository at this point in the history
  • Loading branch information
protocentralashwin committed Nov 14, 2024
1 parent 2e0d250 commit ff56af0
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 74 deletions.
8 changes: 4 additions & 4 deletions app/src/data_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ uint8_t hpi_ov3_ppg_data[HPI_OV3_DATA_PPG_LEN];
extern bool settings_send_ble_enabled;
extern bool settings_send_display_enabled;*/

static bool settings_send_usb_enabled = true;
static bool settings_send_ble_enabled = true;
static bool settings_send_usb_enabled = false;
static bool settings_send_ble_enabled = false;
static bool settings_send_display_enabled = true;
static bool settings_send_rpi_uart_enabled = false;
static bool settings_plot_enabled = true;
Expand Down Expand Up @@ -375,7 +375,7 @@ void record_session_add_ecg_point(int32_t *ecg_samples, uint8_t ecg_len, int32_t
}
}

void buffer_ppg_data_for_serial(int16_t ppg_data_in)
void ppg_buff_for_pkt(int16_t ppg_data_in)
{
if (serial_ppg_counter < HPI_OV3_DATA_IR_LEN)
{
Expand Down Expand Up @@ -516,7 +516,7 @@ void data_thread(void)
if (settings_send_usb_enabled)
{
temp_serial = hpi_hw_read_temp();
buffer_ppg_data_for_serial(ppg_sensor_sample.ppg_red_sample);
ppg_buff_for_pkt(ppg_sensor_sample.ppg_red_sample);
}

// #ifdef CONFIG_BT
Expand Down
130 changes: 73 additions & 57 deletions app/src/display/display_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ lv_style_t style_rr;
lv_style_t style_temp;

lv_style_t style_header_black;
lv_style_t style_header_red;

lv_style_t style_welcome_scr_bg;
lv_style_t style_batt_sym;
Expand All @@ -51,7 +52,7 @@ lv_style_t style_icon;

static lv_obj_t *label_batt_level;
static lv_obj_t *label_batt_level_val;
//static lv_obj_t *label_sym_ble;
// static lv_obj_t *label_sym_ble;

extern struct k_sem sem_hw_inited;
K_SEM_DEFINE(sem_disp_inited, 0, 1);
Expand Down Expand Up @@ -122,6 +123,10 @@ void display_init_styles()
lv_style_set_text_color(&style_header_black, lv_color_black());
lv_style_set_text_font(&style_header_black, &lv_font_montserrat_14);

lv_style_init(&style_header_red);
lv_style_set_text_color(&style_header_red, lv_palette_main(LV_PALETTE_RED));
lv_style_set_text_font(&style_header_red, &lv_font_montserrat_16);

// H2 welcome screen style
lv_style_init(&style_h2);
lv_style_set_text_color(&style_h2, lv_palette_main(LV_PALETTE_ORANGE));
Expand Down Expand Up @@ -238,8 +243,8 @@ void hpi_disp_change_event(enum hpi_scr_event evt)
if ((curr_screen + 1) == SCR_LIST_END)
{
printk("End of list\n");
//return;
hpi_load_screen(SCR_LIST_START+1, SCROLL_LEFT);
// return;
hpi_load_screen(SCR_LIST_START + 1, SCROLL_LEFT);
}
else
{
Expand All @@ -254,8 +259,8 @@ void hpi_disp_change_event(enum hpi_scr_event evt)
if ((curr_screen - 1) == SCR_LIST_START)
{
printk("Start of list\n");
hpi_load_screen(SCR_LIST_END-1, SCROLL_RIGHT);
//return;
hpi_load_screen(SCR_LIST_END - 1, SCROLL_RIGHT);
// return;
}
else
{
Expand All @@ -265,6 +270,61 @@ void hpi_disp_change_event(enum hpi_scr_event evt)
}
}

void draw_header(lv_obj_t *parent, bool showFWVersion)
{
// Draw Header bar

// ProtoCentral logo
/*LV_IMG_DECLARE(logo_oneline);
lv_obj_t *img1 = lv_img_create(parent);
lv_img_set_src(img1, &logo_oneline);
lv_obj_align(img1, LV_ALIGN_TOP_LEFT, 10, 7);
lv_obj_set_size(img1, 104, 10);
*/

lv_obj_t *header_bar = lv_obj_create(parent);
lv_obj_set_size(header_bar, 480, 30);
lv_obj_set_pos(header_bar, 0, 0);
lv_obj_set_style_bg_color(header_bar, lv_color_white(), LV_STATE_DEFAULT);

lv_obj_clear_flag(header_bar, LV_OBJ_FLAG_SCROLLABLE);

if (showFWVersion)
{
// HealthyPi label
lv_obj_t *label_hpi = lv_label_create(parent);
char fw_version[40];
sprintf(fw_version, " HealthyPi 5 (FW v%d.%d.%d)", APP_VERSION_MAJOR, APP_VERSION_MINOR, APP_PATCHLEVEL);
lv_label_set_text(label_hpi, fw_version);
lv_obj_add_style(label_hpi, &style_header_black, LV_STATE_DEFAULT);
// lv_style_set_text_color(label_hpi, lv_color_black());
lv_obj_align(label_hpi, LV_ALIGN_TOP_LEFT, 3, 5);
}
// Label for Symbols

label_batt_level = lv_label_create(parent);
lv_label_set_text(label_batt_level, LV_SYMBOL_BATTERY_FULL);
lv_obj_add_style(label_batt_level, &style_header_black, LV_STATE_DEFAULT);
lv_obj_align(label_batt_level, LV_ALIGN_TOP_RIGHT, -50, 5);

label_batt_level_val = lv_label_create(parent);
lv_label_set_text(label_batt_level_val, "--%");
lv_obj_add_style(label_batt_level, &style_header_black, LV_STATE_DEFAULT);
lv_obj_align_to(label_batt_level_val, label_batt_level, LV_ALIGN_OUT_RIGHT_MID, 7, 0);
lv_obj_add_style(label_batt_level_val, &style_header_black, LV_STATE_DEFAULT);

lv_obj_t *lbl_conn_status = lv_label_create(parent);
lv_label_set_text(lbl_conn_status, LV_SYMBOL_BLUETOOTH " " LV_SYMBOL_USB);
lv_obj_add_style(lbl_conn_status, &style_header_red, LV_STATE_DEFAULT);
lv_obj_align_to(lbl_conn_status, label_batt_level, LV_ALIGN_OUT_LEFT_MID, -15, 0);
//lv_obj_set_text_color(lbl_no_ble, LV_PART_MAIN, LV_STATE_DEFAULT, lv_palette_main(LV_PALETTE_RED));

// label_sym_ble = lv_label_create(parent);
// lv_label_set_text(label_sym_ble, LV_SYMBOL_BLUETOOTH);
// lv_obj_add_style(label_sym_ble, &style_header_black, LV_STATE_DEFAULT);
// lv_obj_align_to(label_sym_ble, label_batt_level_val, LV_ALIGN_OUT_LEFT_MID, -5, 1);
}

void draw_scr_home_footer(lv_obj_t *parent)
{
/*static lv_style_t style;
Expand All @@ -279,7 +339,7 @@ void draw_scr_home_footer(lv_obj_t *parent)
// HR Number label
label_hr = lv_label_create(parent);
lv_label_set_text(label_hr, "---");
lv_obj_align(label_hr, LV_ALIGN_LEFT_MID, 20, 120);
lv_obj_align(label_hr, LV_ALIGN_LEFT_MID, 20, 100);
lv_obj_add_style(label_hr, &style_hr, LV_STATE_DEFAULT);

// HR Title label
Expand Down Expand Up @@ -372,9 +432,9 @@ void draw_scr_home_footer(lv_obj_t *parent)
lv_obj_align_to(label_temp_sub, label_temp, LV_ALIGN_BOTTOM_MID, 0, 10);
lv_obj_add_style(label_temp_sub, &style_sub, LV_STATE_DEFAULT);

// lv_obj_t *label_menu = lv_label_create(parent);
// lv_label_set_text(label_menu, "Press side wheel DOWN for more charts");
// lv_obj_align(label_menu, LV_ALIGN_BOTTOM_MID, 0, -5);
lv_obj_t *label_menu = lv_label_create(parent);
lv_label_set_text(label_menu, "Press side wheel UP/DOWN for other charts");
lv_obj_align(label_menu, LV_ALIGN_BOTTOM_MID, 0, -5);
}

void down_key_event_handler()
Expand Down Expand Up @@ -405,7 +465,7 @@ void hpi_load_screen(enum hpi_disp_screens m_screen, enum scroll_dir m_scroll_di
void disp_screen_event(lv_event_t *e)
{
lv_event_code_t event_code = lv_event_get_code(e);

if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_LEFT)
{
lv_indev_wait_release(lv_indev_get_act());
Expand All @@ -414,8 +474,8 @@ void disp_screen_event(lv_event_t *e)
if ((curr_screen + 1) == SCR_LIST_END)
{
printk("End of list\n");
hpi_load_screen(SCR_LIST_START+1, SCROLL_LEFT);
//return;
hpi_load_screen(SCR_LIST_START + 1, SCROLL_LEFT);
// return;
}
else
{
Expand All @@ -432,7 +492,7 @@ void disp_screen_event(lv_event_t *e)
{
printk("Start of list\n");
hpi_load_screen(SCR_LIST_END, SCROLL_RIGHT);
//return;
// return;
}
else
{
Expand All @@ -454,51 +514,7 @@ void hpi_show_screen(lv_obj_t *parent, enum scroll_dir m_scroll_dir)
// lv_scr_load_anim(parent, LV_SCR_LOAD_ANIM_MOVE_RIGHT, SCREEN_TRANS_TIME, 0, true);
}

void draw_header(lv_obj_t *parent, bool showFWVersion)
{
// Draw Header bar
// ProtoCentral logo
/*LV_IMG_DECLARE(logo_oneline);
lv_obj_t *img1 = lv_img_create(parent);
lv_img_set_src(img1, &logo_oneline);
lv_obj_align(img1, LV_ALIGN_TOP_LEFT, 10, 7);
lv_obj_set_size(img1, 104, 10);
*/

lv_obj_t *header_bar = lv_obj_create(parent);
lv_obj_set_size(header_bar, 480, 25);
lv_obj_set_pos(header_bar, 0, 0);
lv_obj_set_style_bg_color(header_bar, lv_color_white(), LV_STATE_DEFAULT);

if (showFWVersion)
{
// HealthyPi label
lv_obj_t *label_hpi = lv_label_create(parent);
char fw_version[40];
sprintf(fw_version, " HealthyPi 5 (FW v%d.%d.%d)", APP_VERSION_MAJOR, APP_VERSION_MINOR, APP_PATCHLEVEL);
lv_label_set_text(label_hpi, fw_version);
lv_obj_add_style(label_hpi, &style_header_black, LV_STATE_DEFAULT);
// lv_style_set_text_color(label_hpi, lv_color_black());
lv_obj_align(label_hpi, LV_ALIGN_TOP_LEFT, 3, 1);
}
// Label for Symbols

label_batt_level = lv_label_create(parent);
lv_label_set_text(label_batt_level, LV_SYMBOL_BATTERY_FULL);
lv_obj_add_style(label_batt_level, &style_header_black, LV_STATE_DEFAULT);
lv_obj_align(label_batt_level, LV_ALIGN_TOP_RIGHT, -15, 1);

label_batt_level_val = lv_label_create(parent);
lv_label_set_text(label_batt_level_val, "--%");
lv_obj_add_style(label_batt_level, &style_header_black, LV_STATE_DEFAULT);
lv_obj_align_to(label_batt_level_val, label_batt_level, LV_ALIGN_OUT_LEFT_MID, -25, 1);
lv_obj_add_style(label_batt_level_val, &style_header_black, LV_STATE_DEFAULT);

// label_sym_ble = lv_label_create(parent);
// lv_label_set_text(label_sym_ble, LV_SYMBOL_BLUETOOTH);
// lv_obj_add_style(label_sym_ble, &style_header_black, LV_STATE_DEFAULT);
// lv_obj_align_to(label_sym_ble, label_batt_level_val, LV_ALIGN_OUT_LEFT_MID, -5, 1);
}

void hpi_disp_update_batt_level(int batt_level)
{
Expand Down
2 changes: 1 addition & 1 deletion app/src/sampling_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ static void sensor_ecg_bioz_processing_cb(int result, uint8_t *buf,
const struct max30001_encoded_data *edata = (const struct max30001_encoded_data *)buf;
struct hpi_ecg_bioz_sensor_data_t ecg_bioz_sensor_sample;

printk("ECG NS: %d | B: %d ", edata->num_samples_ecg, edata->num_samples_bioz);
//printk("ECG NS: %d | B: %d ", edata->num_samples_ecg, edata->num_samples_bioz);
uint8_t n_samples_ecg = edata->num_samples_ecg;
uint8_t n_samples_bioz = edata->num_samples_bioz;

Expand Down
10 changes: 5 additions & 5 deletions app/src/ui/screens/scr_ecg.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@ void draw_scr_ecg(enum scroll_dir m_scroll_dir)
draw_header(scr_ecg, true);

chart_ecg = lv_chart_create(scr_ecg);
lv_obj_set_pos(chart_ecg, 5, 30);
lv_obj_set_pos(chart_ecg, 5, 35);

lv_obj_set_size(chart_ecg, 475, 200);
lv_obj_set_size(chart_ecg, 475, 185);
lv_obj_set_style_bg_color(chart_ecg, lv_color_black(), LV_STATE_DEFAULT);

lv_obj_set_style_size(chart_ecg, 0, LV_PART_INDICATOR);
lv_chart_set_point_count(chart_ecg, ECG_DISP_WINDOW_SIZE);
lv_chart_set_range(chart_ecg, LV_CHART_AXIS_PRIMARY_Y, -200, 250);
lv_chart_set_div_line_count(chart_ecg, 8, 0);
lv_chart_set_div_line_count(chart_ecg, 0, 0);
lv_chart_set_update_mode(chart_ecg, LV_CHART_UPDATE_MODE_CIRCULAR);

ser_ecg = lv_chart_add_series(chart_ecg, lv_palette_main(LV_PALETTE_RED), LV_CHART_AXIS_PRIMARY_Y);
ser_ecg = lv_chart_add_series(chart_ecg, lv_palette_main(LV_PALETTE_GREEN), LV_CHART_AXIS_PRIMARY_Y);

lv_obj_t *lbl_sig_type = lv_label_create(scr_ecg);
lv_label_set_text(lbl_sig_type, "Showing ECG");
//lv_obj_add_style(lbl_sig_type, &style_header_black, LV_STATE_DEFAULT);
lv_obj_align(lbl_sig_type, LV_ALIGN_TOP_MID, 0, 25);
lv_obj_align(lbl_sig_type, LV_ALIGN_TOP_MID, 0, 35);

curr_screen = SCR_ECG;

Expand Down
6 changes: 3 additions & 3 deletions app/src/ui/screens/scr_ppg.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ void draw_scr_ppg(enum scroll_dir m_scroll_dir)
draw_header(scr_ppg, true);

chart_ppg = lv_chart_create(scr_ppg);
lv_obj_set_pos(chart_ppg, 5, 30);
lv_obj_set_pos(chart_ppg, 5, 35);

lv_obj_set_size(chart_ppg, 475, 200);
lv_obj_set_size(chart_ppg, 475, 185);
lv_obj_set_style_bg_color(chart_ppg, lv_color_black(), LV_STATE_DEFAULT);

lv_obj_set_style_size(chart_ppg, 0, LV_PART_INDICATOR);
Expand All @@ -55,7 +55,7 @@ void draw_scr_ppg(enum scroll_dir m_scroll_dir)
lv_obj_t *lbl_sig_type = lv_label_create(scr_ppg);
lv_label_set_text(lbl_sig_type, "Showing PPG");
// lv_obj_add_style(lbl_sig_type, &style_header_black, LV_STATE_DEFAULT);
lv_obj_align(lbl_sig_type, LV_ALIGN_TOP_MID, 0, 25);
lv_obj_align(lbl_sig_type, LV_ALIGN_TOP_MID, 0, 35);

curr_screen = SCR_PPG;

Expand Down
8 changes: 4 additions & 4 deletions app/src/ui/screens/scr_resp.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,23 @@ void draw_scr_resp(enum scroll_dir m_scroll_dir)
draw_header(scr_resp, true);

chart_resp = lv_chart_create(scr_resp);
lv_obj_set_pos(chart_resp, 10, 25);
lv_obj_set_pos(chart_resp, 10, 35);

lv_obj_set_size(chart_resp, 450, 190);
lv_obj_set_size(chart_resp, 450, 185);
lv_obj_set_style_bg_color(chart_resp, lv_color_black(), LV_STATE_DEFAULT);

lv_obj_set_style_size(chart_resp, 0, LV_PART_INDICATOR);
lv_chart_set_point_count(chart_resp, RESP_DISP_WINDOW_SIZE);
lv_chart_set_range(chart_resp, LV_CHART_AXIS_PRIMARY_Y, 0, 8000);
lv_chart_set_div_line_count(chart_resp, 8, 0);
lv_chart_set_div_line_count(chart_resp, 0, 0);
lv_chart_set_update_mode(chart_resp, LV_CHART_UPDATE_MODE_CIRCULAR);

ser_resp = lv_chart_add_series(chart_resp, lv_palette_main(LV_PALETTE_BLUE), LV_CHART_AXIS_PRIMARY_Y);

lv_obj_t *lbl_sig_type = lv_label_create(scr_resp);
lv_label_set_text(lbl_sig_type, "Showing Resp.");
// lv_obj_add_style(lbl_sig_type, &style_header_black, LV_STATE_DEFAULT);
lv_obj_align(lbl_sig_type, LV_ALIGN_TOP_MID, 0, 25);
lv_obj_align(lbl_sig_type, LV_ALIGN_TOP_MID, 0, 35);

curr_screen = SCR_RESP;

Expand Down

0 comments on commit ff56af0

Please sign in to comment.