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

📄 alarm.c

📁 以ST公司CPU为核心的彩色电视机的完整源程序。
💻 C
字号:
/********************** SGS-THOMSON MICROELECTRONICS ************************
FILENAME     : ALARM.C
VERSION      : V1.0
DATE         : JAN 1999
AUTHOR(s)    : ASHISH RUDOLA / DEEPAK DOSHI
PROCESSOR    : ST92195
DESCRIPTION  : This module contains functions for handling alarms.
MODIFICATIONS:	
  	- 
*****************************************************************************/

#include "alarm.h"
#include "channel.h"
#include "clock.h"
#include "register.h"
#include "i2c_bus.h"
#include "eeprom.h"
#include "display.h"
#include "tv_glob.h"
#include "menuctrl.h"

unsigned char alarm_time[4];
unsigned char alarm_channel;
unsigned char alarm_set;

/*****************************************************************************
INPUTS     : channel - Current TV channel
OUTPUTS    : alarm_on_hour - Set to disable (OFF)
             alarm_on_minute - Cleared
             alarm_off_hour - Set to disable (OFF)
             alarm_off_minute - Cleared
             alarm_channel - set to the current TV channel as default alarm
                             channel
DESCRIPTION: This function disables the alarm on and off time and initializes
             the alarm channel to the current TV channel.
*****************************************************************************/
void init_alarm(void)
{
	/* Set default alarm channel */
	alarm_channel = read_eeprom(EEPROM_ALARM_CHANNEL);

	/* Set to  on time */
	alarm_on_hour = read_eeprom(EEPROM_ALARM_ON_HOUR);
	alarm_on_minute = read_eeprom(EEPROM_ALARM_ON_MINUTE);

	/* Set to  off time */
	alarm_off_hour = read_eeprom(EEPROM_ALARM_OFF_HOUR);
	alarm_off_minute = read_eeprom(EEPROM_ALARM_OFF_MINUTE);

	alarm_set = read_eeprom(EEPROM_ALARM_SET);

}

/*****************************************************************************
INPUTS     : alarm_on_hour - Selected ON time
             alarm_on_minute - Selected ON time
             alarm_off_hour - Selected OFF time
             alarm_off_minute - Selected off time
             alarm_channel - Channel to tune at turn-on event
             hour - Current time of day
             minute - Current time of day
OUTPUTS    : ENABLE_POWER - Set if the power has to be turned-on, clear
                            otherwise
             channel - Alarm channel
DESCRIPTION: This function checks for expired alarms. These alarms include
             the ON and OFF alarms.
             It turns the TV on with the selected alarm channel if it has not
             already been done. If the TV is on, it tunes the selected alarm
             channel. It turns the TV off if it has not already been done.
*****************************************************************************/
void update_alarm(void)
{
	/* Is it time to do something ? */
	if (hour== DISABLE_TIME || minute == DISABLE_TIME)
		return;

	/* Is it time to do something ? on timer */
	if(alarm_set == ALARM_ON)  
	{
		if ((alarm_on_hour == hour) && (alarm_on_minute == minute))
		{
			/* Yes, turn-on if it has to be done */
			if (!(tv_flags & ENABLE_POWER))
				tv_flags = tv_flags | ENABLE_POWER;
					disable_menu_mode();
			/* Get channel to turn-on with */
			channel = alarm_channel;
			write_eeprom(EEPROM_LAST_CHANNEL,channel);
			select_channel();	 /* channel.c */
		}

		/* Is it time to do something ? off timer */
		if ((alarm_off_hour == hour) && (alarm_off_minute == minute))
		{			  
			/* Yes, turn-off if it has to be done */
			if (tv_flags & ENABLE_POWER)
				tv_flags = tv_flags & ~ENABLE_POWER; 
		display_request_flags = display_request_flags | REFRESH_DISPLAY;
      disable_menu_mode();
		}	 
	}
}

⌨️ 快捷键说明

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