生活中我们使用空调的方法一般是:手持空调遥控器对着空调按下相应的按键发出命令,空调室内壁挂机接收到该命令并按命令对应的功能控制空调状态改变,智能化程度较低。另一方面,现有的天猫精灵、小美等,对空调硬件要求高、需要安装相关APP支持才能使用、无关信息(如,播报广告不受用户控制)等,用户体验有待进一步提高。
本系统设计最终要实现的效果是,比如,用户直接以自然语言说出“模式设置,制冷模式”空调便自动工作在这种状态下,其中模式可选择地设置为制热模式,制冷模式和自动模式。用户说出“温度设置,二十六度”空调要自动将温度调整至二十六摄氏度,其中温度值可选择地设置为十七摄氏度至三十摄氏度之间的任意整数级别。用户说出“风速设置,中速”空调要自动将出风流量调至“中速”,其中风速可选择地设置为低速、中速、强劲、自动。从而实现通过自然人语音控制空调改变工作状态。 主函数展示如下:
#include "./ld3320/MCUOperatesBasedOnLD3320.h"
#include "./OLED12864_IIC/OLED_I2C.h"
#include "./OLED12864_IIC/codetab.h"
//#include "./usart/bsp_usart.h"//just for printf().
#include "./Infrared/infrared.h"
#include "./ld3320/ld3320.h"
#include "./delay/delay.h"
#include "stm32f10x.h"
#include "stdio.h"
void ShowAirConStates(void)
{
//show AC state information.
if(state)OLED_ShowStr(80,2,"ON ",1);
else OLED_ShowStr(80,2,"OFF",1);
//show AC temperature information.
sprintf(tempString,"%d",temperature);
OLED_ShowStr(80,4,tempString,1);
//show AC mode information.
switch(mode)
{
case cool_mode:OLED_ShowStr(80,3,"Cool",1);break;
case heat_mode:OLED_ShowStr(80,3,"Heat",1);break;
case auto_mode:OLED_ShowStr(80,3,"Auto",1);break;
default:break;
}
//show AC fanspeed information.
switch(fanspeed)
{
case auto_fanspeed:OLED_ShowStr(80,5,"Auto ",1);break;
case low_fanspeed: OLED_ShowStr(80,5,"Low ",1);break;
case mid_fanspeed: OLED_ShowStr(80,5,"Mid ",1);break;
case high_fanspeed:OLED_ShowStr(80,5,"High ",1);break;
case quit_fanspeed:OLED_ShowStr(80,5,"Quiet",1);break;
default:break;
}
}
int main(void)
{
u8 *isTriggCommdID;
// USART_Config();
LD3320_Config();
delay_Init();
I2C_Configuration();
OLED_Init();
OLED_ClearScreen();
Init_IRSenderGPIO();
OLED_ShowStr(7,0,"AC INFORMATION",2);
OLED_ShowStr(0,2,"AirCon State:",1);
OLED_ShowStr(0,3,"Working Mode:",1);
OLED_ShowStr(0,4,"Target Temp:",1);
OLED_ShowStr(100,4,"C",1);
OLED_ShowStr(0,5,"Wind Speed:",1);
OLED_ShowStr(4,6,"Waiting Wake UP",2);
while(1)
{
LD3320_Recognition(AddTriggerCommnand);
isTriggCommdID=Return_BestOneRecongnitionPoint();
if(*isTriggCommdID==253)
{
*isTriggCommdID=0;
OLED_ShowStr(4,6," ",2);
OLED_ShowStr(16,6,"Listening...",2);
LD3320_Recognition(AddACmodescommnand);
}else if(*isTriggCommdID==254)
{
*isTriggCommdID=0;
OLED_ShowStr(4,6," ",2);
OLED_ShowStr(16,6,"Listening...",2);
LD3320_Recognition(AddACtempcommnand);
}else if(*isTriggCommdID==255)
{
*isTriggCommdID=0;
OLED_ShowStr(4,6, " ",2);
OLED_ShowStr(16,6,"Listening...",2);
LD3320_Recognition(AddACfanspeedcommnand);
}else if(*isTriggCommdID==252)
{
*isTriggCommdID=0;
OLED_ShowStr(4,6,"Power Down! ",2);
Midea_setState(0);
#if SIMULATION
IRsend32bitsCodes(16);
#else
AC_turnOFF();
#endif
}
MCUToDoBasedOnVoiceCommand();
ShowAirConStates();
}
}
全部代码51hei下载地址:
STM32LD3320 Trigger Recongnition Demo_v2.4.zip
(505.81 KB, 下载次数: 53)
|