Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
* text=auto eol=lf
*.md text eol=lf
*.py text eol=lf
*.java text eol=lf
*.cpp text eol=lf
*.h text eol=lf
*.yml text eol=lf
gradlew text eol=lf
*.ps1 text eol=crlf
*.png binary
*.jpg binary
*.gif binary
*.mp4 binary
*.apk binary
*.epro2 binary
*.stl binary
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Bug report / 问题反馈
description: Report a reproducible app, firmware or build problem.
body:
- type: textarea
id: versions
attributes:
label: Versions / 版本
description: App, firmware commit, hardware revision, Android version and phone model.
validations:
required: true
- type: textarea
id: reproduce
attributes:
label: Steps, expected and actual behavior / 复现步骤与结果
validations:
required: true
- type: textarea
id: evidence
attributes:
label: Logs or photos / 日志或照片
description: Redact personal identifiers. State whether a real print was attempted.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
13 changes: 13 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Problem and behavior

Describe the concrete trigger and resulting behavior.

## Validation

- Checks run:
- Versions affected:
- Physical validation performed or outstanding:

## Documentation and compatibility

Explain protocol, hardware, bilingual documentation and source-notice changes.
45 changes: 45 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Android

on:
push:
paths: ['software/android/**', '.github/workflows/android.yml']
pull_request:
paths: ['software/android/**', '.github/workflows/android.yml']
workflow_dispatch:

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 25
defaults:
run:
working-directory: software/android
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4
with:
distribution: temurin
java-version: '17'
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: '3.11'
- uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3
with:
packages: platform-tools
- name: Install pinned Android SDK components
run: sdkmanager 'platforms;android-32' 'build-tools;30.0.3'
- name: Host protocol and failure-boundary checks
run: python test-host.py
- name: Build and lint
run: |
chmod +x gradlew
./gradlew --no-daemon assembleDebug lintDebug
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: foli-android-debug
path: |
software/android/app/build/outputs/apk/debug/app-debug.apk
software/android/app/build/reports/lint-results-debug.html
25 changes: 25 additions & 0 deletions .github/workflows/firmware.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Firmware
on:
push:
paths: ['software/firmware/**', '.github/workflows/firmware.yml']
pull_request:
paths: ['software/firmware/**', '.github/workflows/firmware.yml']
workflow_dispatch:
permissions:
contents: read
jobs:
firmware:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: '3.11'
- name: Host protocol and queue regression tests
run: |
g++ -std=c++11 -Wall -Wextra -Werror -I software/firmware/src software/firmware/tests/protocol_test.cpp -o /tmp/foli-protocol-tests
/tmp/foli-protocol-tests
- name: Install pinned build tool
run: python -m pip install platformio==6.2.0
- name: Compile ESP32 firmware
run: pio run --project-dir software/firmware
20 changes: 20 additions & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Documentation and assets
on:
push:
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
integrity:
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: '3.11'
- run: python tools/check_docs.py
- run: python tools/check_assets.py
- name: Parse Python tooling
run: python -m compileall -q tools software/android/test-host.py
27 changes: 21 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
.pio/
.pioenvs/
.piolibdeps/
.vscode/
.gradle/
**/build/
**/__pycache__/
*.py[cod]
.venv/
.idea/
*.o
*.bin
*.elf
.vscode/
local.properties
.DS_Store
Thumbs.db
*.jks
*.keystore
.env
.env.*
!.env.example
tools/runtime/
media/source/work/
mechanical/cad/*.step
mechanical/cad/*.STEP
*.blend1

*.log
media/rendered/
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Contributing / 参与贡献

Read [getting started](docs/en/getting-started.md) and [verification](docs/en/verification.md). Keep changes focused and describe affected app, firmware and hardware revisions.

1. Explain the problem and resulting behavior.
2. Coordinate Android/firmware protocol changes and document compatibility.
3. Run relevant checks: `python tools/check_docs.py`, `python tools/check_assets.py`, `python software/android/test-host.py`, Android build/Lint, or firmware build/host tests.
4. Update corresponding English/Chinese guidance and retain source notices.
5. State what was verified and what remains outstanding. Compiling firmware is not a physical printer test.

Do not commit SDKs, caches, local paths, signing keys, personal device logs or intermediate frames. Report potential vulnerabilities via [SECURITY.md](SECURITY.md).

中文:请先阅读[入门](docs/zh-CN/getting-started.md)与[验证](docs/zh-CN/verification.md)。提交写明版本、变化、检查结果和未验证范围;协议变更需考虑两端兼容,更新双语说明,保留来源。不提交密钥、个人日志、SDK、缓存或媒体中间帧。
9 changes: 9 additions & 0 deletions NOTICE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Sources and notices / 来源说明

The existing [MIT license](LICENSE) is retained for this repository's software. Preserve original notices in inherited code and dependencies. Android notices are listed in [THIRD_PARTY_NOTICES.md](software/android/THIRD_PARTY_NOTICES.md).

Hardware and mechanical source materials were supplied by the project owner, who confirms purchasing rights to the original Mini-Printer project. Source credits identify the inherited platform; new FOLI Android implementation, integration changes and presentation work are documented separately. This notice does not erase third-party terms or invent an additional upstream license grant.

Generated lifestyle concepts, actual CAD renders, historical photos, UI captures/reconstructions and original synthesized music are itemized in [provenance](docs/en/provenance.md) and the [media manifest](media/manifest.json). System fonts are not bundled. Do not describe synthesized media as physical test evidence.

中文:保留原 MIT 文件及上游、依赖与素材说明。项目所有者提供硬件/机械资料并确认已购买原项目权利;新增实现与既有基础分别记录,不凭此文件编造其他上游授权。详见[中文来源说明](docs/zh-CN/provenance.md)。
130 changes: 45 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,112 +1,72 @@
# MINI PRINTER — 便携式蓝牙热敏打印机
<p align="center"><img src="media/brand/foli-wordmark.svg" alt="FOLI" width="200" /></p>
<h1 align="center">Little prints. Everyday joy.</h1>
<p align="center">A little thought. Made tangible.</p>
<p align="center"><strong>English</strong> · <a href="README.zh-CN.md">简体中文</a></p>
<p align="center"><a href="releases/README.md">Get Android</a> · <a href="docs/en/getting-started.md">Get started</a> · <a href="docs/en/index.md">Explore the engineering</a></p>

![硬件测试](docs/images/hardware-test-bench.jpg)
[![Android](https://github.com/TYF009/Mini-Printer/actions/workflows/android.yml/badge.svg)](https://github.com/TYF009/Mini-Printer/actions/workflows/android.yml)
[![Firmware](https://github.com/TYF009/Mini-Printer/actions/workflows/firmware.yml/badge.svg)](https://github.com/TYF009/Mini-Printer/actions/workflows/firmware.yml)
[![Documentation](https://github.com/TYF009/Mini-Printer/actions/workflows/quality.yml/badge.svg)](https://github.com/TYF009/Mini-Printer/actions/workflows/quality.yml)

电池供电的小型蓝牙热敏打印机:手机通过 BLE 发送单色位图,ESP32 流式缓存并逐行驱动热敏打印头打印。硬件为两层板,锂电池供电,集成充电、升压、电机驱动与多种传感器监测。
[![Watch FOLI — Made Tangible](media/images/hero.jpg)](media/video/FOLI-Made-Tangible-90s.mp4)

**打印测试页**(全字符集 + 校验色块,实测参数:VH 8101mV / 打印头温度 28℃):
**[Watch the 90-second film →](media/video/FOLI-Made-Tangible-90s.mp4)**

![打印测试页](docs/images/print-test-page.jpg)
FOLI is a complete mini thermal-printer project: battery-powered ESP32 electronics, embedded control, a printable enclosure and a native Android companion. Together, they turn notes, lists and little messages into monochrome paper you can keep close.

**PCB 3D 视图**:
A short list beside your keyboard. A few words tucked into a gift. A reminder for the day ahead.

| 顶面 | 底面 |
|---|---|
| ![PCB顶面](docs/images/pcb-3d-top.png) | ![PCB底面](docs/images/pcb-3d-bottom.png) |

> 项目性质:个人复刻/学习项目。硬件参考原始设计(V4 引脚版本)完成,固件经逐行阅读梳理并记录已知问题,手机 App 使用小智学长开源的 Mini-Printer App。

## 文档导航(按阅读顺序)

**一、项目总览**:产品定义、需求拆解、主控选型、系统架构 → [docs/01-项目总览.md](docs/01-项目总览.md)
*Lifestyle concept visuals, actual CAD geometry, reconstructed app interactions and illustrative paper-feed animation.*

**二、硬件设计**([docs/02-硬件设计/](docs/02-硬件设计/)):
## One little flow, three places

| 章节 | 内容 |
|---|---|
| [01-最小系统](docs/02-硬件设计/01-最小系统.md) | Type-C 供电/烧录电路、CH340C、DTR/RTS 交叉耦合自动下载电路 |
| [02-电源架构](docs/02-硬件设计/02-电源架构.md) | 充电管理、LDO 稳压、AP2005 升压 VH 及 Layout 要点 |
| [03-电量检测与输入指示](docs/02-硬件设计/03-电量检测与输入指示.md) | 分压采样、按键、LED 状态设计 |
| [04-打印模组](docs/02-硬件设计/04-打印模组.md) | 一体化机芯、NTC 测温、光电缺纸检测、TC1508S 电机驱动、FPC 接口 |
| [05-PCB-Layout](docs/02-硬件设计/05-PCB-Layout.md) | 结构约束布局、电源走线、铺铜与 DRC 检查 |
![Create, Templates and Device](media/gifs/app-tour.gif)

**三、软件设计**([docs/03-软件设计/](docs/03-软件设计/)):
| Create | Templates | Device |
|---|---|---|
| Shape your words, choose a paper style and inspect the monochrome preview | Start with eight templates, filter, save and make one yours | Discover the printer, inspect reported state and find printing help |

| 章节 | 内容 |
|---|---|
| [01-工程结构与任务模型](docs/03-软件设计/01-工程结构与任务模型.md) | 分层架构、FreeRTOS 三任务 + 定时器 + 中断 |
| [02-消息队列](docs/03-软件设计/02-消息队列.md) | 环形打印缓冲(1000 行×48B)与并发安全 |
| [03-LED与按键](docs/03-软件设计/03-LED与按键.md) | 四态指示、消抖状态机 |
| [04-电量采集](docs/03-软件设计/04-电量采集.md) | ADC eFuse 校准、电压→电量换算 |
| [05-BLE通信](docs/03-软件设计/05-BLE通信.md) | Service/Characteristic 模型、收发流程、防丢包设计 |
| [06-缺纸与温度](docs/03-软件设计/06-缺纸与温度.md) | 中断检测、NTC B 值公式、过热保护 |
| [07-步进电机](docs/03-软件设计/07-步进电机.md) | 四相八拍、2ms 节拍、4 步=行高 |
| [08-打印驱动](docs/03-软件设计/08-打印驱动.md) | SPI→LAT→STB 分时加热时序、动态加热补偿、电源时序规则 |

**四、项目整合**([docs/04-项目整合/](docs/04-项目整合/)):

| 章节 | 内容 |
|---|---|
| [01-App与整机联调](docs/04-项目整合/01-App与整机联调.md) | 开源 App 对接、图片二值化、A6 开始打印指令的由来 |
| [02-已知问题与修复记录](docs/04-项目整合/02-已知问题与修复记录.md) | 17 条已知问题清单与修复进展 |
No account is required. Editing and preview work offline; physical printing needs matching hardware. The tour combines actual captures with interaction visualization; Device is reconstructed from current source in the disconnected state.

**速查参考**:[引脚分配表](docs/pinout.md) · [BLE 协议](docs/ble-protocol.md) · [架构总览](docs/architecture.md)
[Download 0.2.1 development APK](releases/android/FOLI-0.2.1-debug.apk) · [Android source and build guide](software/android/README.md)

## 仓库结构
## From the screen to the paper

```
mini-printer/
├── hardware/
│ ├── EDA-project/ # 嘉立创EDA专业版工程(.epro2)
│ └── exports/ # Gerber 生产文件 / 原理图 / BOM(可直接打样)
├── software/firmware/ # PlatformIO 工程(ESP32 + Arduino + FreeRTOS)
└── docs/ # 全部设计文档与图片
```
![Software-to-paper system architecture](media/images/system-architecture.png)

## 系统概览
The Android renderer turns a layout into a 384-dot monochrome raster. Each row occupies 48 bytes. BLE carries row data to firmware that coordinates the thermal head and paper feed. The enclosure brings the battery, board, roll and mechanism together.

- **主控**:ESP32-S 模组(BLE 4.2)
- **打印头**:384 点/行热敏打印头,6 路 STB 分时加热,32Pin FPC 连接
- **走纸**:两相步进电机 + TC1508S 双 H 桥
- **供电**:2000mAh 动力锂电池(Type-C 充电,ME4054),PMOS 软开关机,AP2005 升压 7.2V 供打印头,XC6210 LDO 3.3V 供数字
- **监测**:电池电量(分压+ADC eFuse 校准)、打印头温度(NTC + B 值公式,>65℃ 保护)、缺纸(LM393 + GPIO 中断)
![Annotated CAD assembly](media/images/assembly-explained.jpg)

**数据流**:手机 App 编辑排版 --BLE--> ESP32 接收入环形缓冲 --> 打印任务逐行取数 --> SPI 送数 / LAT 锁存 / 6 路 STB 分时加热 + 步进电机走纸 --> 热敏纸成像;全程由电量、温度、缺纸三类监测保护。
[Architecture and protocol](docs/en/architecture.md) · [Hardware](hardware/README.md) · [Mechanical and assembly](mechanical/README.md) · [Firmware](software/firmware/)

### 软件任务模型
## Decisions behind the experience

| 任务/中断 | 优先级 | 周期/触发 | 职责 |
|---|---|---|---|
| 打印主任务(loop) | 1 | 常驻 | 打印状态机、打印头时序驱动 |
| 上报任务 | 1 | 100ms | 传感器采集 + BLE 上报;缺纸事件处理 |
| 按键任务 | 0 | 10ms | 消抖、短按(自检)/长按(走纸) |
| Ticker 定时器 | — | 2ms/10s/20s | 电机步进 / 状态刷新 / 打印超时 |
| GPIO 中断 | — | 上升沿 | 缺纸检测 |
- **Preview the raster that will be sent.** Preview and transmission share the encoder, so the paper view reflects monochrome output.
- **Design for an older phone.** Xiaomi Mi 6 checks informed keyboard layout, editor controls and explicit checklist rendering.
- **Separate connection, transfer and completion.** Interrupted or unconfirmed jobs use conservative recovery. Firmware hardening addresses command framing and fault shutdown paths.

## 编译与烧录
[Read the engineering case study](docs/en/product-case-study.md) · [Verification and known limits](docs/en/verification.md)

```bash
cd software/firmware
pio run # 编译
pio run -t upload # 烧录(Type-C 直插,板载 CH340C + 自动下载电路)
pio device monitor # 串口监视
```
## Built, wired, on paper

环境:PlatformIO,`[env:esp32dev]`,Arduino 框架(依赖 Arduino-ESP32 2.x,3.x 已移除 `ledcSetup` 等接口,建议锁定 espressif32 平台版本)。
![Historical hardware and print-test photographs](media/images/hardware-evidence.jpg)

## 待办与改进
Physical hardware has been assembled and previously print-tested. Android 0.2.0 was inspected on Xiaomi Mi 6 for UI and BLE state. Version 0.2.1 adds BLE exception recovery with software checks. The hardened firmware and new app have not been revalidated together in a fresh physical print.

- [x] ~~实物照片 / 打印效果照片~~(docs/images/)
- [x] ~~原理图、Gerber、BOM 导出~~(hardware/exports/,Gerber 可直接下单打样)
- [ ] 修复 [已知问题](docs/04-项目整合/02-已知问题与修复记录.md) 高优先级四项(按键任务饿死 / A6 误入队 / 低电量显示 / 缓冲残留)
- [ ] 打印耗时实测(验证动态加热收益)
- [ ] 状态包增加包头与校验
## Explore the build

## 致谢
| Your next step | Start here |
|---|---|
| Try the app without a printer | [Installation and usage](docs/en/getting-started.md) |
| Build Android | [JDK, SDK and build commands](software/android/README.md) |
| Build and flash firmware | [PlatformIO project](software/firmware/README.md) |
| Inspect or manufacture the board | [Final project, BOM and exports](hardware/README.md) |
| Make the enclosure | [STLs, source mapping and assembly](mechanical/README.md) |
| Reuse the product media | [Provenance and rebuild guide](media/README.md) |

- 手机 App:小智学长开源的 Mini-Printer App
- 本项目硬件在原始设计(V4 引脚版本)基础上复刻完成,仅用于个人学习。如有侵权请联系删除。
## Open development

## License
This repository retains the Mini-Printer history and integrates the FOLI Android app, product design, mechanical assets, presentation media and reliability work. [Sources and contributions](docs/en/provenance.md) distinguish the inherited platform from new implementation.

MIT
[Roadmap](ROADMAP.md) · [Contributing](CONTRIBUTING.md) · [Versions and downloads](releases/README.md) · [License](LICENSE) · [Third-party and media notices](NOTICE.md)
Loading
Loading