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

📄 menuctrl.c

📁 以ST公司CPU为核心的彩色电视机的完整源程序。
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************** SGS-THOMSON MICROELECTRONICS ************************
FILENAME     : MENUCTRL.C
VERSION      : V1.0
DATE         : JAN 1999
AUTHOR(s)    : ASHISH RUDOLA/ DEEPAK DOSHI
PROCESSOR    : ST92195
DESCRIPTION  : This module contains functions for controlling the menu-active
               state.
MODIFICATIONS:
   -
*****************************************************************************/
#include "audio.h"
#include "macro.h" /* DEEPAK */
#include "autosrch.h"
#include "channel.h"
#include "command.h"
#include "control.h"
#include "display.h"
#include "eeprom.h"
#include "osdutil.h"
#include "i2c_bus.h"
#include "label.h"
#include "menuctrl.h"
#include "osdchar.h"
#include "register.h"
#include "timer.h"
#include "utility.h"
#include "video.h"
#include "alarm.h"
#include "clock.h"
#include "tuning.h"
#include "source.h"
#include "tv_glob.h"

unsigned char channel_store;

/*****************************************************************************
INPUTS     : none
OUTPUTS    : MENU_DISPLAY - Enable menu display
             menu_item - Point the first menu item
             nenu_page - Start from the top (in case of scrolling)
             see init_autosearch
             see init_label
DESCRIPTION: This function open the current menu page. This function has
             to be called during the power off procedure to make sure menu
             items enabled while the menu is open (labelling, autosearch...)
             will be disabled.
*****************************************************************************/
void enable_menu_mode(void)
{
	menu_page = MENU_DEFAULT;   
	menu_item = ITEM_PICTURE;
	display_request_flags = display_request_flags & ~(STATUS_DISPLAY|SLEEP_DISPLAY|COMMERCIAL_DISPLAY|PROGRAM_DISPLAY);
	display_request_flags = display_request_flags | MENU_DISPLAY;
	osd_disabled();  
}

/*****************************************************************************
INPUTS     : none
OUTPUTS    : MENU_DISPLAY - Disable menu display
             menu_item - Point the first menu item
             menu_theme - Start from the top (in case of scrolling)
             see init_autosearch
             see init_label
DESCRIPTION: This function closes the current menu page. This function has
             to be called during the power off procedure to make sure menu
             items enabled while the menu is open (labelling, autosearch...)
             will be disabled.
*****************************************************************************/
void disable_menu_mode(void)
{
    menu_page = 0xff;
	menu_item = 0xff;	

    osd_disabled();
	/* Disable menu display */
	display_request_flags = display_request_flags & ~MENU_DISPLAY;
	/* Initialize autosearch */
	init_autosearch();
	/* Initialize labelling */
	init_channel();
    /*	init_label();*/
	init_nibble_time();
	init_tuning();
}


/*****************************************************************************
INPUTS     : 
OUTPUTS    : 
DESCRIPTION: 
*****************************************************************************/
void process_menu_command(unsigned char current_command)
{

   /* Make sure there is one command available */
    if (command_flags & COMMAND_VALID)
    {
    switch(current_command)	
        {
        case COMMAND_CHANNEL_UP:
            stop_autosearch();
            menu_item |= MENU_DIRECTION;
            next_menu_item_change_up_down(); //feman: only change flags 
            update_repeat_timer((MENU_UP_NORMAL_TIME << 8) | MENU_UP_INITIAL_TIME);
            display_request_flags = display_request_flags | REFRESH_DISPLAY;
            display_request_flags = display_request_flags &~MENU_FLASH_DISPLAY;
        break;
        
        case COMMAND_CHANNEL_DOWN:
            stop_autosearch();
            next_menu_item_change_up_down();
            update_repeat_timer((MENU_UP_NORMAL_TIME << 8) | MENU_UP_INITIAL_TIME);
            display_request_flags = display_request_flags | REFRESH_DISPLAY;
            display_request_flags = display_request_flags &~MENU_FLASH_DISPLAY;
        break;
        
        case COMMAND_LEFT:
            next_menu_item_left_right();
            update_repeat_timer((MENU_LEFT_NORMAL_TIME << 8) | MENU_LEFT_INITIAL_TIME);
            display_request_flags = display_request_flags | (MENU_FLASH_DISPLAY|REFRESH_DISPLAY);
        break;
        
        case COMMAND_RIGHT:
            menu_item |= MENU_DIRECTION;
            next_menu_item_left_right();
            update_repeat_timer((MENU_RIGHT_NORMAL_TIME << 8) | MENU_RIGHT_INITIAL_TIME);
            display_request_flags = display_request_flags | (MENU_FLASH_DISPLAY|REFRESH_DISPLAY);
        break;
        }
    }
    
    if (command_flags & COMMAND_NEW )
    {
        if(current_command >= COMMAND_0 && current_command <=COMMAND_9)
            {
            update_menu_digit_entry(current_command);
            display_request_flags = display_request_flags | REFRESH_DISPLAY;
            }
       	
        if(current_command == COMMAND_MENU)
            {
			stop_autosearch();
			/* Time Delay to take care of Menu key when pressed from
			   local KeyBoard */
            update_repeat_timer((MENU_NORMAL_TIME << 8) | MENU_INITIAL_TIME);
            previous_menu();
            display_request_flags = display_request_flags | REFRESH_DISPLAY;
            display_request_flags = display_request_flags & ~MENU_FLASH_DISPLAY;/*2.17*/
            }   
      	
        if (current_command == COMMAND_OK)
            {
            update_repeat_timer((MENU_NORMAL_TIME << 8) | MENU_INITIAL_TIME);
            if (menu_page == MENU_ORGANIZE)
                {
                edit_move();
                display_request_flags = display_request_flags | REFRESH_DISPLAY;
                }
            else
                {
                time_to_zore();
                }
            } 

        if (current_command == COMMAND_TV_AV)
            {
            if (menu_page == MENU_ORGANIZE)
                {
                edit_delete();
                display_request_flags = display_request_flags | REFRESH_DISPLAY;
                }
            }
        if (current_command == COMMAND_POWER)
            {
            tv_flags = tv_flags ^ ENABLE_POWER;
            stop_autosearch();
            display_request_flags = display_request_flags | REFRESH_DISPLAY;
            disable_menu_mode();
            }
        if (current_command == COMMAND_MUTE)
            toggle_mute();

    }
    command_flags = command_flags & ~(COMMAND_NEW | COMMAND_VALID);
}

/*****************************************************************************
INPUTS     : 
OUTPUTS    : 
DESCRIPTION: 
*****************************************************************************/
void menu_item_roll_change(unsigned char max)
{
	if ( menu_item & MENU_DIRECTION)
	{
		menu_item = menu_item &~MENU_DIRECTION;
		if (menu_item == 0)
			menu_item = max;
		else
			menu_item--;
	}	
	else
	{
    	if(menu_item >= max)
	    	 menu_item = 0;
		else
			 menu_item++;
	}
}

/*****************************************************************************
INPUTS     : 
OUTPUTS    : 
DESCRIPTION: 
*****************************************************************************/
void next_menu_item_change_up_down(void)
{
    switch (menu_page)
	{
    case MENU_DEFAULT:

//		if (source ==TUNER)
//			menu_item_roll_change(ITEM_GAME);
//		else
			menu_item_roll_change(ITEM_GAME);
    break;

    case MENU_PICTURE:
		if(source_flags & NTSC_SET)
    		{
			menu_item_roll_change(ITEM_TINT);
	    	}
		else
			{
			menu_item_roll_change(ITEM_SHARPNESS);
			}
    break;
    
    case MENU_SOUND :
        menu_item_roll_change(ITEM_BASS);    
    break;
    
    case MENU_INSTALL:
		menu_item_roll_change(ITEM_ORGANIZE);
    break;

    case MENU_FUNCTION:
		menu_item_roll_change(ITEM_TIMER);
	break;

    case MENU_GAME :
    //empty
    break;
    
//other menu 	
    case MENU_TIMER:
		menu_item_roll_change(ITEM_WAKE_UP_PR);
		init_nibble_time();
		menu_theme =0;
    break;

    case MENU_ORGANIZE :
  	    organize_edit_change();
  	break;
	}
    menu_item &=~MENU_DIRECTION;
}
//**************
void organize_edit_change(void)
{
	signed int i=0,j;

   		switch(menu_theme)
		{  
	    case THEME_PR:
	    	if(menu_item & MENU_DIRECTION)
			{ 
				menu_item = menu_item &~MENU_DIRECTION;
   		  		if(menu_item==STATION_P1)
				{
					if (station_page < 8)    /* for  max station 99 then station max - menu_station */ 
						station_page += 91;
					else
        				station_page -= 8;
		   	    	menu_item=7; 
		   	    }
		   	    else
		   		    menu_item--;
		   }
		   else
			{ /*DOWN*/
			 	if(menu_item==STATION_P8)
				{
				    if (station_page >=92)
				        station_page -= 91;
				    else
				        station_page += 8;
					menu_item = 0;
 		   		 }
 		   		 else
		   			menu_item++;
		    }
			channel = station_page + menu_item;
			if (channel>=CHANNEL_NUMBER) channel -=CHANNEL_NUMBER;
			    channel++;
			if(command_flags & COMMAND_NEW)
				start_tuning();
		break;
		
		case THEME_NAME_0:
		case THEME_NAME_1:
		case THEME_NAME_2:
		case THEME_NAME_3:
		     if(menu_item & MENU_DIRECTION)
			    {
				menu_item &=~MENU_DIRECTION;
				station_item = roll_dec(station_item,39);/*ASHISH 39*/
			    }
			  else
				station_item = roll_inc(station_item,39);/*ASHISH 39*/
   			  if(station_item==29) i=32;/* Corresponding to space */
   			  if(station_item==26) i=164;/* Corresponding to + */
   			  if(station_item==27) i=96;
   			  if(station_item==28) i=58;
   			  if(station_item>=30 && station_item<=39) i=station_item+18;
   			  if(station_item>=0 && station_item<=25)  i=station_item+'A';

		j = EEPROM_START_LABEL_MEMORY+((channel-1)*4)+(menu_theme-1); /*5 ASH*/

 			write_eeprom(j,i);
			read_label();
  		break;

      case THEME_PICTURE: /*picture*/
			j = read_channel_info(SETTINGS);
			i = get_value(j,SYSTEM_MASK);

				if(i==SYSTEM_PAL)
					i=SYSTEM_SECAM;

				else 
					{
						if(i==SYSTEM_SECAM)
							i=SYSTEM_NTSC_1;
						else 
							{
								if(i==SYSTEM_NTSC_1)
									i=SYSTEM_NTSC_2;
								else
								{
									if(i==SYSTEM_NTSC_2)
										i=SYSTEM_AUTO;
							 		else 
										i=SYSTEM_PAL;
								}
							}
					}
			i = set_value(i,SYSTEM_MASK);			
			j = j&~SYSTEM_MASK;
			i = j|i;
		    write_eeprom(EEPROM_START_CHANNEL_MEMORY+((channel-1)*3)+SETTINGS,i);
		   	select_channel();	
		break;

		case THEME_SOUND: /*sound */
			if(command_flags & COMMAND_NEW)
			{
				j = read_channel_info(SETTINGS);
				i = get_value(j,AUDIO_SYSTEM_MASK);/*TRY*/
				if (menu_item & MENU_DIRECTION)
				{
				    i = roll_inc(i,AUDIO_MN);
						if(i == 0x00)
						i = i+1;  
				}
				else
				{
						i = roll_dec(i,AUDIO_MN);
						if(i == 0x00)
							i = 0x04;  
				 }
				i = set_value(i,AUDIO_SYSTEM_MASK);			
				j = j &~AUDIO_SYSTEM_MASK;
				i = j|i;
				write_eeprom(EEPROM_START_CHANNEL_MEMORY+((channel-1)*3)+SETTINGS,i);/*TRY*/
		   	select_channel();	
			}
		break;
		case THEME_SKIP: /*skip*/
			menu_item &=~MENU_DIRECTION;
	      	toggle_skip();
		break;
		}	

}
/*****************************************************************************
INPUTS     : 
OUTPUTS    : 
DESCRIPTION: 
*****************************************************************************/
void next_menu_item_left_right(void)
{
	unsigned int i;
    switch (menu_page)
	{
    case MENU_DEFAULT :
        next_menu();
    break;
    
    case MENU_PICTURE:
		if (menu_item & MENU_DIRECTION)
		{
			switch(menu_item)
			{
			case MENU_DIRECTION|ITEM_BRIGHTNESS:
				brightness_high();				
			break;
			case MENU_DIRECTION|ITEM_CONTRAST:
				contrast_high();
			break;
			case MENU_DIRECTION|ITEM_COLOUR:
				saturation_high();
			break;
			case MENU_DIRECTION|ITEM_SHARPNESS:
				sharpness_high();
			break;
			case MENU_DIRECTION|ITEM_TINT:
				hue_high();
			break;
			}
		}
		else
		{
			switch(menu_item)
			{
			case ITEM_BRIGHTNESS:
				brightness_low();				
			break;
			case ITEM_CONTRAST:
				contrast_low();
			break;
			case ITEM_COLOUR:
				saturation_low();
			break;
			case ITEM_SHARPNESS:
				sharpness_low();
			break;
			case ITEM_TINT:
				hue_low();
			break;
			}
		}
 	break;
    
    case MENU_SOUND:
    //empty;
    break;
    
    case MENU_INSTALL:
        switch( menu_item & ~MENU_DIRECTION)
            {
             case ITEM_AUTO_PROG :
				start_autoprog();

⌨️ 快捷键说明

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