feat: 实现智能按摩器完整功能 (定时/语音/电机/显示)
- 新增MP3语音模块驱动,集成18个语音提示,支持播放/停止/音量调节 - 实现0/10/20/30分钟循环定时倒计时,实时显示剩余时间,定时结束自动停机 - 优化电机控制:一档力度提升至75%,降档冲击时间延长至800ms,降档时触发100%冲击防卡顿 - 屏幕显示重构为分区动态更新:时间状态(Zone1)/档位(Zone2)/加热(Zone3),性能优化 - 新增LED指示:运行时RUN_LED以500ms周期闪烁,无效操作ERR_LED亮1秒 - 操作逻辑改进:所有操作需先设定时间,否则播放"请先设定时间"并亮ERR_LED - 加热控制由GPIO改为PWM(TIM1_CH1),占空比300 - 调整USART3波特率为9600适配MP3模块 - FreeRTOS任务优化:Motor周期500ms,Screen周期10ms,新增定时器秒Tick处理 - 完善开发文档:MP3集成指南、校验和验证脚本、文件重命名工具等 新增文件:mp3_driver.h/c, 多项开发文档 修改文件:freertos.c, gbk_text.h/c, motor_driver.c, screen.h/c, usart.c, gpio.c等
This commit is contained in:
45
Core/Inc/mp3_driver.h
Normal file
45
Core/Inc/mp3_driver.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#ifndef __MP3_DRIVER_H
|
||||
#define __MP3_DRIVER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/* MP3命令定义 */
|
||||
#define MP3_HEADER 0x7E // 帧头
|
||||
#define MP3_VERSION 0xFF // 版本号
|
||||
#define MP3_LENGTH 0x06 // 数据长度
|
||||
#define MP3_FOOTER 0xEF // 帧尾
|
||||
|
||||
/* MP3功能码 */
|
||||
#define MP3_CMD_SET_VOLUME 0x06 // 设置音量
|
||||
#define MP3_CMD_SET_EQ 0x07 // 设置EQ
|
||||
#define MP3_CMD_SET_MODE 0x08 // 设置播放模式
|
||||
#define MP3_CMD_SET_SOURCE 0x09 // 设置音源
|
||||
#define MP3_CMD_PLAY 0x0D // 播放
|
||||
#define MP3_CMD_PAUSE 0x0E // 暂停
|
||||
#define MP3_CMD_PREV 0x0A // 上一曲
|
||||
#define MP3_CMD_NEXT 0x0B // 下一曲
|
||||
#define MP3_CMD_PLAY_INDEX 0x12 // 按索引播放
|
||||
#define MP3_CMD_STOP 0x16 // 停止
|
||||
|
||||
/* MP3音源选择 */
|
||||
#define MP3_SOURCE_U_DISK 0x01 // U盘
|
||||
#define MP3_SOURCE_SD_CARD 0x02 // TF卡/SD卡
|
||||
|
||||
/* 函数声明 */
|
||||
HAL_StatusTypeDef MP3_Init(void);
|
||||
HAL_StatusTypeDef MP3_Play(uint16_t index);
|
||||
HAL_StatusTypeDef MP3_Stop(void);
|
||||
HAL_StatusTypeDef MP3_Pause(void);
|
||||
HAL_StatusTypeDef MP3_SetVolume(uint8_t volume);
|
||||
HAL_StatusTypeDef MP3_SetSource(uint8_t source);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __MP3_DRIVER_H */
|
||||
Reference in New Issue
Block a user