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

📄 main.c

📁 基于MCS-51的电子指南针完整程序包 如果需要原理图的
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************************************************************
***模块名称: 测试主程序                                                                                                    ***
***模块功能:                                                                                                               ***																				                       
***作    者: METAL MAX,CUIT(liyangbbs@126.com)                                                                             ***
***调用方式:                                                                                                               ***
***日    志: 日期             版本                     修改人                               记录                           ***
***           06/10/2008       V1.01                    METALMAX                       总体组合测试通过                     ***
***备    注:                                                                                                               ***
*****************************************************************************************************************************/
#include <reg52.h>
#include <stdio.h>
#include <math.h>                                                       /* T6963驱动库                                      */
#include "DriverT6963.h"
#include "DataBase.h"
#include "PCF8583.h"
#include "UART.h"

unsigned char GblCnt = 0;
unsigned char T0IRQCNT = 0;
unsigned char oldtempx, oldtempy;
unsigned int Angle;
unsigned char keyflag = 0;
extern unsigned char COMBUF[10];
/******************************************************************************************************************************
**函数名称:delay()                                                                                                          **
**函数功能:软件延迟                                                                                                         **   
**入口参数:延迟时间倍数                                                                                                     **
**出口参数:无                                                                                                               **
**具体资源:无                                                                                                               **
**调用程序:无                                                                                                               **
**备    注:延时不精确                                                                                                       **
******************************************************************************************************************************/
void delay(unsigned int time)
{
   unsigned int i,j;
   for (i=0; i<time; i++) {
     for (j=0; j<1700; j++){;}
   }
}


/******************************************************************************************************************************
**函数名称:DisCurTime()                                                                                                     **
**函数功能:在指定位置显示实时芯片内的时间                                                                                   **   
**入口参数:显示位置x, y坐标                                                                                                 **
**出口参数:无                                                                                                               **
**具体资源:无                                                                                                               **
**调用程序:ReadPCF8583(), DisStr()                                                                                          **
**备    注:                                                                                                                 **
******************************************************************************************************************************/
void DisCurTime(unsigned char x, unsigned char y)
{
    unsigned char time[3];
	unsigned char dispBuff[9];
	ReadPCF8583(0x02, 3, time);
	dispBuff[8] = '\0';                                                 /* 在数组最后单元放入标识符以便判断内容结束         */
    dispBuff[7] = (time[0] & 0x0f) + '0';                               /* 提取秒个位                                       */
	dispBuff[6] = (time[0] >> 4)   + '0';                               /* 提取秒十位                                       */
	dispBuff[5] = ':';
	dispBuff[4] = (time[1] & 0x0f) + '0';	                            /* 提取分个位                                       */
	dispBuff[3] = (time[1] >> 4)   + '0';                               /* 提取分十位                                       */
	dispBuff[2] = ':';
	dispBuff[1] = (time[2] & 0x0f) + '0';	                            /* 提取时个位                                       */
	dispBuff[0] = ((time[2] >> 4) & 0x03) + '0';                        /* 提取时十位                                       */
	DispStr(y*20+x, dispBuff);
}

/******************************************************************************************************************************
**函数名称:显示日期                                                                                                         **
**函数功能:在指定位置显示实时芯片内的日期                                                                                   **   
**入口参数:显示位置x, y坐标                                                                                                 **
**出口参数:无                                                                                                               **
**具体资源:无                                                                                                               **
**调用程序:ReadPCF8583(), DisStr()                                                                                          **
**备    注:                                                                                                                 **
******************************************************************************************************************************/
void DisCurDate(unsigned char x, unsigned char y)
{
    unsigned char Date[2];
	unsigned char DisBuf[11];
	ReadPCF8583(0x05, 2, Date);                                         /* 获取PCF8583的日期                                */         
	DisBuf[4] = (Date[0] & 0x0f) + '0';	                                /* 提取日个位                                       */
	DisBuf[3] = ((Date[0] >> 4) & 0x03) + '0';                          /* 提取日十位                                       */
	DisBuf[2] = '/';
	DisBuf[1] = (Date[1] & 0x0f) + '0';	                                /* 提取月个位                                       */
	DisBuf[0] = ((Date[1] >> 4) & 0x01) + '0';                          /* 提取月十位                                       */
	DisBuf[5] = '/';
    DisBuf[6] = '2';
    DisBuf[7] = '0';
    DisBuf[8] = '0';
    DisBuf[9] = '8';
    DisBuf[10]= '\0';                                                   /* 在数组最后单元放入标识符以便判断内容结束         */
    DispStr(y*20+x, DisBuf);
}

/******************************************************************************************************************************
**函数名称:DisClock()                                                                                                       **
**函数功能:绘制钟面                                                                                                         **   
**入口参数:显示位置                                                                                                         **
**出口参数:无                                                                                                               **
**具体资源:无                                                                                                               **
**调用程序:Circle(), Line(), WriteEN(), EasyCH()                                                                            **
**备    注:                                                                                                                 **
******************************************************************************************************************************/
void DrawClock(unsigned char x, unsigned char y, unsigned char r)
{
    Circle(x, y, r);
    Line(x, y-r, x, y-r+5, 0);                                          /* 绘制0点处竖线                                    */
    Line(x, y+r, x, y+r-5, 0);                                          /* 绘制6点处竖线                                    */
    Line(x-r, y, x-r+5, y, 0);                                          /* 绘制9点处竖线                                    */
    Line(x+r, y, x+r-5, y, 0);                                          /* 绘制3点处竖线                                    */
    WriteEN(198,'E');
    WriteEN(273,'S');
    WriteEN(189,'W');
    WriteEN(93,'N');
    EasyCH(3, 1, fang);
    EasyCH(3, 2, wei);
}


/******************************************************************************************************************************
**函数名称:GraphicTest()                                                                                                    **
**函数功能:显示子函数测试程序                                                                                               **   
**入口参数:无                                                                                                               **
**出口参数:无                                                                                                               **
**具体资源:无                                                                                                               **
**调用程序:显示子函数                                                                                                       **
**备    注:                                                                                                                 **
******************************************************************************************************************************/
void GraphicTest(void)
{
  	Circle(80, 63, 60);
	Rectangle(0, 0, 159, 127, 0);
	Triangle(0, 0, 20, 30, 120, 50);
	Line(0, 0, 159, 127, 0);
	Line(0, 127, 159, 0, 1);
}

/******************************************************************************************************************************
**函数名称:DisMain()                                                                                                        **
**函数功能:主显示界面                                                                                                       **   
**入口参数:显示位置                                                                                                         **
**出口参数:无                                                                                                               **
**具体资源:无                                                                                                               **
**调用程序:无                                                                                                               **
**备    注:仅用作测试使用                                                                                                   **
******************************************************************************************************************************/
void DisMain(void)
{
    Rectangle(0, 22, 159, 127, 0);
    DrawClock(113, 70, 45);    
    Line(0, 115, 159, 115, 0);
    Line(64, 22, 64, 115, 0);
}


/******************************************************************************************************************************
**函数名称:DisCurDirc()                                                                                                     **
**函数功能:显示当前方位指针                                                                                                 **   
**入口参数:显示角度                                                                                                         **
**出口参数:无                                                                                                               **
**具体资源:无                                                                                                               **
**调用程序:WriteEN(), Line()                                                                                                **

⌨️ 快捷键说明

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