查看: 6440  |  回复: 7
参赛作品《小炜-智能家居小助手》
Cracker
1
主题
2
回复
发表于2017-06-22 11:11:08 | 显示全部楼层
1# 电梯直达

1. 参赛者姓名(必填项):

Cracker

2. 单位或学校名称(必填项):

物联逸冰工作室

3. 当前职务或职称(必填项):

工程师

4. 参赛作品的名字(必填项):

小炜-智能家居小助手

5. 简要陈述您的idea和作品(必填项):

小炜,是一款结合智能语音和智能家居技术的智能家居小助手。

6. 拟用到的立创商城在售物料(必填项):

STM8L051,电阻,电容,电源芯片,红外接收头等

7. 拟用到的非立创商城物料或其它补充(必填项):

语音芯片, PIC单片机,SPI NOR flash,RTC芯片,LED灯珠等

一、作品简介

小炜,是一款结合智能语音和智能家居技术的智能家居小助手。傍晚当你回到家,小炜会自动为你开好灯,当你需要阅读时,你可以呼唤小炜,帮你设置照明亮度。

当你觉得热的是时候可以呼唤小炜帮你打开空调,如果夜深了,你还在工作,小炜会提醒你早点休息。当你美美的睡着了,不用担心会睡过头,因为早餐小炜会按照你预定的时间叫醒你。
小炜,就是你的家庭小助手,可以有很多扩展的功能。通过智能语音控制,解放你的双手,用一种更直接的方式融入智能家居的生活中,不用再打开APP,点个按钮,开个灯,关个窗帘,也不用拿着手机,傻傻的对着手机说话。你要做的就是把你的要求告诉小炜,让她来帮你管理所有的一切。

目前整个系统模型包含语音识别控制中心(小炜)和炫彩灯(被控设备)两部分。语音识别控制中心以下简称小炜,她的作用就像亚马逊的echo,可以聆听用户的语音输入,当然目前功能没有echo那么强大了。但是一旦识别到用户特定的语音输入,就可以通过其板载的红外,2.4G等方式发送控制命令,达到控制比如电视机,空调,智能灯泡等智能家电设备。为了简化模型的演示效果,这里制作了一款炫彩灯作为智能家电设备,来接受小炜的控制。

目前,废话少数,先上图,有图有真相!以下这个是小炜的核心电路板,不要失望,虽然还不是很炫的机器人或者盒子了,但是这个是整个系统的大脑,有了这个电路板整个系统才有了灵魂。板子包括LD3320语音识别芯片,PICLF726 MCU,PT7C4337 RTC,LM75温度芯片,SPI Nor Flash芯片,红外信号收发头,NRF24L01+,喇叭,咪头等部分组成。

  

 

 下面图片就是被控设备,炫彩灯。板载有STM8L051作为系统核心,控制一些白光和RGB LED,同时支持红外遥控和PIR人体感应控制。系统采用锂电池供电,支持micro-usb充电和太阳能充电。

小炜目前就是通过红外信号的方式来控制这个炫彩灯了。

 

二、系统构架图

系统结构还是比较清楚的,分为小炜和炫彩灯两部分,各个部分功能明确,不做过多解释。

 

三、硬件部分的描述

炫彩灯部分原理图和PCB

 

 

 

 

 

小炜部分原理图和PCB

 

 

四、材料清单(BOM列表)

小炜BOM清单

  

炫彩灯BOM清单

  


五、软件部分的描述(选填)

LD3320语音识别代码

 

#include <htc.h>
#include "typedef.h"
#include "LDChip.h"
#include "io.h"
#include "spi_rw.h"
#include "LDData.h"
#include "mp3_data.h"
#include "RTC.h"

uint32 nMp3StartPos=0;
uint32 nMp3Size=0;
uint32 nMp3Pos=0;
uint8 nLD_Mode = LD_MODE_IDLE;  // 用来记录当前是在进行ASR识别还是在播放MP3
uint8 bMp3Play=0;     // 用来记录播放MP3的状态
uint8 ucRegVal;
uint8 ucHighInt;
uint8 ucLowInt;
uint8 ucStatus;
uint8 nAsrStatus=LD_ASR_NONE;

void delay(uint32 time)
{
 while(time--)
  __delay_us(50);
}

void delay_2(uint32 time)
{
 while(time--)
  __delay_us(50);
}

/****************************************************************
函数名: LD_WriteReg
功能:写LD3320芯片的寄存器
参数:  reg, 8位无符号整数,地址
  value,8位无符号整数,要写入的数据
返回值:无
****************************************************************/

void LD_WriteReg( uint8 reg, uint8 value )
{
   //LD_CSN = 1;                // CSN high
    //LD_SCK = 1;                // Mode 2 SCK when CSN disactivate
   LD_CSN = 0;                // CSN low, init SPI transaction
   SPI_RW_LD(0x04);     //Write specific command
   SPI_RW_LD(reg);      // select register
   SPI_RW_LD(value);    // ..and write value to it..
   LD_CSN = 1;                // CSN high again
}

/****************************************************************
函数名: LD_ReadReg
功能:读LD3320芯片的寄存器
参数:  reg, 8位无符号整数,地址
返回值:8位无符号整数,读取的结果
****************************************************************/

uint8 LD_ReadReg( uint8 reg )
{
 uint8 reg_val;
   //LD_CSN = 1;                // CSN high
    //LD_SCK = 1;                // Mode 2 SCK when CSN disactivate   
   LD_CSN = 0;                // CSN low, initialize SPI communication...
   SPI_RW_LD(0x05);         //Read specific command
   SPI_RW_LD(reg);            // Select register to read from..
   reg_val = SPI_RW_LD(0);    // ..then read registervalue
   LD_CSN = 1;                // CSN high, terminate SPI communication
   return(reg_val);        // return register value
}

void LD_reset()
{
 LD_RST=1;
 delay(10);
 LD_RST=0;
 delay(10);
 LD_RST=1;

 delay(10);
 LD_CSN=0;
 delay(10);
 LD_CSN=1;
 delay(10);

}

bool LD_Init_Common()
{
 bMp3Play = 0;
    nAsrStatus = LD_ASR_NONE;

    INTE = 0;
 LD_ReadReg(0x06);
    LD_WriteReg(0x35, 0xAA);
    if(LD_ReadReg(0x35) != 0xAA)
        return false;
   
 LD_WriteReg(0x17, 0x35);
 delay(10);
 LD_ReadReg(0x06); 

 LD_WriteReg(0x89, 0x03); 
 delay(5);
 LD_WriteReg(0xCF, 0x43);  
 delay(5);
 LD_WriteReg(0xCB, 0x02);
 
 /*PLL setting*/
 LD_WriteReg(0x11, LD_PLL_11);      
 if (nLD_Mode == LD_MODE_MP3)
 {
  LD_WriteReg(0x1E, 0x00);
  LD_WriteReg(0x19, LD_PLL_MP3_19);  
  LD_WriteReg(0x1B, LD_PLL_MP3_1B);  
  LD_WriteReg(0x1D, LD_PLL_MP3_1D);
 }
 else
 {
  LD_WriteReg(0x1E,0x00);
  LD_WriteReg(0x19, LD_PLL_ASR_19);
  LD_WriteReg(0x1B, LD_PLL_ASR_1B);  
     LD_WriteReg(0x1D, LD_PLL_ASR_1D);
 }
 delay(10);
 
 LD_WriteReg(0xCD, 0x04);
 LD_WriteReg(0x17, 0x4c);
 delay(5);
 LD_WriteReg(0xB9, 0x00);
 LD_WriteReg(0xCF, 0x4F);
 LD_WriteReg(0x6F, 0xFF);
    INTF = 0;
    return true;
}

bool LD_Init_MP3()
{
 nLD_Mode = LD_MODE_MP3;
 if(LD_Init_Common() == false)
        return false;

 LD_WriteReg(0xBD,0x02);
 LD_WriteReg(0x17, 0x48);
 delay(10);

 LD_WriteReg(0x85, 0x52);
 LD_WriteReg(0x8F, 0x00); 
 LD_WriteReg(0x81, 0x00);
 LD_WriteReg(0x83, 0x00);
 LD_WriteReg(0x8E, 0xff);
 LD_WriteReg(0x8D, 0xff);
    delay(1);
 LD_WriteReg(0x87, 0xff);
 LD_WriteReg(0x89, 0xff);
 delay(1);
 LD_WriteReg(0x22, 0x00);   
 LD_WriteReg(0x23, 0x00);
 LD_WriteReg(0x20, 0xef);   
 LD_WriteReg(0x21, 0x07);
 LD_WriteReg(0x24, 0x77);         
    LD_WriteReg(0x25, 0x03);
    LD_WriteReg(0x26, 0xbb);   
    LD_WriteReg(0x27, 0x01);
    return true;
}
 
bool LD_Init_ASR()
{
 nLD_Mode=LD_MODE_ASR_RUN;
 if(LD_Init_Common() == false)
        return false;

 LD_WriteReg(0xBD, 0x00);
 LD_WriteReg(0x17, 0x48);
 delay( 10 );

 LD_WriteReg(0x3C, 0x80);   
 LD_WriteReg(0x3E, 0x07);
 LD_WriteReg(0x38, 0xff);   
 LD_WriteReg(0x3A, 0x07);
 
 LD_WriteReg(0x40, 0);         
 LD_WriteReg(0x42, 8);
 LD_WriteReg(0x44, 0);   
 LD_WriteReg(0x46, 8);
 delay( 1 );
    return true;   
}


void LDIsr(void)
{
 uint8 nAsrResCount=0;
 
 ucRegVal = LD_ReadReg(0x2B);
 if(nLD_Mode == LD_MODE_ASR_RUN)
 {
  // 语音识别产生的中断
  // (有声音输入,不论识别成功或失败都有中断)
  LD_WriteReg(0x29,0) ;
  LD_WriteReg(0x02,0) ;
  if((ucRegVal & 0x10) &&
   LD_ReadReg(0xb2)==0x21 &&
   LD_ReadReg(0xbf)==0x35)
  {
   nAsrResCount = LD_ReadReg(0xba);
   if(nAsrResCount>0 && nAsrResCount<=4)
   {
    nAsrStatus=LD_ASR_FOUNDOK;
   }
   else
      {
    nAsrStatus=LD_ASR_FOUNDZERO;
   } 
  }
  else
  {
   nAsrStatus=LD_ASR_FOUNDZERO;
  }
   
  LD_WriteReg(0x2b, 0);
     LD_WriteReg(0x1C,0);
  return;
 }
 
 // 声音播放产生的中断,有三种:
 // A. 声音数据已全部播放完。
 // B. 声音数据已发送完毕。
 // C. 声音数据暂时将要用完,需要放入新的数据。 
 ucHighInt = LD_ReadReg(0x29);
 ucLowInt=LD_ReadReg(0x02);
 LD_WriteReg(0x29,0) ;
 LD_WriteReg(0x02,0) ;
    if(LD_ReadReg(0xBA)&CAUSE_MP3_SONG_END)
    {
 // A. 声音数据已全部播放完。

  LD_WriteReg(0x2B,  0);
       LD_WriteReg(0xBA, 0); 
  LD_WriteReg(0xBC,0x0); 
  bMp3Play=0;     // 声音数据全部播放完后,修改bMp3Play的变量
  LD_WriteReg(0x08,1);
  delay_2(5);
       LD_WriteReg(0x08,0);
  LD_WriteReg(0x33, 0);

  return ;
     }

  if(nMp3Pos>=nMp3Size)
 {
 // B. 声音数据已发送完毕。

  LD_WriteReg(0xBC, 0x01);
  LD_WriteReg(0x29, 0x10);
//  bMp3Play=0;    // 此时,只是主控MCU把所有MP3数据发送到LD3320芯片内,但是还没有把送入的数据全部播放完毕

  return; 
 }

 // C. 声音数据暂时将要用完,需要放入新的数据。 

 LD_ReloadMp3Data_2();
  
 LD_WriteReg(0x29,ucHighInt);
 LD_WriteReg(0x02,ucLowInt) ;

 //delay_2(10);
}

 


void LD_play()
{
 nMp3Pos=0;
 bMp3Play=1;

 if (nMp3Pos >=  nMp3Size)
  return ;

 LD_ReloadMp3Data();

    LD_WriteReg(0xBA, 0x00);
 LD_WriteReg(0x17, 0x48);
 LD_WriteReg(0x33, 0x01);
 LD_WriteReg(0x29, 0x04);
 
 LD_WriteReg(0x02, 0x01);
 LD_WriteReg(0x85, 0x5A);

    INTE = 1;
}

void LD_AdjustMIX2SPVolume(uint8 val)
{
 val = ((15-val)&0x0f) << 2;
 LD_WriteReg(0x8E, val | 0xc3);
 LD_WriteReg(0x87, 0x78);
}

void LD_ReloadMp3Data()
{
 uint32 nCurMp3Pos;
 uint8 val,bit_ctr;

 val = 0; //remove compile warning
 nCurMp3Pos = nMp3StartPos + nMp3Pos;
 FLASH_CSN=1;
 FLASH_SCK=0;
 FLASH_CSN=0;

    SPI_RW_FLASH(W25P_FastReadData);  
    SPI_RW_FLASH(((nCurMp3Pos & 0xFFFFFF) >> 16)); 
    SPI_RW_FLASH(((nCurMp3Pos & 0xFFFF) >> 8));
    SPI_RW_FLASH(nCurMp3Pos & 0xFF);
    SPI_RW_FLASH(0xFF);

 ucStatus = LD_ReadReg(0x06);
 while ( !(ucStatus&MASK_FIFO_STATUS_AFULL) && (nMp3Pos<nMp3Size) )
 {
     for(bit_ctr=8;bit_ctr>0;bit_ctr--)    // output 8-bit
     {
      FLASH_SCK = 1;                    // Set SCK high..
   val <<= 1;                        // shift next bit into MSB..
   val |= FLASH_MISO;           // capture current MISO bit
      FLASH_SCK = 0;                // ..then set SCK low again
     }
        //val = SPI_RW_FLASH(0xFF);
  LD_WriteReg(0x01,val);
  nMp3Pos++;
  ucStatus = LD_ReadReg(0x06);
 }
 
 FLASH_CSN=1;
 FLASH_SCK=0;

}


void LD_ReloadMp3Data_2()
{
 uint32 nCurMp3Pos;
 uint8 val,bit_ctr;

 val = 0; //remove compile warning
 nCurMp3Pos = nMp3StartPos + nMp3Pos;
 FLASH_CSN=1;
 FLASH_SCK=0;
 FLASH_CSN=0;

    SPI_RW_FLASH(W25P_FastReadData);  
    SPI_RW_FLASH(((nCurMp3Pos & 0xFFFFFF) >> 16)); 
    SPI_RW_FLASH(((nCurMp3Pos & 0xFFFF) >> 8));
    SPI_RW_FLASH(nCurMp3Pos & 0xFF);
    SPI_RW_FLASH(0xFF);

 ucStatus = LD_ReadReg(0x06);
 while ( !(ucStatus&MASK_FIFO_STATUS_AFULL) && (nMp3Pos<nMp3Size) )
 {
     for(bit_ctr=8;bit_ctr>0;bit_ctr--)    // output 8-bit
     {
      FLASH_SCK = 1;                    // Set SCK high..
   val <<= 1;                        // shift next bit into MSB..
   val |= FLASH_MISO;           // capture current MISO bit
      FLASH_SCK = 0;                // ..then set SCK low again
     }
        //val = SPI_RW_FLASH(0xFF);
  LD_WriteReg(0x01,val);
  nMp3Pos++;
  ucStatus = LD_ReadReg(0x06);
 }
 
 FLASH_CSN=1;
 FLASH_SCK=0;

}

// Return 1: success.
uint8 LD_Check_ASRBusyFlag_b2()
{
 uint8 j;
 uint8 flag = 0;
 for (j=0; j<10; j++)
 {
  if (LD_ReadReg(0xb2) == 0x21)
  {
   flag = 1;
   break;
  }
  delay(10);  
 }
 return flag;
}


// Return 1: success.
uint8 LD_AsrRun()
{
 LD_WriteReg(0x35, MIC_VOL);
 LD_WriteReg(0x1C, 0x09);
 LD_WriteReg(0xBD, 0x20);
 LD_WriteReg(0x08, 0x01);
 delay( 1 );
 LD_WriteReg(0x08, 0x00);
 delay( 1 );

 if(LD_Check_ASRBusyFlag_b2() == 0)
 {
  return 0;
 }

 LD_WriteReg(0xB2, 0xff); 
 LD_WriteReg(0x37, 0x06);
 delay( 5 );
 LD_WriteReg(0x1C, 0x0b);
 LD_WriteReg(0x29, 0x10);
 
 LD_WriteReg(0xBD, 0x00);

    nAsrStatus=LD_ASR_RUNING;

 INTE = 1;
 return 1;
}

// Return 1: success.
uint8 LD_AsrAddFixed(recg_tab tab)
{
 uint8 i,k, flag,count;
 uint8 nAsrAddLength;
 const char *pRecog;
    const char *pCode;

    if(tab.count == 1)
  LD_WriteReg(0xB8, 60);
    else
  LD_WriteReg(0xB8, 5);

    pCode = tab.pCode;
    pRecog = tab.pVoice;
    count = tab.count;
   
 flag = 1;
    i = 0;
 for (k=0; k<count; k++)
 {
   
  if(LD_Check_ASRBusyFlag_b2() == 0)
  {
   flag = 0;
   break;
  }
  
  LD_WriteReg(0xc1, pCode[k] );
  LD_WriteReg(0xc3, 0 );
  LD_WriteReg(0x08, 0x04);
  delay(1);
  LD_WriteReg(0x08, 0x00);
  delay(1);

        nAsrAddLength = 0;
  while(pRecog[i] != '\n'){
      LD_WriteReg(0x5, pRecog[i++]);
            nAsrAddLength++;
        }
        i++;
       
  LD_WriteReg(0xb9, nAsrAddLength);
  LD_WriteReg(0xb2, 0xff);
  LD_WriteReg(0x37, 0x04);
 }
    return flag;
}

 

uint8 LD_GetResult()
{
 return LD_ReadReg(0xc5);
}

 

uint8 RunASR(const recg_tab *pTab)
{
 uint8 i=0;
 uint8 asrflag=0;
 LD_reset();
 for (i=0; i<5; i++)
 {
  if(LD_Init_ASR() == false)
            return 0;
  delay(100);
  if (LD_AsrAddFixed(*pTab)==0)
  {
   LD_reset(); 
   delay(100);
   continue;
  }
  delay(10);
  if (LD_AsrRun() == 0)
  {
   LD_reset();
   delay(100);
   continue;
  }

  asrflag=1;
  break;
 }

 return asrflag;
}

void PlaySound(uint8 nCode)
{
 switch(nCode)
 {
 case CODE_KAIDENG:
  nMp3StartPos = MP3_KAIDENG_START;
  nMp3Size = MP3_KAIDENG_SIZE;
  break;
 case CODE_GUANDENG:
  nMp3StartPos = MP3_GUANDENG_START;
  nMp3Size = MP3_GUANDENG_SIZE;
  break;
    case CODE_LIANGYIDIAN:
  nMp3StartPos = MP3_LIANGYIDIAN_START;
  nMp3Size = MP3_LIANGYIDIAN_SIZE;
  break; 
    case CODE_ANYIDIAN:
  nMp3StartPos = MP3_ANYIDIAN_START;
  nMp3Size = MP3_ANYIDIAN_SIZE;
        break;
    case CODE_KAI_GUAN_LIANG_AN:
  nMp3StartPos = MP3_KAI_GUAN_LIANG_AN_START;
  nMp3Size = MP3_KAI_GUAN_LIANG_AN_SIZE;
        break;
    case CODE_KAIDENG_KEY_PRESS:
        nMp3StartPos = MP3_KAIDENG_KEY_PRESS_START;
        nMp3Size = MP3_KAIDENG_KEY_PRESS_SIZE;
        break;
    case CODE_GUANDENG_KEY_PRESS:
        nMp3StartPos = MP3_GUANDENG_KEY_PRESS_START;
        nMp3Size = MP3_GUANDENG_KEY_PRESS_SIZE;
        break;
    case CODE_LIANGYIDIAN_KEY_PRESS:
        nMp3StartPos = MP3_LIANGYIDIAN_KEY_PRESS_START;
        nMp3Size = MP3_LIANGYIDIAN_KEY_PRESS_SIZE;
        break;
    case CODE_ANYIDIAN_KEY_PRESS:
        nMp3StartPos = MP3_ANYIDIAN_PRESS_START;
        nMp3Size = MP3_ANYIDIAN_PRESS_SIZE;
        break;
    case CODE_SHIJIAN_SHI:
        nMp3StartPos = MP3_SHIJIANSHI_START;
        nMp3Size = MP3_SHIJIANSHI_SIZE;
        break;
    case CODE_WENDU_SHI:
        nMp3StartPos = MP3_WENDUSHI_START;
        nMp3Size = MP3_WENDUSHI_SIZE;
        break;
    case CODE_NAOZHONG_SHI:
        nMp3StartPos = MP3_NAOZHONGSHI_START;
        nMp3Size = MP3_NAOZHONGSHI_SIZE;
        break;
    case CODE_SHIJIAN_SHEZHI:
        nMp3StartPos = MP3_SHIJIAN_SHEZHI_START;
        nMp3Size = MP3_SHIJIAN_SHEZHI_SIZE;
        break;
    case CODE_NAOZHONG_SHEZHI:
        nMp3StartPos = MP3_NAOZHONG_SHEZHI_START;
        nMp3Size = MP3_NAOZHONG_SHEZHI_SIZE;
        break;
    case CODE_YAOKONG_SHEZHI:
        nMp3StartPos = MP3_YAOKONG_SHEZHI_START;
        nMp3Size = MP3_YAOKONG_SHEZHI_SIZE;
        break;
    case CODE_ZHURENQINGJIANG:
        nMp3StartPos = MP3_ZHURENQINGJIANG_START;
        nMp3Size = MP3_ZHURENQINGJIANG_SIZE;
        break;
    case CODE_SHEZHI_WANCHENG:
        nMp3StartPos = MP3_SHEZHI_WANCHENG_START;
        nMp3Size = MP3_SHEZHI_WANCHENG_SIZE;
        break;
    case CODE_ZHUANGTAISHI:
        nMp3StartPos = MP3_ZHUANGTAISHI_START;
        nMp3Size = MP3_ZHUANGTAISHI_SIZE;
        break;
    case CODE_OK:
        nMp3StartPos = MP3_OK_START;
        nMp3Size = MP3_OK_SIZE;
        break;
    case CODE_BYE_BYE:
        nMp3StartPos = MP3_BYE_BYE_START;
        nMp3Size = MP3_BYE_BYE_SIZE;
        break;
    case CODE_KAIQI_GUANBI_XIUGAI:
        nMp3StartPos = MP3_KAIQI_GUANBI_XIUGAI_START;
        nMp3Size = MP3_KAIQI_GUANBI_XIUGAI_SIZE;
        break;         
    case CODE_XIAOSHI_FENZHONG_SET:
        nMp3StartPos = MP3_XIAOSHI_FENZHONG_SET_START;
        nMp3Size = MP3_XIAOSHI_FENZHONG_SET_SIZE;
        break;
    case CODE_XI_TONG_SHE_ZHI:
        nMp3StartPos = MP3_SHIJIAN_NAOZHONG_YAOKONG_START;
        nMp3Size = MP3_SHIJIAN_NAOZHONG_YAOKONG_SIZE;
        break;
    case CODE_KAIQI:
        nMp3StartPos = MP3_KAIQI_START;
        nMp3Size = MP3_KAIQI_SIZE;
        break;
    case CODE_GUANBI:
        nMp3StartPos = MP3_GUANBI_START;
        nMp3Size = MP3_GUANBI_SIZE;
        break;       
 case CODE_NOT_RECG:
  nMp3StartPos = MP3_NOT_REGNIZE_START;
  nMp3Size = MP3_NOT_REGNIZE_SIZE;
  break;
 case CODE_MUSIC:
  nMp3StartPos = MP3_MUSIC_START;
  nMp3Size = MP3_MUSIC_SIZE;
  break;
    case CODE_DU:
  nMp3StartPos = MP3_DU_START;
  nMp3Size = MP3_DU_SIZE;
        break;
    case CODE_DIAN:
        nMp3StartPos = MP3_DIAN_START;
        nMp3Size = MP3_DIAN_SIZE;
        break;
    case CODE_FEN:
        nMp3StartPos = MP3_FEN_START;
        nMp3Size = MP3_FEN_SIZE;
        break;
 default:
  nMp3StartPos = MP3_WELCOME_START;
  nMp3Size = MP3_WELCOME_SIZE;
  break; 
 }

    LD_reset();
 if(LD_Init_MP3() == false)
        return;
 LD_AdjustMIX2SPVolume(SPK_VOL);
 LD_play();
 while(bMp3Play);

}

void PlayNum(uint8 num)
{
    if(num > 10)
        return;
 switch(num)
 {
 case 0:
        nMp3StartPos = MP3_ZERO_START;
        nMp3Size = MP3_ZERO_SIZE;
        break;
 case 1:
        nMp3StartPos = MP3_ONE_START;
        nMp3Size = MP3_ONE_SIZE;
        break;
 case 2:
        nMp3StartPos = MP3_TWO_START;
        nMp3Size = MP3_TWO_SIZE;
        break;
 case 3:
        nMp3StartPos = MP3_THREE_START;
        nMp3Size = MP3_THREE_SIZE;
        break;
 case 4:
        nMp3StartPos = MP3_FOUR_START;
        nMp3Size = MP3_FOUR_SIZE;
        break;
 case 5:
        nMp3StartPos = MP3_FIVE_START;
        nMp3Size = MP3_FIVE_SIZE;
        break;
 case 6:
        nMp3StartPos = MP3_SIX_START;
        nMp3Size = MP3_SIX_SIZE;
        break;
 case 7:
        nMp3StartPos = MP3_SEVEN_START;
        nMp3Size = MP3_SEVEN_SIZE;
        break;
 case 8:
        nMp3StartPos = MP3_EIGHT_START;
        nMp3Size = MP3_EIGHT_SIZE;
        break;
 case 9:
        nMp3StartPos = MP3_NINE_START;
        nMp3Size = MP3_NINE_SIZE;
        break;
 case 10:
        nMp3StartPos = MP3_SHI_START;
        nMp3Size = MP3_SHI_SIZE;
        break;
 default:
        return;
  //break; 
 }

    LD_reset();
 if(LD_Init_MP3() == false)
        return;
 LD_AdjustMIX2SPVolume(SPK_VOL);
 LD_play();
    while(bMp3Play);
}

void PlayTime(rtc_time rtc)
{
    if(rtc.hour == 0x10){
        PlayNum(10);
    }else if(rtc.hour == 0x20){
        PlayNum(2);
        PlayNum(10);
    }else if(rtc.hour>>4 == 1){
        PlayNum(10);
        PlayNum(rtc.hour&0x0F);       
    }else if(rtc.hour>>4 >1 ){
        PlayNum(rtc.hour>>4);
        PlayNum(10);
        PlayNum(rtc.hour&0x0F);
    }else{
        PlayNum(rtc.hour&0x0F);
    }
    PlaySound(CODE_DIAN);

    if(rtc.min == 0x10){
        PlayNum(10);
    }else if(rtc.min == 0x00){
        PlayNum(0);
    }else if((rtc.min&0x0F) == 0){
        PlayNum(rtc.min>>4);
        PlayNum(10);
    }else if(rtc.min>>4 == 1){
        PlayNum(10);
        PlayNum(rtc.min&0x0F);       
    }else if(rtc.min>>4 > 1){
        PlayNum(rtc.min>>4);
        PlayNum(10);
        PlayNum(rtc.min&0x0F);
    }else{
        PlayNum(0);
        PlayNum(rtc.min&0x0F);
    }

    PlaySound(CODE_FEN);

}

 


 

六、作品演示

 小炜-语音控制的智能家居小助手

 https://v.qq.com/x/page/m0541u0eewa.html

https://v.qq.com/x/page/z0541vbs7d8.html

七、总结

目前作品还是原型阶段,还有很多不完善的地方,在此也就是个人兴趣爱好,起一个抛砖引玉的作用。感谢主办方给予这次机会,希望大家通过这个平台多交流。

有意合作的也可以,一起把它做成个实用产品。

立创商城工程部
【官方工作人员】
113
主题
1325
回复
发表于2017-06-22 11:31:50   |  显示全部楼层
2#

欢迎参与! 有点像apple的siri , 期待楼主的佳作

 

您已经报名成功!

您现在就可以开始进行设计工作了,后期相关内容请在一楼编辑进行完善。

当前所有参赛选手分值统计表及活动详细介绍见:  http://www.szlcsc.com/go/17523dej



主题

回复
  • 温馨提示: 标题不合格、重复发帖、发布广告贴,将会被删除帖子或禁止发言。 详情请参考: 社区发帖规则
  • 您当前输入了 0 个文字。还可以输入 8000 个文字。 已添加复制上传图片功能,该功能目前仅支持chrome和火狐

禁言/删除

X
请选择禁言时长:
是否清除头像:
禁言/删除备注:
昵 称:
 
温馨提示:昵称只能设置一次,设置后无法修改。
只支持中文、英文和数字。

举报

X
请选择举报类型:
请输入详细内容:

顶部