标题:
桑拿浴房控制器电路与单片机程序设计
[打印本页]
作者:
冬晨曦
时间:
2018-11-11 15:45
标题:
桑拿浴房控制器电路与单片机程序设计
桑拿浴房控制器
0.png
(42.62 KB, 下载次数: 38)
下载附件
2018-11-11 16:13 上传
单片机源程序如下:
/***************************************************************
* High grade personal sana control system v3.0 *
* *
* function: 1.control tempreture and time. *
* 2.control push water header. *
* 3.control keyboard and lcd screen. *
* 4.control radio,music,or languge audio output. *
* 5.control outside device(for example: fans,phone..)*
****************************************************************/
#include <at89x52.h>
#include <string.h>
#define uint unsigned int
#define uchar unsigned char
//-------const define--------
#define ENTER_W P1_3 //=0 THEN ENTER WATER
#define GO_W P1_4
#define HEAT P1_5
#define ISD_SCLK P1_6
#define ISD_MOSI P2_5
#define ASK P1_7 //=1 LCD IS BUSY
#define WP_SW P1_0 //=0 WATER IS FULL
#define EEPROM_SDA P1_2 //cat24c021'data pin(24c02+watchdog)
#define EEPROM_SCL P1_1 //cat24c021'clock pin(24c02+watchdog)
#define RM_IN INT0
#define ANSWER INT1
#define LATCH T0
#define TMP_IN T1
#define BEEP P2_7
#define M62429_CL P2_6
#define M62429_DA P2_0
#define RDKEY2 P2_4
#define RDKEY1 P3_6
#define RADIO_DO P2_3
#define RADIO_CL P2_2
#define RADIO_CE P2_1
#define RADIO_DI P2_0
#define ISD_INT P3_7
#define KEYPORT P0
#define LCDPORT P0
#define setb(bitunit) {bitunit=1;out_port();}
#define clrb(bitunit) {bitunit=0;out_port();}
#define NONE_KEY 0
#define UP_KEY 1
#define DOWN_KEY 2
#define LEFT_KEY 3
#define RIGHT_KEY 4
#define OSD_KEY 5
#define SMOKER_KEY 6
#define LAMP_KEY 7
#define AMB_KEY 8
#define POWER_KEY 9
#define MUSIC_KEY 10
#define FAN_KEY 11
#define LP_KEY 12
#define MAXITEMS 4
//---------eeprom unit define
#define ID_ADDR 8 //this address data must is 0x28
#define STATUS_BYTE 18 //this byte save status1 data
#define FM_FRE_ADDR 28 //4 byte fm fre value(low to high) from this address start
#define STMP_ADDR 38 //1 byte save the set tempreture
//---------bit unit define-------
bdata uchar port0,port1,port2,status,status1;
sbit power_sta=status^0; //=1 then power is on
sbit disp_sta_flag=status^1; //=1 then display status line
sbit smoker_flag=status^2; //=1 then in smoker status
sbit waterfull_flag=status^3; //=1 then water is full
sbit menu_flag=status^5; //=1 then menu status
sbit lockf=status^6; //=1 then lock self
sbit lppw_flag=status^7; //=1 then loop push water
sbit keyvoice_flag=status1^0; //=1 then press key BEEP
sbit voice_flag=status1^1; //=1 then voice output
sbit first_chk_flag=status1^2; //=1 then chkself finish
sbit english_chinese=status1^3;//=1 then chinese menu else english menu
sbit mutef=status1^4; //=1 then mute
sbit shift_flag=status1^5; //=1 then send the output bit data
sbit danger_flag=status1^6; //=1 then water is already empty,indicate water don't long time full
sbit first_smoker_flag=status1^7; //=1 then first open the smoker in power on status
//sbit first_speechf=status1^5; //=1 then first speech play complete
sbit AMBDRV=port0^3; //=1 then an mp beng open
sbit O_INC=port0^4; //=1 then o++
sbit KILLV=port0^5; //=1 then kill virus
sbit FCOOL=port0^6; //=1 then cool fan
sbit FWARM=port0^7; //=1 then hot fan
sbit CYY=port1^0; //=1 then chou yang yu open
sbit FAN=port1^1; //=1 fan open
sbit LAMP2=port1^2; //=1 lamp2 on
sbit LAMP1=port1^3; //=1 lamp1 on
sbit W3=port1^4; //=1 4 line push water header
sbit W2=port1^5;
sbit W1=port1^6;
sbit W0=port1^7;
sbit CD_RADIO=port2^0; //=0 cd on else =1 radio on
sbit SOUND_CDRADIO=port2^1; //=0 sound on else cd or radio
sbit ISD_SS=port2^4;
//sbit ISD_SCLK=port2^3;
//sbit ISD_MOSI=port2^5;
sbit LCD_LIT=port2^3;
//sbit RDKEY2=port2^6;
//sbit RDKEY1=port2^7;
//----------function define----------
void out_port();
void initial();
void delay(uint);
void clr_lcd();
void disp_hz_str(uchar col,uchar row,uchar len,uchar *hzstr);
void disp_ch_str(uchar col,uchar row,uchar len,uchar *chstr);
void disp_hz(uchar col,uchar row,uint qwcode);
void disp_ch(uchar col,uchar row,uchar chcode);
void disp_icon(uchar col,uchar row,uchar *icon_ptr);
unsigned char read_key();
void wait_key_off();
void ls_lcd();
void disp_tmp();
unsigned char get_tmp(uint cntval);
void osd();
void fanctrl();
void amb();
void music();
void uk();
void lk();
void rk();
void dk();
void smoker();
void lamp();
void display();//display the menu or the other function
void disp_status();//display the funciotn icon status line
void chkself();//check self whole machine
bit timewait_key_off(uchar wk_time);//timing wait key off
void lp();
void setvol(uchar volv);//set 62429 vol
bit wrt_24cxx(uchar ic_type,uchar byte_addr,wdata);//radom wrt 24cxx,return 0 is ok
bit rd_24cxx(uchar ic_type,uchar byte_addr,uchar *rd_ptr);//radom read 24cxx,return 0 is ok
void reset_dog();
void dly_us(uchar us_v);//delay i us
void sstart();//send start bit
void sstop();//send stop bit
void send_ack();
void send_noack();
bit sdata(uchar tdata);//send data to eeprom, return 0 is ok else return 1
uchar rdata(); //read 1 byte data from at24cxx
bit set_radio_fre(unsigned long int fre);//set FM radio fre(88000khz--108000khz)
unsigned long int rece_pll_data();
void send_pll_data(unsigned long int ccb_data_block);
void mute();//mute
void wpchk();//water position test;if water full then waterfull_flag=1
void play_voice(uchar seg_no);
void send_isd_byte(uchar isd_data);
void delay(uint ms);
void stop_isd();
void up_isd();
void cyc();
void save_par();
void read_par();
void demo(uchar i);
void disp_second_dot();
//-----------unit define------------
uchar seccnt=20,mincnt=60,keycode=0,rmcode,wfcnt=0,wecnt=0,cyc_cnt=0;
uchar stmp,stime,ctmp,vol=50,/*(0--80)*/items=0;
uchar staline_disp_cnt,menu_disp_cnt,icon_cnt=0,speech_num=255;
uchar lppw_cnt=80,music_cnt=0;/*=0:cd,radio all off;=1:radio on;=2:cd on;*/
uint lcd_disp_cnt=3000;
uint enterw_time_cnt,waterfull_hottime_cnt;
unsigned long int fm_fre=94600;//khz
//-----------string define----------
code uchar str1[]="温度:";
code uchar str2[]="+ ";
code uchar fan_on_str[]=" 风扇开启 ";
code uchar fan_off_str[]=" 风扇关闭 ";
code uchar lit1_on_str[]=" 灯一开启 ";
code uchar lit2_on_str[]=" 灯二开启 ";
code uchar lit_off_str[]=" 灯光关闭 ";
code uchar radio_on_str[]=" 收音开启 ";
code uchar sound_off_str[]=" 音乐关闭 ";
code uchar sound_on_str[]=" 音乐开启 ";
code uchar cd_on_str[]=" 唱碟开启 ";
code uchar amb_on_str[]=" 按摩泵开启 ";
code uchar amb_off_str[]=" 按摩泵关闭 ";
code uchar smoke_on_str[]=" 蒸汽开启 ";
code uchar smoke_off_str[]=" 蒸汽关闭 ";
code uchar tp_on_str[]=" 顶喷开启 ";
code uchar tp_off_str[]=" 顶喷关闭 ";
code uchar bp_on_str[]=" 下喷开启 ";
code uchar bp_off_str[]=" 下喷关闭 ";
code uchar mp_on_str[]=" 中喷开启 ";
code uchar mp_off_str[]=" 中喷关闭 ";
code uchar hp_on_str[]=" 上喷开启 ";
code uchar hp_off_str[]=" 上喷关闭 ";
code uchar lp_on_str[]=" 循环喷水开启 ";
code uchar lp_off_str[]=" 循环喷水关闭 ";
code uchar zy_on_str[]=" 增氧开启 ";
code uchar zy_off_str[]=" 增氧关闭 ";
code uchar sj_on_str[]=" 杀菌开启 ";
code uchar sj_off_str[]=" 杀菌关闭 ";
code uchar nf_on_str[]=" 暖风开启 ";
code uchar nf_off_str[]=" 暖风关闭 ";
code uchar lf_on_str[]=" 冷风开启 ";
code uchar lf_off_str[]=" 冷风关闭 ";
code uchar yy_on_str[]=" 语音开启 ";
code uchar yy_off_str[]=" 语音关闭 ";
code uchar jy_on_str[]=" 键音开启 ";
code uchar jy_off_str[]=" 键音关闭 ";
code uchar nopstr[]="";
code uchar chkself_str0[]=" 请 稍 等 ";
code uchar chkself_str1[]="蒸汽机进入自动清";
code uchar chkself_str2[]="洗自动检测状态 ";
code uchar chkself_str5[]="一切功能暂停使用";
code uchar chkself_str3[]=" 自检成功 ";
code uchar chkself_str4[]=" 电脑安全上锁 ";
code uchar chkself_str6[]=" 蒸汽暂停使用 ";
code uchar chkself_str7[]=" 请参考说明书 ";
code uchar power_off_str[6][16]={"您好 谢谢使用 ","Hello,thank you ","for your use ","蒸汽机已安全关闭","The steamer is ","already shutdown"};
code uchar title_str1[3][16]={"您好 欢迎使用","维特斯巡航智能型","电脑蒸汽房产品 "};
code uchar title_str2[11][16]={"Hello,thank you ","for selecting ","Watxfy series ",
"products.Our cru","ising intellectu","al computer ste",
"am room introduc","ed from Finland ","is specially de",
"signed for the ","Chinese market. "};
code uchar help_str[158][16]={" ",
" ",
" ",
" ",
"维特斯巡航智能型",
" ",
"电脑蒸汽房来自芬",
" ",
"兰休闲色彩 本型",
" ",
"号为中国市场特别",
" ",
"设计 ",
" ",
"Watxfy crusing ",
" ",
"intellectual com",
" ",
"puter steam is ",
" ",
"introduced from ",
" ",
"Finland,and its ",
" ",
"W-2000 is specia",
" ",
"lly designed for",
" ",
"the Chinese mark",
" ",
"et. ",
" ",
" ",
" ",
" 功能简介 ",
" Briefs of ",
" functions ",
" ",
" 含选配功能 ",
" ",
" ",
" ",
" 双色幻彩灯 ",
"Safe dual-color ",
" lights ",
" ",
" 电子排气 ",
"Electric exhaust",
" ",
" 音响唱碟转换 ",
" Stereo radio, ",
" CD conversion ",
" ",
" 水力针刺按摩 ",
"Hydraulic acupun",
"cture massage ",
" ",
" 增 氧 ",
" Oxygenation ",
" ",
" 杀 菌 ",
" Sterilization ",
" ",
" 电 话 ",
" Telephone ",
" ",
" 冷 风 ",
" Cool air ",
" ",
" 热风干蒸 ",
" Dry steam by ",
" hot air ",
" ",
" 电子控制冲浪 ",
" Electric wave ",
" ",
" 按键提示音 ",
" Key tone ",
" ",
" 中英文显示 ",
"Chinese and Eng-",
"lish display ",
" ",
" 语音提示 ",
" Speech ",
" ",
" 脚底按摩 ",
" Sole massage ",
" ",
" 药浴蒸汽 ",
" Herbal steam ",
" ",
" 自动恒温 ",
"Automatic thermo",
"stat ",
" 自动定时 ",
"Automatic timing",
" ",
" 蒸汽机自动清洗",
"Automatic clean-",
"ing of steamer ",
" ",
"电脑自动巡航监控",
"Computer auto cr",
"uising monitor ",
" ",
"自动检测故障提示",
"Auto detection, ",
"trouble indicati",
" ",
"及安全上锁 ",
"on and safe lock",
" ",
" 报警装置 ",
" Alarm device ",
" ",
" ",
" ",
" ",
" 全球机型简介 ",
"Briefs of global",
"models: ",
" ",
" 英语机型 ",
"English-langrage",
"models: W-E2000 ",
" ",
" 俄语机型 ",
"Russian-langrage",
"models: W-R2000 ",
" ",
" 汉语机型 ",
"Chinese-langrage",
"models: W-C2000 ",
" ",
" 日语机型 ",
"Japaneselangrage",
"models: W-J2000 ",
" ",
" 法语机型 ",
"French-langrage ",
"models: W-F2000 ",
" ",
" 德语机型 ",
"German-langrage ",
"models: W-G2000 ",
" ",
" 韩语机型 ",
"Korean-langrage ",
"models: W-K2000 ",
" ",
" 西班牙语机型 ",
"Spanish-langrage",
"models: W-S2000 ",
" ",
" ",
" ",
" "};
code uint tmp_tab[]={612,630,660,700,740,770,807,836,880,920,//0-9 C
958,1013,1068,1107,1178,1221,1275,1331,1391,1451,//10-19 C
1528,1606,1675,1744,1769,1901,1916,2023,2101,2180,//20-29 C
2357,2412,2521,2631,2704,2804,2904,3014,3134,3249,//30-39 C
3375,3495,3645,3825,4004,4125,4305,4479,4634,4790,//40-49 C
4891,5063,5263,5477,5691,5841,6087,6287,6513,6739,//50-59 C
6949,7160,7346,7644,7942,8181,8374,8654,8959,9264,//60-69 C
9523,9876,10099,10432,10765,10978,11317,11617,11939,//70-79 C
12642,12950,13250,13550,13900,14250,14600,15000,15400,15800,//80-89 C
16200,16600,17000,17450,17900,18350,18800,19250,19700,20200//90-99 C
};
code uint rm_tab[]={0xA05F,0x8877,0x08F7,0x906F,0xB847,0xF807,0xB04F,0x9867,
0xD827,0xC03F,0x40BF,0x00FF,0x807F,0x609F,0x20DF,0xF00F,
0x58A7,0x28D7,0x6897,0x708F,0x30CF,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000};
code uchar fan_icon[]={0x00,0x00,0x00,0x00,0x07,0x80,0x02,0x40,
0x01,0x20,0x01,0x20,0x01,0x40,0x3b,0x80,
0x46,0x80,0x47,0xc0,0x48,0xbe,0x50,0x84,
0x60,0x48,0x40,0x30,0x00,0x00,0x00,0x00};
code uchar fan1_icon[]={0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x48,
0x00,0x24,0x38,0x24,0x44,0x48,0x87,0xf0,
0x9a,0x80,0x63,0x80,0x00,0xc0,0x00,0xb0,
0x00,0x8c,0x00,0x44,0x00,0xf0,0x00,0x00};
code uchar fan2_icon[]={0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x06,
0x48,0x09,0x44,0x11,0x22,0x21,0x23,0xfe,
0x1f,0xc0,0x01,0x80,0x01,0x80,0x02,0x80,
0x02,0x40,0x02,0x20,0x01,0x20,0x00,0xc0};
code uchar light_icon[]={ 0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,
0x40,0x04,0x23,0x88,0x07,0xc0,0x0f,0xe0,
0x0f,0xe0,0x07,0xc0,0x03,0x80,0x13,0x90,
0x23,0x88,0x03,0x80,0x00,0x00,0x00,0x00};
code uchar music_icon[]={ 0x00,0x00,0x00,0x00,0x07,0x80,0x07,0x80,
0x04,0xe0,0x04,0x3c,0x04,0x04,0x04,0x04,
0x04,0x04,0x3c,0x04,0x3c,0x04,0x38,0x3c,
0x00,0x3c,0x00,0x38,0x00,0x00,0x00,0x00};
code uchar smoker_icon[]={0x0f,0xf0,0x10,0x08,0x21,0xe4,0x42,0x12,
0x82,0x09,0x84,0x01,0x98,0x81,0xa3,0x31,
0xa2,0x71,0xa4,0xf1,0xa1,0xf1,0x83,0xf1,
0x43,0xfa,0x20,0x1c,0x10,0x08,0x0f,0xf0};
code uchar amb_icon[]={0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,
0x23,0xc0,0x24,0x20,0x2a,0x50,0x29,0x90,
0x29,0x90,0x2a,0x50,0x24,0x20,0x23,0xc0,
0x20,0x00,0x3f,0xf8,0x00,0x00,0x00,0x00};
code uchar menu_icon[]={0x0f,0xf0,0x10,0x08,0x20,0x04,0x40,0x02,
0xbb,0xb9,0xaa,0x29,0xaa,0x25,0xaa,0x25,
0xab,0xa5,0xa8,0xa5,0xa8,0xa5,0xa8,0xa9,
0x7b,0xba,0x20,0x04,0x10,0x08,0x0f,0xf0};
code uchar left_icon[]={ 0x00,0x00,0x00,0x00,0x00,0x60,0x00,0xe0,
0x01,0xe0,0x03,0xe0,0x07,0xe0,0x0f,0xe0,
0x0f,0xe0,0x07,0xe0,0x03,0xe0,0x01,0xe0,
0x00,0xe0,0x00,0x60,0x00,0x00,0x00,0x00};
code uchar right_icon[]={ 0x00,0x00,0x00,0x00,0x0c,0x00,0x0e,0x00,
0x0f,0x00,0x0f,0x80,0x0f,0xc0,0x0f,0xe0,
0x0f,0xe0,0x0f,0xc0,0x0f,0x80,0x0f,0x00,
0x0e,0x00,0x0c,0x00,0x00,0x00,0x00,0x00};
code uchar up_icon[]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0x80,0x03,0xc0,0x07,0xe0,
0x0f,0xf0,0x1f,0xf8,0x3f,0xfc,0x3f,0xfc,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
code uchar down_icon[]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x3f,0xfc,0x3f,0xfc,0x1f,0xf8,
0x0f,0xf0,0x07,0xe0,0x03,0xc0,0x01,0x80,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
code uchar cw_fan_icon[]={0x00,0x00,0x00,0x00,0x3f,0xe0,0x20,0x20,
0x20,0x00,0x20,0x70,0x23,0x8e,0x20,0x00,
0x20,0x70,0x23,0x8e,0x20,0x00,0x20,0x70,
0x23,0x87,0x20,0x20,0x3f,0xe0,0x00,0x00};
code uchar o2_icon[]={ 0x00,0x00,0x00,0x00,0x0c,0x00,0x12,0x00,
0x21,0x00,0x21,0x00,0x21,0x00,0x21,0x00,
0x21,0x30,0x21,0x48,0x21,0x08,0x21,0x70,
0x12,0x40,0x0c,0x78,0x00,0x00,0x00,0x00};
code uchar o3_icon[]={ 0x00,0x00,0x00,0x00,0x0c,0x00,0x12,0x00,
0x21,0x00,0x21,0x00,0x21,0x00,0x21,0x30,
0x21,0x48,0x21,0x08,0x21,0x30,0x21,0x08,
0x12,0x48,0x0c,0x30,0x00,0x00,0x00,0x00};
code uchar pushw_icon[]={ 0x00,0x00,0x00,0x00,0x20,0x84,0xf1,0xcf,
0x21,0xc4,0x03,0x80,0x07,0xc0,0x27,0xe4,
0xf5,0xcf,0x25,0xc4,0x0d,0xe0,0x1f,0xf0,
0x03,0xb0,0x01,0xb0,0x01,0xb0,0x00,0x90};
code uchar lock_icon[]={ 0x00,0x00,0x00,0x00,0x03,0xc0,0x04,0x20,
0x04,0x20,0x04,0x20,0x1f,0xf8,0x10,0x08,
0x1f,0xf8,0x10,0x08,0x1f,0xf8,0x10,0x08,
0x1f,0xf8,0x1f,0xf8,0x00,0x00,0x00,0x00};
//
uint code isd_addr[]={ 0x0000,0x0034,0x0077,0x0080,
0x0089,0x0091,0x009b,0x00a5,
0x00af,0x00bb,0x00c8,0x00d2,
0x00db,0x00e6,0x00ef,0x00f7,
0x0100,0x0108,0x0111,0x0119,
0x0122,0x012d,0x013a,0x0142,
0x014c,0x0156,0x0161,0x016e,
0x017c,0x0185,0x018e,0x0198,
0x01a3,0x01aa,0x01b4,0x01d6,
0x01f0,0x020b,0x0216,0x021d};
//
main(void)
{
uint cnt0,i;
uchar j;
// uint waterfull_hottime_cnt;
reset_dog();
delay(200);
read_par();
initial();
first_chk_flag=0;
cnt0=1300;
clr_lcd();
// delay(300);
disp_ch_str(0,2,16," Watxfy ");
while(1)//main loop
{
j=0;
while(keycode!=POWER_KEY&&rmcode!=1)
{
reset_dog();
delay(100);
if(--cnt0==0)
{
cnt0=1300;
GO_W=1; //close water switch
ENTER_W=1;
}
if(cnt0%15==0)
{
demo(j);
if(help_str[j][0]>=0xa0)
j=j+1;
else
j=j+2;
if(j>153)
j=0;
}
keycode=read_key();
}
wait_key_off();
power_sta=1;
rmcode=0;
// if(english_chinese==0)
// {
clr_lcd(); //power key press ,open the machine
disp_hz_str(0,0,8,title_str1[0]);
disp_hz_str(0,1,8,title_str1[1]);
disp_hz_str(0,2,8,title_str1[2]);
disp_hz_str(0,3,8,title_str1[3]);
play_voice(0);
if(voice_flag)
{
while(ISD_INT)
if(keycode=read_key()>0||rmcode>0)
goto power_on;
}
else
{
i=100;
while(i--)
{
delay(100);
if(keycode=read_key()>0||rmcode>0)
goto power_on;
};
}
// }
// else
// {
clr_lcd();
disp_ch_str(0,0,16,title_str2[0]);
disp_ch_str(0,1,16,title_str2[1]);
disp_ch_str(0,2,16,title_str2[2]);
disp_ch_str(0,3,16,title_str2[3]);
disp_ch_str(0,4,16,title_str2[4]);
disp_ch_str(0,5,16,title_str2[5]);
disp_ch_str(0,6,16,title_str2[6]);
disp_ch_str(0,7,16,title_str2[7]);
play_voice(1);
i=100;
while(i--)
{
delay(100);
if(keycode=read_key()>0||rmcode>0)
goto power_on;
};
clr_lcd();
disp_ch_str(0,0,16,title_str2[8]);
disp_ch_str(0,1,16,title_str2[9]);
disp_ch_str(0,2,16,title_str2[10]);
if(voice_flag)
{
while(ISD_INT)
if(keycode=read_key()>0||rmcode>0)
goto power_on;
}
else
{
i=100;
while(i--)
{
delay(100);
if(keycode=read_key()>0||rmcode>0)
goto power_on;
};
}
// }
power_on:
keycode=read_key();
menu_flag=0;
speech_num=255;
first_smoker_flag=1;
// first_speechf=0;
GO_W=1; //close water switch
ENTER_W=1;
// stmp=60;
stime=90;
// enterw_time_cnt=23622; //set enter time is 30s=1.27ms*23622
enterw_time_cnt=300; //set enter time is 30s
// waterfull_hottime_cnt=355719;//set 8 minute hot time in water full state 1.35ms*355719=480s
waterfull_hottime_cnt=4800;//set 8 minute hot time in water full state
music_cnt=0;
mute();
setb(SOUND_CDRADIO);//open cd or radio
// setvol(vol);
if(keycode!=POWER_KEY)
{
display();
disp_status();
}
/* if(waterfull_flag==0&&lockf==0)
{
waterfull_flag=0; //if water is not full then enter water
smoker_flag=0;
ENTER_W=0;
}*/
while(power_sta)
{
delay(1);
disp_second_dot();
disp_tmp();
if(shift_flag)
{
out_port();
display();
shift_flag=0;
}
if(!lockf&&smoker_flag)
{
if(waterfull_flag)
{
ENTER_W=1;
GO_W=1;
enterw_time_cnt=300; //set enter time is 30s=1.27ms*23622
}
else
{
ENTER_W=0;
GO_W=1;
}
}
if(keycode==0)
keycode=read_key();
if(keycode)
{
switch(keycode)
{
case LP_KEY:
lp();
wait_key_off();
break;
case UP_KEY:
uk();
if(timewait_key_off(70))
{
while(timewait_key_off(10))
uk();
}
break;
case DOWN_KEY:
dk();
if(timewait_key_off(70))
{
while(timewait_key_off(10))
dk();
}
break;
case LEFT_KEY:
lk();
if(timewait_key_off(70))
{
while(timewait_key_off(3))
lk();
setvol(vol);
}
break;
case RIGHT_KEY:
rk();
if(timewait_key_off(70))
{
while(timewait_key_off(3))
rk();
setvol(vol);
}
break;
case OSD_KEY:
osd();
display();
wait_key_off();
break;
case SMOKER_KEY:
enterw_time_cnt=300; //set enter time is 30s=1.27ms*23622
waterfull_hottime_cnt=4800;//set 8 minute hot time in water full state 1.35ms*355719=480s
smoker();
wait_key_off();
break;
case LAMP_KEY:
lamp();
wait_key_off();
break;
case AMB_KEY:
amb();
wait_key_off();
break;
case POWER_KEY:
initial();
power_sta=0;
mute();
GO_W=0;
ENTER_W=1;
cnt0=1300;
clr_lcd();
disp_hz_str(0,0,8,power_off_str[0]);
disp_ch_str(0,3,16,power_off_str[1]);
disp_ch_str(0,4,16,power_off_str[2]);
disp_hz_str(0,3,8,power_off_str[3]);
play_voice(37);
wait_key_off();
i=0;
do
{
delay(1);
++i;
}while(i<30000&&(keycode=read_key())!=POWER_KEY&&rmcode!=1);
if(i==30000)
{
GO_W=ENTER_W=1;
delay(800);
ENTER_W=0;
i=0;
do
{
delay(1);
++i;
}while(i<25000&&(keycode=read_key())!=POWER_KEY&&rmcode!=1);
}
GO_W=0;
ENTER_W=1;
break;
case MUSIC_KEY:
music();
wait_key_off();
break;
case FAN_KEY:
fanctrl();
wait_key_off();
break;
}
save_par();
}
if(rmcode)
{
if(keyvoice_flag&&power_sta)
{
BEEP=0;
delay(20);
BEEP=1;
}
switch(rmcode)
{
case 1://power
rmcode=0;
initial();
power_sta=0;
mute();
GO_W=0;
ENTER_W=1;
cnt0=1300;
clr_lcd();
disp_hz_str(0,0,8,power_off_str[0]);
disp_ch_str(0,3,16,power_off_str[1]);
disp_ch_str(0,4,16,power_off_str[2]);
disp_hz_str(0,3,8,power_off_str[3]);
play_voice(37);
i=0;
do
{
delay(1);
++i;
}while(i<30000&&(keycode=read_key())!=POWER_KEY&&rmcode!=1);
if(i==30000)
{
GO_W=ENTER_W=1;
delay(800);
ENTER_W=0;
i=0;
do
{
delay(1);
++i;
}while(i<25000&&(keycode=read_key())!=POWER_KEY&&rmcode!=1);
}
GO_W=0;
ENTER_W=1;
break;
case 2://lamp
lamp();
break;
case 3://smoker
enterw_time_cnt=300; //set enter time is 30s=1.27ms*23622
waterfull_hottime_cnt=4800;//set 8 minute hot time in water full state 1.35ms*355719=480s
smoker();
break;
case 4://fan
fanctrl();
break;
case 5://pump
amb();
break;
case 6://hot fan
AMBDRV=0;
smoker_flag=0;
HEAT=1;
FWARM=~FWARM;
if(FWARM)
FCOOL=1;
else
FCOOL=0;
out_port();
if(english_chinese==0)
FWARM==1?disp_hz_str(0,3,8,nf_on_str):disp_hz_str(0,3,8,nf_off_str);
else
{
disp_hz_str(0,3,8,nopstr);
if(FWARM)
{
disp_ch_str(0,6,16," Dry steam by ");
disp_ch_str(0,7,16," hot air on ");
}
else
{
disp_ch_str(0,6,16," Dry steam by ");
disp_ch_str(0,7,16," hot air off ");
}
}
FWARM==1?play_voice(20):play_voice(21);
break;
case 7://kill virus
KILLV=~KILLV;
out_port();
if(english_chinese==0)
KILLV==1?disp_hz_str(0,3,8,sj_on_str):disp_hz_str(0,3,8,sj_off_str);
else
{
disp_hz_str(0,3,8,nopstr);
if(KILLV)
{
disp_ch_str(0,6,16," Sterilization ");
disp_ch_str(0,7,16," on ");
}
else
{
disp_ch_str(0,6,16," Sterilization ");
disp_ch_str(0,7,16," off ");
}
}
KILLV==1?play_voice(16):play_voice(17);
break;
case 8://o++
O_INC=~O_INC;
out_port();
if(english_chinese==0)
O_INC==1?disp_hz_str(0,3,8,zy_on_str):disp_hz_str(0,3,8,zy_off_str);
else
{
disp_hz_str(0,3,8,nopstr);
if(O_INC)
{
disp_ch_str(0,7,16," Oxygenation on ");
}
else
{
disp_ch_str(0,7,16," Oxygenation off");
}
}
O_INC==1?play_voice(14):play_voice(15);
break;
case 9://cool fan
if(FWARM)
{
FWARM=0;
FCOOL=1;
}
else
{
FCOOL=~FCOOL;
FWARM=0;
}
out_port();
if(english_chinese==0)
FCOOL==1?disp_hz_str(0,3,8,lf_on_str):disp_hz_str(0,3,8,lf_off_str);
else
{
disp_hz_str(0,3,8,nopstr);
if(FCOOL)
{
disp_ch_str(0,7,16," Cool air on ");
}
else
{
disp_ch_str(0,7,16," Cool air off ");
}
}
FCOOL==1?play_voice(18):play_voice(19);
break;
case 10://lp
lp();
break;
case 11://temp inc
menu_flag=1;
items=0;
display();
if(smoker_flag==0)
break;
if(stmp==60)
stmp=35;
else
stmp++;
disp_hz_str(0,0,8,nopstr);
if(english_chinese==0)
disp_hz_str(0,0,8,"温度 时间 ");
else
disp_ch_str(0,1,16,"TEMP TIME ");
disp_ch(14,1,stime/10+'0');
disp_ch(15,1,stime%10+'0');
disp_ch(4,1,stmp/10+'0');
disp_ch(5,1,stmp%10+'0');
play_voice(33);
break;
case 12://time inc
menu_flag=1;
items=0;
display();
if(smoker_flag==0)
break;
if(stime>=90)
stime=5;
else
stime++;
disp_hz_str(0,0,8,nopstr);
if(english_chinese==0)
disp_hz_str(0,0,8,"温度 时间 ");
else
disp_ch_str(0,1,16,"TEMP TIME ");
disp_ch(14,1,stime/10+'0');
disp_ch(15,1,stime%10+'0');
disp_ch(4,1,stmp/10+'0');
disp_ch(5,1,stmp%10+'0');
play_voice(32);
break;
case 13://mute
mutef=~mutef;
if(mutef)
{
mute();
play_voice(12);
disp_hz_str(0,3,8,nopstr);
if(english_chinese==0)
disp_hz_str(0,3,8,sound_off_str);
else
disp_ch_str(0,7,16," Music off ");
}
else
{
setvol(vol);
play_voice(36);
disp_hz_str(0,3,8,nopstr);
if(english_chinese==0)
disp_hz_str(0,3,8,sound_on_str);
else
disp_ch_str(0,7,16," Music on ");
}
break;
case 14://temp dec
menu_flag=1;
items=0;
display();
if(smoker_flag==0)
break;
if(stmp==35)
stmp=60;
else
stmp--;
disp_hz_str(0,0,8,nopstr);
if(english_chinese==0)
disp_hz_str(0,0,8,"温度 时间 ");
else
disp_ch_str(0,1,16,"TEMP TIME ");
disp_ch(14,1,stime/10+'0');
disp_ch(15,1,stime%10+'0');
disp_ch(4,1,stmp/10+'0');
disp_ch(5,1,stmp%10+'0');
play_voice(33);
break;
case 15://time dec
menu_flag=1;
items=0;
display();
if(smoker_flag==0)
break;
if(stime<=1)
stime=90;
else
stime--;
disp_hz_str(0,0,8,nopstr);
if(english_chinese==0)
disp_hz_str(0,0,8,"温度 时间 ");
else
disp_ch_str(0,1,16,"TEMP TIME ");
disp_ch(14,1,stime/10+'0');
disp_ch(15,1,stime%10+'0');
disp_ch(4,1,stmp/10+'0');
disp_ch(5,1,stmp%10+'0');
play_voice(32);
break;
case 16://radio
music_cnt=1;
mutef=0;
setb(SOUND_CDRADIO);//open cd or radio
setb(CD_RADIO);//radio on
setvol(vol);
set_radio_fre(fm_fre);
send_pll_data(0x0200a029);//open the radio
display();
disp_hz_str(0,3,8,nopstr);
play_voice(10);
break;
case 17://vol inc
if(mutef==0&&music_cnt!=0)
{
menu_flag=1;
items=1;
display();
if(vol<80)
{
vol++;
disp_hz(7,0,0x375a);
disp_ch(14,1,vol/10+'0');
disp_ch(15,1,vol%10+'0');
setvol(vol);
play_voice(31);
}
}
break;
case 18://tuning inc
menu_flag=1;
items=1;
display();
if(CD_RADIO)
{
play_voice(30);
rmcode=0;
mute();
do
{
if(fm_fre<108000)
fm_fre=fm_fre+100;
else
fm_fre=88000;
disp_hz(2,0,0x375a);
disp_hz(3,0,0x375a);
disp_hz(4,0,0x375a);
disp_ch_str(6,0,2,"FM");
disp_ch(4,1,fm_fre/100000?'1':' ');
disp_ch(5,1,fm_fre/10000%10+'0');
disp_ch(6,1,fm_fre/1000%10+'0');
disp_ch(7,1,'.');
disp_ch(8,1,fm_fre/100%10+'0');
}while(set_radio_fre(fm_fre)&&read_key()==0&&rmcode==0);//&&timewait_key_off(1));
rmcode=18;
setvol(vol);
send_pll_data(0x0200a029);//open the radio
wait_key_off();
}
break;
case 19://cd
music_cnt=2;
mutef=0;
setb(SOUND_CDRADIO);
clrb(CD_RADIO);//cd on
setvol(vol);
display();
disp_hz_str(0,3,8,nopstr);
play_voice(11);
break;
case 20://vol dec
if(mutef==0&&music_cnt!=0)
{
menu_flag=1;
items=1;
display();
if(vol>0)
{
vol--;
disp_hz(7,0,0x375a);
disp_ch(14,1,vol/10+'0');
disp_ch(15,1,vol%10+'0');
setvol(vol);
play_voice(31);
}
}
break;
case 21://tuning dec
menu_flag=1;
items=1;
display();
if(CD_RADIO)
{
play_voice(30);
rmcode=0;
mute();
do{
if(fm_fre>88000)
fm_fre=fm_fre-100;
else
fm_fre=108000;
disp_hz(2,0,0x375a);
disp_hz(3,0,0x375a);
disp_hz(4,0,0x375a);
disp_ch_str(6,0,2,"FM");
disp_ch(4,1,fm_fre/100000?'1':' ');
disp_ch(5,1,fm_fre/10000%10+'0');
disp_ch(6,1,fm_fre/1000%10+'0');
disp_ch(7,1,'.');
disp_ch(8,1,fm_fre/100%10+'0');
}while(set_radio_fre(fm_fre)&&read_key()==0&&rmcode==0);//&&timewait_key_off(1));
rmcode=21;
setvol(vol);
send_pll_data(0x0200a029);//open the radio
wait_key_off();
}
break;
default:
break;
}
menu_disp_cnt=100; //10s delay
staline_disp_cnt=30; //3 second delay
disp_sta_flag=1;
if(rmcode!=1)
{
rmcode=0;
save_par();
}
}
if(staline_disp_cnt==0&&disp_sta_flag==1)
{
// disp_sta_flag=0;
staline_disp_cnt=3;
disp_status();
}
if(menu_disp_cnt==0&&menu_flag==1)
{
menu_flag=0;
speech_num=255;
// first_speechf=0;
display();
}
if(smoker_flag&&!lockf)
{
//control temp & time
if(stime!=0&&smoker_flag)
{
if(ctmp<stmp)
HEAT=0;
else
HEAT=1;
}
else
{
smoker_flag=0;
HEAT=1;
ENTER_W=GO_W=1;
display();
}
if(smoker_flag)
{
if(waterfull_flag)
{
ENTER_W=GO_W=1;
enterw_time_cnt=300; //set enter time is 30s=1.27ms*23622
// if(ctmp<stmp)
// HEAT=0;
// else
// HEAT=1;
if(danger_flag)
if(waterfull_hottime_cnt<3)
{
waterfull_hottime_cnt=4800;
lockf=1;
HEAT=1;
smoker_flag=0;
ENTER_W=GO_W=1;
display();
if(english_chinese==0)
{
disp_hz_str(0,1,8,chkself_str4);
disp_hz_str(0,2,8,chkself_str6);
disp_hz_str(0,3,8,chkself_str7);
}
else
{
disp_hz_str(0,3,8,nopstr);
disp_ch_str(0,7,16,"Lock the steamer");
}
menu_disp_cnt=100; //10s delay
staline_disp_cnt=30; //3 second delay
disp_sta_flag=1;
}
}
else
{
ENTER_W=0;
GO_W=1;
danger_flag=1;
waterfull_hottime_cnt=4800;//set 8 minute hot time in water full state 1.35ms*355719=480s
// if(ctmp<stmp)
// HEAT=0;
// else
// HEAT=1;
if(enterw_time_cnt<3)
{
enterw_time_cnt=300;
lockf=1;
HEAT=1;
smoker_flag=0;
ENTER_W=GO_W=1;
display();
if(english_chinese==0)
{
disp_hz_str(0,1,8,chkself_str4);
disp_hz_str(0,2,8,chkself_str6);
disp_hz_str(0,3,8,chkself_str7);
}
else
{
disp_hz_str(0,3,8,nopstr);
disp_ch_str(0,7,16,"Lock the steamer");
}
menu_disp_cnt=100; //10s delay
staline_disp_cnt=30; //3 second delay
disp_sta_flag=1;
}
}
}
}
}
}
}
/*void cyc()
{
if(++cyc_cnt==4)
cyc_cnt=0;
switch(cyc_cnt)
{
case 0:
W0=1;
W1=W2=W3=0;
out_port();
if(english_chinese==0)
disp_hz_str(0,3,8,tp_on_str);
else
{
disp_hz_str(0,3,8,nopstr);
disp_ch_str(0,6,16,"Hydraulic acupun");
disp_ch_str(0,7,16,"cture massage on");
}
play_voice(8);
break;
case 1:
W1=1;
W0=W2=W3=0;
out_port();
if(english_chinese==0)
disp_hz_str(0,3,8,hp_on_str);
else
{
disp_hz_str(0,3,8,nopstr);
disp_ch_str(0,6,16,"Hydraulic acupun");
disp_ch_str(0,7,16,"cture massage on");
}
play_voice(8);
break;
case 2:
W2=1;
W1=W0=W3=0;
out_port();
if(english_chinese==0)
disp_hz_str(0,3,8,mp_on_str);
else
{
disp_hz_str(0,3,8,nopstr);
disp_ch_str(0,6,16,"Hydraulic acupun");
disp_ch_str(0,7,16,"cture massage on");
}
play_voice(8);
break;
case 3:
W3=1;
W1=W2=W0=0;
out_port();
if(english_chinese==0)
disp_hz_str(0,3,8,bp_on_str);
else
{
disp_hz_str(0,3,8,nopstr);
disp_ch_str(0,6,16,"Hydraulic acupun");
disp_ch_str(0,7,16,"cture massage on");
}
play_voice(8);
break;
}
}*/
void initial()
{
SCON=0x00;
TMOD=0x51; //time 0 is 16 bit timing;time1 is 16 bit counter
TH1=0;
TL1=0;
TH0=0x3c; //100 ms 6mhz osc
TL0=0xb0;
T2CON=0x00;
RCAP2H=0x00;
RCAP2L=0x00;
TR2=0;
ES=0;
ET1=0;
ET2=0;
IT0=1; //down tridge
EX0=1;
EX1=0;
TR0=1;
TF1=0;
TR1=1;
PX0=1;
PT0=1;
ET0=1;
TF2=0;
EA=1;
mute();
//port ini
P0=0xff;
P1=0xff;
P2=0xff;
P3=0xff;
port0=0x00;
port1=0x00;
port2=0x00;
CY=lockf;
status=0x00;
lockf=CY;
RDKEY1=1;
RDKEY2=1;
// setb(RDKEY1);
// setb(RDKEY2);
setb(SOUND_CDRADIO);
up_isd();//voice chip power up
stop_isd();
// keyvoice_flag=1; //key voice is on
// voice_flag=1;//
//unit ini
// stmp=60;
stime=90;
music_cnt=0;
// wrt_24cxx(0,0,rd_24cxx(0,0));
}
void save_par()
{
wrt_24cxx(1,STATUS_BYTE,status1);
wrt_24cxx(1,FM_FRE_ADDR,fm_fre%256);
wrt_24cxx(1,FM_FRE_ADDR+1,(fm_fre>>8)%256);
wrt_24cxx(1,FM_FRE_ADDR+2,(fm_fre>>16)%256);
wrt_24cxx(1,FM_FRE_ADDR+3,(fm_fre>>24)%256);
wrt_24cxx(1,STMP_ADDR,stmp);
}
void read_par()
{
uchar warm,r0,r1,r2,r3;
if(rd_24cxx(1,ID_ADDR,&warm))
while(1);
else
if(warm!=0x28)
while(1);
if(rd_24cxx(1,STATUS_BYTE,&status1))
while(1);
rd_24cxx(1,FM_FRE_ADDR,&r0);
rd_24cxx(1,FM_FRE_ADDR+1,&r1);
rd_24cxx(1,FM_FRE_ADDR+2,&r2);
rd_24cxx(1,FM_FRE_ADDR+3,&r3);
fm_fre=r3*0x1000000+r2*0x10000+r1*0x100+r0;
if(rd_24cxx(1,STMP_ADDR,&stmp))
while(1);
}
remote() interrupt 0
{
unsigned long int c;
uchar i;
uint j;
for(i=0;i<32;i++)
{
j=300;
while(--j&&!RM_IN);
if(j==0)
return;
TR2=0;
TL2=0;
TH2=0;
TR2=1;
j=500;
while(--j&&RM_IN);
if(j==0)
{
//repeat press control
return;
}
TR2=0;
if(TH2>=4)
return;
else
if(TH2>=2)
c=c<<1|1;
else
c=c<<1;
}
if(c>>16==0x08f7) //remotor code
{
j=c%65536;
for(i=0;i<32;i++)
{
if(j==rm_tab[i])
{
rmcode=i+1;
clrb(LCD_LIT);
lcd_disp_cnt=3000;
// if(keyvoice_flag)
// BEEP=0;
return;
}
}
return;
}
else
return;
}
timer0() interrupt 1 //100ms timing mode
{
uchar i;
TH0=0x3c;
TL0=0xb0;
reset_dog();
if(SOUND_CDRADIO==0)
{
for(i=0;i<100;i++)
{
if(ISD_INT)
break;
}
if(i==100)
{
SOUND_CDRADIO=1;
shift_flag=1;
}
}
wpchk();
--staline_disp_cnt;
--menu_disp_cnt;
--enterw_time_cnt;
--waterfull_hottime_cnt;
if(--lcd_disp_cnt==0)
setb(LCD_LIT);
if(--seccnt==0)
seccnt=20;
if(seccnt%10==0)
{
TR1=0;
ctmp=get_tmp(TH1*256+TL1);
TH1=0x00;
TL1=0x00;
TF1=0;
TR1=1;
if(--mincnt==0)
{
mincnt=60;
if(stime!=0&&smoker_flag==1)
{
stime--;
shift_flag=1;
}
}
if(lppw_flag)
{
--lppw_cnt;
switch(lppw_cnt)
{
case 60:
W0=W2=W3=0;
W1=1;
shift_flag=1;
break;
case 40:
W0=W1=W3=0;
W2=1;
shift_flag=1;
break;
case 20:
W0=W1=W2=0;
W3=1;
shift_flag=1;
break;
case 0:
lppw_cnt=80;
W1=W2=W3=0;
W0=1;
shift_flag=1;
break;
default:
break;
}
}
}
}
uchar read_key()
{
uchar keytemp,i,j;
KEYPORT=0xff;
RDKEY1=0;
// clrb(RDKEY1);
keytemp=~KEYPORT;
RDKEY1=1;
// setb(RDKEY1);
if(keytemp)
{
clrb(LCD_LIT); //lcd on
lcd_disp_cnt=3000;
if(keyvoice_flag&&power_sta)
{
BEEP=0;
delay(50);
BEEP=1;
}
for(i=1,j=1;i<=8;i++,j=j*2)
if(keytemp&j)
return i;
return 0;
}
// clrb(RDKEY2);
RDKEY2=0;
keytemp=(~KEYPORT)&0x0f;
// setb(RDKEY2);
RDKEY2=1;
if(keytemp)
{
clrb(LCD_LIT); //lcd on
lcd_disp_cnt=3000;
if(keyvoice_flag&&power_sta)
{
BEEP=0;
delay(50);
BEEP=1;
}
for(i=9,j=1;i<=12;i++,j=j*2)
if(keytemp&j)
return i;
return 0;
}
BEEP=1;
return 0;
}
void wait_key_off()
{
KEYPORT=0xff;
RDKEY1=0;
// clrb(RDKEY1);
while(KEYPORT!=0xff);
RDKEY1=1;
// setb(RDKEY1);
RDKEY2=0;
// clrb(RDKEY2);
while((KEYPORT&0x0f)!=0x0f);
RDKEY2=1;
// setb(RDKEY2);
BEEP=1;
keycode=0;
}
bit timewait_key_off(uchar wk_time)
{
uchar i;
i=wk_time;
for(;i>0;i--)
{
KEYPORT=0xff;
RDKEY1=0;
// clrb(RDKEY1);
if(KEYPORT==0xff)
{
RDKEY1=1;
// setb(RDKEY1);
RDKEY2=0;
// clrb(RDKEY2);
if((KEYPORT&0x0f)==0x0f)
{
// setb(RDKEY2);
RDKEY2=1;
keycode=0;
return 0;//key off exit
}
// setb(RDKEY2);
RDKEY2=1;
}
// setb(RDKEY1);
RDKEY1=1;
delay(10);
}
return 1;//key no break exit,time over exit
}
void disp_tmp(void)
{
if(smoker_flag==0&&menu_flag==0&&seccnt==20)
{
disp_hz(2,0,0x375a);
disp_hz(3,0,0x375a);
disp_ch(5,1,ctmp/10+48);
disp_ch(6,1,ctmp%10+48);
}
}
uchar get_tmp(uint cntval)
{
uchar i=0;
while(cntval>=tmp_tab[i]&&i<99)
i++;
return i;
}
void wait_til_busy(void)
{
int i=2000;
while(!ASK&&i--);
}
void wait_til_nop(void)
{
int i=2000;
while(ASK&&i--);
}
void disp_hz_str(uchar col,uchar row,uchar len,uchar *hzstr)
//COL=HZ COLS IN SCREEN(00--07);
//ROW=HZ ROWS IN SCREEN\(00--03);
//LEN=HZ NUMBER;
//HZSTR=HANZI NEIMA STRING POINTER;
{
while(len-->0&&*hzstr>=0xa0)
{
ANSWER=0;
ASK=1;
wait_til_nop();
LCDPORT=0xf0;
ANSWER=1;
wait_til_busy();
ANSWER=0;
wait_til_nop();
LCDPORT=col+2; //col from 2 start for hz
ANSWER=1;
wait_til_busy();
ANSWER=0;
wait_til_nop();
LCDPORT=row;
ANSWER=1;
wait_til_busy();
ANSWER=0;
wait_til_nop();
LCDPORT=*hzstr==0xa1&&*(hzstr+1)==0xa1?0x37:*hzstr-0xa0;
hzstr++;
ANSWER=1;
wait_til_busy();
ANSWER=0;
wait_til_nop();
LCDPORT=*hzstr==0xa1&&*(hzstr-1)==0xa1?0x5a:*hzstr-0xa0;
hzstr++;
ANSWER=1;
wait_til_busy();
ANSWER=0;
col++;
}
LCDPORT=0xff;
}
void disp_ch_str(uchar col,uchar row,uchar len,uchar *chstr)
{
//COL=CHAR COLS IN SCREEN(0--15);
//ROW=CHAR LINES IN SCREEN(0--7);
//LEN=CHAR NUMBER;
//CHSTR=CHAR STRING POINTER;
while(len-->0&&*chstr)
{
ANSWER=0;
ASK=1;
wait_til_nop();
LCDPORT=0xf1;
ANSWER=1;
wait_til_busy();
ANSWER=0;
wait_til_nop();
LCDPORT=col+4; //col from 4 start for char
ANSWER=1;
wait_til_busy();
ANSWER=0;
wait_til_nop();
LCDPORT=row*8;
ANSWER=1;
wait_til_busy();
ANSWER=0;
wait_til_nop();
LCDPORT=*chstr++;
ANSWER=1;
wait_til_busy();
ANSWER=0;
col++;
}
LCDPORT=0xff;
}
void disp_hz(uchar col,uchar row,uint qwcode)
//COL=HZ COLS IN SCREEN(00--07);
//ROW=HZ ROWS IN SCREEN(00--03);
//QWCODE=HANZI QU WEI CODE;
{
ANSWER=0;
ASK=1;
wait_til_nop();
LCDPORT=0xf0;
ANSWER=1;
wait_til_busy();
ANSWER=0;
wait_til_nop();
LCDPORT=col+2; //col from 2 start for hz
ANSWER=1;
wait_til_busy();
ANSWER=0;
wait_til_nop();
LCDPORT=row;
ANSWER=1;
wait_til_busy();
ANSWER=0;
wait_til_nop();
LCDPORT=qwcode/256;
ANSWER=1;
wait_til_busy();
ANSWER=0;
wait_til_nop();
LCDPORT=qwcode%256;
ANSWER=1;
wait_til_busy();
ANSWER=0;
LCDPORT=0xff;
}
void disp_ch(uchar col,uchar row,uchar chcode)
{
//COL=CHAR COLS IN SCREEN(0--15);
//ROW=CHAR LINES IN SCREEN(0--7);
//CHCODE=CHAR ASIC CODE;
ANSWER=0;
ASK=1;
wait_til_nop();
LCDPORT=0xf1;
ANSWER=1;
wait_til_busy();
ANSWER=0;
wait_til_nop();
LCDPORT=col+4; //col from 4 start for char
ANSWER=1;
wait_til_busy();
ANSWER=0;
wait_til_nop();
LCDPORT=row*8;
ANSWER=1;
wait_til_busy();
ANSWER=0;
wait_til_nop();
LCDPORT=chcode;
ANSWER=1;
wait_til_busy();
ANSWER=0;
LCDPORT=0xff;
}
void disp_icon(uchar col,uchar row,uchar *icon_ptr)
{
//display 16*16 dot icon
//COL=CHAR COLS IN SCREEN(0--7);
//ROW=CHAR LINES IN SCREEN(0--3);
//ICON_PTR=POINT TO DOT BYTE ARRAY;
uchar coltmp,rowtmp,i;
disp_hz(col,row,0x375a);
for(coltmp=col*2+4,rowtmp=row*16,i=0;i<16;i++)
{
ANSWER=0;
ASK=1;
wait_til_nop();
LCDPORT=0xf3; //dot display
ANSWER=1;
wait_til_busy();
ANSWER=0;
wait_til_nop();
LCDPORT=coltmp; //col from 4 start for char
ANSWER=1;
wait_til_busy();
ANSWER=0;
wait_til_nop();
LCDPORT=rowtmp++;
ANSWER=1;
wait_til_busy();
ANSWER=0;
wait_til_nop();
LCDPORT=icon_ptr[i*2];
ANSWER=1;
wait_til_busy();
ANSWER=0;
LCDPORT=0xff;
}
for(coltmp=col*2+5,rowtmp=row*16,i=0;i<16;i++)
{
ANSWER=0;
ASK=1;
wait_til_nop();
LCDPORT=0xf3; //dot display
ANSWER=1;
wait_til_busy();
ANSWER=0;
wait_til_nop();
LCDPORT=coltmp; //col from 4 start for char
ANSWER=1;
wait_til_busy();
ANSWER=0;
wait_til_nop();
LCDPORT=rowtmp++;
ANSWER=1;
wait_til_busy();
ANSWER=0;
wait_til_nop();
LCDPORT=icon_ptr[i*2+1];
ANSWER=1;
wait_til_busy();
ANSWER=0;
LCDPORT=0xff;
}
}
void clr_lcd(void)
{
ANSWER=0;
ASK=1;
wait_til_nop();
LCDPORT=0xf4;
ANSWER=1;
wait_til_busy();
ANSWER=0;
LCDPORT=0xff;
}
/*void ls_lcd(void)
{
ANSWER=0;
ASK=1;
wait_til_nop();
LCDPORT=0xf7;
ANSWER=1;
wait_til_busy();
ANSWER=0;
LCDPORT=0xff;
}*/
void out_port()
{
mute();
TI=0;
SBUF=port0;
while(!TI);
TI=0;
SBUF=port1;
while(!TI);
TI=0;
SBUF=port2;
while(!TI);
LATCH=0;
TI=0;
LATCH=1;
if(mutef==0)
setvol(vol);
}
void delay(uint ms)
{
uchar i;
uint j;
for(j=0;j<ms;j++)
for(i=250;i>0;i--); //6mhz osc is 1ms
}
void osd()
{
if(!menu_flag)
{
menu_flag=1;
items=0;
menu_disp_cnt=100; //10s delay
play_voice(13);
return;
}
if(items<MAXITEMS)
{
items++;
menu_disp_cnt=100; //10s delay
play_voice(13);
}
else
{
menu_flag=0;
speech_num=255;
// first_speechf=0;
}
}
void fanctrl()
{
FAN=~FAN;
FAN?play_voice(4):play_voice(5);
out_port();
if(english_chinese==0)
FAN==1?disp_hz_str(0,3,8,fan_on_str):disp_hz_str(0,3,8,fan_off_str);
else
{
if(FAN)
{
disp_hz_str(0,3,8,nopstr);
disp_ch_str(0,7,16," Fan on ");
}
else
{
disp_hz_str(0,3,8,nopstr);
disp_ch_str(0,7,16," Fan off ");
}
}
menu_disp_cnt=100; //10s delay
staline_disp_cnt=30; //3 second delay
disp_sta_flag=1;
}
void amb()
{
HEAT=1;
AMBDRV=~AMBDRV;
AMBDRV?play_voice(6):play_voice(7);
out_port();
if(english_chinese==0)
AMBDRV==1?disp_hz_str(0,3,8,amb_on_str):disp_hz_str(0,3,8,amb_off_str);
else
{
if(AMBDRV)
{
disp_hz_str(0,3,8,nopstr);
disp_ch_str(0,7,16," Wave on ");
}
else
{
disp_hz_str(0,3,8,nopstr);
disp_ch_str(0,7,16," Wave off ");
}
}
if(AMBDRV)
{
if(FWARM)
{
FWARM=0;
FCOOL=0;
}
smoker_flag=0;
HEAT=1;
out_port();
}
menu_disp_cnt=100; //10s delay
staline_disp_cnt=30; //3 second delay
disp_sta_flag=1;
}
void music()
{
menu_disp_cnt=100; //10s delay
staline_disp_cnt=50; //5 second delay
mutef=0;
disp_sta_flag=1;
if(++music_cnt>2)
music_cnt=0;
switch(music_cnt)
{
case 0:
mute();
play_voice(12);
display();
if(english_chinese==0)
disp_hz_str(0,3,8,sound_off_str);
else
{
disp_hz_str(0,3,8,nopstr);
disp_ch_str(0,7,16," Music off ");
}
break;
case 1:
setb(SOUND_CDRADIO);
setb(CD_RADIO);//radio on
setvol(vol);
set_radio_fre(fm_fre);
send_pll_data(0x0200a029);//open the radio
display();
disp_hz_str(0,3,8,nopstr);
if(english_chinese==0)
disp_hz_str(0,3,8," 收音开启 ");
else
disp_ch_str(0,8,16," RADIO ON ");
play_voice(10);
break;
case 2:
setb(SOUND_CDRADIO);
clrb(CD_RADIO);//cd on
setvol(vol);
display();
disp_hz_str(0,3,8,nopstr);
if(english_chinese==0)
disp_hz_str(0,3,8," 唱碟输入 ");
else
disp_ch_str(0,8,16," CD INPUT ");
play_voice(11);
break;
}
// display();
}
void smoker()
{
uchar i;
if(first_chk_flag==0)
{
first_chk_flag=1;
chkself();
if(lockf==0)
{
stime=90;
// stmp=60;
smoker_flag=1;
display();
}
else
{
smoker_flag=0;
HEAT=1;
display();
if(english_chinese==0)
disp_hz_str(0,3,8,chkself_str4);
else
{
disp_hz_str(0,3,8,nopstr);
disp_ch_str(0,7,16,"Lock the steamer");
}
// play_voice(36);
}
// display();
menu_disp_cnt=100; //10s delay
staline_disp_cnt=50; //3 second delay
disp_sta_flag=1;
}
else
{
if(smoker_flag)
{
play_voice(29);
smoker_flag=0;
HEAT=1;
display();
disp_hz_str(0,3,8,nopstr);
if(english_chinese==0)
disp_hz_str(0,3,8,smoke_off_str);
else
disp_ch_str(0,7,16," STEAM OFF ");
}
else
{
if(lockf==0)
{
if(first_smoker_flag)
{
first_smoker_flag=0;
if(waterfull_flag==1) //if water is full
{
GO_W=0;
ENTER_W=1;
i=88;
do
{
delay(1000);
i--;
}while(waterfull_flag&&i>0);
if(i==0)
{
lockf=1;
GO_W=1;
ENTER_W=1;
clr_lcd();
if(english_chinese==0)
{
disp_hz_str(0,1,8,chkself_str4);
disp_hz_str(0,2,8,chkself_str6);
disp_hz_str(0,3,8,chkself_str7);
}
else
{
disp_ch_str(0,3,16,"Lock the steamer");
}
play_voice(36);
delay(2000);
return;
}
GO_W=1; //check success
lockf=0;
ENTER_W=1;
}
else //if water is empty
{
ENTER_W=0;
GO_W=1;
i=30;
do
{
delay(1000);
i--;
}while(waterfull_flag==0&&i>0);
if(i==0)
{
lockf=1;
GO_W=1;
ENTER_W=1;
clr_lcd();
if(english_chinese==0)
{
disp_hz_str(0,1,8,chkself_str4);
disp_hz_str(0,2,8,chkself_str6);
disp_hz_str(0,3,8,chkself_str7);
}
else
{
disp_ch_str(0,3,16,"Lock the steamer");
}
play_voice(36);
delay(2000);
return;
}
ENTER_W=1;
lockf=0;
}
}
stime=90;
smoker_flag=1;
display();
disp_hz_str(0,3,8,nopstr);
if(english_chinese==0)
disp_hz_str(0,3,8,smoke_on_str);
else
disp_ch_str(0,7,16," STEAM ON ");
play_voice(28);
}
else
{
smoker_flag=0;
HEAT=1;
display();
if(english_chinese==0)
disp_hz_str(0,3,8,chkself_str4);
else
{
disp_hz_str(0,3,8,nopstr);
disp_ch_str(0,7,16,"Lock the steamer");
}
// delay(5000);
play_voice(36);
}
}
}
// display();
if(smoker_flag)
{
if(FWARM)
{
FWARM=0;
FCOOL=0;
}
AMBDRV=0;
out_port();
}
menu_disp_cnt=100; //10s delay
staline_disp_cnt=50; //3 second delay
disp_sta_flag=1;
}
void lamp()
{
if(LAMP1==0&&LAMP2==0)
{
setb(LAMP1);
clrb(LAMP2);
if(english_chinese==0)
disp_hz_str(0,3,8,lit1_on_str);
else
{
disp_hz_str(0,3,8,nopstr);
disp_ch_str(0,7,16," Light on ");
}
play_voice(2);
menu_disp_cnt=100; //10s delay
staline_disp_cnt=30; //3 second delay
disp_sta_flag=1;
return;
}
if(LAMP1==1&&LAMP2==0)
{
setb(LAMP2);
clrb(LAMP1);
play_voice(2);
if(english_chinese==0)
disp_hz_str(0,3,8,lit2_on_str);
else
{
disp_hz_str(0,3,8,nopstr);
disp_ch_str(0,7,16," Light on ");
}
menu_disp_cnt=100; //10s delay
staline_disp_cnt=30; //3 second delay
disp_sta_flag=1;
return;
}
if(LAMP1==0&&LAMP2==1)
{
clrb(LAMP1);
clrb(LAMP2);
play_voice(3);
if(english_chinese==0)
disp_hz_str(0,3,8,lit_off_str);
else
{
disp_hz_str(0,3,8,nopstr);
disp_ch_str(0,7,16," Light off ");
}
menu_disp_cnt=100; //10s delay
staline_disp_cnt=30; //3 second delay
disp_sta_flag=1;
return;
}
}
void lp()//loop push water
{
lppw_flag=~lppw_flag;
if(english_chinese==0)
lppw_flag==1?disp_hz_str(0,3,8,lp_on_str):disp_hz_str(0,3,8,lp_off_str);
else
{
if(lppw_flag)
{
disp_hz_str(0,3,8,nopstr);
disp_ch_str(0,6,16,"Hydraulic acupun");
disp_ch_str(0,7,16,"cture massage on");
}
else
{
disp_hz_str(0,3,8,nopstr);
disp_ch_str(0,6,16,"Hydraulic acupun");
disp_ch_str(0,7,16,"cture massageoff");
}
}
lppw_flag==1?play_voice(8):play_voice(9);
if(lppw_flag)
{
W1=W2=W3=0;
W0=1;
out_port();
}
else
{
W0=W1=W2=W3=0;
out_port();
}
lppw_cnt=80;
menu_disp_cnt=100; //10s delay
staline_disp_cnt=30; //3 second delay
disp_sta_flag=1;
}
void lk()
{
uchar keyf=0;
if(menu_flag)
{
menu_disp_cnt=100; //10s delay
staline_disp_cnt=30; //3 second delay
disp_sta_flag=1;
switch(items)
{
case 0:
//set tempreture --
if(smoker_flag==0)
break;
if(stmp==35)
stmp=60;
else
stmp--;
disp_hz_str(0,0,8,nopstr);
if(english_chinese==0)
disp_hz_str(0,0,8,"温度 时间 ");
else
disp_ch_str(0,1,16,"TEMP TIME ");
disp_ch(14,1,stime/10+'0');
disp_ch(15,1,stime%10+'0');
disp_ch(4,1,stmp/10+'0');
disp_ch(5,1,stmp%10+'0');
play_voice(33);
break;
case 1:
//radio fm fre dec
if(CD_RADIO)
{
play_voice(30);
// wait_key_off();
rmcode=0;
mute();
if(timewait_key_off(800)==0)
{
if(fm_fre>88000)
fm_fre=fm_fre-100;
else
fm_fre=108000;
disp_hz(2,0,0x375a);
disp_hz(3,0,0x375a);
disp_hz(4,0,0x375a);
if(english_chinese==0)
disp_ch_str(6,0,2,"FM");
else
disp_ch_str(0,1,3,"RAD");
disp_ch(4,1,fm_fre/100000?'1':' ');
disp_ch(5,1,fm_fre/10000%10+'0');
disp_ch(6,1,fm_fre/1000%10+'0');
disp_ch(7,1,'.');
disp_ch(8,1,fm_fre/100%10+'0');
set_radio_fre(fm_fre);
}
else
{
do{
if(read_key()==0)
keyf=1;
if(fm_fre>88000)
fm_fre=fm_fre-100;
else
fm_fre=108000;
disp_hz(2,0,0x375a);
disp_hz(3,0,0x375a);
disp_hz(4,0,0x375a);
if(english_chinese==0)
disp_ch_str(6,0,2,"FM");
else
disp_ch_str(0,1,3,"RAD");
disp_ch(4,1,fm_fre/100000?'1':' ');
disp_ch(5,1,fm_fre/10000%10+'0');
disp_ch(6,1,fm_fre/1000%10+'0');
disp_ch(7,1,'.');
disp_ch(8,1,fm_fre/100%10+'0');
if(keyf==1&&read_key()!=0)
break;
}while(set_radio_fre(fm_fre)&&rmcode==0);
}
setvol(vol);
send_pll_data(0x0200a029);//open the radio
wait_key_off();
}
break;
case 2:
//top push water
W0=~W0;
W1=W2=W3=0;
out_port();
if(english_chinese==0)
W0==1?disp_hz_str(0,3,8,tp_on_str):disp_hz_str(0,3,8,tp_off_str);
else
{
disp_hz_str(0,3,8,nopstr);
if(W0)
{
disp_ch_str(0,6,16,"Hydraulic acupun");
disp_ch_str(0,7,16,"cture massage on");
}
else
{
disp_ch_str(0,6,16,"Hydraulic acupun");
disp_ch_str(0,7,16,"cture massageoff");
}
}
W0==1?play_voice(8):play_voice(9);
break;
case 3:
//O inc
O_INC=~O_INC;
out_port();
if(english_chinese==0)
O_INC==1?disp_hz_str(0,3,8,zy_on_str):disp_hz_str(0,3,8,zy_off_str);
else
{
disp_hz_str(0,3,8,nopstr);
if(O_INC)
{
disp_ch_str(0,7,16," Oxygenation on ");
}
else
{
disp_ch_str(0,7,16," Oxygenation off");
}
}
O_INC==1?play_voice(14):play_voice(15);
break;
case 4:
//voice
voice_flag=~voice_flag;
if(english_chinese==0)
voice_flag==1?disp_hz_str(0,3,8,yy_on_str):disp_hz_str(0,3,8,yy_off_str);
else
{
disp_hz_str(0,3,8,nopstr);
if(voice_flag)
{
disp_ch_str(0,7,16," Speech on ");
}
else
{
disp_ch_str(0,7,16," Speech off ");
}
}
if(voice_flag)
play_voice(22);
else
{
voice_flag=1;
play_voice(23);
voice_flag=0;
}
break;
}
}
}
void rk()
{
uchar keyf=0;
if(menu_flag)
{
menu_disp_cnt=100; //10s delay
staline_disp_cnt=30; //3 second delay
disp_sta_flag=1;
switch(items)
{
case 0:
//set tempreture ++
if(smoker_flag==0)
break;
if(stmp==60)
stmp=35;
else
stmp++;
disp_hz_str(0,0,8,nopstr);
if(english_chinese==0)
disp_hz_str(0,0,8,"温度 时间 ");
else
disp_ch_str(0,1,16,"TEMP TIME ");
disp_ch(14,1,stime/10+'0');
disp_ch(15,1,stime%10+'0');
disp_ch(4,1,stmp/10+'0');
disp_ch(5,1,stmp%10+'0');
play_voice(33);
break;
case 1:
//radio fm fre inc
if(CD_RADIO)
{
play_voice(30);
// wait_key_off();
rmcode=0;
mute();
if(timewait_key_off(800)==0)
{
if(fm_fre<108000)
fm_fre=fm_fre+100;
else
fm_fre=88000;
disp_hz(2,0,0x375a);
disp_hz(3,0,0x375a);
disp_hz(4,0,0x375a);
if(english_chinese==0)
disp_ch_str(6,0,2,"FM");
else
disp_ch_str(0,1,3,"RAD");
disp_ch(4,1,fm_fre/100000?'1':' ');
disp_ch(5,1,fm_fre/10000%10+'0');
disp_ch(6,1,fm_fre/1000%10+'0');
disp_ch(7,1,'.');
disp_ch(8,1,fm_fre/100%10+'0');
set_radio_fre(fm_fre);
}
else
{
do{
if(read_key()==0)
keyf=1;
if(fm_fre<108000)
fm_fre=fm_fre+100;
else
fm_fre=88000;
disp_hz(2,0,0x375a);
disp_hz(3,0,0x375a);
disp_hz(4,0,0x375a);
if(english_chinese==0)
disp_ch_str(6,0,2,"FM");
else
disp_ch_str(0,1,3,"RAD");
disp_ch(4,1,fm_fre/100000?'1':' ');
disp_ch(5,1,fm_fre/10000%10+'0');
disp_ch(6,1,fm_fre/1000%10+'0');
disp_ch(7,1,'.');
disp_ch(8,1,fm_fre/100%10+'0');
if(keyf==1&&read_key()!=0)
break;
}while(set_radio_fre(fm_fre)&&rmcode==0);
}
setvol(vol);
send_pll_data(0x0200a029);//open the radio
wait_key_off();
}
break;
case 2:
//high push water
W1=~W1;
W0=W3=W2=0;
out_port();
if(english_chinese==0)
W1==1?disp_hz_str(0,3,8,hp_on_str):disp_hz_str(0,3,8,hp_off_str);
else
{
disp_hz_str(0,3,8,nopstr);
if(W1)
{
disp_ch_str(0,6,16,"Hydraulic acupun");
disp_ch_str(0,7,16,"cture massage on");
}
else
{
disp_ch_str(0,6,16,"Hydraulic acupun");
disp_ch_str(0,7,16,"cture massageoff");
}
}
W1==1?play_voice(8):play_voice(9);
break;
case 3:
//kill virus
KILLV=~KILLV;
out_port();
if(english_chinese==0)
KILLV==1?disp_hz_str(0,3,8,sj_on_str):disp_hz_str(0,3,8,sj_off_str);
else
{
disp_hz_str(0,3,8,nopstr);
if(KILLV)
{
disp_ch_str(0,6,16," Sterilization ");
disp_ch_str(0,7,16," on ");
}
else
{
disp_ch_str(0,6,16," Sterilization ");
disp_ch_str(0,7,16," off ");
}
}
KILLV==1?play_voice(16):play_voice(17);
break;
case 4:
//key voice
keyvoice_flag=~keyvoice_flag;
if(english_chinese==0)
keyvoice_flag==1?disp_hz_str(0,3,8,jy_on_str):disp_hz_str(0,3,8,jy_off_str);
else
{
disp_hz_str(0,3,8,nopstr);
if(keyvoice_flag)
{
disp_ch_str(0,7,16," Key tone on ");
}
else
{
disp_ch_str(0,7,16," Key tone off ");
}
}
keyvoice_flag==1?play_voice(24):play_voice(25);
break;
}
}
}
void dk()
{
if(menu_flag)
{
menu_disp_cnt=100; //10s delay
staline_disp_cnt=30; //1 second delay
disp_sta_flag=1;
switch(items)
{
case 0:
//set time --
if(smoker_flag==0)
break;
if(stime<=1)
stime=90;
else
stime--;
disp_hz_str(0,0,8,nopstr);
if(english_chinese==0)
disp_hz_str(0,0,8,"温度 时间 ");
else
disp_ch_str(0,1,16,"TEMP TIME ");
disp_ch(14,1,stime/10+'0');
disp_ch(15,1,stime%10+'0');
disp_ch(4,1,stmp/10+'0');
disp_ch(5,1,stmp%10+'0');
play_voice(32);
break;
case 1:
//vol--
if(music_cnt>0&&mutef==0)
{
if(vol>0)
{
vol--;
disp_hz(7,0,0x375a);
disp_ch(14,1,vol/10+'0');
disp_ch(15,1,vol%10+'0');
setvol(vol);
play_voice(31);
}
}
break;
case 2:
//middle push water
W2=~W2;
W0=W1=W3=0;
out_port();
if(english_chinese==0)
W2==1?disp_hz_str(0,3,8,mp_on_str):disp_hz_str(0,3,8,mp_off_str);
else
{
disp_hz_str(0,3,8,nopstr);
if(W2)
{
disp_ch_str(0,6,16,"Hydraulic acupun");
disp_ch_str(0,7,16,"cture massage on");
}
else
{
disp_ch_str(0,6,16,"Hydraulic acupun");
disp_ch_str(0,7,16,"cture massageoff");
}
}
W2==1?play_voice(8):play_voice(9);
break;
case 3:
//warm fan
AMBDRV=0;
smoker_flag=0;
HEAT=1;
FWARM=~FWARM;
if(FWARM)
FCOOL=1;
else
FCOOL=0;
out_port();
if(english_chinese==0)
FWARM==1?disp_hz_str(0,3,8,nf_on_str):disp_hz_str(0,3,8,nf_off_str);
else
{
disp_hz_str(0,3,8,nopstr);
if(FWARM)
{
disp_ch_str(0,6,16," Dry steam by ");
disp_ch_str(0,7,16," hot air on ");
}
else
{
disp_ch_str(0,6,16," Dry steam by ");
disp_ch_str(0,7,16," hot air off ");
}
}
FWARM==1?play_voice(20):play_voice(21);
break;
case 4:
english_chinese=0;
play_voice(26);
display();
//chinese on
break;
}
}
}
void uk()
{
if(menu_flag)
{
menu_disp_cnt=100; //10s delay
staline_disp_cnt=30; //3 second delay
disp_sta_flag=1;
switch(items)
{
case 0:
//set time++
if(smoker_flag==0)
break;
if(stime>=90)
stime=5;
else
stime++;
disp_hz_str(0,0,8,nopstr);
if(english_chinese==0)
disp_hz_str(0,0,8,"温度 时间 ");
else
disp_ch_str(0,1,16,"TEMP TIME ");
disp_ch(14,1,stime/10+'0');
disp_ch(15,1,stime%10+'0');
disp_ch(4,1,stmp/10+'0');
disp_ch(5,1,stmp%10+'0');
play_voice(32);
break;
case 1:
//vol++
if(music_cnt>0&&mutef==0)
{
if(vol<80)
{
vol++;
disp_hz(7,0,0x375a);
disp_ch(14,1,vol/10+'0');
disp_ch(15,1,vol%10+'0');
setvol(vol);
play_voice(31);
}
}
break;
case 2:
//xia push water
W3=~W3;
W2=W0=W1=0;
out_port();
if(english_chinese==0)
W3==1?disp_hz_str(0,3,8,bp_on_str):disp_hz_str(0,3,8,bp_off_str);
else
{
disp_hz_str(0,3,8,nopstr);
if(W3)
{
disp_ch_str(0,6,16,"Hydraulic acupun");
disp_ch_str(0,7,16,"cture massage on");
}
else
{
disp_ch_str(0,6,16,"Hydraulic acupun");
disp_ch_str(0,7,16,"cture massageoff");
}
}
W3==1?play_voice(8):play_voice(9);
break;
case 3:
//cool fan
if(FWARM)
{
FWARM=0;
FCOOL=1;
}
else
{
FCOOL=~FCOOL;
FWARM=0;
}
out_port();
if(english_chinese==0)
FCOOL==1?disp_hz_str(0,3,8,lf_on_str):disp_hz_str(0,3,8,lf_off_str);
else
{
disp_hz_str(0,3,8,nopstr);
if(FCOOL)
{
disp_ch_str(0,7,16," Cool air on ");
}
else
{
disp_ch_str(0,7,16," Cool air off ");
}
}
FCOOL==1?play_voice(18):play_voice(19);
break;
case 4:
english_chinese=1;
play_voice(27);
display();
//english on
break;
}
}
}
void disp_second_dot()
{
if(smoker_flag&&menu_flag==0)
{
if(seccnt==10)
{
disp_hz(6,0,0x375a);
disp_ch(13,1,':');
}
else if(seccnt==20)
{
disp_hz(6,0,0x375a);
}
return;
}
if(lockf==1&&menu_flag==0)
{
if(seccnt==10)
{
disp_hz(6,0,0x375a);
}
else if(seccnt==20)
{
disp_icon(6,0,lock_icon);
}
return;
}
}
void display()
{
if(power_sta==0)
{
clr_lcd();
disp_hz_str(0,0,8,title_str1[0]);
disp_hz_str(0,1,8,title_str1[1]);
return;
}
if(menu_flag)
{
switch(items)
{
case 0: if(english_chinese==0)
{
disp_hz_str(0,0,8,"温度 时间 ");
if(smoker_flag)
{
disp_ch(4,1,stmp/10+'0');
disp_ch(5,1,stmp%10+'0');
disp_ch(14,1,stime/10+'0');
disp_ch(15,1,stime%10+'0');
}
else
{
disp_ch(4,1,'-');
disp_ch(5,1,'-');
disp_ch(14,1,'-');
disp_ch(15,1,'-');
}
disp_hz_str(0,1,8,nopstr);
disp_icon(0,1,left_icon);
disp_icon(2,1,right_icon);
disp_icon(5,1,down_icon);
disp_icon(7,1,up_icon);
disp_hz_str(0,2,8,"减 加 减 加");
}
else
{
disp_hz_str(0,0,8,nopstr);
disp_hz_str(0,1,8,nopstr);
disp_hz_str(0,2,8,nopstr);
disp_ch_str(0,1,16,"TEMP TIME ");
if(smoker_flag)
{
disp_ch(4,1,stmp/10+'0');
disp_ch(5,1,stmp%10+'0');
disp_ch(14,1,stime/10+'0');
disp_ch(15,1,stime%10+'0');
}
else
{
disp_ch(4,1,'-');
disp_ch(5,1,'-');
disp_ch(14,1,'-');
disp_ch(15,1,'-');
}
disp_icon(0,1,left_icon);
disp_icon(2,1,right_icon);
disp_icon(5,1,down_icon);
disp_icon(7,1,up_icon);
disp_ch_str(0,5,16," - + - + ");
}
break;
case 1: if(english_chinese==0)
{
disp_hz_str(0,0,8,"收音 音量 ");
disp_ch_str(6,0,2,"FM");
if(CD_RADIO==0)
{
disp_ch_str(4,1,5,"---.-");
}
else
{
disp_ch(4,1,fm_fre/100000?'1':' ');
disp_ch(5,1,fm_fre/10000%10+'0');
disp_ch(6,1,fm_fre/1000%10+'0');
disp_ch(7,1,'.');
disp_ch(8,1,fm_fre/100%10+'0');
}
if(mutef==0&&music_cnt>0)
{
disp_ch(14,1,vol/10+'0');
disp_ch(15,1,vol%10+'0');
}
else
{
disp_ch(14,1,'-');
disp_ch(15,1,'-');
}
disp_hz_str(0,1,8,nopstr);
disp_icon(0,1,left_icon);
disp_icon(2,1,right_icon);
disp_icon(5,1,down_icon);
disp_icon(7,1,up_icon);
disp_hz_str(0,2,8,"减 加 减 加");
}
else
{
disp_hz_str(0,0,8,nopstr);
disp_hz_str(0,1,8,nopstr);
disp_hz_str(0,2,8,nopstr);
disp_ch_str(0,1,16,"RAD VOL ");
disp_ch_str(6,0,2,"FM");
if(CD_RADIO==0)
{
disp_ch_str(4,1,5,"---.-");
}
else
{
disp_ch(4,1,fm_fre/100000?'1':' ');
disp_ch(5,1,fm_fre/10000%10+'0');
disp_ch(6,1,fm_fre/1000%10+'0');
disp_ch(7,1,'.');
disp_ch(8,1,fm_fre/100%10+'0');
}
if(mutef==0&&music_cnt>0)
{
disp_ch(14,1,vol/10+'0');
disp_ch(15,1,vol%10+'0');
}
else
{
disp_ch(14,1,'-');
disp_ch(15,1,'-');
}
disp_icon(0,1,left_icon);
disp_icon(2,1,right_icon);
disp_icon(5,1,down_icon);
disp_icon(7,1,up_icon);
disp_ch_str(0,5,16," - + - + ");
}
break;
case 2: if(english_chinese==0)
{
disp_hz_str(0,0,8,"顶 上 中 下");
disp_hz_str(0,1,8,"喷 喷 喷 喷");
disp_hz_str(0,2,8,nopstr);
disp_icon(0,2,left_icon);
disp_icon(2,2,right_icon);
disp_icon(5,2,down_icon);
disp_icon(7,2,up_icon);
}
else
{
disp_hz_str(0,0,8,nopstr);
disp_hz_str(0,1,8,nopstr);
disp_hz_str(0,2,8,nopstr);
disp_icon(0,0,left_icon);
disp_icon(4,0,right_icon);
disp_icon(0,2,down_icon);
disp_icon(4,2,up_icon);
disp_ch_str(2,0,6," TOP ");
disp_ch_str(2,1,6," JET ");
disp_ch_str(10,0,6," UP ");
disp_ch_str(10,1,6," JET ");
disp_ch_str(2,4,6,"CENTER");
disp_ch_str(2,5,6," JET ");
disp_ch_str(10,4,6," DOWN ");
disp_ch_str(10,5,6," JET ");
}
break;
case 3: if(english_chinese==0)
{
disp_hz_str(0,0,8,"增 杀 暖 冷");
disp_hz_str(0,1,8,"氧 菌 风 风");
disp_hz_str(0,2,8,nopstr);
disp_icon(0,2,left_icon);
disp_icon(2,2,right_icon);
disp_icon(5,2,down_icon);
disp_icon(7,2,up_icon);
}
else
{
disp_hz_str(0,0,8,nopstr);
disp_hz_str(0,1,8,nopstr);
disp_hz_str(0,2,8,nopstr);
disp_icon(0,0,left_icon);
disp_icon(4,0,right_icon);
disp_icon(0,2,down_icon);
disp_icon(4,2,up_icon);
disp_ch_str(2,0,6,"OXYGE-");
disp_ch_str(2,1,6,"NATION");
disp_ch_str(10,0,6,"STERI-");
disp_ch_str(10,1,6,"LIZE ");
disp_ch_str(2,4,6," DRY ");
disp_ch_str(2,5,6," STEAM");
disp_ch_str(10,4,6," COOL ");
disp_ch_str(10,5,6," AIR ");
}
break;
case 4: if(english_chinese==0)
{
disp_hz_str(0,0,8,"语 键 中 ");
disp_hz_str(0,1,8,"音 音 文 ");
disp_ch_str(14,0,2,"EN");
disp_ch_str(14,1,2,"GL");
disp_ch_str(14,2,2,"IS");
disp_ch_str(14,3,2,"H ");
disp_hz_str(0,2,8,nopstr);
disp_icon(0,2,left_icon);
disp_icon(2,2,right_icon);
disp_icon(5,2,down_icon);
disp_icon(7,2,up_icon);
}
else
{
disp_hz_str(0,0,8,nopstr);
disp_hz_str(0,1,8,nopstr);
disp_hz_str(0,2,8,nopstr);
disp_icon(0,0,left_icon);
disp_icon(4,0,right_icon);
disp_icon(0,2,down_icon);
disp_icon(4,2,up_icon);
disp_ch_str(2,0,6," ");
disp_ch_str(2,1,6,"SPEECH");
disp_ch_str(10,0,6," KEY ");
disp_ch_str(10,1,6," TONE ");
disp_hz_str(1,2,2,"中文");
// disp_ch_str(2,4,6," CHIN-");
// disp_ch_str(2,5,6," ESE ");
disp_ch_str(10,4,6," ENG- ");
disp_ch_str(10,5,6," LISH ");
}
break;
}
}
else
{
if(smoker_flag)
{
disp_hz_str(0,0,8,nopstr);
if(english_chinese==0)
disp_hz_str(0,0,8,"温度 时间 ");
else
disp_ch_str(0,1,16,"TEMP TIME ");
disp_hz_str(0,1,8,nopstr);
disp_ch(5,1,stmp/10+48);
disp_ch(6,1,stmp%10+48);
disp_ch(14,1,stime/10+48);
disp_ch(15,1,stime%10+48);
}
else
{
disp_hz_str(0,0,8,nopstr);
if(english_chinese==0)
disp_hz_str(0,0,8,"温度 时间 ");
else
disp_ch_str(0,1,16,"TEMP TIME ");
disp_hz_str(0,1,8,nopstr);
disp_ch(5,1,ctmp/10+48);
disp_ch(6,1,ctmp%10+48);
// disp_ch_str(5,1,2,"--");
disp_ch_str(14,1,2,"--");
}
if(music_cnt==0)
{
disp_hz_str(0,2,8,nopstr);
// disp_ch_str(3,4,8," ");
}
else
if(CD_RADIO)
{
disp_hz_str(0,2,8,nopstr);
disp_ch_str(3,4,8,"FM");
disp_ch(6,4,fm_fre/100000?'1':' ');
disp_ch(7,4,fm_fre/10000%10+'0');
disp_ch(8,4,fm_fre/1000%10+'0');
disp_ch(9,4,'.');
disp_ch(10,4,fm_fre/100%10+'0');
}
else
{
disp_hz_str(0,2,8,nopstr);
if(english_chinese==0)
disp_hz_str(0,2,8," 唱碟输入 ");
else
disp_ch_str(0,5,16," CD INPUT ");
}
}
}
void disp_status()
{
if(++icon_cnt==3)
icon_cnt=0;
switch(icon_cnt)
{
case 0:
disp_hz(0,3,0x375a);
if(FAN==1)
disp_icon(0,3,fan_icon);
break;
case 1:
disp_hz(0,3,0x375a);
if(FAN==1)
disp_icon(0,3,fan1_icon);
break;
case 2:
disp_hz(0,3,0x375a);
if(FAN==1)
disp_icon(0,3,fan2_icon);
break;
}
disp_hz_str(1,3,7,nopstr);
// FAN==1?disp_icon(0,3,fan_icon):disp_hz(0,3,0x375a);
LAMP1==1||LAMP2==1?disp_icon(1,3,light_icon):disp_hz(1,3,0x375a);
AMBDRV==1?disp_icon(2,3,amb_icon):disp_hz(2,3,0x375a);
music_cnt?disp_icon(3,3,music_icon):disp_hz(3,3,0x375a);
FWARM==1||FCOOL==1?disp_icon(4,3,cw_fan_icon):disp_hz(4,3,0x375a);
O_INC==1?disp_icon(5,3,o2_icon):disp_hz(5,3,0x375a);
KILLV==1?disp_icon(6,3,o3_icon):disp_hz(6,3,0x375a);
W0==1|W1==1|W2==1|W3==1?disp_icon(7,3,pushw_icon):disp_hz(7,3,0x375a);
}
void chkself()
{
int i;
play_voice(34);
if(english_chinese==0)
{
disp_hz_str(0,0,8,chkself_str0);
disp_hz_str(0,1,8,chkself_str1);
disp_hz_str(0,2,8,chkself_str2);
disp_hz_str(0,3,8,chkself_str5);
}
else
{
clr_lcd();
disp_ch_str(0,1,16,"The steamer is ");
disp_ch_str(0,2,16,"in auto cleaning");
disp_ch_str(0,3,16,"and auto inspec-");
disp_ch_str(0,4,16,"tion,and all fun");
disp_ch_str(0,5,16,"tion are stop ");
disp_ch_str(0,6,16,"temporarily. ");
disp_ch_str(0,7,16,"Please wait.....");
}
WP_SW=1;
GO_W=0;
delay(1000);
ENTER_W=0;
delay(3000);
ENTER_W=1;
delay(1400);
GO_W=1;
delay(1000);
ENTER_W=0; //enter water for clear the water box
delay(20000);
ENTER_W=1;
if(waterfull_flag==1) //if water is full
{
GO_W=0;
delay(1000);
GO_W=1;
delay(1000);
GO_W=0;
delay(1000);
GO_W=1;
delay(1000);
GO_W=0;
delay(1000);
i=88;
do
{
delay(1000);
i--;
}while(waterfull_flag&&i>0);
if(i==0)
{
lockf=1;
GO_W=1;
ENTER_W=1;
clr_lcd();
if(english_chinese==0)
{
disp_hz_str(0,1,8,chkself_str4);
disp_hz_str(0,2,8,chkself_str6);
disp_hz_str(0,3,8,chkself_str7);
}
else
{
disp_ch_str(0,3,16,"Lock the steamer");
}
play_voice(36);
delay(2000);
return;
}
GO_W=1; //self check success
delay(1000);
GO_W=0;
delay(1000);
GO_W=1;
delay(1000);
GO_W=0;
delay(1000);
GO_W=1;
lockf=0;
ENTER_W=1;
clr_lcd();
if(english_chinese==0)
{
disp_hz_str(0,1,8,chkself_str3);
}
else
{
disp_ch_str(0,3,16,"Inspection is ok");
}
play_voice(35);
delay(2000);
return;
}
else //if water is empty
{
ENTER_W=0;
i=30;
do
{
delay(1000);
i--;
}while(waterfull_flag==0&&i>0);
if(i==0)
{
lockf=1;
GO_W=1;
ENTER_W=1;
clr_lcd();
if(english_chinese==0)
{
disp_hz_str(0,1,8,chkself_str4);
disp_hz_str(0,2,8,chkself_str6);
disp_hz_str(0,3,8,chkself_str7);
}
else
{
disp_ch_str(0,3,16,"Lock the steamer");
}
play_voice(36);
delay(2000);
return;
}
ENTER_W=1;
lockf=0;
clr_lcd();
if(english_chinese==0)
{
disp_hz_str(0,1,8,chkself_str3);
}
else
{
disp_ch_str(0,3,16,"Inspection is ok");
}
play_voice(35);
delay(2000);
return;
}
}
void setvol(uchar volv)/*volv=0-80 (-80db---0db)*/
{
uchar i=volv+7;
uchar j;
M62429_DA=0;
i=i&0xfc;
for(j=0;j<7;j++)
{
M62429_CL=0;
M62429_DA=i&1;
i=i>>1;
M62429_CL=1;
M62429_DA=0;
}
i=volv+7;
i=i&0x3;
i=i|0xc;
for(j=0;j<4;j++)
{
M62429_CL=0;
M62429_DA=i&1;
i=i>>1;
M62429_CL=1;
M62429_DA=0;
}
M62429_DA=1;
M62429_CL=0;
M62429_DA=0;
M62429_DA=1;
}
void wpchk()
{
if(WP_SW)
{
wfcnt=0;
if(++wecnt>=6)
{
wecnt=0;
waterfull_flag=0;
}
}
else
{
wecnt=0;
if(++wfcnt>=6)
{
wfcnt=0;
waterfull_flag=1;
}
}
}
void send_pll_data(unsigned long int ccb_data_block)
//ccb_data_block define:
//bit0-bit7:<b0,b1,b2,b3,a0,a1,a2,a3>;IN1=0x28;IN2=0x29;
//bit8-bit23:1.IN1 MODE:<p0-p15>;
// 2.IN2 MODE:<IOC1,IOC2,IO1,IO2,BO1,BO2,BO3,BO4,BO5,
// DOC0,DOC1,DOC2,UL0,UL1,DZ0,DZ1>;
//bit24-bit31:1.IN1 MODE:<SNS,DVS,CTE,XS,R0,R1,R2,R3>;
// 2.IN2 MODE:<GT0,GT1,TBC,DLC,IFS,TEST0,TEST1,TEST2>
{
uchar i;
unsigned long int ccb_db=ccb_data_block;
RADIO_CE=0;
RADIO_CL=1;
RADIO_DO=1;
RADIO_DI=1;
for(i=0;i<8;i++) //send IN mode byte
{
RADIO_CL=0;
ccb_db=ccb_db>>1;
RADIO_DI=CY;
RADIO_DI=CY;
RADIO_CL=1;
RADIO_CL=1;
}
RADIO_CL=1;
RADIO_CE=1;
RADIO_CE=1;
RADIO_CE=1;
for(i=0;i<24;i++) //send 24 bit data
{
RADIO_CL=0;
ccb_db=ccb_db>>1;
RADIO_DI=CY;
RADIO_DI=CY;
RADIO_CL=1;
RADIO_CL=1;
}
RADIO_CL=1;
RADIO_CL=1;
RADIO_CE=0;
RADIO_CE=0;
}
unsigned long int rece_pll_data()
//read and return pll ccb data block
//bit0-bit19:<c0-c19>=IF count value;
//bit20-bit23:<UL,NC,I1,I2>;
{
unsigned long int ccb_db=0x00000000;
uchar i,out_mode_byte=0x2a;
RADIO_CE=0;
RADIO_CL=1;
RADIO_DO=1;
RADIO_DI=1;
for(i=0;i<8;i++) //send IN mode byte
{
RADIO_CL=0;
RADIO_CL=0;
RADIO_CL=0;
out_mode_byte=out_mode_byte>>1;
RADIO_DI=CY;
RADIO_DI=CY;
RADIO_DI=CY;
RADIO_CL=1;
RADIO_CL=1;
RADIO_CL=1;
}
RADIO_CL=1;
RADIO_CE=1;
RADIO_CE=1;
RADIO_CE=1;
// C=0;
for(i=0;i<24;i++)
{
RADIO_CL=0;
RADIO_CL=0;
RADIO_CL=0;
RADIO_CL=0;
if(RADIO_DO)
ccb_db=ccb_db+ccb_db+1;
else
ccb_db=ccb_db+ccb_db;
RADIO_CL=1;
RADIO_CL=1;
RADIO_CL=1;
RADIO_CL=1;
}
RADIO_CL=1;
RADIO_CL=1;
RADIO_CE=0;
RADIO_CE=0;
return ccb_db;
}
bit set_radio_fre(unsigned long int fre)
//entry:fre(88000khz--108000khz));
//return 0 if lock success else return 1
{
unsigned long int temp,ccb_db=fre;
uchar i=0;
ccb_db=(ccb_db+10700)/50;
ccb_db=0x22000028|(ccb_db<<8);
send_pll_data(0x12048029);//mute the radio
delay(30);
send_pll_data(ccb_db);//cte=0,reset the IF counter
delay(10);
send_pll_data(0x26000000|ccb_db);//cte=1;start the IF counter
delay(32);
i=0;
while(++i<50&&RADIO_DO)
{
delay(1);
}
temp=rece_pll_data()&0x000fffff;
temp=temp/32;
delay(30);
if(temp>10708||temp<10692)
return 1;
send_pll_data(ccb_db);//cte=0,reset the IF counter
delay(10);
send_pll_data(0x26000000|ccb_db);//cte=1;start the IF counter
delay(32);
i=0;
while(++i<50&&RADIO_DO)
{
delay(1);
}
temp=rece_pll_data()&0x000fffff;
temp=temp/32;
delay(30);
if(temp>10708||temp<10692)
return 1;
send_pll_data(ccb_db);//cte=0,reset the IF counter
delay(10);
send_pll_data(0x26000000|ccb_db);//cte=1;start the IF counter
delay(32);
i=0;
while(++i<50&&RADIO_DO)
{
delay(1);
}
temp=rece_pll_data()&0x000fffff;
temp=temp/32;
delay(30);
if(temp>10708||temp<10692)
return 1;
return 0;
/* disp_hz_str(0,3,8,nopstr);
disp_ch(7,7,ccb_db/100000%10+'0');
disp_ch(8,7,ccb_db/10000%10+'0');
disp_ch(9,7,ccb_db/1000%10+'0');
disp_ch(7,7,ccb_db/100000%10+'0');
disp_ch(8,7,ccb_db/10000%10+'0');
disp_ch(9,7,ccb_db/1000%10+'0');
disp_ch(10,7,ccb_db/100%10+'0');
disp_ch(11,7,ccb_db/10%10+'0');
disp_ch(12,7,ccb_db%10+'0');*/
// send_pll_data(0x0200a029);//open the radio
}
void mute()
{
setvol(0);
}
//***********************************************
//* ISD4002 VOICE CHIP CONTROL PROGRAM SUB *
//* WRITEN BY LIU QING DONG *
//***********************************************
void send_isd_byte(uchar isd_data)
{
uchar i;
clrb(ISD_SS);
for(i=0;i<8;i++)
{
ISD_SCLK=0;
ISD_MOSI=isd_data&0x01;
ISD_SCLK=1;
isd_data=isd_data>>1;
}
ISD_SCLK=0;
}
void stop_isd()
{
send_isd_byte(0x30);
setb(ISD_SS);
delay(50);
}
void up_isd()
{
send_isd_byte(0x20);
setb(ISD_SS);
delay(100);
}
void play_voice(uchar seg_no)
{
/*seg_no:
0: welcome chinese
1: welcome english
2: lamp on
3: lamp off
4: fan on
5: fan off
6: wave on
7: wave off
8: amb on
9: amb off
10: radio on
11: cd input
12: music off
13: menu entry
14: o++ on
15: o++ off
16: killv on
17: killv off
18: cool air on
19: cool air off
20: dry heat on
21: dry heat off
22: speech on
23: speech off
24: key tone on
25: key tone off
26: chinese display
27: english display
28: steam on
29: steam off
30: radio adjust
31: volume control
32: time control
33: temp control
34: chkself start
35: chkself ok
36: chkself fail
37: hello,bye-bye
38: music on
*/
// uchar i,j;
if(voice_flag&&seg_no!=speech_num)
{
speech_num=seg_no;
stop_isd();
clrb(SOUND_CDRADIO);
send_isd_byte(isd_addr[speech_num]%256);
send_isd_byte((isd_addr[speech_num]/256)&0x07|0xe0);
setb(ISD_SS);
delay(50);
// send_isd_byte(0x00);
// send_isd_byte(0xe8);//set fast search address=0;
// setb(ISD_SS);
// if(seg_no)
// {
// TR0=0;
// for(i=0;i<seg_no;i++)
// {
// send_isd_byte(0xf8);//fast search
// setb(ISD_SS);
// for(j=0;j<255;j++)
// while(ISD_INT);
// delay(5);
// }
// }
// else
// {
// stop_isd();
// send_isd_byte(0x00);
// send_isd_byte(0xe0);//set fast play address=0;
// setb(ISD_SS);
// }
// delay(1);
send_isd_byte(0xf0);//play
setb(ISD_SS);
// TR0=1;
// delay(50);
}
else
setb(SOUND_CDRADIO);
}
/**********************************************************
* AT24C01/02/04/16 IC CARD READ&WRITE SUB PROGRAMS GROUP *
* 2001/04/26 *
**********************************************************/
//
//--------------RADOM WRITE IC CARD DATA FOR AT24CXX CARD
//ENTRY: byte_addr----byte data offset address at 24cxx
// ic_type----24cxx type: 0-24c01,1-24c02,2-24c04;3-24c08;4-24c16
// wdata---data want to write
// WRITE success then return 0 else return 1
//
bit wrt_24cxx(uchar ic_type,uchar byte_addr,wdata)
{
uchar at24cxx_cmd;
switch(ic_type)
{
case 0:
at24cxx_cmd=0xa0;//24c01
break;
case 1:
at24cxx_cmd=0xa0;//24c02
break;
case 2:
at24cxx_cmd=0xa2;//24c04
break;
case 3:
at24cxx_cmd=0xa6;//24c08
break;
// case 4:
// at24cxx_cmd=0xa0;//24c16
// break;
default:
at24cxx_cmd=0xa0;
}
sstart();//send the start signal
if(sdata(at24cxx_cmd))
return 1;
if(sdata(byte_addr))
return 1;
// for(i=0;i<data_num;i++)
if(sdata(wdata))
return 1;
sstop();
delay(10);
return 0;
}
//--------------RADOM READ IC CARD DATA FOR AT24CXX CARD
//ENTRY: byte_addr----byte data offset address at 24cxx
// ic_type----24cxx type: 0-24c01,1-24c02,2-24c04;3-24c08;4-24c16
// rd_ptr-->data readed
// read success then return 0 else return 1
//
bit rd_24cxx(uchar ic_type,uchar byte_addr,uchar *rd_ptr)
{
uchar at24cxx_cmd;
switch(ic_type)
{
case 0:
at24cxx_cmd=0xa0;//24c01
break;
case 1:
at24cxx_cmd=0xa0;//24c02
break;
case 2:
at24cxx_cmd=0xa2;//24c04
break;
case 3:
at24cxx_cmd=0xa6;//24c08
break;
// case 4:
// at24cxx_cmd=0xa0;//24c16
// break;
default:
at24cxx_cmd=0xa0;
}
sstart();//send the start signal
if(sdata(at24cxx_cmd))
return 1;
if(sdata(byte_addr))
return 1;
sstart();
if(sdata(at24cxx_cmd|0x01))
return 1;
// for(i=0;i<data_num;i++)
// {
// *rd_ptr=rdata();
// send_ack();
// }
// send_ack();
*rd_ptr=rdata();
send_noack();
sstop();
return 0;
}
void dly_us(uchar us_v)//delay i us
{
uchar i=us_v/4;//6mhz
while(i>0)
i--;
}
//---------------SEND START BIT FOR AT24XX
void sstart()
{
EEPROM_SDA=1;
dly_us(8);
EEPROM_SCL=1;
dly_us(8);
EEPROM_SDA=0;
dly_us(8);
EEPROM_SCL=0;
}
//---------------SEND STOP BIT FOR AT24XX
void sstop()
{
EEPROM_SDA=0;
dly_us(8);
EEPROM_SCL=1;
dly_us(8);
EEPROM_SDA=1;
dly_us(8);
}
//---------------send ack
//void send_ack()
//{
// EEPROM_SCL=0;
// dly_us(10);
// EEPROM_SDA=0;
// dly_us(10);
// EEPROM_SCL=1;
// dly_us(10);
// EEPROM_SCL=0;
//}
void send_noack()
{
EEPROM_SCL=0;
dly_us(10);
EEPROM_SDA=1;
dly_us(10);
EEPROM_SCL=1;
dly_us(10);
EEPROM_SCL=0;
}
//--------------send data TO at24cxx
bit sdata(uchar tdata)
//if success then return 0 else return 1
{
uchar i,j=tdata;
for(i=0;i<8;i++)
{
EEPROM_SDA=j&0x80;
j=j<<1;
dly_us(8);
EEPROM_SCL=1;
dly_us(8);
EEPROM_SCL=0;
}
dly_us(8);
EEPROM_SDA=1;
dly_us(8);
EEPROM_SCL=1;
dly_us(28);
if(EEPROM_SDA==0)
{
EEPROM_SCL=0;
return 0;
}
dly_us(8);
EEPROM_SCL=0;
return 1;
}
uchar rdata() //read 1 byte data from at24cxx
{
uchar i,j=0;
EEPROM_SDA=1;
dly_us(8);
for(i=0;i<8;i++)
{
j=j<<1;
EEPROM_SCL=0;
dly_us(8);
EEPROM_SCL=1;
if(EEPROM_SDA)
j=j|0x01;
else
j=j&0xfe;
dly_us(8);
}
return j;
}
void reset_dog()
{
EEPROM_SDA=0;
EEPROM_SDA=0;
EEPROM_SDA=1;
EEPROM_SDA=1;
}
void demo(uchar i)
{
uchar row=0,k;
// clr_lcd();
for(k=0;k<4;k++)
{
if(help_str[row+i][0]>=0xa0)
disp_hz_str(0,k,8,help_str[row+i]);
else
{
disp_hz_str(0,k,8,nopstr);
disp_ch_str(0,k*2,16,help_str[row+i]);
++row;
disp_ch_str(0,k*2+1,16,help_str[row+i]);
}
++row;
}
}
复制代码
所有资料51hei提供下载:
桑拿浴房控制器.rar
(565.64 KB, 下载次数: 32)
2018-11-11 15:44 上传
点击文件名下载附件
桑拿浴房控制器原理图
下载积分: 黑币 -5
作者:
jubaolun
时间:
2018-11-11 19:37
怎么没压缩包没文件?
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1