Skip to content

Commit bbd51ee

Browse files
authored
Fix stream text display (tuya#132)
* fix display stream ai text bug * fix esp32 stream text display
1 parent 28e99a1 commit bbd51ee

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

apps/tuya.ai/your_chat_bot/src/display/ui/ui_wechat.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,6 @@ static uint8_t __get_words_from_stream_ringbuff(APP_UI_STREAM_T *stream, uint8_t
381381

382382
return get_num;
383383
}
384-
385-
386384
static void __stream_timer_cb(lv_timer_t *lv_timer)
387385
{
388386
uint8_t word_num = 0;
@@ -402,10 +400,13 @@ static void __stream_timer_cb(lv_timer_t *lv_timer)
402400

403401
lv_coord_t content_height = lv_obj_get_height(stream->msg_cont);
404402
lv_coord_t height = lv_obj_get_height(sg_ui.ui.content);
405-
lv_coord_t y_position = content_height;
406403

407404
if(content_height > height) {
408-
lv_obj_scroll_to_y(sg_ui.ui.content, y_position, LV_ANIM_OFF);
405+
lv_coord_t offset = 0;
406+
offset = lv_obj_get_scroll_bottom(sg_ui.ui.content);
407+
if(offset > 0) {
408+
lv_obj_scroll_by_bounded(sg_ui.ui.content, 0, -offset, LV_ANIM_OFF);
409+
}
409410
}else {
410411
lv_obj_scroll_to_view_recursive(stream->msg_cont, LV_ANIM_OFF);
411412
}

boards/ESP32/common/display/ui/ui_wechat.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,12 +401,15 @@ static void __stream_timer_cb(lv_timer_t *lv_timer)
401401

402402
lv_coord_t content_height = lv_obj_get_height(stream->msg_cont);
403403
lv_coord_t height = lv_obj_get_height(sg_ui.ui.content);
404-
lv_coord_t y_position = content_height;
405404

406-
if (content_height > height) {
407-
lv_obj_scroll_to_y(sg_ui.ui.content, y_position, LV_ANIM_OFF);
408-
} else {
409-
lv_obj_scroll_to_view_recursive(stream->msg_cont, LV_ANIM_OFF);
405+
if(content_height > height) {
406+
lv_coord_t offset = 0;
407+
offset = lv_obj_get_scroll_bottom(sg_ui.ui.content);
408+
if(offset > 0) {
409+
lv_obj_scroll_by_bounded(sg_ui.ui.content, 0, -offset, LV_ANIM_OFF);
410+
}
411+
}else {
412+
lv_obj_scroll_to_view_recursive(stream->msg_cont, LV_ANIM_OFF);
410413
}
411414

412415
lv_obj_update_layout(sg_ui.ui.content);

0 commit comments

Comments
 (0)