mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 22:57:50 +03:00
Update XtcParser.h
This commit is contained in:
parent
938ebd01c8
commit
a8d7910cd1
@ -54,6 +54,47 @@ class XtcParser {
|
||||
*/
|
||||
size_t loadPage(uint32_t pageIndex, uint8_t* buffer, size_t bufferSize);
|
||||
|
||||
|
||||
/**
|
||||
* @brief 动态加载下一批页
|
||||
* @return XtcError 加载状态:OK=加载成功,PAGE_OUT_OF_RANGE=无更多页可加载,其他=加载失败
|
||||
*/
|
||||
XtcError loadNextPageBatch();
|
||||
|
||||
/**
|
||||
* @brief 获取当前已经加载的最大页码
|
||||
* @return uint16_t 当前加载的最大有效页码
|
||||
*/
|
||||
uint16_t getLoadedMaxPage() const;
|
||||
|
||||
/**
|
||||
* @brief 获取每次动态加载的页数(批次大小)
|
||||
* @return uint16_t 批次页数,默认10
|
||||
*/
|
||||
uint16_t getPageBatchSize() const;
|
||||
|
||||
uint32_t getChapterstartpage(int chapterIndex) {
|
||||
for(int i = 0; i < 25; i++) {
|
||||
if(ChapterList[i].chapterIndex == chapterIndex) {
|
||||
return ChapterList[i].startPage;
|
||||
}
|
||||
}
|
||||
return 0; // 无此章节返回0
|
||||
}
|
||||
|
||||
std::string getChapterTitleByIndex(int chapterIndex) {
|
||||
Serial.printf("[%lu] [XTC] 已进入getChapterTitleByIndex,chapterActualCount=%d\n", millis(),chapterActualCount);
|
||||
for(int i = 0; i < 25; i++) {
|
||||
if(ChapterList[i].chapterIndex == chapterIndex) {
|
||||
return std::string(ChapterList[i].shortTitle);
|
||||
Serial.printf("[%lu] [XTC] getChapterTitleByIndex里第%d章,名字为:%s %u\n", millis(), i, ChapterList[i].shortTitle);
|
||||
}
|
||||
}
|
||||
return ""; // 无此章节返回空字符串
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Streaming page load
|
||||
* Memory-efficient method that reads page data in chunks.
|
||||
@ -74,6 +115,11 @@ class XtcParser {
|
||||
bool hasChapters() const { return m_hasChapters; }
|
||||
const std::vector<ChapterInfo>& getChapters() const { return m_chapters; }
|
||||
|
||||
XtcError readChapters_gd(uint16_t chapterStart);
|
||||
ChapterData ChapterList[MAX_SAVE_CHAPTER];
|
||||
int chapterActualCount = 0;
|
||||
XtcError loadPageBatchByStart(uint16_t startPage);
|
||||
|
||||
// Validation
|
||||
static bool isValidXtcFile(const char* filepath);
|
||||
|
||||
@ -100,6 +146,8 @@ class XtcParser {
|
||||
XtcError readTitle();
|
||||
XtcError readAuthor();
|
||||
XtcError readChapters();
|
||||
uint16_t m_loadBatchSize = 10; // 每次加载的页数(核心配置,可改)
|
||||
uint16_t m_loadedMaxPage = 0; // 记录当前加载到的最大页码
|
||||
};
|
||||
|
||||
} // namespace xtc
|
||||
|
||||
Loading…
Reference in New Issue
Block a user