diff --git a/.opencode/command/build.md b/.opencode/command/build.md index 757aa187..e3df7c86 100644 --- a/.opencode/command/build.md +++ b/.opencode/command/build.md @@ -1,14 +1,19 @@ --- description: Build the STM32F4-Base Keil MDK project. Use ONLY when the user asks to build, compile, or verify the project. +agent: build --- -Run the Keil MDK-ARM build from the project root: +Run the Keil MDK-ARM build by executing the build script with the bash tool. Use the absolute path, NOT relative cd: -``` -cmd /c "cd /d "D:\Code\DTU 程序\STM32F4-Base\MDK-ARM" && build.bat" +```powershell +& "D:\Code\DTU 程序\STM32F4-Base\MDK-ARM\build.bat" ``` -Check the last 10 lines of `MDK-ARM/build_log.txt` for errors/warnings. -Return code 0 = success (0 errors, 0 warnings). -Return code 1 = warnings-only (also failure per project rules). -Return code 2+ = compile errors. +Then read the tail of `MDK-ARM/build_log.txt` and report the result. + +Exit code interpretation (per AGENTS.md): +- 0 = success (0 errors, 0 warnings) — PASS +- 1 = warnings only — FAIL, must fix +- 2+ = compile errors — FAIL, must fix + +If the build fails, read `MDK-ARM/build_log.txt`, fix the reported errors/warnings, and rerun `@build` until it returns 0. diff --git a/.opencode/mcp/serial_studio_bridge.py b/.opencode/mcp/serial_studio_bridge.py new file mode 100644 index 00000000..c6dc58d8 --- /dev/null +++ b/.opencode/mcp/serial_studio_bridge.py @@ -0,0 +1,125 @@ +"""opencode <-> Serial Studio MCP bridge. + +Serial Studio exposes a native MCP server on TCP port 7777 speaking +JSON-RPC 2.0 (newline-delimited over a raw TCP socket), NOT over HTTP. + +opencode's "remote" MCP type expects HTTP (streamableHttp / SSE), so it +cannot talk to Serial Studio directly. This script is a thin stdio +bridge: opencode launches it as a "local" MCP server, reads newline- +delimited JSON-RPC from stdin, forwards each request over TCP to Serial +Studio on port 7777, and writes the response back to stdout. + +Usage: + python serial_studio_bridge.py [host] [port] +Defaults: host=127.0.0.1, port=7777 +""" + +import json +import socket +import sys + +DEFAULT_HOST = "127.0.0.1" +DEFAULT_PORT = 7777 + + +def main() -> int: + if len(sys.argv) > 1: + host = sys.argv[1] + else: + host = DEFAULT_HOST + if len(sys.argv) > 2: + port = int(sys.argv[2]) + else: + port = DEFAULT_PORT + + sock = socket.create_connection((host, port), timeout=10) + sock.settimeout(30) + buf = b"" + + def send_json(obj) -> None: + line = (json.dumps(obj, separators=(",", ":")) + "\n").encode("utf-8") + sock.sendall(line) + + def read_response(target_id) -> dict: + nonlocal buf + while True: + while b"\n" in buf: + line, buf = buf.split(b"\n", 1) + line = line.strip() + if not line: + continue + try: + resp = json.loads(line.decode("utf-8")) + except Exception: + continue + if resp.get("id") == target_id or target_id is None: + return resp + sock.settimeout(30) + data = sock.recv(65536) + if not data: + raise ConnectionError("Serial Studio closed connection") + buf += data + + try: + for raw in sys.stdin: + raw = raw.strip() + if not raw: + continue + try: + req = json.loads(raw) + except Exception as e: + err = { + "jsonrpc": "2.0", + "id": None, + "error": {"code": -32700, "message": f"Parse error: {e}"}, + } + sys.stdout.write(json.dumps(err) + "\n") + sys.stdout.flush() + continue + + if isinstance(req, list): + results = [] + for sub in req: + try: + send_json(sub) + results.append(read_response(sub.get("id"))) + except Exception as e: + results.append( + { + "jsonrpc": "2.0", + "id": sub.get("id"), + "error": {"code": -32000, "message": str(e)}, + } + ) + sys.stdout.write(json.dumps(results) + "\n") + sys.stdout.flush() + continue + + if req.get("jsonrpc") == "2.0" and not req.get("id"): + send_json(req) + continue + + try: + send_json(req) + resp = read_response(req.get("id")) + sys.stdout.write(json.dumps(resp) + "\n") + sys.stdout.flush() + except Exception as e: + err = { + "jsonrpc": "2.0", + "id": req.get("id"), + "error": {"code": -32000, "message": str(e)}, + } + sys.stdout.write(json.dumps(err) + "\n") + sys.stdout.flush() + finally: + try: + sock.close() + except Exception: + pass + + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/Drivers/BSP/UI/ui_font_cn_12.c b/Drivers/BSP/UI/ui_font_cn_12.c new file mode 100644 index 00000000..4cf3d6ae --- /dev/null +++ b/Drivers/BSP/UI/ui_font_cn_12.c @@ -0,0 +1,990 @@ +/******************************************************************************* + * Size: 12 px + * Bpp: 1 + * Opts: --font C:\Users\16241\AppData\Local\Temp\simsun_regular.ttf --size 12 --bpp 1 -r 0x20-0x7E --symbols 主事交件位作信值元入全出制功动占厂压参双变号告复字定实家开强归录恢息手护据操故数时显未本查检波流测版现电界直看示系络维网置能自节装警认讯记设询调通遥部配量间零面默() --no-compress --format lvgl --lv-font-name ui_font_cn_12 -o D:\Code\DTU 程序\STM32F4-Base\Drivers\BSP\UI\ui_font_cn_12.c + ******************************************************************************/ + +#ifdef LV_LVGL_H_INCLUDE_SIMPLE +#include "lvgl.h" +#else +#include "lvgl/lvgl.h" +#endif + +#ifndef UI_FONT_CN_12 +#define UI_FONT_CN_12 1 +#endif + +#if UI_FONT_CN_12 + +/*----------------- + * BITMAPS + *----------------*/ + +/*Store the image of the glyphs*/ +static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = { + /* U+0020 " " */ + + /* U+0021 "!" */ + 0xfc, 0x80, + + /* U+0022 "\"" */ + 0x55, 0xa0, + + /* U+0023 "#" */ + 0xa, 0xbe, 0xa5, 0x2b, 0xea, 0x50, + + /* U+0024 "$" */ + 0x4e, 0xdc, 0xc6, 0x75, 0xde, 0x44, + + /* U+0025 "%" */ + 0xca, 0xcb, 0x2c, 0x68, 0x53, 0x55, 0x58, + + /* U+0026 "&" */ + 0x71, 0x45, 0x18, 0x4a, 0xab, 0x24, 0x6c, + + /* U+0027 "'" */ + 0xd8, + + /* U+0028 "(" */ + 0x29, 0x49, 0x24, 0x48, 0x80, + + /* U+0029 ")" */ + 0x89, 0x12, 0x49, 0x4a, 0x0, + + /* U+002A "*" */ + 0x0, 0x8e, 0xcc, 0x68, 0x82, 0x0, + + /* U+002B "+" */ + 0x21, 0x9, 0xf2, 0x10, 0x80, + + /* U+002C "," */ + 0xd8, + + /* U+002D "-" */ + 0xfc, + + /* U+002E "." */ + 0xc0, + + /* U+002F "/" */ + 0x0, 0x21, 0x4, 0x10, 0x82, 0x10, 0x42, 0x0, + 0x0, + + /* U+0030 "0" */ + 0x74, 0xa3, 0x18, 0xc6, 0x32, 0x70, + + /* U+0031 "1" */ + 0x19, 0x24, 0x92, 0x40, + + /* U+0032 "2" */ + 0x74, 0x62, 0x11, 0x11, 0x10, 0xf8, + + /* U+0033 "3" */ + 0xe9, 0x91, 0x21, 0x19, 0xe0, + + /* U+0034 "4" */ + 0x10, 0x9c, 0xa9, 0x4b, 0xe2, 0x10, + + /* U+0035 "5" */ + 0x7a, 0x10, 0xe0, 0x84, 0x31, 0x70, + + /* U+0036 "6" */ + 0x74, 0x21, 0x6c, 0xc6, 0x31, 0x70, + + /* U+0037 "7" */ + 0xf2, 0x22, 0x44, 0x44, 0x40, + + /* U+0038 "8" */ + 0x74, 0x62, 0xa7, 0x4e, 0x31, 0x70, + + /* U+0039 "9" */ + 0x74, 0x63, 0x18, 0xbc, 0x22, 0x70, + + /* U+003A ":" */ + 0x84, + + /* U+003B ";" */ + 0x86, + + /* U+003C "<" */ + 0x12, 0x48, 0x88, 0x42, 0x10, + + /* U+003D "=" */ + 0xfc, 0x0, 0x3f, + + /* U+003E ">" */ + 0x84, 0x23, 0x12, 0x48, 0x0, + + /* U+003F "?" */ + 0x74, 0x72, 0x13, 0x10, 0x80, 0x20, + + /* U+0040 "@" */ + 0x39, 0x5b, 0x75, 0xd7, 0x5a, 0x91, 0x38, + + /* U+0041 "A" */ + 0x20, 0xc5, 0x14, 0x51, 0xc4, 0xa2, 0x88, + + /* U+0042 "B" */ + 0x71, 0x24, 0x92, 0x71, 0x34, 0x51, 0x78, + + /* U+0043 "C" */ + 0x3a, 0x21, 0x8, 0x42, 0x11, 0x70, + + /* U+0044 "D" */ + 0x71, 0x24, 0x51, 0x45, 0x14, 0x52, 0x70, + + /* U+0045 "E" */ + 0x7d, 0x4, 0x12, 0x79, 0x24, 0x10, 0x7c, + + /* U+0046 "F" */ + 0x7d, 0x4, 0x12, 0x79, 0x24, 0x10, 0x40, + + /* U+0047 "G" */ + 0x39, 0x28, 0x20, 0x82, 0x78, 0xa2, 0x70, + + /* U+0048 "H" */ + 0x49, 0x24, 0x92, 0x79, 0x24, 0x92, 0x48, + + /* U+0049 "I" */ + 0x71, 0x8, 0x42, 0x10, 0x84, 0x70, + + /* U+004A "J" */ + 0x38, 0x41, 0x4, 0x10, 0x41, 0x4, 0x12, 0x4e, + 0x0, + + /* U+004B "K" */ + 0x49, 0x45, 0x18, 0x51, 0x44, 0x92, 0x4c, + + /* U+004C "L" */ + 0x41, 0x4, 0x10, 0x41, 0x4, 0x11, 0x78, + + /* U+004D "M" */ + 0x44, 0xc9, 0xb3, 0x67, 0x4e, 0x9d, 0x2a, 0x54, + + /* U+004E "N" */ + 0x64, 0xc9, 0x92, 0xa5, 0x4a, 0x93, 0x26, 0x44, + + /* U+004F "O" */ + 0x74, 0xa3, 0x18, 0xc6, 0x32, 0x70, + + /* U+0050 "P" */ + 0x79, 0x14, 0x51, 0x79, 0x4, 0x10, 0x40, + + /* U+0051 "Q" */ + 0x74, 0xa3, 0x18, 0xc6, 0xbe, 0x51, 0xc0, + + /* U+0052 "R" */ + 0x72, 0x52, 0x97, 0x29, 0x4a, 0x48, + + /* U+0053 "S" */ + 0x74, 0x61, 0x83, 0xc, 0x31, 0xf0, + + /* U+0054 "T" */ + 0xf9, 0x8, 0x42, 0x10, 0x84, 0x20, + + /* U+0055 "U" */ + 0x44, 0x89, 0x12, 0x24, 0x48, 0x91, 0x22, 0x38, + + /* U+0056 "V" */ + 0x49, 0x24, 0x94, 0x50, 0xc3, 0x8, 0x20, + + /* U+0057 "W" */ + 0xaa, 0xaa, 0xaa, 0xf1, 0x45, 0x14, 0x50, + + /* U+0058 "X" */ + 0x49, 0x43, 0xc, 0x20, 0xc5, 0x12, 0x48, + + /* U+0059 "Y" */ + 0x8c, 0x94, 0xa6, 0x10, 0x84, 0x20, + + /* U+005A "Z" */ + 0x78, 0x44, 0x22, 0x11, 0x8, 0xf8, + + /* U+005B "[" */ + 0xf2, 0x49, 0x24, 0x92, 0x70, + + /* U+005C "\\" */ + 0x88, 0x84, 0x44, 0x22, 0x11, 0x10, + + /* U+005D "]" */ + 0xe4, 0x92, 0x49, 0x24, 0xf0, + + /* U+005E "^" */ + 0x60, + + /* U+005F "_" */ + 0xfc, + + /* U+0060 "`" */ + 0x40, + + /* U+0061 "a" */ + 0xf4, 0x8d, 0xa9, 0x7c, + + /* U+0062 "b" */ + 0x42, 0x10, 0xe4, 0xa5, 0x29, 0x70, + + /* U+0063 "c" */ + 0x79, 0x88, 0x87, + + /* U+0064 "d" */ + 0x10, 0x84, 0xe9, 0x4a, 0x52, 0x78, + + /* U+0065 "e" */ + 0x74, 0x7f, 0x8, 0xb8, + + /* U+0066 "f" */ + 0x32, 0x10, 0xc4, 0x21, 0x8, 0x40, + + /* U+0067 "g" */ + 0x7c, 0xa4, 0xcc, 0x7e, 0x2e, + + /* U+0068 "h" */ + 0x41, 0x4, 0x1e, 0x49, 0x24, 0x92, 0x48, + + /* U+0069 "i" */ + 0xc0, 0x24, 0x92, 0x40, + + /* U+006A "j" */ + 0x10, 0x1, 0x11, 0x11, 0x11, 0xe0, + + /* U+006B "k" */ + 0x41, 0x4, 0x12, 0x51, 0x47, 0x12, 0x48, + + /* U+006C "l" */ + 0x61, 0x8, 0x42, 0x10, 0x84, 0x70, + + /* U+006D "m" */ + 0xfd, 0x6b, 0x5a, 0xd4, + + /* U+006E "n" */ + 0x79, 0x24, 0x92, 0x49, 0x20, + + /* U+006F "o" */ + 0x74, 0x63, 0x18, 0xb8, + + /* U+0070 "p" */ + 0x79, 0x14, 0x51, 0x45, 0xa5, 0x10, + + /* U+0071 "q" */ + 0x74, 0xa5, 0x29, 0x38, 0x42, + + /* U+0072 "r" */ + 0x5b, 0x10, 0x84, 0x20, + + /* U+0073 "s" */ + 0xf9, 0xc3, 0x1f, + + /* U+0074 "t" */ + 0x4, 0x64, 0x44, 0x47, + + /* U+0075 "u" */ + 0x49, 0x24, 0x92, 0x49, 0xf0, + + /* U+0076 "v" */ + 0x4a, 0x54, 0x63, 0x10, + + /* U+0077 "w" */ + 0xaa, 0xa5, 0x9e, 0x51, 0x40, + + /* U+0078 "x" */ + 0x49, 0x88, 0x65, 0x24, + + /* U+0079 "y" */ + 0x95, 0x28, 0xc6, 0x21, 0x10, + + /* U+007A "z" */ + 0xf2, 0x24, 0x9f, + + /* U+007B "{" */ + 0x29, 0x24, 0xb2, 0x49, 0x10, + + /* U+007C "|" */ + 0xff, 0xf8, + + /* U+007D "}" */ + 0x89, 0x24, 0x9a, 0x49, 0x40, + + /* U+007E "~" */ + 0x40, 0x81, 0x80, + + /* U+4E3B "主" */ + 0x8, 0x0, 0x80, 0x0, 0x3f, 0xe0, 0x40, 0x8, + 0x1, 0x3, 0xfe, 0x4, 0x0, 0x80, 0x10, 0x7f, + 0xf0, + + /* U+4E8B "事" */ + 0x4, 0x1f, 0xfc, 0x92, 0x1f, 0xc0, 0x40, 0xff, + 0x81, 0x17, 0xff, 0x4, 0x4f, 0xf8, 0x10, 0x6, + 0x0, + + /* U+4EA4 "交" */ + 0x8, 0x0, 0x83, 0xff, 0x80, 0x1, 0x10, 0x41, + 0x14, 0x50, 0x50, 0x4, 0x1, 0x40, 0xc6, 0x60, + 0x30, + + /* U+4EF6 "件" */ + 0x21, 0x5, 0x21, 0x24, 0x27, 0xfd, 0x10, 0x82, + 0x10, 0x42, 0xff, 0x41, 0x8, 0x21, 0x4, 0x20, + 0x80, + + /* U+4F4D "位" */ + 0x22, 0x4, 0x21, 0x0, 0x2f, 0xfc, 0x0, 0x90, + 0x92, 0x12, 0x22, 0x44, 0x88, 0x91, 0x4, 0x2f, + 0xf0, + + /* U+4F5C "作" */ + 0x14, 0x2, 0x80, 0x9f, 0x95, 0x6, 0x21, 0x47, + 0x88, 0x81, 0x10, 0x23, 0xe4, 0x40, 0x88, 0x11, + 0x0, + + /* U+4FE1 "信" */ + 0x22, 0x4, 0x21, 0x7f, 0xa0, 0xc, 0xfc, 0x80, + 0x13, 0xf2, 0x0, 0x4f, 0xc9, 0x9, 0x3f, 0x24, + 0x20, + + /* U+503C "值" */ + 0x22, 0x5, 0xfd, 0x8, 0x27, 0xec, 0x84, 0x9f, + 0x92, 0x12, 0x7e, 0x48, 0x49, 0xf9, 0x21, 0x2f, + 0xf0, + + /* U+5143 "元" */ + 0x7f, 0xc0, 0x0, 0x0, 0x0, 0xf, 0xfe, 0x22, + 0x4, 0x40, 0x88, 0x21, 0x28, 0x26, 0x3, 0x80, + + /* U+5165 "入" */ + 0x30, 0x1, 0x0, 0x10, 0x2, 0x0, 0xa0, 0x14, + 0x2, 0x80, 0x88, 0x11, 0x4, 0x11, 0x1, 0x40, + 0x10, + + /* U+5168 "全" */ + 0x4, 0x1, 0x40, 0x44, 0x10, 0x4c, 0x6, 0x7f, + 0x1, 0x0, 0x20, 0x7f, 0xc0, 0x80, 0x10, 0x7f, + 0xf0, + + /* U+51FA "出" */ + 0x4, 0x8, 0x89, 0x11, 0x22, 0x27, 0xfc, 0x8, + 0x1, 0x4, 0x21, 0x84, 0x30, 0x87, 0xff, 0x80, + 0x10, + + /* U+5236 "制" */ + 0x10, 0x2a, 0x5, 0xf4, 0xc8, 0x9f, 0xf2, 0x22, + 0x5f, 0x4a, 0xa9, 0x55, 0x2a, 0x85, 0x70, 0x88, + 0x70, + + /* U+529F "功" */ + 0x2, 0x0, 0x43, 0xe8, 0x13, 0xf2, 0x22, 0x44, + 0x48, 0x89, 0x11, 0x3c, 0x38, 0x84, 0x20, 0x88, + 0x60, + + /* U+52A8 "动" */ + 0x1, 0xe, 0x20, 0x4, 0x1, 0xff, 0x92, 0x42, + 0x50, 0x4a, 0x89, 0x89, 0x3f, 0x44, 0x8, 0x82, + 0x60, + + /* U+5360 "占" */ + 0x8, 0x2, 0x0, 0x80, 0x3f, 0x8, 0x2, 0xf, + 0xfa, 0x2, 0x80, 0xa0, 0x2f, 0xfa, 0x2, + + /* U+5382 "厂" */ + 0x7f, 0xe8, 0x1, 0x0, 0x20, 0x4, 0x0, 0x80, + 0x10, 0x2, 0x0, 0x40, 0x8, 0x2, 0x0, 0x0, + + /* U+538B "压" */ + 0x7f, 0xe8, 0x1, 0x8, 0x21, 0x4, 0x20, 0xbf, + 0x90, 0x82, 0x14, 0x42, 0x48, 0x42, 0xff, 0x80, + + /* U+53C2 "参" */ + 0x10, 0x4, 0x11, 0xff, 0x4, 0xf, 0xfe, 0x45, + 0x13, 0x15, 0x89, 0x6, 0xf, 0x8, 0xe, 0x3e, + 0x0, + + /* U+53CC "双" */ + 0xfb, 0xe1, 0x44, 0x28, 0xc5, 0x15, 0x14, 0xa2, + 0x88, 0x21, 0x4, 0x51, 0x4a, 0x4a, 0x10, 0x80, + + /* U+53D8 "变" */ + 0x4, 0x1f, 0xfc, 0x44, 0x28, 0xa9, 0x12, 0x0, + 0x1f, 0xe1, 0x4, 0x11, 0x1, 0xc0, 0xc6, 0x60, + 0x30, + + /* U+53F7 "号" */ + 0x3f, 0x84, 0x10, 0x82, 0x1f, 0xc0, 0x1, 0xff, + 0xc4, 0x1, 0x0, 0x3f, 0xc0, 0x8, 0x1, 0x0, + 0xc0, + + /* U+544A "告" */ + 0x4, 0x4, 0x80, 0xff, 0x22, 0x0, 0x41, 0xff, + 0xc0, 0x3, 0xfe, 0x40, 0x48, 0x9, 0xff, 0x20, + 0x20, + + /* U+590D "复" */ + 0x3f, 0xe8, 0x2, 0xff, 0x10, 0x23, 0xfc, 0x40, + 0x8f, 0xf0, 0x80, 0x3f, 0xca, 0x10, 0x3c, 0x38, + 0x70, + + /* U+5B57 "字" */ + 0x8, 0x0, 0x83, 0xff, 0xc0, 0x10, 0x0, 0x7f, + 0x0, 0x40, 0x10, 0xff, 0xe0, 0x80, 0x10, 0xe, + 0x0, + + /* U+5B9A "定" */ + 0x8, 0x0, 0x83, 0xff, 0xc0, 0x10, 0x1, 0xff, + 0xc1, 0x1, 0x20, 0x27, 0xc4, 0x81, 0x50, 0x47, + 0xf0, + + /* U+5B9E "实" */ + 0x4, 0x1f, 0xfe, 0x0, 0x89, 0x0, 0xa0, 0x44, + 0x4, 0x87, 0xff, 0x4, 0x1, 0x30, 0xc1, 0x60, + 0x10, + + /* U+5BB6 "家" */ + 0x4, 0x1f, 0xfe, 0x0, 0xbf, 0xe0, 0x80, 0x28, + 0x9a, 0xa0, 0x98, 0x66, 0x83, 0x4f, 0x88, 0x6, + 0x0, + + /* U+5F00 "开" */ + 0x7f, 0xc2, 0x20, 0x44, 0x8, 0x81, 0x11, 0xff, + 0xc4, 0x40, 0x88, 0x21, 0x4, 0x21, 0x4, 0x0, + + /* U+5F3A "强" */ + 0x7, 0xdc, 0x88, 0x91, 0x13, 0xee, 0x11, 0x1f, + 0xe2, 0x4f, 0x49, 0x2f, 0xe4, 0x20, 0x85, 0x67, + 0xf0, + + /* U+5F52 "归" */ + 0x10, 0x2, 0xfe, 0x40, 0xc8, 0x19, 0x3, 0x27, + 0xe4, 0xc, 0x81, 0x90, 0x24, 0x4, 0x9f, 0xa0, + 0x10, + + /* U+5F55 "录" */ + 0x7f, 0x80, 0x10, 0xfe, 0x0, 0x4f, 0xfe, 0x8, + 0x11, 0x11, 0x74, 0x15, 0x4, 0x93, 0x11, 0x86, + 0x0, + + /* U+6062 "恢" */ + 0x24, 0x4, 0x80, 0xbf, 0xda, 0xa, 0x49, 0x49, + 0x6a, 0xb1, 0x54, 0x28, 0x85, 0x28, 0xc9, 0x12, + 0x10, + + /* U+606F "息" */ + 0x8, 0xf, 0xf9, 0x1, 0x3f, 0xe4, 0x4, 0xff, + 0x90, 0x13, 0xfe, 0x4, 0xa, 0x49, 0x42, 0xc7, + 0xd0, + + /* U+624B "手" */ + 0x3, 0xcf, 0x80, 0x10, 0x2, 0x7, 0xfc, 0x8, + 0x1, 0x7, 0xff, 0x4, 0x0, 0x80, 0x10, 0xe, + 0x0, + + /* U+62A4 "护" */ + 0x21, 0x4, 0x10, 0x9f, 0xfa, 0x12, 0x42, 0x48, + 0x4d, 0xff, 0x21, 0x24, 0x4, 0x80, 0x90, 0x34, + 0x0, + + /* U+636E "据" */ + 0x20, 0x4, 0xfc, 0x90, 0xfb, 0xf2, 0x48, 0x4f, + 0xcd, 0x27, 0x3f, 0x26, 0x25, 0x44, 0xaf, 0xb9, + 0x10, + + /* U+64CD "操" */ + 0x27, 0xc4, 0x88, 0x9f, 0x78, 0x2, 0xee, 0x55, + 0x4f, 0xbf, 0x8, 0x2f, 0xe4, 0x70, 0x95, 0x34, + 0x90, + + /* U+6545 "故" */ + 0x22, 0x4, 0x40, 0x88, 0x7d, 0xf2, 0x44, 0x44, + 0xbe, 0x94, 0x52, 0x8a, 0x91, 0x23, 0xea, 0x46, + 0x30, + + /* U+6570 "数" */ + 0x11, 0xa, 0xa0, 0x44, 0x7e, 0xf3, 0x24, 0xb2, + 0xa5, 0x51, 0xa, 0xf9, 0x49, 0x10, 0xc5, 0x65, + 0x10, + + /* U+65F6 "时" */ + 0x0, 0x5e, 0xa, 0x41, 0x4b, 0xf9, 0x5, 0xe0, + 0xa4, 0x94, 0x8a, 0x91, 0x5e, 0xa, 0x41, 0x0, + 0xe0, + + /* U+663E "显" */ + 0x7f, 0xc8, 0x9, 0xff, 0x20, 0x27, 0xfc, 0x22, + 0x24, 0x4a, 0x8a, 0x31, 0x82, 0x23, 0xff, 0x80, + + /* U+672A "未" */ + 0x4, 0x0, 0x81, 0xff, 0x2, 0x0, 0x41, 0xff, + 0xc3, 0x80, 0xa8, 0x24, 0x98, 0x8c, 0x10, 0x2, + 0x0, + + /* U+672C "本" */ + 0x4, 0x0, 0x83, 0xff, 0x82, 0x0, 0xe0, 0x2a, + 0x5, 0x41, 0x24, 0x44, 0x57, 0xf4, 0x10, 0x2, + 0x0, + + /* U+67E5 "查" */ + 0x4, 0x1f, 0xfc, 0x54, 0x12, 0x4c, 0x46, 0x7f, + 0x8, 0x21, 0xfc, 0x20, 0x87, 0xf0, 0x0, 0x7f, + 0xf0, + + /* U+68C0 "检" */ + 0x21, 0x4, 0x20, 0x8a, 0x7a, 0x22, 0x82, 0xcf, + 0x9c, 0x5, 0x12, 0x29, 0x44, 0xa8, 0x92, 0x17, + 0xf0, + + /* U+6CE2 "波" */ + 0x1, 0x10, 0x21, 0x7f, 0x88, 0x91, 0x11, 0x3f, + 0x95, 0x10, 0xa2, 0x12, 0x8a, 0x22, 0x4a, 0x16, + 0x30, + + /* U+6D41 "流" */ + 0x2, 0x10, 0x21, 0x7f, 0x82, 0x0, 0x85, 0x3f, + 0xd0, 0x8, 0x54, 0xa, 0x89, 0x56, 0x4a, 0x91, + 0x30, + + /* U+6D4B "测" */ + 0x0, 0x37, 0xc5, 0x8a, 0x95, 0x52, 0xab, 0x55, + 0x5a, 0xa9, 0x55, 0x2a, 0xa9, 0x6, 0x50, 0x91, + 0x30, + + /* U+7248 "版" */ + 0x10, 0x6a, 0xf1, 0x50, 0x2a, 0x7, 0xfe, 0x8a, + 0x51, 0x4b, 0xaa, 0x55, 0x4a, 0x91, 0x65, 0x49, + 0x10, + + /* U+73B0 "现" */ + 0xf7, 0xc4, 0x88, 0x95, 0x12, 0xaf, 0x54, 0x4a, + 0x89, 0x51, 0x14, 0x32, 0x98, 0x94, 0x21, 0x80, + + /* U+7535 "电" */ + 0x8, 0x1, 0x3, 0xfe, 0x44, 0x48, 0x89, 0xff, + 0x22, 0x24, 0x44, 0xff, 0x91, 0x4, 0x20, 0x83, + 0xf0, + + /* U+754C "界" */ + 0x7f, 0xc8, 0x89, 0xff, 0x22, 0x27, 0xfc, 0x8, + 0x6, 0xc7, 0x7, 0x11, 0x2, 0x20, 0x84, 0x20, + 0x80, + + /* U+76F4 "直" */ + 0x8, 0x3f, 0xf0, 0x81, 0xfe, 0x40, 0x9f, 0xe4, + 0x9, 0xfe, 0x40, 0x9f, 0xe4, 0xb, 0xff, + + /* U+770B "看" */ + 0x3, 0xcf, 0x80, 0x10, 0x3f, 0xe0, 0x81, 0xff, + 0xc8, 0x13, 0xfe, 0xa0, 0x47, 0xf8, 0x81, 0x1f, + 0xe0, + + /* U+793A "示" */ + 0x3f, 0x80, 0x0, 0x0, 0x7f, 0xf0, 0x40, 0x8, + 0x9, 0x21, 0x22, 0x44, 0x30, 0x84, 0x30, 0x0, + + /* U+7CFB "系" */ + 0x3, 0xcf, 0x80, 0x20, 0x8, 0x43, 0xf0, 0xc, + 0x6, 0x13, 0xff, 0x4, 0x24, 0x91, 0x11, 0x46, + 0x10, + + /* U+7EDC "络" */ + 0x22, 0x4, 0x79, 0x11, 0x4d, 0x4e, 0x10, 0x45, + 0x13, 0x1f, 0xbe, 0x4, 0x46, 0x8b, 0x1f, 0x2, + 0x20, + + /* U+7EF4 "维" */ + 0x22, 0x84, 0x49, 0x1f, 0xca, 0x4e, 0xc8, 0x4f, + 0xd1, 0x27, 0xa4, 0x7, 0xe6, 0x93, 0x12, 0x3, + 0xf0, + + /* U+7F51 "网" */ + 0xff, 0xf0, 0x6, 0x0, 0xe2, 0x3a, 0xab, 0x22, + 0x64, 0x4d, 0x55, 0xc4, 0x70, 0x6, 0x0, 0xc0, + 0x70, + + /* U+7F6E "置" */ + 0x7f, 0xc9, 0x49, 0xff, 0x2, 0xf, 0xfe, 0x8, + 0xf, 0xe1, 0x4, 0x20, 0x84, 0x90, 0x92, 0x7f, + 0xf0, + + /* U+80FD "能" */ + 0x22, 0x49, 0x53, 0xec, 0x1, 0x17, 0x9e, 0x90, + 0x1e, 0x82, 0x52, 0x7a, 0x89, 0x65, 0x28, 0xac, + 0xf0, + + /* U+81EA "自" */ + 0x8, 0x8, 0x3f, 0xf0, 0x18, 0xf, 0xfe, 0x3, + 0x1, 0xff, 0xc0, 0x60, 0x3f, 0xf0, + + /* U+8282 "节" */ + 0x11, 0x2, 0x23, 0xff, 0x88, 0x80, 0x1, 0xff, + 0x82, 0x10, 0x42, 0x8, 0x41, 0x18, 0x20, 0x4, + 0x0, + + /* U+88C5 "装" */ + 0x91, 0xa, 0x20, 0x7f, 0x98, 0x85, 0x11, 0x2f, + 0x81, 0x7, 0xff, 0xa, 0x6, 0x2b, 0x52, 0xc, + 0x30, + + /* U+8B66 "警" */ + 0x49, 0x1f, 0xbd, 0x29, 0x3e, 0xad, 0x48, 0xea, + 0x82, 0x8f, 0xff, 0x0, 0xf, 0xf8, 0x82, 0x1f, + 0xc0, + + /* U+8BA4 "认" */ + 0x41, 0x4, 0x20, 0x4, 0x0, 0x8e, 0x10, 0x42, + 0x8, 0xa1, 0x14, 0x2a, 0x86, 0x88, 0x91, 0x4, + 0x10, + + /* U+8BAF "讯" */ + 0x40, 0x5, 0xf0, 0x12, 0x2, 0x4e, 0x48, 0x5f, + 0x9, 0x21, 0x24, 0x24, 0x86, 0x94, 0x91, 0x82, + 0x10, + + /* U+8BB0 "记" */ + 0x40, 0x4, 0xf8, 0x1, 0x0, 0x2e, 0x4, 0x4f, + 0x89, 0x1, 0x20, 0x2c, 0x6, 0x84, 0x90, 0x81, + 0xf0, + + /* U+8BBE "设" */ + 0x47, 0x84, 0x90, 0x12, 0x2, 0x4e, 0x86, 0x40, + 0xb, 0xf1, 0x22, 0x22, 0x86, 0x20, 0x8a, 0x6, + 0x30, + + /* U+8BE2 "询" */ + 0x88, 0x9, 0xfc, 0x40, 0x97, 0xdc, 0x8a, 0x91, + 0x53, 0xea, 0x45, 0x48, 0xad, 0xf5, 0x20, 0x80, + 0x60, + + /* U+8C03 "调" */ + 0x8f, 0xe9, 0x4, 0x24, 0x85, 0xdc, 0x92, 0x9f, + 0xd2, 0xa, 0x5d, 0x4a, 0xad, 0x75, 0x20, 0x88, + 0x70, + + /* U+901A "通" */ + 0x9f, 0x88, 0x90, 0xc, 0xf, 0xed, 0x24, 0xbf, + 0x94, 0x92, 0xfe, 0x52, 0x4a, 0x59, 0x0, 0x5f, + 0xf0, + + /* U+9065 "遥" */ + 0x80, 0xeb, 0xe0, 0x28, 0x82, 0xac, 0x7c, 0x92, + 0x17, 0xfa, 0x8, 0x49, 0x29, 0xfd, 0x0, 0x5f, + 0xf0, + + /* U+90E8 "部" */ + 0x10, 0xf, 0xbc, 0x4, 0xa2, 0x92, 0x95, 0xfe, + 0x80, 0x4b, 0xe9, 0x45, 0x28, 0xb9, 0xf4, 0x22, + 0x80, + + /* U+914D "配" */ + 0xfe, 0xe5, 0x7, 0xf8, 0xd5, 0x1a, 0xaf, 0x8d, + 0x20, 0xa7, 0xf4, 0x82, 0xbf, 0xd6, 0x9, 0x80, + + /* U+91CF "量" */ + 0x7f, 0xc8, 0x89, 0x9, 0x7f, 0xf4, 0x44, 0xff, + 0x91, 0x13, 0xfe, 0x4, 0xf, 0xf8, 0x10, 0x7f, + 0xf0, + + /* U+95F4 "间" */ + 0x9f, 0xd0, 0x10, 0x6, 0xfd, 0xa1, 0x68, 0x5b, + 0xf6, 0x85, 0xa1, 0x6f, 0xd8, 0x6, 0x7, + + /* U+96F6 "零" */ + 0x7f, 0xc0, 0x83, 0xff, 0xda, 0xd0, 0x40, 0xeb, + 0x82, 0x81, 0xac, 0xdf, 0x60, 0x40, 0x70, 0x1, + 0x80, + + /* U+9762 "面" */ + 0xff, 0xe0, 0x80, 0x20, 0x3f, 0xf4, 0x92, 0x9e, + 0x52, 0x4a, 0x79, 0x49, 0x2f, 0xfd, 0x0, 0x80, + + /* U+9ED8 "默" */ + 0xfc, 0x92, 0x9b, 0x72, 0xca, 0x4f, 0xde, 0x21, + 0x3f, 0x20, 0x84, 0x1d, 0x5c, 0x29, 0x55, 0x55, + 0x10, + + /* U+FF08 "(" */ + 0x29, 0x49, 0x22, 0x44, + + /* U+FF09 ")" */ + 0x89, 0x12, 0x4a, 0x50 +}; + + +/*--------------------- + * GLYPH DESCRIPTION + *--------------------*/ + +static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = { + {.bitmap_index = 0, .adv_w = 0, .box_w = 0, .box_h = 0, .ofs_x = 0, .ofs_y = 0} /* id = 0 reserved */, + {.bitmap_index = 0, .adv_w = 96, .box_w = 0, .box_h = 0, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 0, .adv_w = 96, .box_w = 1, .box_h = 9, .ofs_x = 2, .ofs_y = 0}, + {.bitmap_index = 2, .adv_w = 96, .box_w = 4, .box_h = 3, .ofs_x = 1, .ofs_y = 7}, + {.bitmap_index = 4, .adv_w = 96, .box_w = 5, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 10, .adv_w = 96, .box_w = 4, .box_h = 12, .ofs_x = 1, .ofs_y = -2}, + {.bitmap_index = 16, .adv_w = 96, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 23, .adv_w = 96, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 30, .adv_w = 96, .box_w = 2, .box_h = 3, .ofs_x = 1, .ofs_y = 7}, + {.bitmap_index = 31, .adv_w = 96, .box_w = 3, .box_h = 11, .ofs_x = 3, .ofs_y = -1}, + {.bitmap_index = 36, .adv_w = 96, .box_w = 3, .box_h = 11, .ofs_x = 1, .ofs_y = -1}, + {.bitmap_index = 41, .adv_w = 96, .box_w = 6, .box_h = 7, .ofs_x = 0, .ofs_y = 1}, + {.bitmap_index = 47, .adv_w = 96, .box_w = 5, .box_h = 7, .ofs_x = 1, .ofs_y = 1}, + {.bitmap_index = 52, .adv_w = 96, .box_w = 2, .box_h = 3, .ofs_x = 1, .ofs_y = -1}, + {.bitmap_index = 53, .adv_w = 96, .box_w = 6, .box_h = 1, .ofs_x = 0, .ofs_y = 4}, + {.bitmap_index = 54, .adv_w = 96, .box_w = 1, .box_h = 2, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 55, .adv_w = 96, .box_w = 6, .box_h = 11, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 64, .adv_w = 96, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 70, .adv_w = 96, .box_w = 3, .box_h = 9, .ofs_x = 2, .ofs_y = 0}, + {.bitmap_index = 74, .adv_w = 96, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 80, .adv_w = 96, .box_w = 4, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 85, .adv_w = 96, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 91, .adv_w = 96, .box_w = 5, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 97, .adv_w = 96, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 103, .adv_w = 96, .box_w = 4, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 108, .adv_w = 96, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 114, .adv_w = 96, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 120, .adv_w = 96, .box_w = 1, .box_h = 6, .ofs_x = 2, .ofs_y = 0}, + {.bitmap_index = 121, .adv_w = 96, .box_w = 1, .box_h = 8, .ofs_x = 2, .ofs_y = -2}, + {.bitmap_index = 122, .adv_w = 96, .box_w = 4, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 127, .adv_w = 96, .box_w = 6, .box_h = 4, .ofs_x = 0, .ofs_y = 3}, + {.bitmap_index = 130, .adv_w = 96, .box_w = 4, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 135, .adv_w = 96, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 141, .adv_w = 96, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 148, .adv_w = 96, .box_w = 6, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 155, .adv_w = 96, .box_w = 6, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 162, .adv_w = 96, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 168, .adv_w = 96, .box_w = 6, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 175, .adv_w = 96, .box_w = 6, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 182, .adv_w = 96, .box_w = 6, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 189, .adv_w = 96, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 196, .adv_w = 96, .box_w = 6, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 203, .adv_w = 96, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 209, .adv_w = 96, .box_w = 6, .box_h = 11, .ofs_x = 1, .ofs_y = -2}, + {.bitmap_index = 218, .adv_w = 96, .box_w = 6, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 225, .adv_w = 96, .box_w = 6, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 232, .adv_w = 96, .box_w = 7, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 240, .adv_w = 96, .box_w = 7, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 248, .adv_w = 96, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 254, .adv_w = 96, .box_w = 6, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 261, .adv_w = 96, .box_w = 5, .box_h = 10, .ofs_x = 1, .ofs_y = -1}, + {.bitmap_index = 268, .adv_w = 96, .box_w = 5, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 274, .adv_w = 96, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 280, .adv_w = 96, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 286, .adv_w = 96, .box_w = 7, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 294, .adv_w = 96, .box_w = 6, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 301, .adv_w = 96, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 308, .adv_w = 96, .box_w = 6, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 315, .adv_w = 96, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 321, .adv_w = 96, .box_w = 5, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 327, .adv_w = 96, .box_w = 3, .box_h = 12, .ofs_x = 2, .ofs_y = -1}, + {.bitmap_index = 332, .adv_w = 96, .box_w = 4, .box_h = 11, .ofs_x = 1, .ofs_y = -2}, + {.bitmap_index = 338, .adv_w = 96, .box_w = 3, .box_h = 12, .ofs_x = 1, .ofs_y = -1}, + {.bitmap_index = 343, .adv_w = 96, .box_w = 4, .box_h = 1, .ofs_x = 1, .ofs_y = 10}, + {.bitmap_index = 344, .adv_w = 96, .box_w = 6, .box_h = 1, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 345, .adv_w = 96, .box_w = 2, .box_h = 1, .ofs_x = 1, .ofs_y = 10}, + {.bitmap_index = 346, .adv_w = 96, .box_w = 5, .box_h = 6, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 350, .adv_w = 96, .box_w = 5, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 356, .adv_w = 96, .box_w = 4, .box_h = 6, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 359, .adv_w = 96, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 365, .adv_w = 96, .box_w = 5, .box_h = 6, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 369, .adv_w = 96, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 375, .adv_w = 96, .box_w = 5, .box_h = 8, .ofs_x = 1, .ofs_y = -2}, + {.bitmap_index = 380, .adv_w = 96, .box_w = 6, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 387, .adv_w = 96, .box_w = 3, .box_h = 9, .ofs_x = 2, .ofs_y = 0}, + {.bitmap_index = 391, .adv_w = 96, .box_w = 4, .box_h = 11, .ofs_x = 1, .ofs_y = -2}, + {.bitmap_index = 397, .adv_w = 96, .box_w = 6, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 404, .adv_w = 96, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 410, .adv_w = 96, .box_w = 5, .box_h = 6, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 414, .adv_w = 96, .box_w = 6, .box_h = 6, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 419, .adv_w = 96, .box_w = 5, .box_h = 6, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 423, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 429, .adv_w = 96, .box_w = 5, .box_h = 8, .ofs_x = 1, .ofs_y = -2}, + {.bitmap_index = 434, .adv_w = 96, .box_w = 5, .box_h = 6, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 438, .adv_w = 96, .box_w = 4, .box_h = 6, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 441, .adv_w = 96, .box_w = 4, .box_h = 8, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 445, .adv_w = 96, .box_w = 6, .box_h = 6, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 450, .adv_w = 96, .box_w = 5, .box_h = 6, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 454, .adv_w = 96, .box_w = 6, .box_h = 6, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 459, .adv_w = 96, .box_w = 5, .box_h = 6, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 463, .adv_w = 96, .box_w = 5, .box_h = 8, .ofs_x = 1, .ofs_y = -2}, + {.bitmap_index = 468, .adv_w = 96, .box_w = 4, .box_h = 6, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 471, .adv_w = 96, .box_w = 3, .box_h = 12, .ofs_x = 3, .ofs_y = -1}, + {.bitmap_index = 476, .adv_w = 96, .box_w = 1, .box_h = 13, .ofs_x = 3, .ofs_y = -2}, + {.bitmap_index = 478, .adv_w = 96, .box_w = 3, .box_h = 12, .ofs_x = 1, .ofs_y = -1}, + {.bitmap_index = 483, .adv_w = 96, .box_w = 6, .box_h = 3, .ofs_x = 0, .ofs_y = 8}, + {.bitmap_index = 486, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 503, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 520, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 537, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 554, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 571, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 588, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 605, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 622, .adv_w = 192, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 638, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 655, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 672, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 689, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 706, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 723, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 740, .adv_w = 192, .box_w = 10, .box_h = 12, .ofs_x = 1, .ofs_y = -2}, + {.bitmap_index = 755, .adv_w = 192, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 771, .adv_w = 192, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 787, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 804, .adv_w = 192, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 820, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 837, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 854, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 871, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 888, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 905, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 922, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 939, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 956, .adv_w = 192, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 972, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 989, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1006, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1023, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1040, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1057, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1074, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1091, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1108, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1125, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1142, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1159, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1176, .adv_w = 192, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1192, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1209, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1226, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1243, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1260, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1277, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1294, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1311, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1328, .adv_w = 192, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1344, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1361, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1378, .adv_w = 192, .box_w = 10, .box_h = 12, .ofs_x = 1, .ofs_y = -2}, + {.bitmap_index = 1393, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1410, .adv_w = 192, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1426, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1443, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1460, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1477, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1494, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1511, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1528, .adv_w = 192, .box_w = 9, .box_h = 12, .ofs_x = 1, .ofs_y = -2}, + {.bitmap_index = 1542, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1559, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1576, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1593, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1610, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1627, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1644, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1661, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1678, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1695, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1712, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1729, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1746, .adv_w = 192, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1762, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1779, .adv_w = 192, .box_w = 10, .box_h = 12, .ofs_x = 1, .ofs_y = -2}, + {.bitmap_index = 1794, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1811, .adv_w = 192, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1827, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1844, .adv_w = 192, .box_w = 3, .box_h = 10, .ofs_x = 6, .ofs_y = -1}, + {.bitmap_index = 1848, .adv_w = 192, .box_w = 3, .box_h = 10, .ofs_x = 2, .ofs_y = -1} +}; + +/*--------------------- + * CHARACTER MAPPING + *--------------------*/ + +static const uint16_t unicode_list_1[] = { + 0x0, 0x50, 0x69, 0xbb, 0x112, 0x121, 0x1a6, 0x201, + 0x308, 0x32a, 0x32d, 0x3bf, 0x3fb, 0x464, 0x46d, 0x525, + 0x547, 0x550, 0x587, 0x591, 0x59d, 0x5bc, 0x60f, 0xad2, + 0xd1c, 0xd5f, 0xd63, 0xd7b, 0x10c5, 0x10ff, 0x1117, 0x111a, + 0x1227, 0x1234, 0x1410, 0x1469, 0x1533, 0x1692, 0x170a, 0x1735, + 0x17bb, 0x1803, 0x18ef, 0x18f1, 0x19aa, 0x1a85, 0x1ea7, 0x1f06, + 0x1f10, 0x240d, 0x2575, 0x26fa, 0x2711, 0x28b9, 0x28d0, 0x2aff, + 0x2ec0, 0x30a1, 0x30b9, 0x3116, 0x3133, 0x32c2, 0x33af, 0x3447, + 0x3a8a, 0x3d2b, 0x3d69, 0x3d74, 0x3d75, 0x3d83, 0x3da7, 0x3dc8, + 0x41df, 0x422a, 0x42ad, 0x4312, 0x4394, 0x47b9, 0x48bb, 0x4927, + 0x509d, 0xb0cd, 0xb0ce +}; + +/*Collect the unicode lists and glyph_id offsets*/ +static const lv_font_fmt_txt_cmap_t cmaps[] = +{ + { + .range_start = 32, .range_length = 95, .glyph_id_start = 1, + .unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY + }, + { + .range_start = 20027, .range_length = 45263, .glyph_id_start = 96, + .unicode_list = unicode_list_1, .glyph_id_ofs_list = NULL, .list_length = 83, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY + } +}; + + + +/*-------------------- + * ALL CUSTOM DATA + *--------------------*/ + +#if LVGL_VERSION_MAJOR == 8 +/*Store all the custom data of the font*/ +static lv_font_fmt_txt_glyph_cache_t cache; +#endif + +#if LVGL_VERSION_MAJOR >= 8 +static const lv_font_fmt_txt_dsc_t font_dsc = { +#else +static lv_font_fmt_txt_dsc_t font_dsc = { +#endif + .glyph_bitmap = glyph_bitmap, + .glyph_dsc = glyph_dsc, + .cmaps = cmaps, + .kern_dsc = NULL, + .kern_scale = 0, + .cmap_num = 2, + .bpp = 1, + .kern_classes = 0, + .bitmap_format = 0, +#if LVGL_VERSION_MAJOR == 8 + .cache = &cache +#endif +}; + + + +/*----------------- + * PUBLIC FONT + *----------------*/ + +/*Initialize a public general font descriptor*/ +#if LVGL_VERSION_MAJOR >= 8 +const lv_font_t ui_font_cn_12 = { +#else +lv_font_t ui_font_cn_12 = { +#endif + .get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt, /*Function pointer to get glyph's data*/ + .get_glyph_bitmap = lv_font_get_bitmap_fmt_txt, /*Function pointer to get glyph's bitmap*/ + .line_height = 13, /*The maximum line height required by the font*/ + .base_line = 2, /*Baseline measured from the bottom of the line*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = -1, + .underline_thickness = 1, +#endif + .dsc = &font_dsc, /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ +#if LV_VERSION_CHECK(8, 2, 0) || LVGL_VERSION_MAJOR >= 9 + .fallback = NULL, +#endif + .user_data = NULL, +}; + + + +#endif /*#if UI_FONT_CN_12*/ + diff --git a/Lib/lv_conf.h b/Lib/lv_conf.h index 98489a3a..d25152d6 100644 --- a/Lib/lv_conf.h +++ b/Lib/lv_conf.h @@ -1,40 +1,40 @@ -/** +/** * @file lv_conf.h - * @brief LVGL v9 ÅäÖã¨STM32F407ZGTx£¬160x160 µ¥ɫ 1bpp£¬ÀëÆÁäÖȾ+ÍøÂçÍÆÁ÷£© - * @note ±¾ÏîĿ½öÓÃ×÷ÀëÆÁäÖȾ£ºflush °Ñ 1bpp ÏñËØдÈëÄڴæ֡»º³壬 - * ÓÉ RemoDispBus ЭÒ鰴Ð辭ÍøÂ緢³ö¡£ÎÞÕæʵÆÁ¡¢Î޴¥Ãþ¡£ + * @brief LVGL v9 配置(STM32F407ZGTx,160x160 单色 1bpp,离屏渲染+网络推流) + * @note 本项目仅用作离屏渲染:flush 把 1bpp 像素写入内存帧缓冲, + * 由 RemoDispBus 协议按需经网络发出。无真实屏、无触摸。 */ #ifndef LV_CONF_H #define LV_CONF_H -/* 1bpp µ¥ɫ */ +/* 1bpp 单色 */ #define LV_COLOR_DEPTH 1 #define LV_COLOR_CHROMA_KEY 0x000000 -/* ±ØÐè¿ؼþ£¨lv_menu ÒÀÀµ flex/label/button£© */ +/* 必需控件(lv_menu 依赖 flex/label/button) */ #define LV_USE_OBJ 1 #define LV_USE_FLEX 1 #define LV_USE_LABEL 1 #define LV_USE_BUTTON 1 #define LV_USE_MENU 1 -/* ˢÐÂÖÜÆڣ¨ms£©£ºÀëÆÁäÖȾ£¬ÎÞÐè¸ßˢ */ +/* 刷新周期(ms):离屏渲染,无需高刷 */ #define LV_DEF_REFR_PERIOD 20 -/* ¹رն¯»­/ÈÕ־£¬ʡ RAM Óë´úÂë */ +/* 关闭动画/日志,省 RAM 与代码 */ #define LV_USE_ANIMATION 0 #define LV_USE_LOG 0 -/* ²»ʹÓà LVGL ×Դø OS ³éÏó£¬ÓÉ ui_task Êֶ¯µ÷Óà lv_timer_handler */ +/* 不使用 LVGL 自带 OS 抽象,由 ui_task 手动调用 lv_timer_handler */ #define LV_USE_OS 0 #define LV_OS_PRIORITY 0 #define LV_OS_TASK_NAME "ui" -/* Äڴæ³أº1bpp С½çÃ棬²˵¥ҳ½϶࣬¸ø 40KB */ +/* 内存池:1bpp 小界面,菜单页较多,给 40KB */ #define LV_MEM_SIZE (40 * 1024) -#define LV_MEM_ADR 0 /* 0 = Äڲ¿¾²̬·ÖÅä */ +#define LV_MEM_ADR 0 /* 0 = 内部静态分配 */ -/* ¶ÏÑÔȫ²¿¹رգ¬¼õÉÙÌå»ý */ +/* 断言全部关闭,减少体积 */ #define LV_USE_ASSERT_NULL 0 #define LV_USE_ASSERT_MALLOC 0 #define LV_USE_ASSERT_USER_CODE 0 @@ -42,8 +42,8 @@ #define LV_USE_ASSERT_STYLE 0 #define LV_USE_ASSERT_LAYOUT 0 -/* ÄÚÖÃ×ÖÌ壺ÏÈÆôÓà Latin ÒÔͨ¹ý±àÒ룻 - * ÖÐÎÄ 1bpp ×ֿâÓÉ fontconverter Éú³ɺóͨ¹ý ui_font_cn_12 ½ÓÈ벢Ì滻ĬÈÏ×ÖÌå */ +/* 内置字体:先启用 Latin 以通过编译; + * 中文 1bpp 字库由 fontconverter 生成后通过 ui_font_cn_12 接入并替换默认字体 */ #define LV_FONT_MONTSERRAT_12 1 #define LV_FONT_MONTSERRAT_14 0 #define LV_FONT_MONTSERRAT_16 0 @@ -57,29 +57,30 @@ #define LV_FONT_UNSCII_8 0 #define LV_FONT_UNSCII_16 0 #define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 0 -#define LV_FONT_SIMSUN_16_CJK 0 /* ԤÁô£ºÖÐÎÄȫ×ֿ⣨ÈôÆôÓÃÐè¶ÔӦԴÎļþ£© */ +#define LV_FONT_SIMSUN_16_CJK 0 /* 预留:中文全字库(若启用需对应源文件) */ -/* ĬÈÏ×ÖÌ壺½׶ÎһÏÈÓà Latin 12£»ÖÐÎĽÓÈëºó¸ÄΪ &ui_font_cn_12 */ -#define LV_FONT_DEFAULT &lv_font_montserrat_12 +/* 默认字体:阶段一先用 Latin 12;中文接入后改为 &ui_font_cn_12 */ +#define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(ui_font_cn_12) +#define LV_FONT_DEFAULT &ui_font_cn_12 -/* Îı¾±àÂë UTF-8£¨²˵¥º¬ÖÐÎģ© */ +/* 文本编码 UTF-8(菜单含中文) */ #define LV_TXT_ENC LV_TXT_ENC_UTF8 -/* Ö÷Ì⣺¹رÕĬÈÏÖ÷Ì⣬¿ؼþÓÃÄÚÖûù´¡Ñùʽ£¬ʡ´úÂë */ +/* 主题:关闭默认主题,控件用内置基础样式,省代码 */ #define LV_USE_THEME_DEFAULT 0 #define LV_USE_THEME_BASIC 0 -/* »æÖÆÏà¹أº1bpp ÎÞÐè GPU/¿¹¾â³Ý */ +/* 绘制相关:1bpp 无需 GPU/抗锯齿 */ #define LV_DRAW_SW_COMPLEX_GRAD 0 #define LV_DRAW_SW_YIELD 0 #define LV_DRAW_SW_ASYNC 0 -/* ÊäÈëÉ豸£ºÆôÓüüÅÌ/±àÂëÆ÷£¨Զ³̰´¼ü×ß keypad£© */ +/* 输入设备:启用键盘/编码器(远程按键走 keypad) */ #define LV_USE_KEYBOARD 0 #define LV_USE_MOUSEWHEEL 0 #define LV_USE_ENCODER 0 -/* ²»ʹÓõĵÚÈý·½À©չ */ +/* 不使用的第三方扩展 */ #define LV_USE_PNG 0 #define LV_USE_BMP 0 #define LV_USE_JPG 0 @@ -90,7 +91,7 @@ #define LV_USE_GRIDNAV 0 #define LV_USE_FRAGMENT 0 -/* ²üôδÓÿؼþ£¬¼õСÌå»ý£¨menu/label/btn/img µȱ£Áô£© */ +/* 裁剪未用控件,减小体积(menu/label/btn/img 等保留) */ #define LV_USE_ANIMIMG 0 #define LV_USE_ARC 0 #define LV_USE_CHART 0 @@ -116,7 +117,7 @@ #define LV_USE_TABLE 0 #define LV_USE_CALENDAR 0 #define LV_USE_CANVAS 0 -#define LV_USE_IMAGE 1 /* lv_menu ·µ»Øͼ±êÒÀÀµ */ +#define LV_USE_IMAGE 1 /* lv_menu 返回图标依赖 */ #define LV_USE_TEXTLINE 0 #endif /* LV_CONF_H */ diff --git a/MDK-ARM/STM32F407-Demo.uvprojx b/MDK-ARM/STM32F407-Demo.uvprojx index 2576829f..5b099d93 100644 --- a/MDK-ARM/STM32F407-Demo.uvprojx +++ b/MDK-ARM/STM32F407-Demo.uvprojx @@ -3123,6 +3123,11 @@ 1 ..\Drivers\BSP\UI\ui_net_sink.c + + ui_font_cn_12.c + 1 + ..\Drivers\BSP\UI\ui_font_cn_12.c + diff --git a/MDK-ARM/build_log.txt b/MDK-ARM/build_log.txt index 409dc18e..b2f25c58 100644 --- a/MDK-ARM/build_log.txt +++ b/MDK-ARM/build_log.txt @@ -2,277 +2,278 @@ Rebuild target 'STM32F407-Demo' assembling startup_stm32f407xx.s... compiling ui_task.c... -compiling stm32f4xx_it.c... -compiling usart.c... -compiling i2c.c... -compiling freertos.c... -compiling stm32f4xx_hal_tim.c... -compiling dma.c... -compiling stm32f4xx_hal_flash_ramfunc.c... -compiling sys_clock.c... -compiling stm32f4xx_hal_timebase_tim.c... -compiling stm32f4xx_hal_dma_ex.c... -compiling stm32f4xx_hal_gpio.c... -compiling gpio.c... -compiling stm32f4xx_hal_msp.c... -compiling stm32f4xx_hal_flash.c... compiling spi.c... -compiling stm32f4xx_hal_rcc_ex.c... -compiling app_main.c... -compiling stm32f4xx_hal_flash_ex.c... -compiling stm32f4xx_hal_dma.c... -compiling stm32f4xx_hal_rcc.c... compiling time_sync.c... -compiling net_task.c... compiling stm32f4xx_hal_tim_ex.c... compiling main.c... -compiling stm32f4xx_hal_pwr_ex.c... -compiling stm32f4xx_hal_pwr.c... +compiling stm32f4xx_hal_timebase_tim.c... +compiling net_task.c... +compiling sys_clock.c... +compiling stm32f4xx_hal_tim.c... +compiling usart.c... +compiling dma.c... +compiling stm32f4xx_hal_flash.c... +compiling stm32f4xx_it.c... +compiling stm32f4xx_hal_flash_ramfunc.c... +compiling gpio.c... +compiling stm32f4xx_hal_msp.c... +compiling stm32f4xx_hal_rcc.c... +compiling stm32f4xx_hal_flash_ex.c... +compiling stm32f4xx_hal_rcc_ex.c... +compiling i2c.c... +compiling stm32f4xx_hal_gpio.c... +compiling app_main.c... +compiling freertos.c... +compiling stm32f4xx_hal_dma_ex.c... compiling lftpd_string.c... compiling croutine.c... compiling event_groups.c... compiling list.c... -compiling stm32f4xx_hal_cortex.c... -compiling stream_buffer.c... compiling queue.c... +compiling stm32f4xx_hal_dma.c... +compiling stream_buffer.c... +compiling stm32f4xx_hal_pwr.c... compiling timers.c... -compiling heap_4.c... compiling tasks.c... +compiling heap_4.c... +compiling stm32f4xx_hal_cortex.c... +compiling stm32f4xx_hal_pwr_ex.c... +compiling stm32f4xx_hal.c... +compiling system_stm32f4xx.c... +compiling stm32f4xx_hal_exti.c... compiling port.c... +compiling stm32f4xx_hal_i2c_ex.c... compiling journal.c... compiling map.c... -compiling ff.c... -compiling stm32f4xx_hal.c... -compiling stm32f4xx_hal_exti.c... -compiling stm32f4xx_hal_spi.c... -compiling system_stm32f4xx.c... -compiling stm32f4xx_hal_i2c_ex.c... -compiling lv_group.c... -compiling lv_obj_class.c... compiling rs485.c... -compiling ch395f.c... -compiling lv_obj.c... -compiling lv_obj_draw.c... -compiling tpafe5160.c... compiling sd2506.c... -compiling lv_obj_event.c... -compiling stm32f4xx_hal_uart.c... -compiling nand_ftl.c... -compiling gd5f2gq5ue.c... -compiling lftpd_inet.c... +compiling tpafe5160.c... compiling lftpd_io.c... -compiling lv_obj_id_builtin.c... +compiling stm32f4xx_hal_uart.c... compiling net_select.c... -compiling stm32f4xx_hal_i2c.c... -compiling lv_obj_pos.c... -compiling lv_obj_property.c... +compiling lftpd_inet.c... +compiling gd5f2gq5ue.c... +compiling nand_ftl.c... +compiling ch395f.c... +compiling ff.c... +compiling stm32f4xx_hal_spi.c... compiling lftpd.c... -compiling test_config.c... +compiling lv_obj_class.c... +compiling lv_group.c... +compiling lv_obj_id_builtin.c... +compiling lv_obj_event.c... +compiling lv_obj_draw.c... +compiling lv_obj.c... compiling net_socket.c... -compiling ch395f_test_task.c... +compiling lv_obj_property.c... +compiling stm32f4xx_hal_i2c.c... compiling lv_draw_3d.c... -compiling gd5f_test_task.c... -compiling net_test_task.c... -compiling lv_obj_scroll.c... -compiling storage_test_task.c... -compiling lv_obj_tree.c... -compiling cmsis_os2.c... -compiling lv_draw_line.c... -compiling lv_draw_arc.c... -compiling sd2506_test_task.c... +compiling lv_obj_pos.c... compiling lv_obj_style_gen.c... -compiling lv_draw_mask.c... -compiling lv_draw_image.c... +compiling lv_obj_tree.c... +compiling lv_obj_scroll.c... compiling lv_draw.c... compiling lv_obj_style.c... -compiling lv_draw_vector.c... -compiling lv_draw_buf.c... +compiling lv_draw_arc.c... +compiling lv_draw_mask.c... +compiling lv_refr.c... +compiling lv_draw_line.c... +compiling lv_draw_image.c... +compiling lv_display.c... compiling lv_draw_triangle.c... +compiling lv_draw_buf.c... compiling lv_draw_rect.c... compiling lv_draw_label.c... -compiling lv_refr.c... -compiling lv_display.c... -compiling lv_image_decoder.c... +compiling lv_draw_vector.c... compiling lv_draw_sw_blend.c... +compiling lv_image_decoder.c... compiling lv_draw_sw_blend_to_al88.c... compiling lv_draw_sw_grad.c... compiling lv_draw_sw_arc.c... +compiling lv_draw_sw.c... +compiling lv_draw_sw_blend_to_argb8888_premultiplied.c... compiling lv_draw_sw_border.c... compiling lv_draw_sw_fill.c... -compiling lv_draw_sw_blend_to_argb8888_premultiplied.c... compiling lv_draw_sw_letter.c... -compiling lv_draw_sw.c... -compiling lv_draw_sw_mask_rect.c... -compiling lv_draw_sw_blend_to_argb8888.c... -compiling lv_draw_sw_line.c... compiling lv_draw_sw_blend_to_l8.c... -compiling lv_draw_sw_vector.c... +compiling lv_draw_sw_blend_to_argb8888.c... +compiling lv_draw_sw_blend_to_i1.c... +compiling lv_draw_sw_blend_to_rgb888.c... compiling lv_draw_sw_box_shadow.c... +compiling lv_draw_sw_img.c... +compiling lv_draw_sw_line.c... +compiling lv_draw_sw_blend_to_rgb565.c... +compiling lv_draw_sw_mask_rect.c... +compiling lv_draw_sw_blend_to_rgb565_swapped.c... +compiling cmsis_os2.c... +compiling lv_draw_sw_vector.c... compiling lv_draw_sw_triangle.c... compiling lv_draw_sw_utils.c... -compiling lv_draw_sw_img.c... -compiling lv_draw_sw_blend_to_rgb888.c... -compiling lv_draw_sw_blend_to_i1.c... compiling lv_font.c... compiling lv_draw_sw_mask.c... -compiling lv_draw_sw_blend_to_rgb565.c... -compiling lv_draw_sw_blend_to_rgb565_swapped.c... -compiling lv_font_dejavu_16_persian_hebrew.c... +compiling gd5f_test_task.c... +compiling test_config.c... compiling lv_binfont_loader.c... compiling lv_draw_sw_transform.c... +compiling lv_font_dejavu_16_persian_hebrew.c... +compiling ch395f_test_task.c... +compiling net_test_task.c... compiling lv_font_fmt_txt.c... compiling lv_font_montserrat_10.c... compiling lv_font_montserrat_12.c... compiling lv_font_montserrat_14.c... +compiling storage_test_task.c... +compiling lv_font_montserrat_14_aligned.c... compiling lv_font_montserrat_16.c... compiling lv_font_montserrat_18.c... +compiling sd2506_test_task.c... compiling lv_font_montserrat_20.c... -compiling lv_font_montserrat_14_aligned.c... compiling lv_font_montserrat_22.c... compiling lv_font_montserrat_24.c... +compiling lv_font_montserrat_28_compressed.c... compiling lv_font_montserrat_26.c... compiling lv_font_montserrat_28.c... -compiling lv_font_montserrat_28_compressed.c... compiling lv_font_montserrat_30.c... -compiling lv_font_montserrat_32.c... compiling lv_font_montserrat_34.c... +compiling lv_font_montserrat_32.c... compiling lv_font_montserrat_36.c... compiling lv_font_montserrat_38.c... compiling lv_font_montserrat_40.c... compiling lv_font_montserrat_42.c... -compiling lv_font_montserrat_44.c... compiling lv_font_montserrat_46.c... +compiling lv_font_montserrat_44.c... compiling lv_font_montserrat_48.c... +compiling lv_indev_gesture.c... compiling lv_font_montserrat_8.c... compiling lv_font_simsun_14_cjk.c... -compiling lv_font_simsun_16_cjk.c... -compiling lv_indev_gesture.c... -compiling lv_font_source_han_sans_sc_14_cjk.c... compiling lv_font_unscii_16.c... +compiling lv_font_source_han_sans_sc_14_cjk.c... +compiling lv_font_simsun_16_cjk.c... compiling lv_font_source_han_sans_sc_16_cjk.c... compiling lv_font_unscii_8.c... -compiling lv_cache_lru_ll.c... compiling lv_indev_scroll.c... -compiling lv_layout.c... +compiling lv_cache_lru_ll.c... compiling lv_cache_lru_rb.c... -compiling lv_cache_entry.c... -compiling lv_cache.c... -compiling lv_array.c... -compiling lv_async.c... -compiling lv_indev.c... -compiling lv_init.c... -compiling lv_grid.c... -compiling lv_anim_timeline.c... -compiling lv_image_header_cache.c... +compiling lv_layout.c... compiling lv_flex.c... +compiling lv_init.c... +compiling lv_cache.c... +compiling lv_indev.c... compiling lv_image_cache.c... -compiling lv_bidi.c... +compiling lv_grid.c... +compiling lv_cache_entry.c... compiling lv_bin_decoder.c... -compiling lv_circle_buf.c... +compiling lv_image_header_cache.c... +compiling lv_anim_timeline.c... +compiling lv_array.c... compiling lv_anim.c... -compiling lv_area.c... +compiling lv_async.c... +compiling lv_bidi.c... +compiling lv_circle_buf.c... compiling lv_color_op.c... -compiling lv_color.c... compiling lv_grad.c... +compiling lv_color.c... compiling lv_iter.c... compiling lv_ll.c... compiling lv_log.c... +compiling lv_area.c... compiling lv_event.c... -compiling lv_fs.c... compiling lv_lru.c... +compiling lv_fs.c... compiling lv_matrix.c... compiling lv_palette.c... +compiling lv_math.c... compiling lv_templ.c... compiling lv_rb.c... -compiling lv_math.c... -compiling lv_text_ap.c... compiling lv_tree.c... -compiling lv_style.c... -compiling lv_utils.c... +compiling lv_text_ap.c... compiling lv_cmsis_rtos2.c... -compiling lv_style_gen.c... -compiling lv_profiler_builtin.c... -compiling lv_text.c... -compiling lv_timer.c... compiling lv_freertos.c... +compiling lv_utils.c... compiling lv_linux.c... compiling lv_mqx.c... +compiling lv_style_gen.c... +compiling lv_text.c... +compiling lv_style.c... compiling lv_os_none.c... +compiling lv_profiler_builtin.c... +compiling lv_timer.c... compiling lv_pthread.c... +compiling lv_os.c... compiling lv_rtthread.c... compiling lv_sdl2.c... compiling lv_windows.c... -compiling lv_os.c... -compiling lv_tlsf.c... -compiling lv_mem_core_builtin.c... compiling lv_mem_core_clib.c... -compiling lv_string_clib.c... -compiling lv_sprintf_builtin.c... compiling lv_sprintf_clib.c... compiling lv_string_builtin.c... -compiling lv_mem_core_rtthread.c... +compiling lv_string_clib.c... compiling lv_mem_core_micropython.c... -compiling lv_string_rtthread.c... +compiling lv_mem_core_builtin.c... +compiling lv_mem_core_rtthread.c... +compiling lv_sprintf_builtin.c... compiling lv_sprintf_rtthread.c... +compiling lv_string_rtthread.c... +compiling lv_tlsf.c... compiling lv_mem_core_uefi.c... compiling lv_mem.c... compiling lv_3dtexture.c... compiling lv_theme_default.c... +compiling lv_theme.c... compiling lv_tick.c... compiling lv_animimage.c... -compiling lv_theme.c... compiling lv_arc.c... compiling lv_button.c... -compiling lv_theme_simple.c... -compiling lv_theme_mono.c... -compiling lv_bar.c... -compiling lv_calendar_header_arrow.c... compiling lv_calendar_chinese.c... +compiling lv_calendar_header_arrow.c... compiling lv_calendar_header_dropdown.c... -compiling lv_buttonmatrix.c... +compiling lv_theme_mono.c... +compiling lv_theme_simple.c... compiling lv_canvas.c... +compiling lv_bar.c... compiling lv_chart.c... -compiling lv_calendar.c... compiling lv_checkbox.c... +compiling lv_calendar.c... compiling lv_dropdown.c... +compiling lv_buttonmatrix.c... compiling lv_keyboard.c... compiling lv_led.c... compiling lv_imagebutton.c... -compiling lv_lottie.c... compiling lv_line.c... compiling lv_list.c... +compiling lv_lottie.c... +compiling lv_image.c... +compiling lv_label.c... compiling lv_objx_templ.c... compiling lv_dropdown_properties.c... -compiling lv_image.c... compiling lv_msgbox.c... -compiling lv_label.c... -compiling lv_image_properties.c... -compiling lv_animimage_properties.c... compiling lv_menu.c... -compiling lv_keyboard_properties.c... -compiling lv_label_properties.c... -compiling lv_obj_properties.c... -compiling lv_roller_properties.c... +compiling lv_animimage_properties.c... compiling lv_style_properties.c... +compiling lv_keyboard_properties.c... +compiling lv_image_properties.c... +compiling lv_roller_properties.c... +compiling lv_obj_properties.c... compiling lv_slider_properties.c... +compiling lv_label_properties.c... compiling lv_textarea_properties.c... compiling lv_roller.c... compiling lv_scale.c... compiling lv_slider.c... -compiling lv_span.c... compiling lv_spinbox.c... +compiling lv_span.c... compiling lv_switch.c... compiling lv_table.c... compiling lv_spinner.c... -compiling lv_tileview.c... compiling ui_net_sink.c... +compiling lv_tileview.c... compiling lv_tabview.c... compiling lv_win.c... +compiling ui_font_cn_12.c... compiling ui_port.c... compiling ui_menu.c... compiling lv_textarea.c... linking... -Program Size: Code=212836 RO-data=17612 RW-data=440 ZI-data=106204 +Program Size: Code=212836 RO-data=9684 RW-data=440 ZI-data=106204 FromELF: creating hex file... ".\STM32F407-Demo\STM32F407-Demo.axf" - 0 Error(s), 0 Warning(s). -Build Time Elapsed: 00:00:22 +Build Time Elapsed: 00:00:20 diff --git a/docs/UI_中文字体生成与配置.md b/docs/UI_中文字体生成与配置.md new file mode 100644 index 00000000..66b8982a --- /dev/null +++ b/docs/UI_中文字体生成与配置.md @@ -0,0 +1,152 @@ +# UI 中文字体生成与配置 + +> **适用范围**:STM32F4-Base 远程单色屏(160×160,1bpp,`LV_COLOR_FORMAT_I1`)的 LVGL 中文显示。 +> **目标**:把工程实际用到的汉字生成**子集化 1bpp 位图字体**,挂到 `LV_FONT_DEFAULT`,使菜单/标签正常显示中文并推流到客户端。 + +--- + +## 1. 背景 + +- LVGL 内置字体(Montserrat 等)**不含中文**;`LV_FONT_SIMSUN_16_CJK` 等全字库体积过大,不适合 160×160 小屏。 +- 本工程显示是 **1bpp 单色**:像素 1=亮(白)/0=暗(黑),与客户端 `mono_to_png` 的 `1→白` 语义一致。 +- 方案:用 `lv_font_conv` 把系统中文字体(**宋体 SimSun**)按"实际用到的汉字 + ASCII"子集,生成 1bpp 的 LVGL 字体 `.c`。 + +生成产物:`Drivers/BSP/UI/ui_font_cn_12.c`(变量名 `ui_font_cn_12`)。 + +--- + +## 2. 工具准备 + +### 2.1 工具与环境确认 + +| 工具 | 用途 | 安装 | +|------|------|------| +| Node.js (≥ v14) | 运行 `lv_font_conv` | 已具备 | +| `lv_font_conv` | TTF/OTF → LVGL 字体 `.c`(官方离线转换器) | `npm i -g lv_font_conv` | +| Python `fontTools` | `make_font.py` 读取 `.ttc` 集合时抽取单字重(仅在字库为 `.ttc` 时需要) | `pip install fonttools` | + +安装完成后验证可用:`lv_font_conv -h` 能打印用法即成功。 + +--- + +## 3. 提取字符集(只取会显示的汉字) + +已落库脚本 `tools/font_gen/extract_cn.py`:扫描 `Drivers/BSP/UI/*.c/.h` 与 `App/task/ui_task.c/.h` 中**字符串字面量**里的非 ASCII 字符,跳过 `/* */`、`//` 注释与字符常量(避免把注释里的汉字也打进字体、徒增体积),输出 `<仓库根>/ui_cn_chars.txt`。脚本自动定位仓库根,可在任意目录运行。 + +**执行命令(在仓库根目录):** + +```bash +python tools/font_gen/extract_cn.py +``` + +输出示例: + +``` +scanned 9 files; unique non-ASCII chars: 83 +-> D:\Code\DTU 程序\STM32F4-Base\ui_cn_chars.txt +``` + +产物 `ui_cn_chars.txt` 为本工程实际显示的汉字清单(当前 83 字),可留作字符集记录。 + +--- + +## 4. 生成字体 + +已落库脚本 `tools/font_gen/make_font.py`:自动定位 `lv_font_conv`(全局安装或 PATH)、自动处理宋体 `.ttc` 的 face0 抽取,直接生成 `Drivers/BSP/UI/ui_font_cn_12.c`。 + +**前置依赖(仅需一次):** + +```bash +npm i -g lv_font_conv # TTF/OTF -> LVGL 字体 离线转换器 +pip install fonttools # 仅当使用 .ttc 集合字体(如宋体)时需要 +``` + +> 若 `npm i -g lv_font_conv` 报代理错误,先清代理:`npm config delete proxy` / `npm config delete https-proxy`。 + +**执行命令(在仓库根目录):** + +```bash +python tools/font_gen/make_font.py # 默认:宋体, 12px, 1bpp +python tools/font_gen/make_font.py --bpp 2 # 宋体细笔画发虚时改用 2bpp +python tools/font_gen/make_font.py --font C:/path/to/font.ttf # 换其他字体 +``` + +输出示例: + +``` +extracted SimSun regular (face0) -> C:\Users\...\Temp\simsun_regular.ttf +RUN: lv_font_conv.cmd --font ... --size 12 --bpp 1 -r 0x20-0x7E --symbols ... --no-compress --format lvgl --lv-font-name ui_font_cn_12 -o ...\ui_font_cn_12.c +OK 36393 bytes -> ...\Drivers\BSP\UI\ui_font_cn_12.c +``` + +参数说明: +- `--bpp 1`:单色无抗锯齿;体积最小。**注意** lv_font_conv 在 1bpp 下斜线/细笔画偶发"丢像素",宋体尤甚。 +- `--bpp 2/3`:字形带灰度,渲染到 1bpp 屏时按 `LV_DRAW_SW_I1_LUM_THRESHOLD` 阈值化,笔画更连贯;子集仅几十~上百字,体积仍很小。 +- `--no-compress`:关闭内置压缩,规避 `LV_FONT_COMPRESSED` 未启用导致的兼容问题。 +- `--lv-font-name ui_font_cn_12`:生成的 `lv_font_t` 变量名,须与下面 `LV_FONT_DECLARE` 一致。 + +--- + +## 5. 配置接入 + +### 5.1 声明与设为默认字体(`Lib/lv_conf.h`) + +该文件当前为 **UTF-8(带 BOM)**。历史上它曾为 GBK,且工作区版本因某次整文件文本重写导致中文注释被 `U+FFFD` 不可逆损坏(`HEAD` 中的 GBK 版本仍干净)。 + +> **损坏恢复**:若二次损坏,不要用整文件文本重写。正确做法: +> `git show HEAD:Lib/lv_conf.h` 以 `gbk` 解码得到干净中文 → 叠加第 5.1 节的字体配置改动 → 重新写为 `utf-8-sig`(UTF-8 带 BOM)。这样中文可完整恢复,不会引入 `U+FFFD`。 + +```c +/* 自定义中文 1bpp 字体:由 lv_font_conv 生成(ASCII + 本工程所需汉字子集) */ +#define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(ui_font_cn_12) + +/* 默认字体:中文 1bpp 子集字体(已含 ASCII),菜单/标签均使用它 */ +#define LV_FONT_DEFAULT &ui_font_cn_12 +``` + +> 字体 `.c` 自身通过 `#ifndef UI_FONT_CN_12` 自包含,编译进工程即生效;无需额外 `#include`。 + +### 5.2 加入 Keil 工程 + +`MDK-ARM/STM32F407-Demo.uvprojx` 的 `Drivers/BSP/UI` 组追加(纯 ASCII 插入): + +```xml + + ui_font_cn_12.c + 1 + ..\Drivers\BSP\UI\ui_font_cn_12.c + +``` + +--- + +## 6. 编译验证 + +```bash +@build # 即 MDK-ARM\build.bat,调用 UV4 全量重建 +``` + +要求:`0 Error(s), 0 Warning(s)`。重新生成/修改字体或 `lv_conf.h` 后务必重建验证。当前已验证通过,`ui_font_cn_12.c` 正常编入。 + +--- + +## 7. 注意事项 + +1. **1bpp 细笔画发虚**:宋体在 1bpp 下可能丢像素。若上板/客户端中文偏淡,把第 4 节 `--bpp` 改为 `2` 重生成即可(子集小,体积可接受)。 +2. **字符集变更**:以后新增中文菜单项,须重跑第 3、4 节(重新提取 `ui_cn_chars.txt` 并生成),否则新字显示为方框。 +3. **编码**:UI 源文件须为 **UTF-8(带 BOM)**,LVGL 按 UTF-8 解码中文串;字体 `.c` 为纯 ASCII,无编码风险。当前 Keil 已加 Misc Controls 抑制项,无需额外 `--locale=english`。 +4. **字体体积**:12px + 1bpp + ~83 字 ≈ 36KB(RO-data);改 bpp 2 约翻倍,仍在 F407 Flash 余量内。 +5. **换字体**:黑体用 `simhei.ttf`(单文件免抽取);其余字体同理替换 `--font` 路径后重生成。 + +--- + +## 8. 文件清单 + +| 文件 | 说明 | +|------|------| +| `Drivers/BSP/UI/ui_font_cn_12.c` | 生成的中文 1bpp 字体(变量 `ui_font_cn_12`) | +| `Lib/lv_conf.h` | 字体声明与默认字体配置 | +| `MDK-ARM/STM32F407-Demo.uvprojx` | UI 组包含该字体 `.c` | +| `ui_cn_chars.txt`(工程根) | 实际显示汉字清单记录(可删) | +| `tools/font_gen/extract_cn.py` | 提取字符集脚本(见第 3 节) | +| `tools/font_gen/make_font.py` | 生成字体脚本,自动定位 lv_font_conv 并处理 `.ttc`(见第 4 节) | diff --git a/docs/UI_图形界面实施规划.md b/docs/UI_图形界面实施规划.md index 24ae737f..9da71b0c 100644 --- a/docs/UI_图形界面实施规划.md +++ b/docs/UI_图形界面实施规划.md @@ -21,7 +21,7 @@ | 源码规范 | 中文注释;新增 .c/.h 需手动加入 Keil 工程;禁止整文件文本重写 | ### 关键推论 -- 我们目标 **1bpp**:整帧 = 160×160÷8 = **3200 字节(3.1KB)**,直接整帧作绘制缓冲。 +- 我们目标 **1bpp**:整帧 = 160×160÷8 = **3200 字节(3.1KB)**,直接整帧作绘制缓冲。git - 参考项目 `key.h` 已有 `g_tRemoteKey`(`bUseRkey` 远程按键)→ ✅ 菜单导航由远端发键值驱动(双向交互已定)。 - 参考项目 `def.h`:✅ 中文 12px、行高 14px、可视约 11 行。 @@ -197,8 +197,3 @@ - [x] J 库(LVGL v9 1bpp) - [x] L 持久化(不需) - [x] M 异常(掉线暂停+软看门狗) - -### ⚠️ 仍需你最后确认的一点(影响 RAM 与客户端兼容) -- **像素深度取舍**:默认按 **1bpp(3200B)** 实施(守"少占用 RAM"),远端客户端据 INIT 的 `memsize` 推导为 1bpp。若你坚持**字节级兼容旧 `remo_disp_server.py`(8bpp/25600B)**,请告知——那将多占约 22KB RAM,与本目标冲突,需你权衡。 - -> 上述像素深度确认后(默认 1bpp 即无需回复),我将把第 4 节架构落成代码骨架(阶段 1–2),并开始 `@build` 验证。 diff --git a/tools/font_gen/extract_cn.py b/tools/font_gen/extract_cn.py new file mode 100644 index 00000000..86fa9b04 --- /dev/null +++ b/tools/font_gen/extract_cn.py @@ -0,0 +1,95 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""提取工程 UI 源码中字符串字面量里的非 ASCII 字符(实际显示的汉字), +输出 <仓库根>/ui_cn_chars.txt,供 make_font.py 生成中文字体子集。 + +用法(在仓库根目录执行,或任意目录均可,脚本自动定位仓库根): + python tools/font_gen/extract_cn.py +""" +import os +import glob + +ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +UI_DIR = os.path.join(ROOT, 'Drivers', 'BSP', 'UI') +TASK_DIR = os.path.join(ROOT, 'App', 'task') +SCAN = (glob.glob(os.path.join(UI_DIR, '*.c')) + + glob.glob(os.path.join(UI_DIR, '*.h')) + + [os.path.join(TASK_DIR, 'ui_task.c'), os.path.join(TASK_DIR, 'ui_task.h')]) + + +def collect(text): + """跳过 /* */ 与 // 注释、字符常量,只收集双引号字符串内的非 ASCII 字符。""" + out, i, n = set(), 0, len(text) + blk = line = sstr = cchr = False + while i < n: + c = text[i] + nx = text[i + 1] if i + 1 < n else '' + if blk: + if c == '*' and nx == '/': + blk = False + i += 2 + continue + i += 1 + continue + if line: + if c == '\n': + line = False + i += 1 + continue + if sstr: + if c == '\\': + i += 2 + continue + if c == '"': + sstr = False + i += 1 + continue + if ord(c) > 0x7F: + out.add(c) + i += 1 + continue + if cchr: + if c == '\\': + i += 2 + continue + if c == "'": + cchr = False + i += 1 + continue + if c == '/' and nx == '*': + blk = True + i += 2 + continue + if c == '/' and nx == '/': + line = True + i += 2 + continue + if c == '"': + sstr = True + i += 1 + continue + if c == "'": + cchr = True + i += 1 + continue + i += 1 + return out + + +def main(): + chars = set() + for f in SCAN: + if not os.path.exists(f): + print(' skip (not found):', os.path.relpath(f, ROOT)) + continue + chars |= collect(open(f, encoding='utf-8-sig', errors='ignore').read()) + s = ''.join(sorted(chars)) + out_path = os.path.join(ROOT, 'ui_cn_chars.txt') + with open(out_path, 'w', encoding='utf-8') as fp: + fp.write(s) + print('scanned %d files; unique non-ASCII chars: %d' % (len(SCAN), len(s))) + print('->', out_path) + + +if __name__ == '__main__': + main() diff --git a/tools/font_gen/make_font.py b/tools/font_gen/make_font.py new file mode 100644 index 00000000..03d2d794 --- /dev/null +++ b/tools/font_gen/make_font.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""生成中文子集位图字体 ui_font_cn_12.c(LVGL 格式,输出到 Drivers/BSP/UI/)。 + +前置依赖: + npm i -g lv_font_conv # 离线 TTF/OTF -> LVGL 字体 转换器 + pip install fonttools # 仅当字体源是 .ttc 集合时需要(用于抽取单字重) + +用法: + python tools/font_gen/make_font.py # 默认:宋体, 12px, 1bpp + python tools/font_gen/make_font.py --bpp 2 # 宋体细笔画发虚时改用 2bpp + python tools/font_gen/make_font.py --font C:/path/to/font.ttf +""" +import os +import sys +import argparse +import tempfile +import subprocess + +ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +OUT = os.path.join(ROOT, 'Drivers', 'BSP', 'UI', 'ui_font_cn_12.c') +CHARS_FILE = os.path.join(ROOT, 'ui_cn_chars.txt') +FONT_NAME = 'ui_font_cn_12' + + +def resolve_lv_font_conv(): + # 1) 全局 node 模块路径(npm i -g) + try: + groot = subprocess.check_output(['npm', 'root', '-g'], text=True).strip() + p = os.path.join(groot, 'lv_font_conv', 'lv_font_conv.js') + if os.path.exists(p): + return ['node', p] + except Exception: + pass + # 2) PATH 上的可执行 + for cmd in ('lv_font_conv.cmd', 'lv_font_conv'): + if subprocess.run(['where', cmd], capture_output=True, shell=True).returncode == 0: + return [cmd] + sys.exit('ERROR: 找不到 lv_font_conv。请先执行: npm i -g lv_font_conv') + + +def resolve_font(path): + if path: + if not os.path.exists(path): + sys.exit('ERROR: --font 指定的文件不存在: ' + path) + return path + # 默认字体:Windows 宋体集合 simsun.ttc(lv_font_conv 不支持 .ttc,需先抽取 face0) + ttc = r'C:\Windows\Fonts\simsun.ttc' + if os.path.exists(ttc): + try: + from fontTools.ttLib import TTCollection + coll = TTCollection(ttc) + tmp = os.path.join(tempfile.gettempdir(), 'simsun_regular.ttf') + coll.fonts[0].save(tmp) + print('extracted SimSun regular (face0) ->', tmp) + return tmp + except Exception as e: + sys.exit('ERROR: 抽取 simsun.ttc 失败,请 pip install fonttools,或用 --font 指定 ttf: ' + str(e)) + sys.exit('ERROR: 未找到 C:\\Windows\\Fonts\\simsun.ttc,请用 --font 指定字体 ttf/otf 路径') + + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument('--bpp', type=int, default=1, help='字体位深 1/2/3(默认 1)') + ap.add_argument('--size', type=int, default=12, help='字号(默认 12)') + ap.add_argument('--font', default=None, help='自定义字体 ttf/otf 路径(默认宋体)') + args = ap.parse_args() + + if not os.path.exists(CHARS_FILE): + sys.exit('ERROR: 请先运行 extract_cn.py 生成 ui_cn_chars.txt') + + chars = open(CHARS_FILE, encoding='utf-8').read().strip() + cmd = resolve_lv_font_conv() + font = resolve_font(args.font) + cmd += ['--font', font, + '--size', str(args.size), + '--bpp', str(args.bpp), + '-r', '0x20-0x7E', # 含 ASCII,使字体自包含 + '--symbols', chars, # 本工程实际显示的汉字子集 + '--no-compress', # 关闭 RLE 压缩,保证兼容 + '--format', 'lvgl', + '--lv-font-name', FONT_NAME, + '-o', OUT] + + print('RUN:', ' '.join(cmd)) + r = subprocess.run(cmd) + if r.returncode != 0: + sys.exit('FAILED rc=%d' % r.returncode) + print('OK %d bytes -> %s' % (os.path.getsize(OUT), OUT)) + + +if __name__ == '__main__': + main() diff --git a/ui_cn_chars.txt b/ui_cn_chars.txt new file mode 100644 index 00000000..786bd31b --- /dev/null +++ b/ui_cn_chars.txt @@ -0,0 +1 @@ +主事交件位作信值元入全出制功动占厂压参双变号告复字定实家开强归录恢息手护据操故数时显未本查检波流测版现电界直看示系络维网置能自节装警认讯记设询调通遥部配量间零面默() \ No newline at end of file