📄 channel.c
字号:
/********************** SGS-THOMSON MICROELECTRONICS ************************
FILENAME : CHANNEL.C
VERSION : V1.0
DATE : JAN 1999
AUTHOR(s) : ASHISH RUDOLA/ DEEPAK DOSHI
PROCESSOR : ST92195
DESCRIPTION : This module contains functions for handling the selection of
channels. This includes functions to manage the channel
memory into the EEPROM.
MODIFICATIONS:
-
*****************************************************************************/
#include "autosrch.h"
#include "macro.h"
#include "eeprom.h"
#include "channel.h"
#include "command.h"
#include "i2c_bus.h"
#include "st92196.h"
#include "label.h"
#include "menuctrl.h"
#include "osdchar.h"
#include "register.h"
#include "source.h"
#include "timer.h"
#include "tuning.h"
#include "utility.h"
#include "alarm.h"
#include "tv_glob.h"
unsigned char channel;
unsigned char previous_channel;
unsigned char channel_tens;
/*****************************************************************************
INPUTS : none
OUTPUTS : channel - Set to the first available TV channel.
previous_channel - Same as current TV channel
DESCRIPTION: This function initializes the current channel and previous
channel to cold start values.
*****************************************************************************/
void init_channel(void)
{
/* Save channel as previous channel */
previous_channel = channel;
/* need for status channel display */
// channel_tens = channel;
}
/*****************************************************************************
INPUTS :
OUTPUTS :
DESCRIPTION:
*****************************************************************************/
void channel_up(void)
{
get_valid_channel(SCAN_UP);
select_channel();
}
/*****************************************************************************
INPUTS : none
OUTPUTS : see get_valid_channel
see select_channel
DESCRIPTION: This function selects the previous available TV channel in the
channel memory.
*****************************************************************************/
void channel_down(void)
{
get_valid_channel(SCAN_DOWN);
select_channel();
}
/*****************************************************************************
INPUTS : channel - Current TV channel
scanning mode (UP/DOWN)
OUTPUTS : previous_channel - Current TV channel
channel - Next/previous available TV channel
see read_channel_info
see get_possible_channel
see update_settings
DESCRIPTION: This function updates the current channel with the next/previous
channel stored in the channel list. If no channel has been found,
return the same channel.
*****************************************************************************/
void get_valid_channel(unsigned char scanning_mode)
{
unsigned char i, j; /* Temporary storage */
/* Save the current channel as the previous channel */
previous_channel = channel;
j = 0;
do {
j++;
/* Get the next/previous possible channel */
channel = get_possible_channel(scanning_mode, channel);
/* Check if this channel is stored in the channel list (EEPROM) */
i = read_channel_info(SETTINGS);
if (!(i & SKIP_MASK))
/* If so, exit loop */
return;
} while (previous_channel != channel && j != CHANNEL_NUMBER+1);
}
/*****************************************************************************
INPUTS : scanning mode (UP/DOWN)
Channel to start with
OUTPUTS : Next/previous channel
DESCRIPTION: This function returns the next/previous available channel without
taking care of the channel list.
*****************************************************************************/
unsigned char get_possible_channel(unsigned char scanning_mode,
unsigned char current_channel)
{
/* Get next valid channel (1 to CHANNEL_NUMBER) */
if (scanning_mode == SCAN_UP)
{
current_channel++;
if (current_channel > CHANNEL_NUMBER)
current_channel = 1;
}
else
{
current_channel--;
if (current_channel == VIDEO_CHANNEL || current_channel > CHANNEL_NUMBER)
current_channel = CHANNEL_NUMBER;
}
return current_channel;
}
/*****************************************************************************
INPUTS : Remote control digits
OUTPUTS : STATUS_DISPLAY - Enable status display
REFRESH_DISPLAY - Refresh the current display
previous channel - current channel number
channel - New channel number
see select_channel
see init_digit_entry
DESCRIPTION: This function updates channel entry. It handles the first and
second digit commands.
*****************************************************************************/
void update_digit_entry(unsigned char digit_command)
{
/* source = TUNER;*/
/* It no longer use the flags TENS_DIGIT|FIRST_DIGIT */
if (digit_command >= COMMAND_0 && digit_command <=COMMAND_9 && command_flags & COMMAND_NEW )
{
digit_command &= 0x0F;
if((slow_timers[DIGIT_TIMER]!=0 )&& (display_request_flags & PROGRAM_DISPLAY))
{
if(channel_tens == DISABLE_CHANNEL )
{
channel_tens = digit_command;
display_request_flags = display_request_flags | (REFRESH_DISPLAY|PROGRAM_DISPLAY);
slow_timers[STATUS_TIMER] = STATUS_TIME_OUT;
return;
}
else
channel = (channel_tens*10) + digit_command;
}
else
channel = digit_command&0x0f;
if(channel == 0)
channel=1;
previous_channel = channel;
init_digit_entry();
select_channel();
}
}
/*****************************************************************************
INPUTS : none
OUTPUTS : TENS_DIGIT - Reset two digits request
FIRST_DIGIT - Reset partial digits entry
channel_tens - Cleared
DESCRIPTION: This function initializes partial channel entry.
*****************************************************************************/
void init_digit_entry(void)
{
/* Reset partial digit entry */
command_flags = command_flags & ~(TENS_DIGIT|FIRST_DIGIT);
slow_timers[DIGIT_TIMER] = 0;
display_request_flags &= ~(PROGRAM_DISPLAY | SLEEP_DISPLAY | NORMAL_DISPLAY);
channel_tens = DISABLE_CHANNEL;
}
/*****************************************************************************
INPUTS : channel - Current TV channel
information to return
OUTPUTS : information requested
see read_eeprom
DESCRIPTION: This function returns TV channel informations stored in the
EEPROM.
*****************************************************************************/
unsigned char read_channel_info(unsigned char info)
{
return read_eeprom(EEPROM_START_CHANNEL_MEMORY + info + ((channel-1)*3));
}
/*****************************************************************************
INPUTS : none
OUTPUTS : STATUS_DISPLAY - Enable status display
REFRESH_DISPLAY - Refresh the current display
STATUS_TIMER - Status display time-out
see init_autosearch
see init_digit_entry
see start_tuning
see read_label
DESCRIPTION: This function starts the tuning procedure for the current TV
channel.
*****************************************************************************/
void select_channel(void)
{
/* Stop autosearch (in case of) */
init_autosearch();
/* Reset partial channel entry (in case of) */
init_digit_entry();
/* Read new label */
read_label();
/* Set status time-out */
slow_timers[STATUS_TIMER] = STATUS_TIME_OUT;
/* Start a new tuning */
start_tuning();
}
/*****************************************************************************
INPUTS : station_source channel - menu TV channel
OUTPUTS : see write_eeprom
copy_channel
DESCRIPTION: This function removes the selected channel from the EEPROM
channel memory.
*****************************************************************************/
void delete_channel(void)
{
unsigned char i;
if (station_source>=99)
station_source-= 99;
copy_channel(CHANNEL_NUMBER,station_source);
i =read_eeprom(EEPROM_START_CHANNEL_MEMORY+(CHANNEL_NUMBER *3)+SETTINGS);
i |= SKIP_MASK;
write_eeprom(EEPROM_START_CHANNEL_MEMORY+(CHANNEL_NUMBER *3)+SETTINGS,i);
/* Get EEPROM location to free-up */
for (i = station_source;i<CHANNEL_NUMBER;i++)
copy_channel(i,i+1);
station_edit_flags = EDIT_DONE;
start_tuning();
display_request_flags = display_request_flags | REFRESH_DISPLAY;
}
/*****************************************************************************
INPUTS : station_source channel - menu TV channel
station_target channel
OUTPUTS : see write_eeprom
copy_channel
DESCRIPTION: This function removes the selected channel from the EEPROM
channel memory.
*****************************************************************************/
void move_channel(void)
{
unsigned char i;
copy_channel(CHANNEL_NUMBER,station_source);/*2.19*/
if (station_target >=station_source)
{
for (i=station_source;i<station_target;i++)
copy_channel(i,i+1);
}
else
{
for (i=station_source;i>station_target;i--)
copy_channel(i,i-1);
}
copy_channel(station_target,CHANNEL_NUMBER);
station_edit_flags = EDIT_DONE;
start_tuning();
display_request_flags = display_request_flags | REFRESH_DISPLAY;
}
/*****************************************************************************
INPUTS :
OUTPUTS : see write_eeprom
DESCRIPTION: This function removes the selected channel from the EEPROM
channel memory.
*****************************************************************************/
void copy_channel(unsigned char copy_target,unsigned char copy_source)
{
unsigned char i;
for (i=0;i<4;i++)
{
write_eeprom(EEPROM_START_LABEL_MEMORY+(copy_target*4)+i,read_eeprom(EEPROM_START_LABEL_MEMORY+(copy_source*4)+i));
}
for (i=0;i<3;i++)
{
write_eeprom(EEPROM_START_CHANNEL_MEMORY+(copy_target*3)+i,read_eeprom(EEPROM_START_CHANNEL_MEMORY+(copy_source*3)+i));
}
}
void check_edit_channel(void)
{
if (station_edit_flags &DISPLAY_WAIT)
return;
if (station_edit_flags & EDIT_DELETE)
delete_channel();
if (station_edit_flags & EDIT_MOVE_TARGET)
move_channel();
}
/**********************************************************************************************************************************************
**********************************************************************************************************************************************/
void store_nicam_info(unsigned char channel)
{
#ifdef NICAM
// k = EEPROM_START_NICAM_STANDARD + (channel-1);
write_eeprom(EEPROM_START_NICAM_STANDARD + (channel-1), 0x00);/* Write AutoNICAM standard*/
#endif
}
void init_label(void)
{
unsigned char i;
unsigned int k;
k = EEPROM_START_LABEL_MEMORY + ((channel - 1)*4);
for(i=0;i<4; i++,k++)
{
write_eeprom(k, MINUS);
}
}
void store_skip_nonecolor_label_info(unsigned char channel)
{
unsigned int k;
unsigned char i;
write_eeprom(EEPROM_START_CHANNEL_MEMORY+((channel-1)*3)+SETTINGS,0x10) ;
k = EEPROM_START_LABEL_MEMORY + ((channel - 1)*4);
for(i=0;i<4; i++,k++)
{
write_eeprom(k, MINUS);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -