#include "includes.h"

MusicList_Struct PlayList;


void TempPrompt_Fun_Init(void)
{
	memset(&PlayList,0,sizeof(MusicList_Struct));
	PlayList.EnFlag = 0x00;
	PlayList.DevAddr = Find_AllDevice_List_Information2(Bus_port,DEV_RS485_MUSIC,0x01);
}


void AddPrompt_ToList(uint8_t event)
{
	if(PlayList.ListNum < LIST_MAXNUM)
	{
		Dbg_Println(DBG_BIT_SYS_STATUS_bit,"AddPrompt_ToList:%d - %d - %d",event,PlayList.ListNum,PlayList.EnFlag);
//		printf("AddPrompt_ToList:%d\n\r",event);
		if(PlayList.ListEnd == LIST_MAXNUM)
		{
			PlayList.ListEnd = 0x00;
		}
		
		switch(event)
		{
			case 0x00:     //制冷
//				printf("制冷:%d\n\r",PlayList.ListEnd);
				PlayList.PlayList[PlayList.ListEnd] = 0xA013;
				PlayList.ListNum++;
				PlayList.ListEnd++;
				break;
			case 0x01:     //制热
//				printf("制热:%d\n\r",PlayList.ListEnd);
				PlayList.PlayList[PlayList.ListEnd] = 0xA113;
				PlayList.ListNum++;
				PlayList.ListEnd++;
				break;
			case 0x02:     //送风
//				printf("送风:%d\n\r",PlayList.ListEnd);
				PlayList.PlayList[PlayList.ListEnd] = 0xA213;
				PlayList.ListNum++;
				PlayList.ListEnd++;
				break;
			case 0x03:     //低风速
//				printf("低风速:%d\n\r",PlayList.ListEnd);
				PlayList.PlayList[PlayList.ListEnd] = 0xA313;
				PlayList.ListNum++;
				PlayList.ListEnd++;
				break;
			case 0x04:     //中风速
//				printf("中风速:%d\n\r",PlayList.ListEnd);
				PlayList.PlayList[PlayList.ListEnd] = 0xA413;
				PlayList.ListNum++;
				PlayList.ListEnd++;
				break;
			case 0x05:     //高风速
//				printf("高风速:%d\n\r",PlayList.ListEnd);
				PlayList.PlayList[PlayList.ListEnd] = 0xA513;
				PlayList.ListNum++;
				PlayList.ListEnd++;
				break;
			default:
				break;
		}
	}
}


void TempPrompt_Fun_Task(void)
{
	Device_Public_Information_G BUS_Public;   //共用
	BUS_C5MUSIC_INFO C5Music_Info;
	
	if((PlayList.DevAddr == NULL) || (PlayList.EnFlag != 0x01))
	{
//		Dbg_Println(DBG_BIT_SYS_STATUS_bit,"TempPrompt_Fun_Task Addr Or EnFlag 0");
		return;
	}
	
	SRAM_DMA_Read_Buff((uint8_t *)&BUS_Public,sizeof(Device_Public_Information_G),PlayList.DevAddr);	//拷贝所有共有数据
	SRAM_DMA_Read_Buff((uint8_t *)&C5Music_Info,sizeof(BUS_C5MUSIC_INFO),PlayList.DevAddr+Dev_Privately);
	
	if((PlayList.EnFlag == 0x01) && (BUS_Public.type == DEV_C5MUSIC_Type) && (BUS_Public.Protocol == 0x01))
	{
		if(NULL != BUS_Public.DevFunInfo.Dev_Output_Loop_State_Get)
		{
			PlayList.PlayState = BUS_Public.DevFunInfo.Dev_Output_Loop_State_Get(PlayList.DevAddr,0x00);
//			Dbg_Println(DBG_BIT_SYS_STATUS_bit,"TempPrompt_Fun_Task state：%d",PlayList.PlayState);
			if(PlayList.ListNum > 0x00)
			{
				if((PlayList.PlayState == 0x02)  \
					|| (~((PlayList.PlayState == 0x01) && (C5Music_Info.now_playback_dir == 0x01) && \
				(C5Music_Info.now_playback_idx >= 160 && C5Music_Info.now_playback_idx <= 165))))
				{
					Dbg_Println(DBG_BIT_SYS_STATUS_bit,"TempPrompt_Fun_Task 2 Index:%d",PlayList.PlayIndex);
	//				printf("TempPrompt_Fun_Task 2 Index:%d\n\r",PlayList.PlayIndex);
					BUS_Public.DevFunInfo.Dev_Output_Ctrl(NULL, NULL, PlayList.DevAddr, 0x00, PlayList.PlayList[PlayList.PlayIndex]);
					PlayList.ListNum--;
					PlayList.PlayIndex++;
					if(PlayList.PlayIndex == LIST_MAXNUM)
					{
						PlayList.PlayIndex = 0x00;
					}
				}
			}
		}
	}

}



