Ejemplo n.º 1
0
int main(void)
{

	PORTC=0xFF;
	unsigned char key;
	static FILE mystdout = FDEV_SETUP_STREAM(lcd_printf, NULL, _FDEV_SETUP_WRITE);
	// setup our stdio stream
	stdout = &mystdout;

	keypad_init();
	lcd_init ();
	lcd_gotoxy(1,1);
	printf("keypad");
	lcd_gotoxy(1,2);

	while(1)
	{
		/* the function to get the pressed key*/
		key=key_scan();
		/*important to write only when a key is pressed*/
		//if (key!=0)	printf("%c",key);
		if (key!=0)	PORTC=key_scan();

	}
	return(0);
}
Ejemplo n.º 2
0
int main(void)
{
	uint8_t result;
	
	///////////////////////////////////////
	sys_state = SYS_INIT;
	sd_avlb = 1;
	speeder_avlb = 1;
	gps_avlb = 1;
	///////////////////////////////////////
	
/////////////////////////////////////////////////////////////
	result = init();
	if(result)
	{
#if DEBUG
		uart_puts_p(PSTR("\nINIT Failed! \n\n"));
#endif		
		Disp_Clear();
		XY_Str_P(0,0,PSTR("NO SD Card! -"));
		XY_Num(13,0,result);
		XY_Char(11,1,m_arrow);
		XY_Str_P(12,1,PSTR("SKIP"));
		//XY_Str_P(12,1,m_item[4]);
		sd_avlb = 0;
		timer1_start();
		
		while(!(key_scan() == KEY_OK))
			_delay_ms(100);
		sei();
	}
#if DEBUG
	else
		uart_puts_p(PSTR("\nINIT Completed! \n\n"));
#endif
	sys_state = SYS_READY;
/////////////////////////////////////////////////////////////


	while(1)
	{
	/////////////////////////////////////////////////////////////	
#if DEBUG	
		uart_puts_p(PSTR("get_ready() start! \n"));
#endif
		while(sys_state == SYS_READY)
			get_ready();
	/////////////////////////////////////////////////////////////

				
	/////////////////////////////////////////////////////////////	
#if DEBUG	
		uart_puts_p(PSTR("task() start! \n"));
#endif	
		while(sys_state == SYS_WORKING)
			task();
	/////////////////////////////////////////////////////////////
	}
	return 0;
}
Ejemplo n.º 3
0
void Key_task(void)
{
	key_scan();
	
	if(keycode != KEY_NULL)
	{
		if(scn_mode == GPS_MAIN_SCN)
		{
			switch(keycode)
			{
				case KEY_UP:
				case KEY_DOWN:
					switch_scn_flag(0);
					set_screen(GPS_MAIN_SCN);
					break;
				case KEY_LEFT:
					save_position();
					break;	
				case KEY_OK:
				case KEY_CANCEL:
					menu_start();
					break;
				default:
					break;
			}
		}
	}
}
Ejemplo n.º 4
0
int main(void)
{
    systick_init();
    eep_init();         //读取EEPROM内的数据
    lcd_init();
    key_init();
    io_init();
    pwm_init();
    ntc_init();
    
    while (1)
    {
        if (time_1ms_flag == 1)
        {
            //1ms进入一次
            time_1ms_flag = 0;

        }

        if(time_10ms_flag == 1)
        {
            //10ms进入一次
            time_10ms_flag = 0;

            key_scan();
        }

        if(time_100ms_flag == 1)
        {
            //100ms进入一次
            time_100ms_flag = 0;

            key_done();
        }

        if(time_1s_flag == 1)
        {
            //1s执行一次
            time_1s_flag = 0;

        }
    }
}
Ejemplo n.º 5
0
void menu_key_loop(void)
{
	while(1)
	{
		key_scan();
		
		_delay_ms(120);
		
		if(menu_type)
		{
			if(keycode == KEY_LEFT)
			{
				move_arrow_left();
				continue;
			}
			
			if(keycode == KEY_RIGHT)
			{
				move_arrow_right();
				continue;
			}
		}
		else
		{
			if(keycode == KEY_UP)
			{
				move_arrow_up();
				continue;
			}
			
			if(keycode == KEY_DOWN)
			{
				move_arrow_down();
				continue;
			}	
		}
		
		if(keycode == KEY_OK || keycode == KEY_CANCEL)
			return;
	}
}
Ejemplo n.º 6
0
unsigned char getNum(){
	unsigned char keyValue;
	keyValue = key_scan();
	switch(keyValue)
	{
		case 0x7E: return 1;
		case 0x7D: return 2;
		case 0x7B: return 3;
		case 0x77: return 4;
		case 0xBE: return 5;
		case 0xBD: return 6;
		case 0xBB: return 7;
		case 0xB7: return 8;
		case 0xDE: return 9;
		case 0xDD: return 10;
		case 0xDB: return 11;
		case 0xD7: return 12;
		case 0xEE: return 13;
		case 0xED: return 14;
		case 0xEB: return 15;
		case 0xE7: return 16;
		default: return  0;
	}
}
Ejemplo n.º 7
0
unsigned char getNum(){
	unsigned char keyValue;
	keyValue = key_scan();
	switch(keyValue)
	{
		case 0x7E: return 1;
		case 0x7D: return 4;
		case 0x7B: return 7;
		case 0x77: return 0;
		case 0xBE: return 2;
		case 0xBD: return 5;
		case 0xBB: return 8;
		case 0xB7: return 'C';
		case 0xDE: return 3;
		case 0xDD: return 6;
		case 0xDB: return 9;
		case 0xD7: return '=';
		case 0xEE: return '+';
		case 0xED: return '-';
		case 0xEB: return '*';
		case 0xE7: return '/';
		default: return  0xFF;
	}
}
Ejemplo n.º 8
0
//按键操作处理,菜单显示
void keyproc(void)
{ 
    LongPressSec=0;
    gKeyValue=key_scan();
    if(gKeyValue)
    {
        if(bPrompt)     //如果接收提示铃声响,第一次按键选停止提示铃声
        {
//             PromptTim_tmp=0;
            bPrompt=0;
            gKeyValue=0;
            delayms(300);
        }
    }

    switch(gKeyValue)
    {
        case KEY_VALUE_OK:
            LCDBK_ON(15);        
            if(!bBkLight)      //第一次打开背光灯时不能进入菜单 
            {
                bBkLight=1;     
                LCDBK=0;
                while(!KEY_OK) ClearWatchDog();  
                break;
            }
            index = MenuProc[index].Enter;
            Function = MenuProc[index].handle;
            MenuTimout(20);
            (*Function)();
            while(!KEY_OK) ClearWatchDog();
            break;
        
        case KEY_VALUE_UP:
            LCDBK_ON(15);       
            if(!bBkLight)
            {
                bBkLight=1;LCDBK=0;
                while(!KEY_UP)ClearWatchDog();
                break;
            }
            index = MenuProc[index].Up;
            Function = MenuProc[index].handle;
            MenuTimout(20);            
            (*Function)();
            break;
        
        case KEY_VALUE_DOWN:
            LCDBK_ON(15); 
            if(!bBkLight)
            {
                bBkLight=1;LCDBK=0;
                while(!KEY_DOWN)ClearWatchDog();
                break;
            }        
            index = MenuProc[index].Down;
            Function = MenuProc[index].handle;
            MenuTimout(20);
            (*Function)();            

            break;
            
        case KEY_VALUE_RETURN:
            LCDBK_ON(15);        
            if(!bBkLight)
            {
                bBkLight=1;LCDBK=0;
                while(!KEY_RETURN)ClearWatchDog();  
                break;
            }
            else
            {
                while((!KEY_RETURN)&&(index==0))
                {
                    if( LongPressSec>2)      // 长按
                    {
                        index=63;
                        MenuMode=3;
                         Function = MenuProc[63].handle;
                        (*Function)();
                        return;
                    }
                    ClearWatchDog();                      
                }
						index = MenuProc[index].Return;
            Function = MenuProc[index].handle;
            if(index==0)
            {
                MenuTimout(0);
            }
            else
            {
                MenuTimout(20); 
            }
            (*Function)();
            delayms(80);
            break;
            }
            break;
#if 0		 /*sjz change*/							
                    if( LongPressSec>2)      // 长按
                    {
                        index=58;
                        MenuMode=3;
                         Function = MenuProc[58].handle;
                        (*Function)();
                        return;
                    }
                    ClearWatchDog();                      
                }
            }
Ejemplo n.º 9
0
int main(void)
{
  unsigned int sec_time;
  unsigned long prev_total_sys_time;
  unsigned long count_sys_time;

  TIME now;
  key_status key;

  char flag = 0;

  ROMEMU();

  sys_time = 0;
  total_sys_time = 0;
  prev_total_sys_time = 0;
  count_sys_time = 0;
  sec_time = 0;

  timer_init();
  timer_set(0,INT1MS);
  timer_start(0);

  lcd_init();

  time_init(&now);

  key_init(&key);

  lcd_cursor(0,0);
  time_print(now);

  ENINT();

  while (1) {

	if(sys_time>=1000)
	{
	  sec_time++;
	  sys_time = 0;
	}

	key_scan(&key);

	switch(key_press_check(&key))
	{
	case '0':
	  if(flag==1)
	  {
	    count_sys_time = time_to_msec(now);
		prev_total_sys_time = total_sys_time;
		flag = 0;
	  }
	  else
	  {
	    flag = 1;
	  }
	  break;
	case '6':
	  if(flag==1)
	  {
		if(now.second<60)
		  now.second += 1;
		count_sys_time=time_to_msec(now);
	  }
	  break;
	case '9':
	  if(flag==1)
	  {
		if(now.second>0)
		  now.second -= 1;
		count_sys_time=time_to_msec(now);
	  }
	  break;
	case '5':
	  if(flag==1)
	  {
		if(now.minute<60)
		  now.minute += 1;
		count_sys_time=time_to_msec(now);
	  }
	  break;
	case '8':
	  if(flag==1)
	  {
		if(now.minute>0)
		  now.minute -= 1;
		count_sys_time=time_to_msec(now);
	  }
	  break;
	case '4':
	  if(flag==1)
	  {
		if(now.hour<23)
		now.hour += 1;
		count_sys_time=time_to_msec(now);
	  }
	  break;
	case '7':
	  if(flag==1)
	  {
		if(now.hour>0)
		  now.hour -= 1;
		count_sys_time=time_to_msec(now);
	  }
	  break;
	}

	if(flag==0)
	{
	  count_sys_time += total_sys_time - prev_total_sys_time;
	  prev_total_sys_time = total_sys_time;
	}

	lcd_cursor(0,0);
	time_msec_to(&now,count_sys_time);
	time_print(now);
  }
  return 1;
}
Ejemplo n.º 10
0
int main(void)
{
  unsigned int sec_time;
  unsigned long prev_total_sys_time;
  unsigned long count_sys_time;

  TIME now;
  key_status key;

  char stop_flag = 0;

  ROMEMU();

  sys_time = 0;
  total_sys_time = 0;
  prev_total_sys_time = 0;
  count_sys_time = 0;
  sec_time = 0;

  timer_init();
  timer_set(0,INT1MS);
  timer_start(0);

  lcd_init();

  time_init(&now);

  key_init(&key);

  lcd_cursor(0,0);
  stop_watch_print(now);

  ENINT();

  while (1) {

	if(sys_time>=1000)
	{
	  sec_time++;
	  sys_time = 0;
	}

	key_scan(&key);

	switch(key_press_check(&key))
	{
	case '0':
	  stop_flag = 0;
	  count_sys_time = 0;
	  break;
	case '*':
	  stop_flag = 1;
	  prev_total_sys_time = total_sys_time;
	  break;
	case '#':
	  stop_flag = 0;
	  break;
	}

	if(stop_flag==1)
	{
	  count_sys_time += total_sys_time - prev_total_sys_time;
	  prev_total_sys_time = total_sys_time;
	}

	lcd_cursor(0,0);
	stop_watch_msec_to(&now,count_sys_time);
	stop_watch_print(now);
  }
  return 1;
}
Ejemplo n.º 11
0
/**
* Function       main
* @author        Danny
* @date          2017.08.16
* @brief         When key is pressed, Ultrasonic obstacle avoidance mode is opened
* @param[in]     void
* @retval        void
* @par History   
*/
void main()
{
  float distance;
  
  //Initialize wiringPi
  wiringPiSetup();
  
  //Initialize the motor drive IO as the output mode
  pinMode(Left_motor_go, OUTPUT);
  pinMode(Left_motor_back, OUTPUT);
  pinMode(Right_motor_go, OUTPUT);
  pinMode(Right_motor_back, OUTPUT);
  
  softPwmCreate(Left_motor_pwm,0,255); 
  softPwmCreate(Right_motor_pwm,0,255);

  //Initialize the key interface as the input mode
   pinMode(key, INPUT);

  //Initialize ultrasonic pin
  pinMode(EchoPin, INPUT);    
  pinMode(TrigPin, OUTPUT);   

  key_scan();

  while(1)
  {
   distance = Distance_test();

   if (distance > 55)
   {
     run(150, 150);      
   }
   else if (distance >= 30 && distance <= 55)
   {
     run(80, 80);      
   }
  else if (distance < 30)
   {
     spin_right(350);    
     brake(1);
     distance = Distance_test();    
     if (distance >= 30)
     {
       run(120, 120);    
     }
     else if (distance < 30)
     {
       spin_left(800);     
       brake(1);
      distance =  Distance_test();  
       if (distance >= 30)
       {
         run(120, 120);  
       }
       else if (distance < 30)
       {
         spin_left(400); 
         brake(1);
       }
     }
   }
 }
 return;
}
Ejemplo n.º 12
0
/**
* Function       main
* @author        Danny
* @date          2017.08.16
* @brief         When key is pressed, Ultrasonic obstacle avoidance mode is opened
* @param[in]     void
* @retval        void
* @par History   
*/
void main()
{
  //Initialize wiringPi
  wiringPiSetup();
	
  //Initialize the motor drive IO as the output mode
  pinMode(Left_motor_go, OUTPUT);
  pinMode(Left_motor_back, OUTPUT);
  pinMode(Right_motor_go, OUTPUT);
  pinMode(Right_motor_back, OUTPUT);

  //Create two software-controlled PWM pins to control motor speed 
  softPwmCreate(Left_motor_pwm,0,255); 
  softPwmCreate(Right_motor_pwm,0,255);
  
   //Initialize the key interface as the input mode
  pinMode(key, INPUT);

  //Initialize the tracksensor IO as the input mode
  pinMode(TrackSensorLeftPin1, INPUT);
  pinMode(TrackSensorLeftPin2, INPUT);
  pinMode(TrackSensorRightPin1, INPUT);
  pinMode(TrackSensorRightPin2, INPUT);

  key_scan();
  
  while(1)
  {
   // When the black line is detected, the corresponding indicator of the tracking module is on, and the port level is LOW.
   // When the black line is not detected, the corresponding indicator of the tracking module is off, and the port level is HIGH.
   TrackSensorLeftValue1  = digitalRead(TrackSensorLeftPin1);
   TrackSensorLeftValue2  = digitalRead(TrackSensorLeftPin2);
   TrackSensorRightValue1 = digitalRead(TrackSensorRightPin1);
   TrackSensorRightValue2 = digitalRead(TrackSensorRightPin2);

   //4 tracking pins level status
   // 0 0 X 0
   // 1 0 X 0
   // 0 1 X 0
   //Turn right in place,speed is 150,delay 80ms
   //Handle right acute angle and right right angle
   if ( (TrackSensorLeftValue1 == LOW || TrackSensorLeftValue2 == LOW) &&  TrackSensorRightValue2 == LOW)
   {
     spin_right(150, 150);
     delay(80);
   }
   //4 tracking pins level status
   // 0 X 0 0       
   // 0 X 0 1 
   // 0 X 1 0       
   //Turn right in place,speed is 150,delay 80ms   
   //Handle left acute angle and left right angle 
   else if ( TrackSensorLeftValue1 == LOW && (TrackSensorRightValue1 == LOW ||  TrackSensorRightValue2 == LOW))
   {
     spin_left(150, 150);
     delay(80);
   }
    // 0 X X X
    //Left_sensor1 detected black line
   else if ( TrackSensorLeftValue1 == LOW)
   {
     spin_left(150, 150);
    // delay(10);
   }
    // X X X 0
    //Right_sensor2 detected black line
   else if ( TrackSensorRightValue2 == LOW )
   {
     spin_right(150, 150);
    // delay(10);
   }
    //4 tracking pins level status
    // X 0 1 X
   else if ( TrackSensorLeftValue2 == LOW && TrackSensorRightValue1 == HIGH)
   {
     left(0, 150);
   }
    //4 tracking pins level status
    // X 1 0 X  
   else if (TrackSensorLeftValue2 == HIGH && TrackSensorRightValue1 == LOW)
   {
     right(150, 0);
   }
    //4 tracking pins level status
    // X 0 0 X
   else if (TrackSensorLeftValue2 == LOW && TrackSensorRightValue1 == LOW)
   {
     run(150, 150);
   }
    //When the level of 4 pins are 1 1 1 1 , the car keeps the previous running state.
 }
 return;
}
Ejemplo n.º 13
0
/* Semantik: Event tasks are functions, that need to be called when a signal is set.
  In most cases the signal is set by an IRQ handler and the event task is the bottom half.
  Events therefore have a higher priority than normal tasks. Before a normal task is allowed to run,
  all pending events are handled.
  TODO priority within events is not implemented and fast recurring events are not handled here.
  TODO we could add some functions to attach/detach a handler to/from each signal
*/
static void 
handle_events(){

	if (signal_is_set(SIG_TIMER))
		timer_tick();
#if 0			
	if (signal_is_set(SIG_NEW_TIME))
		NewTimeTask();
#endif		
#if 0		
	if (signal_is_set(SIG_RTC))
		RtcTask();
#endif		
	
#if 0
	if (pending_tasks & (1<<5)){
			RTCget_busy = 0;
			RTCtest(task3_dat);
		};
#endif 
			

	if (signal_is_set(SIG_RX_PACKET)) {
		rfRcvPacket();
	};
#if 0		
		
		if (signal_is_set(SIG_NEW_PACKET)) {
		signal_clr(SIG_NEW_PACKET);
		pkt_cnt++;
		packet[packet_length] = 0;
		process_packet((char *)packet, packet_length);
	};
#endif
				
#if 0
	if (signal_is_set(SIG_TX)){
		do_tx();
	};
	
#endif

#if 0		
	if (signal_is_set(SIG_KEYSCAN)) {
		key_scan();
	};
#endif				

#if 1	
	if (signal_is_set(SIG_KEY_CHG)) {
		key_change();
	};
#endif	
#if 0
	if (signal_is_set(SIG_RTC_INT)) {
		Task30();
	};
#endif
#if 0
	if (signal_is_set(SIG_RTC_UNLOCK)) {
		rtc_unlock();
	};
#endif 
			
#if 1	
	// SIG_NONE is used, when the API needs a signal, but no handler needs to be invoked
	if (signal_is_set(SIG_NONE)) {
		signal_clr(SIG_NONE);
	};
#endif					
}
Ejemplo n.º 14
0
void CALLBACK_Updated_Data(SDK_CALLBACKS_UPDATED_DATA_TYPE updatedType)
{
#ifdef OPTION__INCLUDE_MODE__DAB
#ifndef OPTION__OPERATE_AS_SLAVE_NO_MMI
	u8 i;
	static u16 temp_index =0;
    u8 totalFrequencyIndex;
#endif
#endif

    switch(updatedType)
    {
#ifdef OPTION__INCLUDE_MODE__FM
        case UPDATED_RDS_PI:
			rds_update_ready_item |=UPDATED_RDS_PI_ITEM;
        	break;

        case UPDATED_RDS_PTY:
			rds_update_ready_item |=UPDATED_RDS_PTY_ITEM;
        	break;

        case UPDATED_RDS_RT:
			rds_update_ready_item |=UPDATED_RDS_RT_ITEM;
        	break;

        case UPDATED_RDS_PST:
			rds_update_ready_item |=UPDATED_RDS_PST_ITEM;
        	break;

        case UPDATED_RDS_TIME:
			rds_update_ready_item |=UPDATED_RDS_TIME_ITEM;
        	break;

        case UPDATED_RDS_ALT_FREQ:
			rds_update_ready_item |=UPDATED_RDS_ALT_FREQ_ITEM;
        	break;
#endif //OPTION__INCLUDE_MODE__FM
#ifdef OPTION__INCLUDE_MODE__FMHD
    #ifdef OPTION__DECODE_SIS
        //SIS
        case UPDATED_SIS_SLOGAN:
			sis_update_ready_item |= UPDATED_SIS_SLOGAN_ITEM;
        	break;

        case UPDATED_SIS_UNIVERSAL_SHORT_NAME:
			sis_update_ready_item |= UPDATED_SIS_UNIVERSAL_SHORT_NAME_ITEM;
        	break;

        case UPDATED_SIS_STATION_MESSAGE:
			sis_update_ready_item |= UPDATED_SIS_STATION_MESSAGE_ITEM;
        	break;

        case UPDATED_SIS_STATION_NAME_LONG:
			sis_update_ready_item |= UPDATED_SIS_STATION_NAME_LONG_ITEM;
        	break;

        case UPDATED_SIS_STATION_NAME_SHORT:
			sis_update_ready_item |= UPDATED_SIS_STATION_NAME_SHORT_ITEM;
        	break;

        case UPDATED_SIS_STATION_ID:
			sis_update_ready_item |= UPDATED_SIS_STATION_ID_ITEM;
        	break;

        case UPDATED_SIS_LOC_LAT:
			sis_update_ready_item |= UPDATED_SIS_LOC_LAT_ITEM;
        	break;

        case UPDATED_SIS_LOC_LON:
			sis_update_ready_item |= UPDATED_SIS_LOC_LON_ITEM;
        	break;
    #endif //OPTION__DECODE_SIS
    #ifdef OPTION__DECODE_PSD
        //PSD
        case UPDATED_PSD_TITLE:
			psd_update_ready_item |= UPDATED_PSD_TITLE_ITEM;
        	break;

        case UPDATED_PSD_ARTIST:
			psd_update_ready_item |= UPDATED_PSD_ARTIST_ITEM;
        	break;

        case UPDATED_PSD_ALBUM:
			psd_update_ready_item |= UPDATED_PSD_ALBUM_ITEM;
        	break;

        case UPDATED_PSD_GENRE:
			psd_update_ready_item |= UPDATED_PSD_GENRE_ITEM;
        	break;

    #endif //OPTION__DECODE_PSD
    #ifdef OPTION__DECODE_HD_ALERTS
        case UPDATED_HD_ALERT:
			alert_update_ready_item |= UPDATED_ALERT_ITEM;
        	break;
    #endif //OPTION__DECODE_HD_ALERTS

        case UPDATED_SERVICE_LIST_FAST:	
    	case UPDATED_SERVICE_LIST_AUDIO:
	    case UPDATED_SERVICE_LIST_DATA:

#ifndef OPTION__OPERATE_AS_SLAVE_NO_MMI
				show_freq(0,0);
#endif //OPTION__OPERATE_AS_SLAVE_NO_MMI
			break;

#endif //OPTION__INCLUDE_MODE__FMHD
#ifdef OPTION__INCLUDE_MODE__DAB
        case DAB_SERVICE_LIST_REQUIRED_UPDATE:
            if(!dab_scan_flag)//avoid display scroll when tuning not scanning
			{

#ifndef OPTION__OPERATE_AS_SLAVE_NO_MMI
				LCD_Clear(LCD_CLEAR_LINE1);
                LCD_DisplayStr("List Update\n",0,0);
                display_refresh_flag = 1;
#endif //OPTION__OPERATE_AS_SLAVE_NO_MMI

			}
            break;
//#ifdef OPTION__DAB_SERVICE_LIST_PERSISTENCE
//        case UPDATED_SERVICE_LIST_DAB:
//            eeprom_save_parameter();
//            break;
//#endif //OPTION__DAB_SERVICE_LIST_PERSISTENCE
    #ifdef OPTION__DECODE_DLS
        //DLS
        case UPDATED_DLS_STRING:
			dls_update_ready_item |= UPDATED_DLS_STRING_ITEM;
        	break;
    #endif //OPTION__DECODE_DLS
        case SERVICE_LIST_BUFFER_FULL_ERROR:

#ifndef OPTION__OPERATE_AS_SLAVE_NO_MMI
            LCD_DisplayStr("LIST FULL \n",0,0);
			wait_ms(1000);
#endif //OPTION__OPERATE_AS_SLAVE_NO_MMI
            break;

		case DAB_TUNE_SCAN_PROCESS_UPDATE:

#ifdef OPTION__OPERATE_AS_SLAVE_NO_MMI
			seek_scan_process_dispatch();
#endif

#ifndef OPTION__OPERATE_AS_SLAVE_NO_MMI

			key_scan();
			if(key_flag)
			{
				key_flag = 0;
				switch(key_value)
				{
					case MODE_KEY:
					case ON_OFF_KEY:
					case DAB_RESCAN_KEY:
						ScanBandCancel_DAB();
						LCD_DisplayStr("Stop scan\n",0,0);
						wait_ms(1000);
						break;
					default:break;
				}
			}
			if(!dab_scan_flag)//avoid display scroll when tuning not scanning
			{
				break;
			}
			if(temp_index == MetricsGetDABPtr()->FREQUENCY_INDEX)
			{
				break;
			}
			temp_index = MetricsGetDABPtr()->FREQUENCY_INDEX;

			LCD_DisplayNum(DABServiceListAudioPtr()->SERVICE_COUNT,14,0);

            if(dab_reduced_list_flag)
            {
                totalFrequencyIndex = DAB_NUM_ENSEMBLES_UK_REGION;
            }
            else
            {
                totalFrequencyIndex = DAB_STANDARD__MAX_ENSEMBLES_EUROPE;
            }
			for(i=0;i<16;i++)
			{	
				if((((temp_index+1)*16)/totalFrequencyIndex)>i)
				{
					LCD_DisplayCBD(DEF_SFRECTANGLE,i,1);
				}
				else
				{
					LCD_DisplayCBD(DEF_SERECTANLG,i,1);	
				}			
			}
#endif //OPTION__OPERATE_AS_SLAVE_NO_MMI
			break;
        case DAB_TUNE_REQUIRED_UPDATE:

#ifndef OPTION__OPERATE_AS_SLAVE_NO_MMI
            LCD_Clear(LCD_CLEAR_ALL);
    		LCD_DisplayStr("Tuning...\n",0,0);
    		LCD_DisplayStr("Please wait\n",0,1);
#endif //OPTION__OPERATE_AS_SLAVE_NO_MMI

            break;
		case DAB_TUNE_SCAN_PROCESS_COMPLETE:
#ifndef OPTION__OPERATE_AS_SLAVE_NO_MMI
				LCD_Clear(LCD_CLEAR_LINE2);
				//LCD_DisplayStr("- Complete -\n",2,1);
				//wait_ms(1000);//comment for speeding up in manual tuning
#endif //OPTION__OPERATE_AS_SLAVE_NO_MMI
			break;
//		case EVENT_ENSEMBLE_RECONFIGURATION:
//
//            break;
//        case EVENT_ENSEMBLE_RECONFIGURATION_WARNING:
//
//            break;
//        case EVENT_CURRENT_SERVICE_NO_LONGER_AVAILABLE:
//
//            break;
        case EVENT_FINDING_ALTERNATE_SERVICE:

#ifndef OPTION__OPERATE_AS_SLAVE_NO_MMI
            LCD_Clear(LCD_CLEAR_ALL);
    		LCD_DisplayStr("Searching\n",0,0);
#endif //OPTION__OPERATE_AS_SLAVE_NO_MMI

            break;
    #ifdef OPTION__INCLUDE_FRONT_END_TEST_FUNCTIONS
        case DAB_FRONT_END_CAL_PROCESS_UPDATE:

			#ifndef OPTION__OPERATE_AS_SLAVE_NO_MMI
            LCD_Clear(LCD_CLEAR_LINE1);
            LCD_DisplayNum(_ANTCAP_DAB,0,0);
			#endif //OPTION__OPERATE_AS_SLAVE_NO_MMI

            break;
    #endif
#endif //OPTION__INCLUDE_MODE__DAB

        case EVENT_READY_FOR_FIRMWARE_UPDATE:

			#ifndef OPTION__OPERATE_AS_SLAVE_NO_MMI
            LCD_DisplayStr("FIRMWARE UPDATE\n",0,0);
			#endif //OPTION__OPERATE_AS_SLAVE_NO_MMI

			//wait_ms(1000);
            break;
#ifdef OPTION__INCLUDE_MODE__FM
        case FM_SEEK_PROCESS_UPDATE:
		case AM_SEEK_PROCESS_UPDATE:
			
    #ifdef 	OPTION__OPERATE_AS_SLAVE_NO_MMI
			seek_scan_process_dispatch();
    #else 
            if(work_mode == fmonly)
			{
                fm_freq = MetricsGetFMPtr()->FREQUENCY_10KHZ;
                rds_update_ready_item = 0;
			}    
		#ifdef OPTION__INCLUDE_MODE__AM
			else if(work_mode == am)
			{
				am_freq = MetricsGetAMPtr()->FREQUENCY_1KHZ;
			}
		#endif
		#ifdef OPTION__INCLUDE_MODE__FMHD 
			else if(work_mode == fmhd)
			{
                fmhd_freq = MetricsGetFMHDPtr()->FREQUENCY_10KHZ;
                rds_update_ready_item = 0;
			    sis_update_ready_item = 0;
                psd_update_ready_item = 0;
                alert_update_ready_item = 0;
			}
    	#endif //OPTION__INCLUDE_MODE__FMHD
		#ifdef OPTION__INCLUDE_MODE__AMHD 
			else if(work_mode == amhd)
			{
                amhd_freq = MetricsGetAMHDPtr()->FREQUENCY_1KHZ;
			    sis_update_ready_item = 0;
                psd_update_ready_item = 0;
                alert_update_ready_item = 0;
			}
    	#endif //OPTION__INCLUDE_MODE__FMHD
		    show_freq(0,0);
    #endif //OPTION__OPERATE_AS_SLAVE_NO_MMI

            break;
        
        case FM_SEEK_PROCESS_COMPLETE:
		case AM_SEEK_PROCESS_COMPLETE:
            if(work_mode == fmonly)
			{
				fm_freq = MetricsGetFMPtr()->FREQUENCY_10KHZ;
			}
    #ifdef OPTION__INCLUDE_MODE__FMHD
			else if(work_mode == fmhd)
			{
    
                fmhd_freq = MetricsGetFMHDPtr()->FREQUENCY_10KHZ;
            }
    #endif //OPTION__INCLUDE_MODE__FMHD
	#ifdef OPTION__INCLUDE_MODE__AM
			else if(work_mode == am)
			{
				am_freq = MetricsGetAMPtr()->FREQUENCY_1KHZ;
			}
	#endif
	#ifdef OPTION__INCLUDE_MODE__AMHD
			else if(work_mode == amhd)
			{
				amhd_freq = MetricsGetAMHDPtr()->FREQUENCY_1KHZ;
			}
	#endif
            seek_state = SEEK_NULL;
            display_refresh_flag = 1;
            break;
#endif // OPTION__INCLUDE_MODE__FM
        default:
        	break;
    }
}