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:
@@ -6,46 +6,46 @@
|
||||
// GBK文本数组声明(定义在gbk_text.c中)
|
||||
extern const uint8_t text_device_name_GBK[];
|
||||
extern const uint8_t text_loading_GBK[];
|
||||
extern const uint8_t text_massage_on_GBK[];
|
||||
extern const uint8_t text_massage_off_GBK[];
|
||||
extern const uint8_t text_heat_on_GBK[];
|
||||
extern const uint8_t text_heat_off_GBK[];
|
||||
extern const uint8_t text_gear_GBK[];
|
||||
extern const uint8_t text_time_GBK[];
|
||||
extern const uint8_t text_cont_GBK[];
|
||||
extern const uint8_t text_gear_1_GBK[];
|
||||
extern const uint8_t text_gear_2_GBK[];
|
||||
extern const uint8_t text_gear_3_GBK[];
|
||||
extern const uint8_t text_time_1_GBK[];
|
||||
extern const uint8_t text_time_2_GBK[];
|
||||
extern const uint8_t text_time_3_GBK[];
|
||||
extern const uint8_t text_remaining_GBK[];
|
||||
extern const uint8_t text_running_GBK[];
|
||||
extern const uint8_t text_paused_GBK[];
|
||||
extern const uint8_t text_ended_GBK[];
|
||||
extern const uint8_t text_stop_GBK[];
|
||||
|
||||
// GBK文本长度宏(预计算,不含\0)
|
||||
#define text_device_name_LEN (10)
|
||||
#define text_loading_LEN (6)
|
||||
#define text_massage_on_LEN (8)
|
||||
#define text_massage_off_LEN (8)
|
||||
#define text_heat_on_LEN (8)
|
||||
#define text_heat_off_LEN (8)
|
||||
#define text_gear_LEN (4)
|
||||
#define text_time_LEN (6)
|
||||
#define text_cont_LEN (4)
|
||||
#define text_remaining_LEN (8)
|
||||
#define text_running_LEN (6)
|
||||
#define text_paused_LEN (6)
|
||||
#define text_ended_LEN (6)
|
||||
#define text_massage_off_LEN (13)
|
||||
#define text_heat_on_LEN (13)
|
||||
#define text_heat_off_LEN (13)
|
||||
#define text_gear_1_LEN (15)
|
||||
#define text_gear_2_LEN (15)
|
||||
#define text_gear_3_LEN (15)
|
||||
#define text_time_1_LEN (15)
|
||||
#define text_time_2_LEN (15)
|
||||
#define text_time_3_LEN (15)
|
||||
#define text_remaining_LEN (13)
|
||||
#define text_stop_LEN (14)
|
||||
|
||||
// 兼容旧代码的别名
|
||||
#define text_device_name text_device_name_GBK
|
||||
#define text_loading text_loading_GBK
|
||||
#define text_massage_on text_massage_on_GBK
|
||||
#define text_massage_off text_massage_off_GBK
|
||||
#define text_heat_on text_heat_on_GBK
|
||||
#define text_heat_off text_heat_off_GBK
|
||||
#define text_gear text_gear_GBK
|
||||
#define text_time text_time_GBK
|
||||
#define text_cont text_cont_GBK
|
||||
#define text_gear_1 text_gear_1_GBK
|
||||
#define text_gear_2 text_gear_2_GBK
|
||||
#define text_gear_3 text_gear_3_GBK
|
||||
#define text_time_1 text_time_1_GBK
|
||||
#define text_time_2 text_time_2_GBK
|
||||
#define text_time_3 text_time_3_GBK
|
||||
#define text_remaining text_remaining_GBK
|
||||
#define text_running text_running_GBK
|
||||
#define text_paused text_paused_GBK
|
||||
#define text_ended text_ended_GBK
|
||||
#define text_stop text_stop_GBK
|
||||
|
||||
#endif // __GBK_TEXT_H__
|
||||
|
||||
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