app_state.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. ******************************************************************************
  3. * @file app_state.h
  4. * @brief 应用层共享状态声明
  5. * 所有变量在 main.c 中定义, 各模块通过此头文件访问.
  6. ******************************************************************************
  7. */
  8. #ifndef __APP_STATE_H
  9. #define __APP_STATE_H
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. #include <stdint.h>
  14. /* ========== 主从同步变量 (来自主板) ========== */
  15. extern volatile uint8_t g_inputSource; /* 0=未知, 1=BT, 2=AUX */
  16. extern volatile uint8_t g_btConnState; /* 蓝牙连接状态 */
  17. extern volatile uint8_t g_audioPlaying; /* 音频播放状态 (0=停, 1=播放) */
  18. extern volatile uint8_t g_batteryPct; /* 电量 0-100 */
  19. extern volatile uint8_t g_chgFull; /* 充满标志 */
  20. extern volatile uint8_t g_chgIng; /* 充电中: 0/1/0xFE */
  21. extern volatile uint8_t g_dacMute; /* DAC静音状态 */
  22. /* ========== 音量等级 (本地操作值) ========== */
  23. extern volatile int16_t g_volLRLevel; /* 主音量 0-100 */
  24. extern volatile int16_t g_volBassLevel; /* 低音音量 0-100 */
  25. /* ========== 异步发送标志 (由中断置位, 主循环处理) ========== */
  26. extern volatile uint8_t g_flagSendVolLR;
  27. extern volatile uint8_t g_flagSendVolBass;
  28. extern volatile uint8_t g_flagSendDacUnmute;
  29. /* ========== 面板本地状态 ========== */
  30. extern volatile uint8_t g_dataReceived; /* 是否收到过主板数据 */
  31. extern volatile uint8_t g_mutedByBtn; /* 是否被SW2_KEY静音 */
  32. /* 各状态接收标志 (用于开机全亮无缝切换) */
  33. extern volatile uint8_t g_volLRReceived;
  34. extern volatile uint8_t g_volBassReceived;
  35. extern volatile uint8_t g_batteryReceived;
  36. extern volatile uint8_t g_sourceReceived;
  37. /* ========== 系统毫秒计时 ========== */
  38. extern volatile uint32_t g_sysMs; /* 系统毫秒计数器 */
  39. /* ========== 空闲查询计时 ========== */
  40. extern volatile uint16_t g_idleTimer; /* 空闲计时器(ms) */
  41. extern volatile uint8_t g_userActive; /* 用户是否在操作 */
  42. #ifdef __cplusplus
  43. }
  44. #endif
  45. #endif /* __APP_STATE_H */