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

📄 lcdshow.c

📁 单片机接LCD的程序
💻 C
📖 第 1 页 / 共 3 页
字号:
//********************** 使用 Lcd 硬件 工作 通信 ****************
#include "msp430x14x.h"
#include "main.h"
//********************** extern 区****************extern 区****************
//********************** extern 区****************extern 区****************
//form main.c
//用作为 16 个位!BOOLEAN 变量来使用
extern unsigned int g_intMark;
extern unsigned int g_intMarkA;
extern unsigned char g_chSecond, g_chMinute, g_chHour, g_chDay, g_chMonth, g_chYear;
extern unsigned int intTBCount_50ms;
//from lcd.c
extern unsigned char g_chLcdDriveBuf[33];
extern unsigned char g_chLcdDriveHead;
extern unsigned char g_chLcdDriveTail;
extern unsigned char g_chLcdDrive_Stat;
//from debug.c
extern unsigned int g_int135Ver;
////////////////////////////////////////////////
//from innerComm.c
extern unsigned char g_chFS_Status;
extern unsigned char g_chFS_SelfCheck_Status;
extern unsigned char g_chGP_SelfCheck_Status;
extern unsigned char g_chGP_Status;
extern unsigned char g_chCable_Status;

extern unsigned int g_intGP_Current[8];
extern unsigned int g_intGP_FixedCurrent[8];
//from env.c
extern unsigned char g_chEnv_Free;
extern unsigned char g_chEnv_Status;//-按位表明1-2通道的环境的告警/恢复状态
                        //3--5位为三路环境模拟量(温度1,48V,有害气体):
                        //6位为门禁,
                        //7位为温度2 剩下一个可以以后扩展
//温度                      
extern unsigned char g_chTemperature;
extern unsigned char g_chTemperatureBoard;
//门
extern unsigned char g_chDoorStat;//0-门关 1-密码开门 2-非法开门 3-中心开门 4-禁用门禁 5-启用 6-门开
extern unsigned char g_chOpenDoorID[3];//记录开门人,保留的是索引号

//2 个 A/D 处理
extern unsigned char g_chDC;
extern unsigned char g_chBadGas;
//********************** extern 区****************extern 区****************
//********************** extern 区****************extern 区****************
//********************** const 区****************const 区****************
//********************** const 区****************const 区****************   
const unsigned char chInitiativeReport_0[] = "正在等待135 启动";
const unsigned char chInitiativeReport_1[] = "局有无DTMF模块";
const unsigned char chInitiativeReport_2[] = "主动报告方式:";
const unsigned char chInitiativeReport_2_1[] = "无DTMF模块";
const unsigned char chInitiativeReport_2_2[] = "无中心号码";
//
const unsigned char chInitiativeReport_10[] = "无活动告警";
//
const unsigned char chActiveAlert_20[] = "活动告警  共05条";
const unsigned char chActiveAlert_23[] = "配线架第";//xx01列
const unsigned char chActiveAlert_21_1[] = "列";
const unsigned char chActiveAlert_120[] = "未设置门禁系统";
const unsigned char chActiveAlert_120_1[] = "用户开门非法开门中心开门";
const unsigned char chActiveAlert_120_2[] = "门开门关禁用";
const unsigned char chActiveAlert_121[] = "温度01度";
const unsigned char chActiveAlert_122[] = "直流电压伏";
const unsigned char chActiveAlert_123[] = "有害气体";
const unsigned char chActiveAlert_124[] = "强电固有值";
const unsigned char chActiveAlert_24[] = "信号线第";//
const unsigned char chActiveAlert_21[] = "工频设备第";//05工频设备第01列
//const unsigned char chActiveAlert_22[] = "信号线第";//04强电01列9999mA 
const unsigned char chActiveAlert_25[] = "主干电缆第";//02主干电缆第01列  
const unsigned char chActiveAlert_8[] = "消音键坏自校验键坏";//02主干电缆第01列  
//********************** const 区****************const 区****************
//********************** const 区****************const 区****************
void MainLcdProcess(void);
    unsigned char g_chMainLcdProcess_Stat;
    unsigned char g_chMainLcdProcess_1s;
unsigned char g_chIndex;
unsigned char g_chBit;
unsigned char AlertSum(void);
void ProcessKeyStoke(void);

void ProcessKeyStoke(void)
{
    
    if(g_intMarkA & KeyStokeGood_MarkA)
    {
        //表明按纽OK
    }
    else
    {
        return;
    }
    if(P6IN & NOspeak)
    {//NOspeak BIT7 //P6.7--J2.4---Speak按键控制端,低有效
        //高,没有动作
    }
    else
    {///有动作
        g_chBit = 8;
    }
    if(P1IN & CHEK)
    {//CHEK BIT2        //CHEK----P1.2,自检按键控制端,常态为高,低有效
        //高,没有动作
    }
    else
    {///有动作
        if(g_chMainLcdProcess_Stat < 120)
        {
            g_chMainLcdProcess_Stat = 120;
        }
    }
}
/**************************************
*功能: 查询活动告警的数量   
*参数: 
*返回: 
*备注: 
**************************************/
unsigned char AlertSum(void)
{
    unsigned char chSum = 0;
    unsigned char chI;
    for(chI = 0; chI < 8; chI++)
    {//对各种。。。按位来处理
        if(g_chFS_Status & (1 << chI))
        {
            chSum++;
        }
        if(g_chFS_SelfCheck_Status & (1 << chI))
        {
            chSum++;
        }
        if(g_chGP_SelfCheck_Status & (1 << chI))
        {
            chSum++;
        }
        if(g_chGP_Status & (1 << chI))
        {
            chSum++;
        }
        if(g_chCable_Status & (1 << chI))
        {
            chSum++;
        }
    }
    //环境只用到 7 个
    for(chI = 0; chI < 7; chI++)
    {//对各种。。。按位来处理
        if(g_chEnv_Free & (1 << chI))
        {
            //no
        }
        else
        {
            if(g_chEnv_Status & (1 << chI))
            {
                chSum++;
            }
        }
    }
    return(chSum);
}   
/**************************************
*功能: LCD 显示应用层,负责写入缓冲中的信息   
*参数:  
*返回: 
*备注: 实时运行
**************************************/
void MainLcdProcess(void)
{
    if((g_chLcdDriveTail == 0) || (g_chLcdDriveTail == 16))//---no
    {//当缓冲区里的信息 为空的时候才可以来处理发送新的信息
        unsigned char chI;
        g_chMainLcdProcess_1s = 0;
        switch(g_chMainLcdProcess_Stat)
        {
            case 0:
                //等待 135 正常
                if(intTBCount_50ms > 10)
                {
                    if(g_int135Ver > 0)
                    {
                        g_chMainLcdProcess_Stat = 1;
                    }
                    else
                    {
                        for(chI = 0; chI < 16; chI++)
                        {
                            g_chLcdDriveBuf[1 + chI] = chInitiativeReport_0[chI];
                        }
                        g_chLcdDriveTail = 32;
                    }
                }
            break;
            //1---10 显示开机信息,不必特别控制显示时间!
            case 1:
            //局及版本信息
                //第一行 局号
                for(chI = 0; chI < 4; chI++)
                {
                    g_chLcdDriveBuf[1 + chI] = *(unsigned char *)(StationID_Info + chI);
                }
                g_chLcdDriveBuf[5] = chInitiativeReport_1[0];
                g_chLcdDriveBuf[6] = chInitiativeReport_1[1];
                if(g_intMark & HaveDTMFModule_Mark)
                {//有
                    g_chLcdDriveBuf[7] = chInitiativeReport_1[2];
                    g_chLcdDriveBuf[8] = chInitiativeReport_1[3];
                }
                else
                {//无
                    g_chLcdDriveBuf[7] = chInitiativeReport_1[4];
                    g_chLcdDriveBuf[8] = chInitiativeReport_1[5];
                }
                for(chI = 0; chI < 8; chI++)
                {
                    g_chLcdDriveBuf[9 + chI] = chInitiativeReport_1[chI + 6];
                }
                //第二行 版本号
                if(g_int135Ver % 10 == 1)
                {//版本相同
                    g_chLcdDriveBuf[22] = 'V';
                    g_chLcdDriveBuf[23] = Ver_ID0;
                    g_chLcdDriveBuf[24] = '.';
                    g_chLcdDriveBuf[25] = Ver_ID1;
                    g_chLcdDriveBuf[26] = Ver_ID2;
                }
                else
                {//版本不相同
                    g_chLcdDriveBuf[19] = 'V';
                    g_chLcdDriveBuf[20] = Ver_ID0;
                    g_chLcdDriveBuf[21] = '.';
                    g_chLcdDriveBuf[22] = Ver_ID1;
                    g_chLcdDriveBuf[23] = Ver_ID2;
                    
                    g_chLcdDriveBuf[27] = 'V';
                    g_chLcdDriveBuf[28] = (g_int135Ver / 1000) % 10 + 48;
                    g_chLcdDriveBuf[29] = '.';
                    g_chLcdDriveBuf[30] = (g_int135Ver / 100) % 10 + 48;;
                    g_chLcdDriveBuf[31] = (g_int135Ver / 10) % 10 + 48;;
                }
                g_chLcdDriveTail = 32;
                g_chMainLcdProcess_Stat = 2;
            break;
            case 2:
            // 主动报告方式
                //第一行 主动报告方式: chInitiativeReport_1
                for(chI = 0; chI < 13; chI++)
                {
                    g_chLcdDriveBuf[3 + chI] = chInitiativeReport_2[chI];
                }
                //第二行 DTMFxx无中心号码  DTMFxx无模块 DTMFxxxxxxxxxx56  RS232xxx4800xxxx
                if(*(unsigned char *)(CommMode_Info) == '1')
                {//DTMF
                    g_chLcdDriveBuf[17] = 'D';
                    g_chLcdDriveBuf[18] = 'T';
                    g_chLcdDriveBuf[19] = 'M';
                    g_chLcdDriveBuf[20] = 'F';
                    if(g_intMark & HaveDTMFModule_Mark)
                    {//有
                        if(g_intMarkA & DTMFCallCenter_MarkA)
                        {//有
                            for(chI = 0; chI < 12; chI++)
                            {
                                g_chLcdDriveBuf[21 + chI] = *(unsigned char *)(DesTeleID_Info + chI + 6);
                            }
                            for(chI = 0; chI < 12; chI++)
                            {
                                if(g_chLcdDriveBuf[21 + chI] == '9')
                                {
                                    g_chLcdDriveBuf[21 + chI] = ' ';
                                }
                                else
                                {
                                    break;  
                                }
                            }
                        }
                        else
                        {//无
                            for(chI = 0; chI < 10; chI++)
                            {
                                g_chLcdDriveBuf[23 + chI] = chInitiativeReport_2_2[chI];
                            }
                        }
                    }
                    else
                    {//无  无DTMF模块
                        for(chI = 0; chI < 10; chI++)
                        {
                            g_chLcdDriveBuf[23 + chI] = chInitiativeReport_2_1[chI];
                        }
                    }
                }
                else
                {//RS232
                    g_chLcdDriveBuf[17] = 'R';
                    g_chLcdDriveBuf[18] = 'S';
                    g_chLcdDriveBuf[19] = '2';
                    g_chLcdDriveBuf[20] = '3';
                    g_chLcdDriveBuf[21] = '2';
                    g_chLcdDriveBuf[31] = '0';
                    g_chLcdDriveBuf[32] = '0';
                    if(*(unsigned char *)(CommMode_Info) == '2')
                    {//9600
                        g_chLcdDriveBuf[29] = '9';
                        g_chLcdDriveBuf[30] = '6';
                    }
                    else if(*(unsigned char *)(CommMode_Info) == '4')
                        {//2400
                            g_chLcdDriveBuf[29] = '2';
                            g_chLcdDriveBuf[30] = '4';
                        }
                        else 
                        {//4800
                            g_chLcdDriveBuf[29] = '4';
                            g_chLcdDriveBuf[30] = '8';
                        }
                } 
                g_chLcdDriveTail = 32;
                g_chMainLcdProcess_Stat = 10;//--------no 
            break;
            case 8://显示按键坏

⌨️ 快捷键说明

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