日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁(yè) > 單片機(jī) > 單片機(jī)
[導(dǎo)讀]********************************************************************************************************** FORMAT CURRENT TIME INTO STRING** Description : Formats the current time into an ASCII string

*********************************************************************************************************
* FORMAT CURRENT TIME INTO STRING
*
* Description : Formats the current time into an ASCII string.
* Arguments : mode is the format type:
* 1 will format the time as "HH:MM:SS" (24 Hour format)
* (needs at least 9 characters)
* 2 will format the time as "HH:MM:SS AM" (With AM/PM indication)
* (needs at least 13 characters)
* s is a pointer to the destination string. The destination string must be large
* enough to hold the formatted time.
* contain
* Returns : None.
* Notes : - A 'switch' statement has been used to allow you to add your own time formats.
* - This function assumes that strcpy() is reentrant.
*********************************************************************************************************
*/
void Clk_format_time (UCHAR mode, char *s)
{
UCHAR hr;
switch (mode)
{
case 1:
strcpy(s, "HH:MM:SS"); /* Create the template for the selected format */
s[0] = ClkHr / 10 + '0'; /* Convert TIME to ASCII */
s[1] = ClkHr % 10 + '0';
s[3] = ClkMin / 10 + '0';
s[4] = ClkMin % 10 + '0';
s[6] = ClkSec / 10 + '0';
s[7] = ClkSec % 10 + '0';
break;

case 2:
strcpy(s, "HH:MM:SS AM"); /* Create the template for the selected format */
s[9] = (ClkHr >= 12) ? 'P' : 'A'; /* Set AM or PM indicator */
if (ClkHr > 12)
{ /* Adjust time to be displayed */
hr = ClkHr - 12;
}
else
{
hr = ClkHr;
}
s[0] = hr / 10 + '0'; /* Convert TIME to ASCII */
s[1] = hr % 10 + '0';
s[3] = ClkMin / 10 + '0';
s[4] = ClkMin % 10 + '0';
s[6] = ClkSec / 10 + '0';
s[7] = ClkSec % 10 + '0';
break;

default:
strcpy(s, "?");
break;
}
}
/*
*********************************************************************************************************
* UPDATE THE TIME
*
* Description : This function is called to update the time (i.e. hours, minutes and seconds)
* Arguments : None.
* Returns : TRUE if we have completed one day.
* FALSE otherwise
* Notes : This function updates ClkSec, ClkMin and ClkHr.
*********************************************************************************************************
*/
static BOOL ClkUpdateTime (void)
{
BOOL newday;

newday = FALSE; /* Assume that we haven't completed one whole day yet */
if (ClkSec >= 59)
{ /* See if we have completed one minute yet */
ClkSec = 0; /* Yes, clear seconds */
if (ClkMin >= 59)
{ /* See if we have completed one hour yet */
ClkMin = 0; /* Yes, clear minutes */
if (ClkHr >= 23)
{ /* See if we have completed one day yet */
ClkHr = 0; /* Yes, clear hours ... */
newday = TRUE; /* ... change flag to indicate we have a new day */
}
else
{
ClkHr++; /* No, increment hours */
}
}
else
{
ClkMin++; /* No, increment minutes */
}
}
else
{
ClkSec++; /* No, increment seconds */
}
return (newday);
}
/*
*********************************************************************************************************
* SET TIME ONLY
*
* Description : Set the time-of-day clock
* Arguments : hr is the desired hour (0..23)
* min is the desired minutes (0..59)
* sec is the desired seconds (0..59)
* Returns : None.
* Notes : It is assumed that you are specifying a correct time (i.e. there is no range checking
* done by this function).
*********************************************************************************************************
*/
void Clk_set_time (UCHAR hr, UCHAR min, UCHAR sec)
{
ENTER_CRITICAL(); /* Gain exclusive access to time-of-day clock */
ClkHr = hr;
ClkMin = min;
ClkSec = sec;
EXIT_CRITICAL(); /* Release access to time-of-day clock */
}
/*


本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請(qǐng)聯(lián)系該專(zhuān)欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請(qǐng)及時(shí)聯(lián)系本站刪除( 郵箱:macysun@21ic.com )。
換一批
延伸閱讀
關(guān)閉