feat(box): volume slider on radio screen
This commit is contained in:
+24
-9
@@ -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 <stddef.h>
|
||||
#include <stdint.h>
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user