📄 timer.c
字号:
#include "osd_vx1828.h"
#include "ext_globl.h"
#include "ext_osd.h"
#include "ir.h"
#include "func_shi.h"
#include "menu.h"
#include "config.h"
#include "pindef.h"
#if _debug
#include <stdio.h> // printf() in the file .
#endif
#define EEPROM 0xA0
#define title 0x01
#define content 0x02
#define bottom 0x03
#define highlight 0x01
#define normal 0x00
#define foreground 0x01
#define background 0x00
#define bl 0x01
#define hl 0x00
#define britc 0x00
#define contc 0x01
#define satr 0x02
#define hue 0x03
#define sharp 0x04
// Define Color .
#define Black 0x00
#define Blue 0x01
#define Green 0x02
#define Cyan 0x03
#define Red 0x04
#define Fuchsia 0x05
#define Yellow 0x06
#define White 0x07
#define Transparent 0x08
#define RoyalBlue 0x09
#define MediumAquamarine 0x0a
#define LightGreen 0x0b
#define Orange 0x0c
#define HotPink 0x0d
#define Silver 0x0e
#define Gray 0x0f
sbit ptime_int2 = P1^7;//zl.d
sbit ptime_int1 = P3^6;
extern unsigned int idata osd_timer;
extern bit XIE_Power;
struct TIME{
//nsigned char year;
//nsigned char month;
//nsigned char day;
unsigned char hour;
unsigned char minute;
unsigned char second;
};
void read_timer(char,struct TIME *);
void write_timer(char,struct TIME *);
void timer_on_off(void);
static struct TIME curr_time={0,0,0},on_time={0,0,0},off_time={0,0,0};
unsigned char timer_able_flag=0;
static data Timer_numer=0;
unsigned char time_sel=1;
bit timeshow_flag=0;
extern unsigned int idata osd_timer;
char code Timer[0x06]={0x6d,0x13,0x22,0x26,0x1e,0x2b};
char code enable[0x07]={0x6d,0x1e,0x27,0x1a,0x1b,0x25,0x1e};
char code disable[0x07]={0x1d,0x22,0x2c,0x1a,0x1b,0x25,0x1e};
char code TIME_SET_UP[14]={0x13,0x08,0x0c,0x04,0x6d,0x12,0x04,0x13,0x6d,0x14,0x0f};
char code current_time[14]={0x1c,0x2e,0x2b,0x2b,0x1e,0x27,0x2d,0x6d,0x6d,0x2d,0x22,0x26,0x1e,0x6d};
char code power_on_time[14]={0x29,0x28,0x30,0x1e,0x2b,0x6d,0x28,0x27,0x6d,0x6d,0x2d,0x22,0x26,0x1e};
char code power_off_time[14]={0x29,0x28,0x30,0x1e,0x2b,0x6d,0x28,0x1f,0x1f,0x6d,0x2d,0x22,0x26,0x1e};
char code time_exit[4]={0x1e,0x31,0x22,0x2d};
//=========================================================
void init_timer_menu()
{
// Set initial address of OSD block
osd_clearall();
osd_madr(content,0x30); // Set the initial address of Content Block
osd_switch(4);// Turn the OSD T/C/B block off
// Disable blink or highlight zone
osd_hbsection(content,bl,0x00,0x00,0x00,0x00);
osd_hbsection(content,hl,0x00,0x00,0x00,0x00);
// Set size of block
osd_size(content,0x20,0x05); // Set Content block size adjust by cswu.
// Set position of block
osd_pos(content,0x40,19); // Set Content block position
// Select Block Color
osd_color(title,foreground,normal,LightGreen); // Content
osd_color(title,background,normal,Transparent); // Content
osd_color(content,foreground,normal,LightGreen); // Content
osd_color(content,background,normal,Transparent); // Content
osd_color(content,foreground,highlight,HotPink); // Content
osd_color(content,background,highlight,Transparent); // Content
osd_clear(0x30);osd_clear(0x40);
osd_clear(0x50);osd_clear(0x60);
osd_clear(0x70);osd_clear(0x80);
osd_clear(0x90);osd_clear(0xa0);
osd_clear(0xb0);osd_clear(0xc0);
//osd_clear(0xa0);osd_clear(0xb0);
osd_show(0x3A,10,&TIME_SET_UP);
osd_show(0x50,13,¤t_time);
osd_show(0x70,13,&power_on_time);
osd_show(0x90,13,&power_off_time);
//osd_show(0xb0,4,&Timer);
osd_show(0xb0,0x03,&time_exit);
osd_switch(6); // Turn Title/Content/Bottom Block on
}
//===============================================================
void current_time_menu(unsigned char temphour,unsigned char tempminute,unsigned char tempsecond)//zl.d
{
unsigned char idata temp[8];
unsigned char idata i;
// Show Number of hour --------------------------------------
temp[0] = temphour/10 + 0x62; // 1
i = temphour%10;
temp[1] = i + 0x62; // 2
temp[2]=0x47;
// Show Number of minute -----------------------------------
temp[3] = tempminute/10 + 0x62; // 1
i = tempminute%10;
temp[4] = i + 0x62; // 2
temp[5] = 0x47;
// Show Number of second -----------------------------------
temp[6] =tempsecond/10 + 0x62;
i = tempsecond%10;
temp[7] = i + 0x62; // 3
osd_show(0x62,7,&temp);
}
void on_time_menu(unsigned char temphour,unsigned char tempminute)
{
unsigned char idata temp[5];
unsigned char idata i;
// Show Number of hour --------------------------------------
temp[0] = temphour/10 + 0x62; // 1
i = temphour%10;
temp[1] = i + 0x62; // 2
temp[2]=0x47;
// Show Number of minute -----------------------------------
temp[3] = tempminute/10 + 0x62; // 1
i = tempminute%10;
temp[4] = i + 0x62; // 2
osd_show(0x82,4,&temp);
}
void off_time_menu(unsigned char temphour,unsigned char tempminute)
{
unsigned char data temp[5];
unsigned char data i;
// Show Number of hour --------------------------------------
temp[0] = temphour/10 + 0x62; // 1
i = temphour%10;
temp[1] = i + 0x62; // 2
temp[2]=0x47;
// Show Number of minute -----------------------------------
temp[3] = tempminute/10 + 0x62; // 1
i = tempminute%10;
temp[4] = i + 0x62; // 2
osd_show(0xa2,4,&temp);
}
void able_time_menu(unsigned char able)
{
if(able){
osd_show(0x89,6,&enable);
osd_show(0xa9,6,&enable);
}
else{
osd_show(0x89,6,&disable);
osd_show(0xa9,6,&disable);
}
}
//==================================================
#if 1
void time_setup_process()
{
unsigned char data temp[5]=0,temp1[3]=0 ,tmp3[7]=0;
if(timemenu_flag){
if(!timeshow_flag){
/* tmp3[0]=1;tmp3[1]=2;tmp3[2]=3;
shi_sub_write1(0x66, 0x02, &tmp3);
shi_sub_read1( 0x66, 0x02, &tmp3);
printf("state4==%bx%bx%bx\n",tmp3[0],tmp3[1],tmp3[2]);
tmp3[0]=4;tmp3[1]=5;tmp3[2]=6;
shi_sub_write1(0x66, 0x02, &tmp3);
shi_sub_read1( 0x66, 0x02, &tmp3);
printf("state4==%bx%bx%bx\n",tmp3[0],tmp3[1],tmp3[2]);
tmp3[0]=17;tmp3[1]=18;tmp3[2]=9;
shi_sub_write1(0x66, 0x02, &tmp3);
shi_sub_read1( 0x66, 0x02, &tmp3);
printf("state4==%bx%bx%bx\n",tmp3[0],tmp3[1],tmp3[2]);
curr_time.hour=0, curr_time.minute=0;
read_timer(&curr_time);//zl.d
printf("curr_time.hour, curr_time.minute==%bx%bx\n",curr_time.hour, curr_time.minute);
write_timer(&curr_time);
curr_time.hour=0, curr_time.minute=0;
read_timer(&curr_time);//zl.d
printf("curr_time.hour, curr_time.minute==%bx%bx\n",curr_time.hour, curr_time.minute);
write_timer(&curr_time);
curr_time.hour=0, curr_time.minute=0;
read_timer(&curr_time);//zl.d
printf("curr_time.hour, curr_time.minute==%bx%bx\n",curr_time.hour, curr_time.minute);
write_timer(&curr_time);
curr_time.hour=0, curr_time.minute=0;
read_timer(&curr_time);//zl.d
printf("curr_time.hour, curr_time.minute==%bx%bx\n",curr_time.hour, curr_time.minute);
write_timer(&curr_time);
curr_time.hour=0, curr_time.minute=0;
read_timer(&curr_time);//zl.d
printf("curr_time.hour, curr_time.minute==%bx%bx\n",curr_time.hour, curr_time.minute);
write_timer(&curr_time);
curr_time.hour=0, curr_time.minute=0;
read_timer(&curr_time);//zl.d
printf("curr_time.hour, curr_time.minute==%bx%bx\n",curr_time.hour, curr_time.minute);
write_timer(&curr_time);
curr_time.hour=0, curr_time.minute=0;
read_timer(&curr_time);//zl.d
printf("curr_time.hour, curr_time.minute==%bx%bx\n",curr_time.hour, curr_time.minute);
write_timer(&curr_time);
read_timer(&curr_time);//zl.d
*/
read_timer(0x01,&curr_time);//zl.d
init_timer_menu();
osd_clear(0xd0);osd_clear(0xdd);
//===load time from timer.===================
current_time_menu(curr_time.hour, curr_time.minute,curr_time.second);
//===load time from EEPROM .================
shi_sub_read(EEPROM, 0x20, 0, &on_time.hour);
shi_sub_read(EEPROM, 0x21, 0, &on_time.minute);
shi_sub_read(EEPROM, 0x22, 0, &off_time.hour);
shi_sub_read(EEPROM, 0x23, 0, &off_time.minute);
shi_sub_read(EEPROM, 0x24, 0, &timer_able_flag);
on_time_menu(on_time.hour,on_time.minute);
off_time_menu(off_time.hour,off_time.minute);
able_time_menu(timer_able_flag);
//===================================
timeshow_flag=1;
osd_hbsection(content,hl,0x13,0x14,0x02,0x02);
osd_color(content,background,highlight,Yellow);
}
//=====load timer value on time.
}
/////////////////////////////////////////////////////////////////zl.d
if(timemenu_flag)
{
++Timer_numer;
while(Timer_numer>10)
{
read_timer(0x01,&curr_time);//zl.d
current_time_menu(curr_time.hour, curr_time.minute,curr_time.second);
Timer_numer=0;
}
}
////////////////////////////////////////////////////////////////////
if(timemenu_flag&&(irdown_flag||irup_flag))
{
osd_timer=0;
if(irup_flag){
irup_flag=0;
time_sel--;
if(time_sel==0){
osd_timer=0;
DelayXms(0xff);osd_timer=0;DelayXms(0xff); osd_timer=0;
osd_show(00, 11, &NULLC);
//osd_show(0xd0, 0x10, &NULLC);osd_show(0xe0, 0x10, &NULLC);osd_show(0xf0, 0x08, &NULLC);
osd_clear(0x30);osd_clear(0x40);osd_clear(0x50);osd_clear(0x30);osd_clear(0x60);
osd_clear(0x70);osd_clear(0x80);osd_clear(0x90);osd_clear(0xa0);osd_clear(0xb0);
osd_clear(0xc0);osd_clear(0xd0);osd_clear(0xe0);osd_clear(0xf0);
if(mute_flag){
osd_size(content, 0, 0);
}
irup_flag=1;topmenu_flag=1;osd_timer=0;TR0=1;
time_sel=1;
timemenu_flag=0;
timeshow_flag=0;
inittopmenu();
initsubmenu1();
Submenu1(britc_sel);
osd_timer=0;
osd_switch(7);
}
}
else if(irdown_flag){
irdown_flag=0;
time_sel++;
if(time_sel==10){time_sel=9;}
}
#if _debug
//printf("time_sel=%bx\n",time_sel);
#endif
osd_timer=0;
switch(time_sel){
case 1:
osd_hbsection(content,hl,0x13,0x14,0x02,0x02);
osd_color(content,background,highlight,Yellow);
osd_timer=0;
break;
case 2:
osd_hbsection(content,hl,0x16,0x17,0x02,0x02);
osd_color(content,background,highlight,Yellow);
osd_timer=0;
break;
case 3:
osd_hbsection(content,hl,0x13,0x14,0x03,0x03);
osd_color(content,background,highlight,Yellow);
break;
case 4:
osd_hbsection(content,hl,0x16,0x17,0x03,0x03);
osd_color(content,background,highlight,Yellow);
osd_timer=0;
break;
case 5:
osd_hbsection(content,hl,0x1a,0x20,0x03,0x03);
osd_color(content,background,highlight,Yellow);
osd_timer=0;
break;
case 6:
osd_hbsection(content,hl,0x13,0x14,0x04,0x04);
osd_color(content,background,highlight,Yellow);
osd_timer=0;
break;
case 7:
osd_hbsection(content,hl,0x16,0x17,0x04,0x04);
osd_color(content,background,highlight,Yellow);
osd_timer=0;
break;
case 8:
osd_hbsection(content,hl,0x1a,0x20,0x04,0x04);
osd_color(content,background,highlight,Yellow);
osd_timer=0;
break;
case 9:
osd_hbsection(content,hl,0x00,0x04,0x05,0x05);
osd_color(content,background,highlight,Yellow);
osd_timer=0;
DelayXms(0xff);osd_timer=0;DelayXms(0xff); osd_timer=0;
osd_show(00, 11, &NULLC);
//osd_show(0xd0, 0x10, &NULLC);osd_show(0xe0, 0x10, &NULLC);osd_show(0xf0, 0x08, &NULLC);
osd_clear(0x30);osd_clear(0x40);osd_clear(0x50);osd_clear(0x30);osd_clear(0x60);
osd_clear(0x70);osd_clear(0x80);osd_clear(0x90);osd_clear(0xa0);osd_clear(0xb0);
osd_clear(0xc0);osd_clear(0xd0);osd_clear(0xe0);osd_clear(0xf0);
if(mute_flag){
osd_size(content, 0, 0);
}
top_sel=7;
time_sel=1;
topmenu_flag=1;
britmenu_flag = 0;
timemenu_flag=0;
timeshow_flag=0;
volshow_flag = 0;
exit_flag=0;
inittopmenu();
osd_hbsection(content,hl,0x01,0x10,0x07,0x07);
osd_color(content,background,highlight,Yellow);
osd_timer=0;
TR0=1;
osd_switch(7);
break;
default:
osd_timer=0;
break;
}
osd_timer=0;
}
if(timemenu_flag&&irleft_flag){
irleft_flag=0;
switch (time_sel){
case 1:
read_timer(0x01,&curr_time);
if(curr_time.hour==0){
curr_time.hour=24;
}
curr_time.hour--;
//printf("curr_time.minute%bx",curr_time.minute);
current_time_menu(curr_time.hour, curr_time.minute,curr_time.second);
//temp[0]=curr_time.hour;
//curr_time.hour=temp[0];
write_timer(0x01,&curr_time);
//shi_sub_read1(0x66, 0x02, &temp);
//printf("temp%bx\n",temp[1]);
//shi_sub_write1(0x66, 0x00, &curr_time.hour);
//write to timer chip
break;
case 2:
read_timer(0x01,&curr_time);
if(curr_time.minute==0){
curr_time.minute=60;
}
curr_time.minute--;
current_time_menu(curr_time.hour, curr_time.minute,curr_time.second);
//write to timer chip
//temp[1]=curr_time.minute;
//read_timer(&curr_time);
//curr_time.minute=temp[1];
write_timer(0x01,&curr_time);
break;
case 3:
//on_time.hour=12;on_time.minute=4;
//temp[0]=1;temp[2]=2;temp[3]=3;
//shi_sub_write1(0x68, 0x02, &temp);
//write_timer(0x02, &on_time);
//shi_sub_read1(0x68, 0x02,&temp);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -