Fix UI overlap: space Reset below hits on 320x240 layout.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
name: CYD Whistle Sound Sensor (cyd)
|
||||
git: b2052a7
|
||||
git: b04464d
|
||||
date: 2026-10-23
|
||||
board: ESP32-2432S028R (ILI9341)
|
||||
features: SoftSPI touch, LVGL, whistle/sound digital H/L on GPIO22
|
||||
@@ -12,5 +12,5 @@ offsets:
|
||||
sha256:
|
||||
bootloader.bin 3D234A7471F67B013686DABD4DEE7C1FA915C9928463616A94BC9297ACF1ABF8
|
||||
boot_app0.bin F94C5D786A7A8FAB06AC5D10E33BF37711A6697636DC037559EA19CC410A17F0
|
||||
firmware.bin 5CCE5B8CF5A31950C109E477A563FD31B1848ABE26C98D5AE70AC60450288634
|
||||
firmware.bin A1BCCD76CC251EF7541DCD92E949B47C487D321E99F77BD4B80EC2867541B01C
|
||||
partitions.bin 148B959CBFF1C38AA8E1D5C0BA9D612C54997B945E56A63F41223EEF650653A1
|
||||
|
||||
Binary file not shown.
30
src/ui.cpp
30
src/ui.cpp
@@ -18,7 +18,6 @@ static lv_obj_t *lbl_pin;
|
||||
static lv_obj_t *lbl_state;
|
||||
static lv_obj_t *lbl_level;
|
||||
static lv_obj_t *lbl_count;
|
||||
static lv_obj_t *lbl_hint;
|
||||
static lv_obj_t *btn_reset;
|
||||
static lv_obj_t *bar_pulse;
|
||||
|
||||
@@ -44,34 +43,37 @@ void ui_create() {
|
||||
lv_obj_t *scr = lv_screen_active();
|
||||
lv_obj_set_style_bg_color(scr, lv_color_hex(COL_BG), 0);
|
||||
lv_obj_set_style_bg_opa(scr, LV_OPA_COVER, 0);
|
||||
/* 320x240:自上而下分区,互不重叠
|
||||
* title 8 | pin 42 | state 70 | level 108 | bar 136 | count 162 | reset 192
|
||||
*/
|
||||
|
||||
lbl_title = lv_label_create(scr);
|
||||
lv_label_set_text(lbl_title, "Whistle / Sound");
|
||||
lv_obj_set_style_text_color(lbl_title, lv_color_hex(COL_INK), 0);
|
||||
lv_obj_set_style_text_font(lbl_title, &lv_font_montserrat_28, 0);
|
||||
lv_obj_align(lbl_title, LV_ALIGN_TOP_MID, 0, 12);
|
||||
lv_obj_set_style_text_font(lbl_title, &lv_font_montserrat_20, 0);
|
||||
lv_obj_align(lbl_title, LV_ALIGN_TOP_MID, 0, 8);
|
||||
|
||||
lbl_pin = lv_label_create(scr);
|
||||
lv_label_set_text_fmt(lbl_pin, "OUT -> GPIO%d (H/L)", SOUND_PIN);
|
||||
lv_obj_set_style_text_color(lbl_pin, lv_color_hex(COL_MUTED), 0);
|
||||
lv_obj_set_style_text_font(lbl_pin, &lv_font_montserrat_14, 0);
|
||||
lv_obj_align(lbl_pin, LV_ALIGN_TOP_MID, 0, 48);
|
||||
lv_obj_align(lbl_pin, LV_ALIGN_TOP_MID, 0, 36);
|
||||
|
||||
lbl_state = lv_label_create(scr);
|
||||
lv_label_set_text(lbl_state, "QUIET");
|
||||
lv_obj_set_style_text_color(lbl_state, lv_color_hex(COL_MUTED), 0);
|
||||
lv_obj_set_style_text_font(lbl_state, &lv_font_montserrat_28, 0);
|
||||
lv_obj_align(lbl_state, LV_ALIGN_TOP_MID, 0, 78);
|
||||
lv_obj_align(lbl_state, LV_ALIGN_TOP_MID, 0, 62);
|
||||
|
||||
lbl_level = lv_label_create(scr);
|
||||
lv_label_set_text(lbl_level, "pin: LOW");
|
||||
lv_obj_set_style_text_color(lbl_level, lv_color_hex(COL_MUTED), 0);
|
||||
lv_obj_set_style_text_font(lbl_level, &lv_font_montserrat_16, 0);
|
||||
lv_obj_align(lbl_level, LV_ALIGN_TOP_MID, 0, 114);
|
||||
lv_obj_align(lbl_level, LV_ALIGN_TOP_MID, 0, 100);
|
||||
|
||||
bar_pulse = lv_bar_create(scr);
|
||||
lv_obj_set_size(bar_pulse, UI_HOR_RES - 48, 18);
|
||||
lv_obj_align(bar_pulse, LV_ALIGN_TOP_MID, 0, 144);
|
||||
lv_obj_set_size(bar_pulse, UI_HOR_RES - 48, 16);
|
||||
lv_obj_align(bar_pulse, LV_ALIGN_TOP_MID, 0, 128);
|
||||
lv_bar_set_range(bar_pulse, 0, 100);
|
||||
lv_bar_set_value(bar_pulse, 0, LV_ANIM_OFF);
|
||||
lv_obj_set_style_bg_color(bar_pulse, lv_color_hex(COL_QUIET), 0);
|
||||
@@ -86,17 +88,11 @@ void ui_create() {
|
||||
lv_label_set_text(lbl_count, "hits: 0");
|
||||
lv_obj_set_style_text_color(lbl_count, lv_color_hex(COL_INK), 0);
|
||||
lv_obj_set_style_text_font(lbl_count, &lv_font_montserrat_20, 0);
|
||||
lv_obj_align(lbl_count, LV_ALIGN_TOP_MID, 0, 174);
|
||||
|
||||
lbl_hint = lv_label_create(scr);
|
||||
lv_label_set_text(lbl_hint, "dB N/A (digital only)");
|
||||
lv_obj_set_style_text_color(lbl_hint, lv_color_hex(COL_MUTED), 0);
|
||||
lv_obj_set_style_text_font(lbl_hint, &lv_font_montserrat_14, 0);
|
||||
lv_obj_align(lbl_hint, LV_ALIGN_TOP_MID, 0, 204);
|
||||
lv_obj_align(lbl_count, LV_ALIGN_TOP_MID, 0, 154);
|
||||
|
||||
btn_reset = lv_button_create(scr);
|
||||
lv_obj_set_size(btn_reset, 120, 40);
|
||||
lv_obj_align(btn_reset, LV_ALIGN_BOTTOM_MID, 0, -12);
|
||||
lv_obj_set_size(btn_reset, 140, 44);
|
||||
lv_obj_align(btn_reset, LV_ALIGN_TOP_MID, 0, 188);
|
||||
style_btn(btn_reset, COL_BTN);
|
||||
lv_obj_add_event_cb(btn_reset, on_reset, LV_EVENT_CLICKED, nullptr);
|
||||
lv_obj_t *lbl = lv_label_create(btn_reset);
|
||||
|
||||
Reference in New Issue
Block a user