Skip to content

Commit b3d683a

Browse files
authored
Merge pull request #34 from minjiezhong/main
阅读设置页面的触控失灵问题
2 parents 851433b + 4c33537 commit b3d683a

8 files changed

Lines changed: 31 additions & 7 deletions

File tree

SiFli-SDK

Submodule SiFli-SDK updated 308 files

epdiy-epub/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ uint32_t epd_wave_table_get_frames(int temperature, EpdDrawMode mode)
277277
return wave_table[i].frame_count;
278278
}
279279
}
280+
// 默认回退到第一组
280281
p_current_wave_from = (const uint8_t *)(*wave_table[0].wave_table);
281282
return wave_table[0].frame_count;
282283
}

epdiy-epub/lib/Epub/EpubList/EpubReader.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,12 +411,20 @@ void EpubReader::render_overlay()
411411
// 三行布局:3, 5, 4(第三行加了"设置"按钮)
412412
const int rows = 3;
413413
const int cols[rows] = {3, 5, 4};
414-
const int gap_h = 20;
415414
const int gap_w = 10;
416-
const int row_h = 80;
415+
416+
// 动态计算 row_h 和 gap_h,确保三行按钮自适应填满 overlay 区域
417+
const int min_gap = 6;
418+
int avail_for_rows = area_h - (rows + 1) * min_gap;
419+
int row_h = avail_for_rows / rows;
420+
if (row_h > 80) row_h = 80; // 上限,按钮不要太大
421+
if (row_h < 40) row_h = 40; // 下限,保证可点击
422+
int gap_h = (area_h - rows * row_h) / (rows + 1);
423+
if (gap_h < 2) gap_h = 2;
424+
417425
int content_h = rows * row_h + (rows + 1) * gap_h;
418426
int y0 = area_y + (area_h - content_h) / 2;
419-
if (y0 < area_y + 4) y0 = area_y + 4;
427+
if (y0 < area_y + 2) y0 = area_y + 2;
420428

421429
int index = 0;
422430
auto fill_label = [&](int idx, char *label, size_t cap) {

epdiy-epub/lib/Epub/EpubList/EpubToc.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ void EpubToc::render()
196196
draw_button(btn_x0, "上一页", m_bottom_mode && m_bottom_idx == 0);
197197
draw_button(btn_x1, "书库", m_bottom_mode && m_bottom_idx == 1);
198198
draw_button(btn_x2, "下一页", m_bottom_mode && m_bottom_idx == 2);
199+
200+
// 注册底部三按钮的触控区域(对应 g_area_array[6,7,8])
201+
static_add_area(btn_x0, btn_y, btn_w, btn_h, 6);
202+
static_add_area(btn_x1, btn_y, btn_w, btn_h, 7);
203+
static_add_area(btn_x2, btn_y, btn_w, btn_h, 8);
199204
}
200205

201206
uint16_t EpubToc::get_selected_toc()

epdiy-epub/src/epub_mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ rt_uint32_t heap_free_size(void)
8484

8585

8686
/*==========================================================================
87-
* FreeType 内存分配适配
87+
* FreeType ÄÚ´æ·ÖÅäÊÊÅä
8888
*========================================================================*/
8989
#ifdef PKG_FREETYPE
9090
#include <string.h>

epdiy-epub/src/epub_screen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,4 +450,4 @@ int handleSettingsPage(Renderer *renderer, UIAction action, bool needs_redraw)
450450
break;
451451
}
452452
return 0;
453-
}
453+
}

epdiy-epub/src/reading_settings.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,17 @@ void reading_settings_draw(Renderer *renderer)
247247

248248
int page_w = renderer->get_page_width();
249249
int page_h = renderer->get_page_height();
250+
/*
251+
* 自适应行高:取实际字体行高,但封顶保证 6 个设置项 + 标题 + 提示区都能放进页面。
252+
* 布局公式:20(top) + line_h*2(title) + 10(sep) + 6*line_h*2(items) + line_h*3(hints)
253+
* = 30 + 17 * line_h ≤ page_h
254+
* => max_line_h = (page_h - 30) / 17
255+
*/
250256
int line_h = renderer->get_line_height();
257+
int max_lh = (page_h - 30) / 17;
258+
if (max_lh < 20) max_lh = 20;
259+
if (line_h > max_lh) line_h = max_lh;
260+
251261
int y = 20;
252262
int x_label = 30;
253263
int x_value = page_w * 2 / 5;

epdiy-epub/src/type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ typedef enum {
2222
CHARGING_PAGE, // 充电页面
2323
SHUTDOWN_PAGE // 关机页面
2424
} AppUIState;
25-
#endif
25+
#endif

0 commit comments

Comments
 (0)