int send_card_info( DWORD card_id, int ok_flag ) { extern int g_record_id; extern int g_host_type; switch( g_host_type ){ case 1: return send_card_info_by_tcmd( RTC_Get(), get_sys_tick(), g_record_id, card_id, ok_flag ); break; case 2: return send_card_info_by_dlc( RTC_Get(), get_sys_tick() ); break; } return 0; }
//RTC时钟中断 //每秒触发一次 //extern u16 tcnt; void RTC_IRQHandler(void) { if (RTC_GetITStatus(RTC_IT_SEC) != RESET)//秒钟中断 { RTC_Get();//更新时间 } if(RTC_GetITStatus(RTC_IT_ALR)!= RESET)//闹钟中断 { RTC_ClearITPendingBit(RTC_IT_ALR); //清闹钟中断 RTC_Get(); //更新时间 printf("Alarm Time:%d-%d-%d %d:%d:%d\n",calendar.w_year,calendar.w_month,calendar.w_date,calendar.hour,calendar.min,calendar.sec);//输出闹铃时间 } RTC_ClearITPendingBit(RTC_IT_SEC|RTC_IT_OW); //清闹钟中断 RTC_WaitForLastTask(); }
u8 RTC_Set(u16 syear,u8 smon,u8 sday,u8 hour,u8 min,u8 sec) { u16 t; u32 seccount=0; if(syear<1970||syear>2099)return 1; for(t=1970;t<syear;t++) //把所有年份的秒钟相加 { if(Is_Leap_Year(t))seccount+=31622400;//闰年的秒钟数 else seccount+=31536000; //平年的秒钟数 } smon-=1; for(t=0;t<smon;t++) //把前面月份的秒钟数相加 { seccount+=(u32)mon_table[t]*86400;//月份秒钟数相加 if(Is_Leap_Year(syear)&&t==1)seccount+=86400;//闰年2月份增加一天的秒钟数 } seccount+=(u32)(sday-1)*86400;//把前面日期的秒钟数相加 seccount+=(u32)hour*3600;//小时秒钟数 seccount+=(u32)min*60; //分钟秒钟数 seccount+=sec;//最后的秒钟加上去 RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE); //使能PWR和BKP外设时钟 PWR_BackupAccessCmd(ENABLE); //使能RTC和后备寄存器访问 RTC_SetCounter(seccount); //设置RTC计数器的值 RTC_WaitForLastTask(); //等待最近一次对RTC寄存器的写操作完成 RTC_Get(); return 0; }
//syear,smon,sday,hour,min,sec:年月日时分秒 //返回值:设置结果。0,成功;1,失败。 u8 RTC_Set(u16 syear,u8 smon,u8 sday,u8 hour,u8 min,u8 sec) { u16 t; u32 seccount=0; if(syear<1970||syear>2099)return 1; for(t=1970;t<syear;t++) //把所有年份的秒钟相加 { if(Is_Leap_Year(t))seccount+=31622400;//闰年的秒钟数 else seccount+=31536000; //平年的秒钟数 } smon-=1; for(t=0;t<smon;t++) //把前面月份的秒钟数相加 { seccount+=(u32)mon_table[t]*86400;//月份秒钟数相加 if(Is_Leap_Year(syear)&&t==1)seccount+=86400;//闰年2月份增加一天的秒钟数 } seccount+=(u32)(sday-1)*86400;//把前面日期的秒钟数相加 seccount+=(u32)hour*3600;//小时秒钟数 seccount+=(u32)min*60; //分钟秒钟数 seccount+=sec;//最后的秒钟加上去 //设置时钟 RCC->APB1ENR|=1<<28;//使能电源时钟 RCC->APB1ENR|=1<<27;//使能备份时钟 PWR->CR|=1<<8; //取消备份区写保护 //上面三步是必须的! RTC->CRL|=1<<4; //允许配置 RTC->CNTL=seccount&0xffff; RTC->CNTH=seccount>>16; RTC->CRL&=~(1<<4);//配置更新 while(!(RTC->CRL&(1<<5)));//等待RTC寄存器操作完成 RTC_Get();//设置完之后更新一下数据 return 0; }
int do_cam() { char show[30]; extern unsigned g_deal_card_no; if( do_cam_check_file() <= 0 ) return -3; return sub_do_cam( g_device_no, g_deal_card_no, RTC_Get(), show, sizeof(show) ); }
unsigned int uffs_GetCurDateTime(void) { // FIXME: return system time, please modify this for your platform ! // or just return 0 if you don't care about file time. time_t tvalue; //tvalue = time(NULL); tvalue = RTC_Get(); return (unsigned int)tvalue; }
//获取RTC时间 //time:存放时间字符串,形如:"2012-09-27 12:33:00" //time,最少得有17个字节的空间! void get_time(u8 *time) { RTC_Get(); time[4]='-';time[7]='-';time[10]=' '; time[13]=':';time[16]=':';time[19]=0; //最后添加结束符 num2str(calendar.w_year,time,4); //年份->字符串 num2str(calendar.w_month,time+5,2); //月份->字符串 num2str(calendar.w_date,time+8,2); //日期->字符串 num2str(calendar.hour,time+11,2); //小时->字符串 num2str(calendar.min,time+14,2); //分钟->字符串 num2str(calendar.sec,time+17,2); //秒->字符串 }
//重新初始化闹钟 //alarmx:闹钟结构体 //calendarx:日历结构体 void calendar_alarm_init(_alarm_obj *alarmx,_calendar_obj *calendarx) { u8 temp; RTC_Get(); if(calendarx->week==7)temp=1<<0; else temp=1<<calendarx->week; if(alarmx->weekmask&temp) //需要闹铃 { printf("alarm:%d-%d-%d %d:%d\r\n",calendarx->w_year,calendarx->w_month,calendarx->w_date,alarmx->hour,alarmx->min); RTC_Alarm_Set(calendarx->w_year,calendarx->w_month,calendarx->w_date,alarmx->hour,alarmx->min,0);//设置闹铃时间 } }
//RTC时钟中断 //每秒触发一次 //extern u16 tcnt; void RTC_IRQHandler(void) { if (RTC_GetITStatus(RTC_IT_SEC) != RESET)//秒钟中断 { RTC_Get();//更新时间 } if(RTC_GetITStatus(RTC_IT_ALR)!= RESET)//闹钟中断 { RTC_ClearITPendingBit(RTC_IT_ALR); //清闹钟中断 } RTC_ClearITPendingBit(RTC_IT_SEC|RTC_IT_OW); //清闹钟中断 RTC_WaitForLastTask(); }
/*! * @brief Thread handling the RTC */ void RtcThread(void *data) { for (;;) { OS_SemaphoreWait(RtcSemaphore, 0); uint8_t h, m, s; RTC_Get(&h, &m, &s); CMD_SendTime(h, m, s); if (ProjectMode == MODE_DEFAULT) { LEDs_Toggle(LED_YELLOW); } } }
//RTC中断服务函数 void RTC_IRQHandler(void) { if(RTC->CRL&0x0001)//秒钟中断 { RTC_Get();//更新时间 } if(RTC->CRL&0x0002)//闹钟中断 { RTC->CRL&=~(0x0002);//清闹钟中断 //闹钟处理 } RTC->CRL&=0X0FFA; //清除溢出,秒钟中断标志 while(!(RTC->CRL&(1<<5)));//等待RTC寄存器操作完成 }
//RTC时钟中断 //每秒触发一次 void RTC_IRQHandler(void) { if(RTC->CRL&0x0001)//秒钟中断 { RTC_Get();//更新时间 //printf("sec:%d\r\n",calendar.sec); } if(RTC->CRL&0x0002)//闹钟中断 { RTC->CRL&=~(0x0002); //清闹钟中断 //printf("Alarm!\n"); } RTC->CRL&=0X0FFA; //清除溢出,秒钟中断标志 while(!(RTC->CRL&(1<<5)));//等待RTC寄存器操作完成 }
//RTC中断服务函数 //const u8* Week[2][7]= //{ //{"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}, //{"日","一","二","三","四","五","六"} //}; //RTC时钟中断 //每秒触发一次 void RTC_IRQHandler(void) { if(RTC->CRL&0x0001)//秒钟中断 { RTC_Get();//更新时间 //printf("CRL:%d\n",RTC->CRL); } if(RTC->CRL&0x0002)//闹钟中断 { //printf("Alarm!\n"); RTC->CRL&=~(0x0002);//清闹钟中断 //闹钟处理 } RTC->CRL&=0X0FFA; //清除溢出,秒钟中断标志 while(!(RTC->CRL&(1<<5)));//等待RTC寄存器操作完成 }
//实时时钟配置 //初始化RTC时钟,同时检测时钟是否工作正常 //BKP->DR1用于保存是否第一次配置的设置 //返回0:正常 //其他:错误代码 u8 RTC_Init(void) { //检查是不是第一次配置时钟 u8 temp=0; if(BKP->DR1!=0X5050)//第一次配置 { RCC->APB1ENR|=1<<28; //使能电源时钟 RCC->APB1ENR|=1<<27; //使能备份时钟 PWR->CR|=1<<8; //取消备份区写保护 RCC->BDCR|=1<<16; //备份区域软复位 RCC->BDCR&=~(1<<16); //备份区域软复位结束 RCC->BDCR|=1<<0; //开启外部低速振荡器 while((!(RCC->BDCR&0X02))&&temp<250)//等待外部时钟就绪 { temp++; delay_ms(10); }; if(temp>=250)return 1;//初始化时钟失败,晶振有问题 RCC->BDCR|=1<<8; //LSI作为RTC时钟 RCC->BDCR|=1<<15;//RTC时钟使能 while(!(RTC->CRL&(1<<5)));//等待RTC寄存器操作完成 while(!(RTC->CRL&(1<<3)));//等待RTC寄存器同步 RTC->CRH|=0X01; //允许秒中断 while(!(RTC->CRL&(1<<5)));//等待RTC寄存器操作完成 RTC->CRL|=1<<4; //允许配置 RTC->PRLH=0X0000; RTC->PRLL=32767; //时钟周期设置(有待观察,看是否跑慢了?)理论值:32767 Auto_Time_Set(); //RTC_Set(2009,12,2,10,0,55); //设置时间 RTC->CRL&=~(1<<4); //配置更新 while(!(RTC->CRL&(1<<5))); //等待RTC寄存器操作完成 BKP->DR1=0X5050; //BKP_Write(1,0X5050);;//在寄存器1标记已经开启了 //printf("FIRST TIME\n"); }else//系统继续计时 { while(!(RTC->CRL&(1<<3)));//等待RTC寄存器同步 RTC->CRH|=0X01; //允许秒中断 while(!(RTC->CRL&(1<<5)));//等待RTC寄存器操作完成 //printf("OK\n"); } MY_NVIC_Init(0,0,RTC_IRQChannel,2);//RTC,G2,P2,S2.优先级最低 RTC_Get();//更新时间 return 0; //ok }
uint08 RTC_Init(void) { //检查是不是第一次配置时钟 uint08 temp=0; if ( BKP_ReadBackupRegister(BKP_DR1) != 0x5050 ) //从指定的后备寄存器中读出数据:读出了与写入的指定数据不相乎 { RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE); //使能PWR和BKP外设时钟 PWR_BackupAccessCmd(ENABLE); //使能后备寄存器访问 BKP_DeInit(); //复位备份区域 RCC_LSEConfig(RCC_LSE_ON); //设置外部低速晶振(LSE),使用外设低速晶振 while ( RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET && temp< 252) //检查指定的RCC标志位设置与否,等待低速晶振就绪 { temp++; //delay_ms(10); //OSTimeDlyHMSM(0, 0, 0, 10); } if ( temp>=250 ) { return 1;//初始化时钟失败,晶振有问题 } RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); //设置RTC时钟(RTCCLK),选择LSE作为RTC时钟 RCC_RTCCLKCmd(ENABLE); //使能RTC时钟 RTC_WaitForLastTask(); //等待最近一次对RTC寄存器的写操作完成 RTC_WaitForSynchro(); //等待RTC寄存器同步 RTC_ITConfig(RTC_IT_SEC, ENABLE); //使能RTC秒中断 RTC_WaitForLastTask(); //等待最近一次对RTC寄存器的写操作完成 RTC_EnterConfigMode();/// 允许配置 RTC_SetPrescaler(32767); //设置RTC预分频的值 RTC_WaitForLastTask(); //等待最近一次对RTC寄存器的写操作完成 RTC_Set(2009,12,2,10,0,55); //设置时间 RTC_ExitConfigMode(); //退出配置模式 BKP_WriteBackupRegister(BKP_DR1, 0X5050); //向指定的后备寄存器中写入用户程序数据 } else//系统继续计时 { RTC_WaitForSynchro(); //等待最近一次对RTC寄存器的写操作完成 RTC_ITConfig(RTC_IT_SEC, ENABLE); //使能RTC秒中断 RTC_WaitForLastTask(); //等待最近一次对RTC寄存器的写操作完成 } RTC_NVIC_Config();//RCT中断分组设置 RTC_Get();//更新时间 return 0; //ok }
//RTC时钟中断 //每秒触发一次 void RTC_IRQHandler(void) { #warning !!!And code here!!! //用户程序.. if ( RTC_GetITStatus(RTC_IT_SEC) != RESET )//秒钟中断 { RTC_Get();//更新时间 ReNewRTC();//更新时间 } if ( RTC_GetITStatus(RTC_IT_ALR)!= RESET )//闹钟中断 { RTC_ClearITPendingBit(RTC_IT_ALR); //清闹钟中断 } RTC_ClearITPendingBit(RTC_IT_SEC|RTC_IT_OW); //清闹钟中断 RTC_WaitForLastTask(); #warning !!!And code here!!! }
int access_loop() { //int rel; int ok_cam_flag; int ok_send_flag; u32 time, tick; char record_buf[64]; if( check_card_action() > 0 ){ g_deal_card_no = g_card_no; g_card_no = 0; ok_cam_flag = do_cam(); if( ok_cam_flag <= -2 ){ // invailed card set_illegal_card_page(); set_page_keep_second( 5 ); } else if( ok_cam_flag == -1 ){ // disable enter set_forbid_enter_page(); set_page_keep_second( 5 ); } else if( ok_cam_flag == 1 ){ set_allow_enter_page(); set_page_keep_second( 5 ); } time = RTC_Get(); tick = get_sys_tick(); // make send record buf gen_record_string( record_buf, time, tick, g_record_id, g_deal_card_no, ok_cam_flag ); ok_send_flag = system_send_buf_to_host( record_buf, strlen( record_buf ) ); // make save file record buf sprintf( &record_buf[ strlen( record_buf ) ], "%d", ok_send_flag ); save_card_info( g_record_id, record_buf, ok_send_flag ); show_main_page(); g_record_id ++; } timer_process(); access_command_deal(); return 0; }
u8 RTC_Init(void) { //检查是不是第一次配置时钟 u8 temp=0; RTC_NVIC_Config(); //if(BKP->DR1!=0X5050)//第一次配置 if (BKP_ReadBackupRegister(BKP_DR1) != 0x5050) //从指定的后备寄存器中读出数据:读出了与写入的指定数据不相乎 { RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE); //使能PWR和BKP外设时钟 PWR_BackupAccessCmd(ENABLE); //使能RTC和后备寄存器访问 BKP_DeInit(); //将外设BKP的全部寄存器重设为缺省值 RCC_LSEConfig(RCC_LSE_ON); //设置外部低速晶振(LSE),使用外设低速晶振 while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) //检查指定的RCC标志位设置与否,等待低速晶振就绪 { temp++; delay_ms(10); } if(temp>=250)return 1;//初始化时钟失败,晶振有问题 RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); //设置RTC时钟(RTCCLK),选择LSE作为RTC时钟 RCC_RTCCLKCmd(ENABLE); //使能RTC时钟 RTC_WaitForSynchro(); //等待最近一次对RTC寄存器的写操作完成 RTC_WaitForLastTask(); //等待最近一次对RTC寄存器的写操作完成 RTC_ITConfig(RTC_IT_SEC, ENABLE); //使能RTC秒中断 RTC_WaitForLastTask(); //等待最近一次对RTC寄存器的写操作完成 RTC_SetPrescaler(32767); //设置RTC预分频的值 RTC_WaitForLastTask(); //等待最近一次对RTC寄存器的写操作完成 RTC_Set(2009,12,2,10,0,55); //设置时间 BKP_WriteBackupRegister(BKP_DR1, 0X5050); //向指定的后备寄存器中写入用户程序数据 } else//系统继续计时 { RTC_WaitForSynchro(); //等待最近一次对RTC寄存器的写操作完成 RTC_ITConfig(RTC_IT_SEC, ENABLE); //使能RTC秒中断 RTC_WaitForLastTask(); //等待最近一次对RTC寄存器的写操作完成 } RTC_Get();//更新时间 RCC_ClearFlag(); //清除RCC的复位标志位 return 0; //ok }
int timer_process() { static unsigned second = 0; static unsigned beat_second = 0; unsigned val = RTC_Get(); if( val - second >= 2 || (int)val - (int)second < 0 ){ if( g_page_keep_second > 0 ){ g_page_keep_second -= val - second; if( g_page_keep_second <= 0 ){ set_main_page(); g_page_keep_second = 0; } } second = val; show_main_page(); } if( val - beat_second >= 10 || (int)val - (int)beat_second < 0 ){ char *buf = "beats "; system_send_buf_to_host( buf, strlen( buf ) ); beat_second = val; } return 0; }
u8 RTC_Init(void) { //检查是不是第一次配置时钟 u8 temp=0; RTC_NVIC_Config(); //if(BKP->DR1!=0X5050)//第一次配置 if (BKP_ReadBackupRegister(BKP_DR1) != 0x5050) //从指定的后备寄存器中读出数据:读出了与写入的指定数据不相乎 { /* Enable PWR and BKP clocks */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE); //使能PWR和BKP外设时钟 /* Allow access to BKP Domain */ PWR_BackupAccessCmd(ENABLE); //使能RTC和后备寄存器访问 /* Reset Backup Domain */ BKP_DeInit(); //将外设BKP的全部寄存器重设为缺省值 /* Enable LSE */ RCC_LSEConfig(RCC_LSE_ON); //设置外部低速晶振(LSE),使用外设低速晶振 /* Wait till LSE is ready */ while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) //检查指定的RCC标志位设置与否,等待低速晶振就绪 { temp++; delay_ms(10); } if(temp>=250)return 1;//初始化时钟失败,晶振有问题 /* Select LSE as RTC Clock Source */ RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); //设置RTC时钟(RTCCLK),选择LSE作为RTC时钟 /* Enable RTC Clock */ RCC_RTCCLKCmd(ENABLE); //使能RTC时钟 /* Wait for RTC registers synchronization */ RTC_WaitForSynchro(); //等待最近一次对RTC寄存器的写操作完成 /* Wait until last write operation on RTC registers has finished */ RTC_WaitForLastTask(); //等待最近一次对RTC寄存器的写操作完成 /* Enable the RTC Second */ RTC_ITConfig(RTC_IT_SEC, ENABLE); //使能RTC秒中断 /* Wait until last write operation on RTC registers has finished */ RTC_WaitForLastTask(); //等待最近一次对RTC寄存器的写操作完成 /* Set RTC prescaler: set RTC period to 1sec */ /* RTC period = RTCCLK/RTC_PR = (32.768 KHz)/(32767+1) */ RTC_SetPrescaler(32767); //设置RTC预分频的值 /* Wait until last write operation on RTC registers has finished */ RTC_WaitForLastTask(); //等待最近一次对RTC寄存器的写操作完成 RTC_Set(2009,12,2,10,0,55); //设置时间 BKP_WriteBackupRegister(BKP_DR1, 0X5050); //向指定的后备寄存器中写入用户程序数据 } else//系统继续计时 { /* Check if the Power On Reset flag is set */ if (RCC_GetFlagStatus(RCC_FLAG_PORRST) != RESET) //检查指定的RCC标志位设置与否:POR/PDR复位 { //printf("\rPower On Reset occurred...."); } /* Check if the Pin Reset flag is set */ else if (RCC_GetFlagStatus(RCC_FLAG_PINRST) != RESET) //检查指定的RCC标志位设置与否:管脚复位 { //printf("\rExternal Reset occurred...."); } //printf("\rNo need to configure RTC...."); /* Wait for RTC registers synchronization */ RTC_WaitForSynchro(); //等待最近一次对RTC寄存器的写操作完成 /* Enable the RTC Second */ RTC_ITConfig(RTC_IT_SEC, ENABLE); //使能RTC秒中断 /* Wait until last write operation on RTC registers has finished */ RTC_WaitForLastTask(); //等待最近一次对RTC寄存器的写操作完成 } RTC_Get();//更新时间 /* Clear reset flags */ RCC_ClearFlag(); //清除RCC的复位标志位 return 0; //ok }
//时间显示模式 u8 calendar_play(void) { u8 second=0; short temperate=0; //温度值 u8 t=0; u8 tempdate=0; u8 rval=0; //返回值 u8 res; u16 xoff=0; u16 yoff=0; //表盘y偏移量 u16 r=0; //表盘半径 u8 d=0; //指针长度 u8 TEMP_SEN_TYPE=0; //默认使用DS18B20 FIL* f_calendar=0; f_calendar=(FIL *)gui_memin_malloc(sizeof(FIL));//开辟FIL字节的内存区域 if(f_calendar==NULL)rval=1; //申请失败 else { res=f_open(f_calendar,(const TCHAR*)APP_ASCII_S6030,FA_READ);//打开文件 if(res==FR_OK) { asc2_s6030=(u8*)gui_memex_malloc(f_calendar->fsize); //为大字体开辟缓存地址 if(asc2_s6030==0)rval=1; else { res=f_read(f_calendar,asc2_s6030,f_calendar->fsize,(UINT*)&br); //一次读取整个文件 } f_close(f_calendar); } if(res)rval=res; } if(rval==0)//无错误 { LCD_Clear(BLACK);//清黑屏 second=calendar.sec;//得到此刻的秒钟 POINT_COLOR=GBLUE; Show_Str(48,60,lcddev.width,lcddev.height,(u8*)calendar_loading_str[gui_phy.language][0],16,0x01); //显示进入信息 if(DS18B20_Init()) { Show_Str(48,76,lcddev.width,lcddev.height,(u8*)calendar_loading_str[gui_phy.language][1],16,0x01); delay_ms(500); Show_Str(48,92,lcddev.width,lcddev.height,(u8*)calendar_loading_str[gui_phy.language][2],16,0x01); TEMP_SEN_TYPE=1; } delay_ms(1100);//等待1.1s BACK_COLOR= BLACK; LCD_Clear(BLACK);//清黑屏 if(lcddev.width==240) { r=80; d=7; }else if(lcddev.width==320) { r=120; d=9; }else if(lcddev.width==480) { r=160; d=12; } yoff=(lcddev.height-r*2-140)/2; TIME_TOPY=yoff+r*2+10; OTHER_TOPY=TIME_TOPY+60+10; xoff=(lcddev.width-240)/2; calendar_circle_clock_drawpanel(lcddev.width/2,yoff+r,r*2,d);//显示指针时钟表盘 calendar_date_refresh(); //加载日历 tempdate=calendar.w_date;//天数暂存器 gui_phy.back_color=BLACK; gui_show_ptchar(xoff+70-4,TIME_TOPY,lcddev.width,lcddev.height,0,GBLUE,60,':',0); //":" gui_show_ptchar(xoff+150-4,TIME_TOPY,lcddev.width,lcddev.height,0,GBLUE,60,':',0); //":" } while(rval==0) { RTC_Get(); //更新时间 if(system_task_return)break;//需要返回 if(second!=calendar.sec) //秒钟改变了 { second=calendar.sec; calendar_circle_clock_showtime(lcddev.width/2,yoff+r,r*2,d,calendar.hour,calendar.min,calendar.sec);//指针时钟显示时间 gui_phy.back_color=BLACK; gui_show_num(xoff+10,TIME_TOPY,2,GBLUE,60,calendar.hour,0X80); //显示时 gui_show_num(xoff+90,TIME_TOPY,2,GBLUE,60,calendar.min,0X80); //显示分 gui_show_num(xoff+170,TIME_TOPY,2,GBLUE,60,calendar.sec,0X80); //显示秒 if(t%2==0)//等待2秒钟 { if(TEMP_SEN_TYPE)temperate=Get_Temp();//得到内部温度传感器的温度值,0.1℃ else temperate=DS18B20_Get_Temp();//得到18b20温度 if(temperate<0)//温度为负数的时候,红色显示 { POINT_COLOR=RED; temperate=-temperate; //改为正温度 }else POINT_COLOR=BRRED; //正常为棕红色字体显示 gui_show_num(xoff+90,OTHER_TOPY,2,GBLUE,60,temperate/10,0X80); //XX gui_show_ptchar(xoff+150,OTHER_TOPY,lcddev.width,lcddev.height,0,GBLUE,60,'.',0); //"." gui_show_ptchar(xoff+180-15,OTHER_TOPY,lcddev.width,lcddev.height,0,GBLUE,60,temperate%10+'0',0);//显示小数 gui_show_ptchar(xoff+210-10,OTHER_TOPY,lcddev.width,lcddev.height,0,GBLUE,60,95+' ',0);//显示℃ if(t>0)t=0; } if(calendar.w_date!=tempdate) { calendar_date_refresh(); //天数变化了,更新日历. tempdate=calendar.w_date; //修改tempdate,防止重复进入 } t++; } delay_ms(20); }; while(tp_dev.sta&TP_PRES_DOWN)tp_dev.scan(0);//等待TP松开. gui_memex_free(asc2_s6030); //删除申请的内存 asc2_s6030=0; //清零 gui_memin_free(f_calendar); //删除申请的内存 POINT_COLOR=BLUE; BACK_COLOR=WHITE ; return rval; }