From 3cb3bdb4ebbc6b640175540e070856ced4e80de4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Saillant?= Date: Mon, 15 Jun 2026 12:05:54 +0200 Subject: [PATCH] feat(box): volume slider on radio screen --- main/modes/radio.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/main/modes/radio.c b/main/modes/radio.c index 05a8dfd..12e62e5 100644 --- a/main/modes/radio.c +++ b/main/modes/radio.c @@ -20,6 +20,7 @@ #include "ui/assets/lisael_icons.h" #include "audio/radio_pipeline.h" #include "audio/audio_player.h" +#include "lisael_config.h" // LISAEL_VOLUME_MAX #include #include @@ -107,7 +108,7 @@ static void make_arrow(lv_obj_t *parent, const char *sym, lv_align_t al, int dir lv_obj_set_style_radius(b, 19, 0); lv_obj_set_style_bg_opa(b, LV_OPA_40, 0); lv_obj_set_style_bg_color(b, lv_color_white(), 0); - lv_obj_align(b, al, (al == LV_ALIGN_LEFT_MID) ? 2 : -2, -10); + lv_obj_align(b, al, (al == LV_ALIGN_LEFT_MID) ? 2 : -2, -36); lv_obj_add_event_cb(b, arrow_cb, LV_EVENT_CLICKED, (void *)(intptr_t)dir); lv_obj_t *l = lv_label_create(b); lv_label_set_text(l, sym); @@ -134,6 +135,12 @@ static void stop_cb(lv_event_t *e) set_status("Silence"); } +static void vol_cb(lv_event_t *e) +{ + // Applies live: the codec out-volume is shared with the running stream. + lisael_audio_set_volume((int)lv_slider_get_value(lv_event_get_target(e))); +} + static void add_station_slide(lv_obj_t *track, const radio_station_t *st, uint32_t color) { lv_obj_t *slide = lv_obj_create(track); @@ -150,7 +157,7 @@ static void add_station_slide(lv_obj_t *track, const radio_station_t *st, uint32 lv_obj_set_style_bg_grad_color(card, lv_color_hex(color), 0); lv_obj_set_style_translate_y(card, 4, LV_STATE_PRESSED); lv_obj_set_style_shadow_ofs_y(card, 3, LV_STATE_PRESSED); - lv_obj_set_size(card, 188, 116); + lv_obj_set_size(card, 188, 98); lv_obj_set_flex_flow(card, LV_FLEX_FLOW_COLUMN); lv_obj_set_flex_align(card, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); @@ -160,7 +167,7 @@ static void add_station_slide(lv_obj_t *track, const radio_station_t *st, uint32 lv_obj_t *icon = lv_image_create(card); lv_image_set_src(icon, &lisael_ic_radio); - lv_obj_set_size(icon, 56, 56); // scale-to-fit by size (reliable) + lv_obj_set_size(icon, 48, 48); // scale-to-fit by size (reliable) lv_image_set_inner_align(icon, LV_IMAGE_ALIGN_CONTAIN); lv_obj_t *name = lv_label_create(card); @@ -190,8 +197,8 @@ lv_obj_t *lisael_screen_radio(void) // Carousel of station cards. s_track = lv_obj_create(s_root); lv_obj_remove_style_all(s_track); - lv_obj_set_size(s_track, RADIO_SLIDE_W, 124); - lv_obj_align(s_track, LV_ALIGN_TOP_MID, 0, 42); + lv_obj_set_size(s_track, RADIO_SLIDE_W, 104); + lv_obj_align(s_track, LV_ALIGN_TOP_MID, 0, 32); lv_obj_set_flex_flow(s_track, LV_FLEX_FLOW_ROW); lv_obj_set_style_pad_all(s_track, 0, 0); lv_obj_set_style_pad_column(s_track, 0, 0); @@ -209,7 +216,7 @@ lv_obj_t *lisael_screen_radio(void) lv_obj_t *dotrow = lv_obj_create(s_root); lv_obj_remove_style_all(dotrow); lv_obj_set_size(dotrow, LV_PCT(90), 14); - lv_obj_align(dotrow, LV_ALIGN_TOP_MID, 0, 170); + lv_obj_align(dotrow, LV_ALIGN_TOP_MID, 0, 140); lv_obj_set_flex_flow(dotrow, LV_FLEX_FLOW_ROW); lv_obj_set_flex_align(dotrow, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); @@ -231,16 +238,24 @@ lv_obj_t *lisael_screen_radio(void) make_arrow(s_root, LV_SYMBOL_RIGHT, LV_ALIGN_RIGHT_MID, +1); } + // Volume slider (applies live to the running stream; persists to NVS). + lv_obj_t *vol = lv_slider_create(s_root); + lv_obj_set_width(vol, 210); + lv_obj_align(vol, LV_ALIGN_TOP_MID, 0, 158); + lv_slider_set_range(vol, 0, LISAEL_VOLUME_MAX); + lv_slider_set_value(vol, lisael_audio_get_volume(), LV_ANIM_OFF); + lv_obj_add_event_cb(vol, vol_cb, LV_EVENT_VALUE_CHANGED, NULL); + // Status line + Stop button at the bottom. s_status_lbl = lv_label_create(s_root); lv_obj_set_style_text_color(s_status_lbl, lv_color_hex(0x8A4B16), 0); lv_label_set_text(s_status_lbl, ""); - lv_obj_align(s_status_lbl, LV_ALIGN_BOTTOM_MID, 0, -60); + lv_obj_align(s_status_lbl, LV_ALIGN_TOP_MID, 0, 178); lv_obj_t *stop = lv_button_create(s_root); lv_obj_add_style(stop, lisael_ui_style_button(), 0); - lv_obj_set_size(stop, 130, 48); - lv_obj_align(stop, LV_ALIGN_BOTTOM_MID, 0, -8); + lv_obj_set_size(stop, 124, 40); + lv_obj_align(stop, LV_ALIGN_BOTTOM_MID, 0, -4); lv_obj_add_event_cb(stop, stop_cb, LV_EVENT_CLICKED, NULL); lv_obj_t *stop_lbl = lv_label_create(stop); lv_label_set_text(stop_lbl, LV_SYMBOL_STOP " Stop");