git-subtree-dir: sdk git-subtree-mainline:17a972d46fgit-subtree-split:2e7561d74f
52 lines
2.0 KiB
C
52 lines
2.0 KiB
C
/* render_sb_statusbar.c — 宿主可视化渲染:把「同一个状态栏」画进 back_buf 并 dump PPM 目检。
|
|
* 仅用于宿主验证(无 /dev/fb0 → 480x720 离屏;字体缺失时图标仍画,数值可能缺字)。
|
|
* 编译(宿主 gcc):
|
|
* gcc -o render_sb_statusbar render_sb_statusbar.c meow_ui_gfx.c meow_ui_sys.c meow_ui_theme.c \
|
|
* meow_ui_vol.c meow_ui_log.c /tmp/meow_font_host.o -I. -I../meow_launcherd -lz
|
|
*/
|
|
#include "meow_ui.h"
|
|
#include "meow_ui_internal.h"
|
|
#include "meow_ui_sys.h"
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
(void)argc;
|
|
meow_ui_opts o = { 480, 720 };
|
|
if (meow_ui_init(&o) != 0) { printf("init failed\n"); return 1; }
|
|
meow_ui_sys_set_system_mode(1);
|
|
meow_ui_set_statusbar(1);
|
|
|
|
/* 喂权威快照(模拟 launcher):电量81/充电/音量60/蓝牙连/WiFi已连-50(强)/亮度100 */
|
|
meow_ui_feed f;
|
|
memset(&f, 0, sizeof f);
|
|
f.batt = 81; f.charging = 1; f.wifi_on = 1; f.wifi_connected = 1; f.wifi_level = -50;
|
|
f.bt_seen = 1; f.bt_on = 1; f.vol = 60; f.brightness = 100;
|
|
meow_ui_sys_feed(&f);
|
|
|
|
/* 清整屏(背景)→ 画状态栏 → 把 top 28 行 + 一点内容区 dump 成 PPM */
|
|
meow_ui_clear(0x141824);
|
|
meow_ui_sys_statusbar_render();
|
|
|
|
const char *path = argv[1] ? argv[1] : "/tmp/sb_statusbar.ppm";
|
|
FILE *fp = fopen(path, "wb");
|
|
if (!fp) { printf("cannot open %s\n", path); return 1; }
|
|
int w = 480, h = 480; /* 宽 x 全屏高,看顶条+背景 */
|
|
fprintf(fp, "P6\n%d %d\n255\n", w, h);
|
|
unsigned char *bb = meow_ui_back_buf();
|
|
for (int ry = 0; ry < h; ry++) {
|
|
for (int cx = 0; cx < w; cx++) {
|
|
uint16_t p = *(uint16_t *)(bb + (size_t)ry * (size_t)(w * 2) + (size_t)cx * 2);
|
|
int r = ((p >> 11) & 0x1F) << 3;
|
|
int g = ((p >> 5) & 0x3F) << 2;
|
|
int b = (p & 0x1F) << 3;
|
|
fputc(r, fp); fputc(g, fp); fputc(b, fp);
|
|
}
|
|
}
|
|
fclose(fp);
|
|
printf("wrote %s (%dx%d)\n", path, w, h);
|
|
return 0;
|
|
}
|