模拟器新增 RemoDispBus 推流服务端,修复远端取图
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <Windows.h>
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@@ -35,6 +36,7 @@
|
||||
#include "lvgl.h"
|
||||
#include "sim_port.h"
|
||||
#include "ui_menu.h"
|
||||
#include "ui_net_sink.h"
|
||||
#include "net_cfg.h"
|
||||
|
||||
/* 屏幕尺寸(与 MCU 端一致) */
|
||||
@@ -181,6 +183,12 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
/* 初始化 Winsock(供 ui_net_sink 使用) */
|
||||
#ifdef _MSC_VER
|
||||
WSADATA wsa;
|
||||
WSAStartup(MAKEWORD(2, 2), &wsa);
|
||||
#endif
|
||||
|
||||
/* 初始化 SDL2(仅 timer + events,视频由 lv_sdl_window 内部初始化) */
|
||||
if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_EVENTS) != 0) {
|
||||
fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError());
|
||||
@@ -213,6 +221,13 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* 启动 RemoDispBus TCP 监听(端口 7003,与 MCU 端一致) */
|
||||
if (ui_net_sink_start(7003) == 0) {
|
||||
printf("RemoDispBus server listening on port 7003\n");
|
||||
} else {
|
||||
fprintf(stderr, "ui_net_sink_start failed (port 7003)\n");
|
||||
}
|
||||
|
||||
printf("=== LVGL Simulator Started ===\n");
|
||||
printf("Screen: %dx%d 1bpp\n", SIM_SCREEN_W, SIM_SCREEN_H);
|
||||
printf("Keyboard: ↑↓←→ navigate, Enter confirm, Escape back\n");
|
||||
@@ -224,6 +239,9 @@ int main(int argc, char **argv)
|
||||
* 本循环不得再调 SDL_PollEvent,否则会先消费事件队列,
|
||||
* 导致键盘输入永远到不了 LVGL */
|
||||
while (1) {
|
||||
/* 轮询 RemoDispBus 协议(非阻塞收发) */
|
||||
ui_net_sink_poll();
|
||||
|
||||
/* 驱动 LVGL 定时器与刷新 */
|
||||
uint32_t sleep_ms = lv_timer_handler();
|
||||
if (sleep_ms == LV_NO_TIMER_READY) {
|
||||
|
||||
Reference in New Issue
Block a user