V1.5: 恢复OLED防烧屏像素偏移并修复左侧残留(移位前先清腾空列)
This commit is contained in:
parent
af4e4efdc4
commit
ebc1ca5255
|
|
@ -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, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -200,3 +200,4 @@
|
|||
- 485 接收架构重写为 DMA+IDLE(DMA1_Channel6 + 空闲中断定帧,与 4G/WiFi 同架构):
|
||||
根治字节中断+软件超时方案的丢帧/停摆问题;实测秒回/慢回全部一次成功。
|
||||
过程:DWT 硬件观察点抓到合法写点无误,定位为原中断接收路径在特定时序下字节丢失
|
||||
- 恢复 OLED 防烧屏像素偏移(每10s 右移 0/2/4px),并修复左侧残留(移位前先写空格清腾空列)
|
||||
|
|
|
|||
Loading…
Reference in New Issue