feat(control): 添加选手 FPS 键鼠操作与 C3 用户 UART 输出
构建客户端 / 检查(类型 + 单元测试) (push) Canceled after 0s
构建客户端 / Linux x64(deb + AppImage) (push) Canceled after 0s
构建客户端 / Windows x64(NSIS 安装包) (push) Canceled after 0s
构建客户端 / macOS 通用(.app + .dmg) (push) Canceled after 0s

This commit is contained in:
sloray committed 2026-10-31 18:34:30 +08:00
1 parent aea1cf60ae
commit 38410bacd4
43 files changed
+2389 -77

No files matched your search

@@ -0,0 +1,41 @@
#ifndef RMIC_CONTROL_H
#define RMIC_CONTROL_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#define RMIC_CONTROL_FRAME_SIZE 20u
#define RMIC_CONTROL_TIMEOUT_MS 100u
/* Channel order: forward, strafe-right, yaw-right, pitch-up. Speed: -1000..1000. */
typedef struct {
int16_t channel[4];
bool enabled;
bool debug;
bool fire;
} rmic_control;
typedef struct {
uint8_t buffer[RMIC_CONTROL_FRAME_SIZE];
size_t used;
bool synchronized;
uint32_t sequence;
uint32_t last_valid_ms;
rmic_control control;
} rmic_receiver;
void rmic_receiver_init(rmic_receiver *receiver);
/* Call from one task/context only; feed arbitrary UART chunks, never assume frame alignment.
* Returns number of accepted fresh frames. Noise/bad/duplicate frames do not renew timeout.
* now_ms is a monotonic uint32 clock (wraparound is supported). */
size_t rmic_receiver_feed(rmic_receiver *receiver, const uint8_t *data, size_t length,
uint32_t now_ms);
/* Call at least once per control-loop iteration, including when UART is silent.
* This function stops all channels/fire after 100ms and requires a neutral frame to resync.
* Use only this returned state when applying motor/gimbal/launcher setpoints. */
rmic_control rmic_receiver_poll(rmic_receiver *receiver, uint32_t now_ms);
#endif