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

📄 measure.c

📁 这是一个远程温度计 MCU: AT89S52 温度传感器: DS18B20 晶振: 12MHz 使用串口连接,在PC端使用"超级终端"打开 设置如下: 波特率: 4800 数据
💻 C
字号:
/*------------------------------------------------------------------------------
MCOMMAND.C:  Time Set Commands for the Remote Measurement
------------------------------------------------------------------------------*/

#include <stdio.h>		/* standard ANSI I/O .h-file         */
#include <reg52.h>		/* special function register 80515   */
#include "type.h"
#include "measure.h"		/* global project definition file    */

struct mrec current;		/* current measurements           */



/******************************************************************************/
/*                           Display measurements                             */
/******************************************************************************/
void measure_display(struct mrec display)
{
	P1 ^= 0x01;				/* Toggle P1.0 each time we print */	
	printf("\r当前系统时间: %2bd:%02bd:%02bd    当前温度: %s 摄氏度",
	  display.time.hour,	/* display hour                      */
	  display.time.min,	/* display minute                    */
	  display.time.sec,	/* display second                    */
	  display.temper);	    /* display thermometer value         */
}


/******************************************************************************/
/*                           Set Current Time                                 */
/******************************************************************************/
void set_time(uchar *buffer)
{
	struct clock time;	/* temporary time values             */
	uchar args;	/* number of arguments               */

	time.sec = 0;		/* preset seconds...                 */
	args = sscanf(buffer, "%bd:%bd:%bd",	/* scan input line for               */
		      &time.hour,	/* hour, minute and second           */
		      &time.min, &time.sec);
	if (time.hour > 23 || time.min > 59 ||	/* check for valid inputs      */
	    time.sec > 59 || args < 2 || args == EOF) {
		printf(ERROR, "INVALID TIME FORMAT");
	} else {		/* if inputs valid then              */
		DISABLE();	/* disable interrupts while          */
		current.time = time;	/* setting the new time              */
		ENABLE();	/* enable interrupts again           */
	}
}


⌨️ 快捷键说明

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