⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ir_rx.c

📁 Wiznet iRadio Source
💻 C
字号:
#include "eic.h"
#include "util.h"
#include "gpio.h"
#include "ir_rx.h"
#include "vs1033.h"
#include "netconfig.h"
#include "socket.h"
#include "lcd.h"
#include "eeprom.h"
#include <string.h>
#include <stdlib.h>

extern volatile u8 bit_IrReadStart;
extern volatile u32 IR_TimerCount;
extern volatile u32 INT_IrCount100uS;
u8 IR_Buffer[32];
u8 IR_Index = 0;

extern u16 LastChannel;	 
extern u16 Cur_Ch;
extern CONFIG_MSG Config_Msg;
extern u16	vs1033_current_volume;

void (*jump_function2)(void);

void Mov_Ch(u8 val)
{
	//u16 cur_ch;

	if (val == 1) {
		if (Cur_Ch++ >= LastChannel) Cur_Ch = LastChannel;
	}else if (val == 0) {
		if (Cur_Ch-- <= 1) Cur_Ch = 1;

	}
		Config_Msg.Cur_Ch[0] = HIGH(Cur_Ch);
		Config_Msg.Cur_Ch[1] = LOW(Cur_Ch);

		EEP_Write(EEP_CUR_CH, Config_Msg.Cur_Ch[0]); 
		EEP_Write(EEP_CUR_CH+1, Config_Msg.Cur_Ch[1]); 

}

void Nav_Key(u8 key)
{
	
	switch(key) {
		case KEY_POWER :
			disconnect(SOCK_CLIENT);	
				// Jump to Net IAP
			      jump_function2 = (void*) 0x40000000;
			      jump_function2();
			
			break;
		case KEY_MUTE :
			vs1033_mute();
			break;
		case KEY_VOL_UP1 :
		case KEY_VOL_UP2 :
			vs1033_volume_up();
			break;
		case KEY_VOL_DN1 :
		case KEY_VOL_DN2 :
			vs1033_volume_down();
			break;
		case KEY_PC :  // Ch up
		case KEY_AUX :// Ch down
			disconnect(SOCK_CLIENT);	
			MyPrintf("\r\n IR: Disconnect");
			if (key == KEY_PC) {
				Mov_Ch(1);
#ifdef DEBUG_IR    	 	
	 		MyPrintf("\r\nCh UP");
#endif
			
			}else if (key == KEY_AUX) {
				Mov_Ch(0);
#ifdef DEBUG_IR    	 	
	 		MyPrintf("\r\nCh DOWN");
#endif
			}
			
			
			
			break;
	}
	

}


void IR_MainProc(void)
{
	u8 i, buf[4];
	u8 idx, bit; 
	
	
    if(bit_IrReadStart == 1) 
    {
#ifdef DEBUG_IR    
    	MyPrintf("\r\nIR Proc");
#endif
	idx = 0;
	bit = 0x80;
	memset(buf, 0 ,4);
       for (i = 0; i < 32; i++) {
	   	//MyPrintf("\r\n[%d] %d",i,IR_Buffer[i]);
		if (IR_Buffer[i] >= 7 && IR_Buffer[i] <= 14){
			//
			
		}else if (IR_Buffer[i] >= 19 && IR_Buffer[i] <= 25){
			buf[idx] |= bit;
		}
			
		bit >>= 1;
		if (!bit) {
			idx++;
			bit = 0x80;
		}
       }

	 if (buf[0] + buf[1] == 0xff) {
	 	if (buf[2] + buf[3] == 0xff) {
			Nav_Key(buf[2]);

#ifdef DEBUG_IR    
			MyPrintf("IR_Recv = %02x", buf[2]);
#endif


	 	}else {
#ifdef DEBUG_IR    	 	
	 		MyPrintf("\r\nIR Error 1");
#endif
	 	}
		
	 }else{
#ifdef DEBUG_IR    	 
	 		MyPrintf("\r\nIR Error 2");
#endif
	 
	 }
			
	// MyPrintf("\r\nbuf = %x,%x,%x,%x", buf[0],buf[1],buf[2],buf[3]);
	
	 bit_IrReadStart = 0;
	  
    }
}
//------------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -