
本文来源:https://m5ware.com/projects/1580
若有版权问题,请来信告知:13951431913#139.com 或在右方提交评论。
一款适用于 M5Paper v1 及 v1.1(ESP32 + 电子纸墨水屏)开发套件的基础中文 TXT 电子书阅读器。
本项目在墨水屏上实现了中文阅读功能,包含自定义字体渲染、后台分页索引、自定义壁纸选择,以及用于在局域网内通过 Wi-Fi 传输书籍和字体的网页界面。
注意:本项目仅用于个人学习与探索。开发过程中使用了 AI 辅助设计、编写与调试,并参考了优秀的开源项目 M5ReadPaper。
电子纸界面:高对比度墨水屏界面,含电池图标、触控区域与可配置的全刷间隔。
多编码中文文本支持:自动识别并转换 UTF-8、GBK / GB18030 与 UTF-16(LE/BE)文本文件,并实现中文排版的换行与行首禁则标点处理。
自定义字体系统(直读 .ttf + .bin 字体包):通过 FreeType 直接渲染 /fonts 目录下的 .ttf 字体,并在后台自动生成 /configs/fontcache/ 下的预渲染 .bin 字形缓存;同时支持由网页界面或 Python 脚本预转换的 .bin 字体包,界面字体固定为 30px、正文字体可独立缩放,外部字体缺失时自动回退内置 30px NotoSansSC 字体。
阅读排版与方向设置(带实时预览):正文字号 20px–60px 可调,行间距五档(1.0/1.5/2.0/2.5/3.0 倍),页边距 0–80px,可选两字符段首缩进与行下虚线,支持四向阅读(竖屏、左右横屏与竖屏倒置),全刷间隔 1–99 页可配置。
后台增量分页与精准跳转:打开书籍即刻渲染,后台增量建立二进制 .idx 分页索引,通过数字键盘按页码或百分比跳转,顶部显示当前页、总页数与进度。
Wi-Fi 无线传书(网页界面):在 M5Paper 上运行本地 Web 服务器,可手机或电脑直接上传 .txt 书籍、.ttf/.bin 字体与锁屏图片。
电源与存储管理:从 SD 卡图片选择壁纸,支持深度休眠与开机直达阅读界面,一键清理过期阅读记录与未使用的 TTF 字形缓存。
阅读页操作:点击屏幕左侧三分之一区域返回上一页、右侧三分之一区域进入下一页,拨动物理滚轮翻页,下压滚轮键清除残影,点击中间三分之一区域唤出阅读菜单。
书架与系统设置:点击书籍卡片开始阅读,最近阅读的书籍自动置顶;点击“传书”启动局域网 Wi-Fi 热点;设置页可配置正文字体、字号、行间距、页边距、段首缩进、行下虚线、阅读方向、全刷间隔、界面字体、锁屏壁纸,以及清理过期进度与字体缓存。
快速上手:通过 pip 安装 PlatformIO Core(pip install -U platformio),准备 FAT32 格式 Micro SD 卡,克隆项目,用 USB-C 连接 M5Paper,执行 pio run 编译、pio run -t upload 烧录,可用 pio device monitor 打开串口监视器。
SD 卡目录结构:系统首次开机自动创建 /configs,进入“WiFi 传书”页面时自动创建 /books、/fonts 和 /images;若线下拷贝需手动建立 books、configs、fonts、images 四个目录。
Wi-Fi 传书与传字体:在书架点击“传书”,将手机或电脑连接屏幕显示的 Wi-Fi 热点,浏览器访问显示的地址(如 http://192.168.4.1),通过网页上传 TXT 书籍或二进制字体文件。
自定义字体转换:使用项目自带脚本(python tools/ttf2bin.py input_font.ttf output_font.bin)将 TrueType .ttf 字体转换为自定义二进制格式,再把 .bin 文件拷贝到 SD 卡 /fonts 目录或通过 Wi-Fi 传书上传,并在设置页切换使用。

本文来源:https://m5ware.com/projects/1580
若有版权问题,请来信告知:13951431913#139.com 或在右方提交评论。
A basic TXT ebook reader designed for the M5Paper v1 and v1.1 (ESP32 + E-Ink) development kit.
This project provides a Chinese reading implementation on the e-paper screen, featuring custom font rendering, background pagination indexing, custom wallpaper selection, and a web-based interface for transferring books and fonts over Wi-Fi.
Note: This project is solely for personal learning and exploration. During development, AI was used to assist with design, coding and debugging, with reference to the excellent M5ReadPaper project.
E-paper Interface: High-contrast E-paper interface with a battery indicator, touch targets, and configurable full-refresh intervals.
Multi-Encoding Chinese Text Support: automatic detection and conversion for UTF-8, GBK / GB18030, and UTF-16 (LE/BE) text files, with word wrapping and line-start punctuation rules (kinsoku) for Chinese typography.
Custom Font Subsystem (Direct .ttf + .bin Packs): directly renders .ttf fonts from the /fonts directory via FreeType and automatically builds pre-rendered .bin glyph caches in /configs/fontcache/ in the background. It also supports pre-converted .bin font packs generated via the Web UI or Python script, with separate fixed 30px UI fonts and scalable body fonts, and a built-in 30px NotoSansSC fallback when external fonts are missing.
Reading Layout and Orientation Settings (with Live Preview): body font size adjustable from 20px to 60px, line spacing at five levels (1.0x / 1.5x / 2.0x / 2.5x / 3.0x), page margins from 0px to 80px, optional two-character paragraph indentation and dashed under-line guides, four-direction reading (portrait, left/right landscape and inverted portrait), and a configurable full-refresh interval from 1 to 99 pages.
Incremental Background Pagination and Jump: opens books immediately and builds binary .idx page indexes incrementally in the background, with jumping by page number or percentage via a numeric keypad showing current page, total pages and progress.
Wi-Fi File Transfer (Web UI): runs a local web server on M5Paper to upload .txt books, .ttf/.bin fonts and lock-screen images directly from a phone or computer.
Power and Storage Management: wallpaper selection from SD card images, deep sleep integration with boot-to-reader support, and one-click cleanup for obsolete reading records and unused TTF font caches.
Reading Page operations: tap the left one-third of the screen to go to the previous page and the right one-third for the next page, scroll the physical wheel to flip pages, press the wheel down to clear screen ghosting, and tap the center one-third to open the reading menu.
Bookshelf and System Settings: tapping a book card starts reading with the most recently read book pinned to the top; the Transfer button starts a local Wi-Fi hotspot; the Settings page configures body font, font size, line spacing, margins, paragraph indent, line guides, reading orientation, full-refresh interval, UI font, lock screen wallpaper, obsolete progress cleanup and font cache cleanup.
Getting Started: install PlatformIO Core via pip (pip install -U platformio), prepare a FAT32-formatted Micro SD card, clone the repository, connect the M5Paper via USB-C, compile with pio run, and upload firmware with pio run -t upload, optionally opening the serial monitor with pio device monitor.
SD Card Directory Structure: the system auto-creates /configs on first boot and auto-creates /books, /fonts and /images when entering the WiFi Transfer page; manual copying requires a books, configs, fonts and images folder structure on a FAT32 card.
Wi-Fi Book and Font Transfer: tap Transfer on the bookshelf, connect your phone or computer to the displayed Wi-Fi hotspot, open the shown IP address such as http://192.168.4.1, and upload TXT books or binary font files through the web interface.
Converting Custom Fonts: use the bundled Python script (python tools/ttf2bin.py input_font.ttf output_font.bin) to convert TrueType .ttf fonts into the custom binary format, then copy the .bin file to the SD card /fonts directory or upload it via Wi-Fi Transfer and select it in Settings.