diff --git a/V1.5/STM32F103_App1/HardWare/SYSINIT/app_loop.c b/V1.5/STM32F103_App1/HardWare/SYSINIT/app_loop.c index c431137..1091f44 100644 --- a/V1.5/STM32F103_App1/HardWare/SYSINIT/app_loop.c +++ b/V1.5/STM32F103_App1/HardWare/SYSINIT/app_loop.c @@ -244,9 +244,24 @@ void app_oled_presched_tick(void) oled_home_refresh(0); } +/* 写一整行(带防烧屏偏移):先写空格清掉左移腾出的列,再从偏移处写内容 */ +static void oled_row(uint8_t row, uint8_t xoff, const char *s) +{ + if (xoff) { + oled_locate(row, 0); + oled_print(" "); /* 清掉左侧腾出的列,防止残留 */ + oled_locate(row, 0); + } + oled_locate(row, 0); + oled_xoff(xoff); + oled_print_line(s); +} + static void oled_home_refresh(uint32_t up_ms) { char buf[24]; + /* 防烧屏:每 10s 换一档水平偏移(0/2/4px) */ + uint8_t xoff = (uint8_t)((HAL_GetTick() / 10000u) % 3u) * 2u; if (g_net_mqtt_ready) { /*---- 已联网界面 ----*/ @@ -257,19 +272,19 @@ static void oled_home_refresh(uint32_t up_ms) (unsigned)(mins / 1440u), (unsigned)((mins % 1440u) / 60u), (unsigned)(mins % 60u)); - oled_locate(0, 0); oled_print_line(buf); + oled_row(0, xoff, buf); /* R1/R2: 电能参数 */ if (hlw8032_online()) { snprintf(buf, sizeof(buf), "%.1fV %.2fA", (double)hlw8032_get_voltage_v(), (double)hlw8032_get_current_a()); - oled_locate(1, 0); oled_print_line(buf); + oled_row(1, xoff, buf); snprintf(buf, sizeof(buf), "%.1fW %.2fkWh", (double)hlw8032_get_power_w(), (double)hlw8032_get_energy_kwh()); - oled_locate(2, 0); oled_print_line(buf); + oled_row(2, xoff, buf); } else { - oled_locate(1, 0); oled_print_line("计量芯片离线"); - oled_locate(2, 0); oled_print_line(""); + oled_row(1, xoff, "计量芯片离线"); + oled_row(2, xoff, ""); } /* R3: 带秤模式显示重量(读不到显示原因),无秤模式显示开关状态 */ @@ -289,34 +304,34 @@ static void oled_home_refresh(uint32_t up_ms) } snprintf(buf, sizeof(buf), "重量:%s", reason); } - oled_locate(3, 0); oled_print_line(buf); + oled_row(3, xoff, buf); } else { snprintf(buf, sizeof(buf), "开关:%s%s%s%s", MqttInfoStr.Relay_State[1] ? "开" : "关", MqttInfoStr.Relay_State[2] ? "开" : "关", MqttInfoStr.Relay_State[3] ? "开" : "关", MqttInfoStr.Relay_State[4] ? "开" : "关"); - oled_locate(3, 0); oled_print_line(buf); + oled_row(3, xoff, buf); } } else { /*---- 未联网界面:联网进度 ----*/ net_ui_phase_t ph = g_net_ui_phase; - oled_locate(0, 0); oled_print_line("断网"); + oled_row(0, xoff, "断网"); if (ph == NET_UI_WIFI_FIXED || ph == NET_UI_WIFI_SMART || NET_GetActiveBackend() == NET_BACKEND_WIFI) { if (ph == NET_UI_WIFI_FIXED) { - oled_locate(1, 0); oled_print_line("WiFi固定模式"); - oled_locate(2, 0); oled_print_line("正在搜索热点"); + oled_row(1, xoff, "WiFi固定模式"); + oled_row(2, xoff, "正在搜索热点"); } else if (ph == NET_UI_WIFI_SMART) { - oled_locate(1, 0); oled_print_line("智能配网"); - oled_locate(2, 0); oled_print_line("请打开APP广播"); + oled_row(1, xoff, "智能配网"); + oled_row(2, xoff, "请打开APP广播"); } else { - oled_locate(1, 0); oled_print_line("WiFi模式"); - oled_locate(2, 0); oled_print_line("初始化中..."); + oled_row(1, xoff, "WiFi模式"); + oled_row(2, xoff, "初始化中..."); } snprintf(buf, sizeof(buf), "剩余 %ds", g_net_ui_countdown); - oled_locate(3, 0); oled_print_line(g_net_ui_countdown > 0 ? buf : ""); + oled_row(3, xoff, g_net_ui_countdown > 0 ? buf : ""); } else { /* 4G 进度:显示最近完成的阶段 */ const char *step = "初始化中"; @@ -329,9 +344,9 @@ static void oled_home_refresh(uint32_t up_ms) case NET_UI_4G_NOSIM: step = "无SIM卡!"; break; default: break; } - oled_locate(1, 0); oled_print_line("正在等待4G联网"); - oled_locate(2, 0); oled_print_line(step); - oled_locate(3, 0); oled_print_line(""); + oled_row(1, xoff, "正在等待4G联网"); + oled_row(2, xoff, step); + oled_row(3, xoff, ""); } } } diff --git a/V1.5/鐗堟湰璇存槑.md b/V1.5/鐗堟湰璇存槑.md index 8efc937..9634577 100644 --- a/V1.5/鐗堟湰璇存槑.md +++ b/V1.5/鐗堟湰璇存槑.md @@ -200,3 +200,4 @@ - 485 鎺ユ敹鏋舵瀯閲嶅啓涓 DMA+IDLE锛圖MA1_Channel6 + 绌洪棽涓柇瀹氬抚锛屼笌 4G/WiFi 鍚屾灦鏋勶級锛 鏍规不瀛楄妭涓柇+杞欢瓒呮椂鏂规鐨勪涪甯/鍋滄憜闂锛涘疄娴嬬鍥/鎱㈠洖鍏ㄩ儴涓娆℃垚鍔熴 杩囩▼锛欴WT 纭欢瑙傚療鐐规姄鍒板悎娉曞啓鐐规棤璇紝瀹氫綅涓哄師涓柇鎺ユ敹璺緞鍦ㄧ壒瀹氭椂搴忎笅瀛楄妭涓㈠け +- 鎭㈠ OLED 闃茬儳灞忓儚绱犲亸绉伙紙姣10s 鍙崇Щ 0/2/4px锛夛紝骞朵慨澶嶅乏渚ф畫鐣欙紙绉讳綅鍓嶅厛鍐欑┖鏍兼竻鑵剧┖鍒楋級