WIP checkpoint (M2.53→M2.54 工作区): 字体归MeowOS/fonts+SDK跟随+多字体(进行中)+boot板载+状态栏28+亮度/音量修复+文档刷新
This commit is contained in:
1 parent
245bee2946
commit
064635b3c4
44 files changed
+2834
-308
No files matched your search
+15
-18
@@ -14,6 +14,7 @@
|
||||
*/
|
||||
#include "meow_ui_sys.h"
|
||||
#include "meow_ui_internal.h"
|
||||
#include "meow_ui_vol.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -23,7 +24,6 @@
|
||||
#include <time.h>
|
||||
|
||||
#define MEOW_SETTINGS_FILE "/usr/data/meow/settings.conf"
|
||||
#define VOL_DEFAULT 60
|
||||
|
||||
/* 蓝牙 powered 缓存刷新间隔(hciconfig 较贵) */
|
||||
#define BT_REFRESH_MS 30000
|
||||
@@ -80,22 +80,15 @@ static int hci_powered(void)
|
||||
return up;
|
||||
}
|
||||
|
||||
/* 音量:读 settings.conf 的 audio.volume(launcher 同源,watchdog 写同文件)。 */
|
||||
/* 音量:读 settings.conf 的 audio.volume(launcher 同源,watchdog 写同文件)。
|
||||
* 与 launcher 口径一致:0-100,且尊重 audio.volume_max 上限 clamp(vol_clamp 同义)。
|
||||
* 注意 settings 落盘为 "key = value"(带空格),必须按 '=' 切分解析,不能朴素前缀匹配——
|
||||
* 否则永远读不到(回退默认 60,即「状态栏音量数字不对、卡在 60」的根因)。 */
|
||||
static int settings_vol(void)
|
||||
{
|
||||
FILE *f = fopen(MEOW_SETTINGS_FILE, "r");
|
||||
if (!f) return VOL_DEFAULT;
|
||||
int vol = VOL_DEFAULT;
|
||||
char buf[128];
|
||||
while (fgets(buf, sizeof buf, f)) {
|
||||
if (!strncmp(buf, "audio.volume=", 13)) {
|
||||
int v = atoi(buf + 13);
|
||||
if (v >= 0 && v <= 100) vol = v;
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
return vol;
|
||||
int vol = meow_ui_vol_read(MEOW_SETTINGS_FILE, "audio.volume", MEOW_UI_VOL_DEFAULT);
|
||||
int vol_max = meow_ui_vol_read(MEOW_SETTINGS_FILE, "audio.volume_max", MEOW_UI_VOL_MAX_DEF);
|
||||
return meow_ui_vol_clamp(vol, vol_max);
|
||||
}
|
||||
|
||||
int meow_ui_sys_init(void)
|
||||
@@ -210,21 +203,25 @@ void meow_ui_sys_statusbar_render(void)
|
||||
/* 整条清底:覆盖 app 可能画进顶行的内容(z 最顶) */
|
||||
meow_ui_fill_rect(0, 0, w, h, th->bg);
|
||||
|
||||
/* 文字垂直锚 y:(栏高-行高)/2 居中;下限 1 防极端行高 > 栏高时负 y 溢出顶端(不越界优先)。 */
|
||||
int ty = (h - meow_ui_text_height(MUI_SBAR_FONT)) / 2;
|
||||
if (ty < 1) ty = 1;
|
||||
|
||||
/* 时钟(左):每秒现取 localtime */
|
||||
char timebuf[16];
|
||||
time_t t = time(NULL);
|
||||
struct tm tm;
|
||||
localtime_r(&t, &tm);
|
||||
snprintf(timebuf, sizeof timebuf, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, tm.tm_sec);
|
||||
meow_ui_text(8, (h - meow_ui_text_height(MUI_SBAR_FONT)) / 2, timebuf, MUI_SBAR_FONT, th->fg);
|
||||
meow_ui_text(8, ty, timebuf, MUI_SBAR_FONT, th->fg);
|
||||
|
||||
/* 右侧信息串:batt% WIFI 蓝牙 VOL nn% */
|
||||
char right[96];
|
||||
statusbar_right_str(right, sizeof right);
|
||||
if (right[0])
|
||||
meow_ui_text_right(w - 8, (h - meow_ui_text_height(MUI_SBAR_FONT)) / 2, right, MUI_SBAR_FONT, th->fg);
|
||||
meow_ui_text_right(w - 8, ty, right, MUI_SBAR_FONT, th->fg);
|
||||
|
||||
/* 分隔线(栏内最底 1px,主题次要色);内容 inset=statusbar_height()=40 从 y=40 起即干净 */
|
||||
/* 分隔线(栏内最底 1px,主题次要色);内容 inset=statusbar_height()=28 从 y=28 起即干净 */
|
||||
meow_ui_fill_rect(0, h - 1, w, 1, th->dim);
|
||||
|
||||
g_statusbar_force = 0;
|
||||
|
||||
Reference in new issue
Block a user