视频监控测试工程宝原理图及PCB资料,有兴趣的可以拿去研究下
单片机源程序如下:
- //******************************************************************************************************
- //
- // (c) Copyright 2009-2010, ZCQ
- // All Rights Reserved
- // V2.00.0
- //
- //-----------------------------------------文件信息-----------------------------------------------------
- //
- //文 件 名: F:\shoup\程序\New\AgeTwoV1.21\main.c(KEIL C V2.38a)
- //创 建 人: ZCQ
- //最后修改日期: 2010年02月05日
- //描 述:
- //
- //-----------------------------------------历史版本信息-------------------------------------------------
- //
- // 创建人: ZCQ
- // 版 本: V1.20.0
- // 日 期: 2009年11月14日
- // 描 述:
- //
- //-----------------------------------------当前版本修订-------------------------------------------------
- //
- // 修改人: ZCQ V1.21.0
- // 日 期: 2010年01月07日
- // 描 述: 对应硬件 工程宝2代原理图.sch
- // cpu STC12C5A60S-37I-LQFP48 osc = 18.432MHZ
- //------------------------------------------------------------------------------------------------------
- //******************************************************************************************************/
- #include "headers\STC12C5A60S2.h"
- #include "headers\define.h"
- #include <stdio.h>
- #include <intrins.h>
- #include <math.h>
- #include <string.h>
- #include <MC51.h>
- //#include "headers\Eeprom.h"
- #include "headers\Serial.h"
- #include "headers\AD.h"
- #include "headers\74HC164.h"
- #include "headers\Key.h"
- #include "headers\Head.h"
- //chen++
- extern unsigned char Wipper_state;
- extern unsigned char Light_state;
- extern unsigned char Power_state;
- extern unsigned char Cruise_state;
- extern unsigned char ScanStop_Interface;
- extern void PtzFunction5(unsigned char uNumData, unsigned char uPresetAddrNum);//预置位设置
- extern void PtzFunction6(unsigned char uNumData); //预置位调用
- extern void PtzFunction7(unsigned char uNumData); //预置位清除
- /*******************************主程序*****************************/
- /*函数原型:main(void)
- /*函数功能:主程序
- /*输入参数:无
- /*输出参数:无
- /*调用模块:无
- /*建立时间:2009/10/14
- /*作者:zcq
- /******************************************************************/
- void main(void)
- {
- unsigned char uTemp = 0x00;
- bit bFlag = FALSE;
- PowerOn(); //开机函数
- STATUS_LED = 1;
- EA =1; //初始化完成后打开总中断
- WDT_CONTR = 0x3D; //1.3653S = 12*64(Pre-scale)*32768/18.43200000(OSC) /*0011 1100 EN_WDT = 1; CLR_WDT; IDLE_WDT = 1; PS2=1 PS1 = 0 PS0 =1*/
- while(1)
- {
- _nop_();
- _nop_();
- if(bPowerOnFlag)
- {
- PowerOff();//关机函数
- }
- if(!bPowerOnOffFlag)
- {
- WDT_CONTR = 0x3E;
- //LED闪烁
- if(gWorkLedTimes >= 200) //5ms中断一次 200*5 = 1000ms 用示波器测试查看是否是1秒
- {
- gWorkLedTimes = 0;
- STATUS_LED = ~STATUS_LED; //1秒闪烁一下
- if(!bKeyNoPressFlag) // = FALSE 表示有按键按下
- {
- uMinutesNum = 0;
- uMinutesTime = 0;
- }
- ////////////////////////////////////////////以下是计时关机判断/////////////////////////////////////////////
- if( uStandbyTime != 0 && bKeyNoPressFlag && !bAutoScanStartFlag) //关机时间为0 并且没有按键按下
- {
- TimePowerOff(); //计时关机
- }
- }
- ///按键检测
- if(uKeyDelay >= 3) //大概3*5ms*15检测一次按键 大概0.5秒
- {
- uTemp = KeyScan();
- uKeyDelay = 0;
- if(uTemp == 0xAA || uTemp == 0x55 ) //按键按下或者弹起
- {
- // SendBufferOne(uKey_Data);
- // SendBufferOne(uTemp);
- KeyDealwith(uKey_Data,uTemp);
- WDT_CONTR = 0x3D; //chen++
- Delay100ms(5); //chen++
- WDT_CONTR = 0x3D; //chen++
- SOUND = 0; //chen++
- bKeyFlag = FALSE;
- uKey_Data = 0;
- }
- }
- //网线运行测试
- if(gNetSendRunTimes >= 200/uNetSpeed)
- {
- gNetSendRunTimes = 0;
- if(bNetSendRunFlag)
- {
- uTemp = 128/(pow(2,uNetSendRunLoop-1));
- SendOneData(uTemp); //74HC164
- uNetSendRunLoop = uNetSendRunLoop - 1;
- if(uNetSendRunLoop == 0)
- {
- uNetSendRunLoop = 8;
- }
- NetLineSendMode(TRUE, uNetMcuLedLoop);
- uNetMcuLedLoop = uNetMcuLedLoop + 1;
- if(uNetMcuLedLoop == 9)
- {
- uNetMcuLedLoop = 1;
- }
- }
- }
- //电池检测
- //bPresetSet_Flag
- if(!bPresetSet_Flag)
- {
- if(!bPresetVideo_Flag)
- {
- if(gBatFlagTimes >= 150) //5ms中断一次 200*5 = 1000ms
- {
- if(BAT_FLAG) //假设P3.2为高电平 表示有充电信号
- {
- DelayX1ms(2); //延时去抖
- if(BAT_FLAG)
- {
- bBatChargeFlag = TRUE;
- if(uInterfaceNum != 1 && uInterfaceNum != 10 && uInterfaceNum != 11 && !bLogoFlag && !bVideoGenerationFlag) //假设P3.2为高电平 表示有充电信号
- {
- //SendBufferOne(0x32);
- //显示电池格数
- if(uBatGridNumTemp == 5)
- {
- uBatGridNumTemp = 0;
- }
- else
- {
- uBatGridNumTemp = uBatGridNumTemp+1;
- }
- TopRight(bAlarmSoundFlag, bKeyLockFlag, bPowerInOutFlag, uBatGridNumTemp); //充电显示
- }
- }
- }
- else
- {
- bBatChargeFlag = FALSE;
- }
- if(bBatEmptyFlag && !bBatChargeFlag) //电池为空 并且没有在充电 要求闪烁空电池图标
- {
- if(!bFlashFlag)
- {
- bFlashFlag = TRUE;
- if(!bAlarmSoundFlag && !bKeyLockFlag) //当长按模式键时关闭报警声音
- {
- SOUND = 1;
- }
- if(uInterfaceNum != 1 && !bLogoFlag && !bVideoGenerationFlag)
- {
- TopRight(bAlarmSoundFlag, bKeyLockFlag, bPowerInOutFlag, 0); //空
- }
- }
- else
- {
- bFlashFlag = FALSE;
- SOUND = 0;
- if(uInterfaceNum != 1 && !bLogoFlag && !bVideoGenerationFlag)
- {
- TopRight(bAlarmSoundFlag, bKeyLockFlag, bPowerInOutFlag, 6); // 6表示 下画线 空
- }
- }
- }
- gBatFlagTimes = 0;
- }
- //电压检测
- if(uVolAdChangeTimes >= 100 ) //100*5ms执行一次AD采样。
- {
- VolAdChangeOpen(); //得到电压
- DealWithVolAdDispBat(FALSE); //处理电压报警 并显示对于电池格数
- uVolAdChangeTimes = 0;
- }
- }
- }
- //串口数据接收显示LED
- if(uGetComDataTimes >= 10 && bComuRecLedFlashFlag)
- {
- //显示LED
- if(bLedStartFlag)
- {
- ComuRecLedFlash(uDataLedLoop);
- uDataLedLoop = uDataLedLoop + 1;
- if(uDataLedLoop == 9)
- {
- uDataLedLoop = 1;
- }
- }
- bLedStartFlag = FALSE;
- uGetComDataTimes = 0;
- }
- //球机地址自动停止命令
- if(bAutoScanFlag && bAutoScanStartFlag && !bAutoScanEndFlag) //当TRUE时发送命令
- {
- // uComSereialItem = 1; //测试
- if(!bAutoFirstFlag)
- {
- uAutoSendTempAddr = uAutoStartAddr;
- uAutoScanSendData1Time = 0;
- uAutoScanSendData1Time = 0;
- bAutoFirstFlag = TRUE;
- }
- //分4次发送命令 上 停止下 停止 时间/2 500ms为一单位发送 uAutoSpaceTime
- if(uAutoSendTempAddr<= uAutoEndAddr && !bAutoFullExitFlag)
- {
- if(uAutoRunTimes == 1)
- {
- DE = 1;
- AutoPtzUp(uAutoControlRuleItem);
- DE = 0;
- uAutoRunTimes = 2;
- uAutoScanSend1Times = 0;
- uAutoScanSendData1Time = 0;
- }
- if(uAutoRunTimes == 2)
- {
- if(uAutoScanSendData1Time>=100) //500ms
- {
- uAutoScanSendData1Time = 0;
- uAutoScanSend1Times = uAutoScanSend1Times+1;
- }
- if(uAutoScanSend1Times >= uAutoSpaceTime)
- {
- DE = 1;
- AutoStopPtzRunFun();
- Delay100ms(1);
- DE = 0;
- uAutoRunTimes = 3;
- uAutoScanSend2Times = 0;
- }
- }
- if(uAutoRunTimes == 3)
- {
- DE = 1;
- AutoPtzDown(uAutoControlRuleItem);
- DE = 0;
- uAutoRunTimes = 4;
- uAutoScanSend2Times = 0;
- uAutoScanSendData2Time = 0;
- }
- if(uAutoRunTimes == 4)
- {
- if(uAutoScanSendData2Time>=100) //500ms
- {
- uAutoScanSendData2Time = 0;
- uAutoScanSend2Times = uAutoScanSend2Times+1;
- }
- if(uAutoScanSend2Times >= uAutoSpaceTime)
- {
- DE = 1;
- AutoStopPtzRunFun();
- Delay100ms(1);
- DE = 0;
- uAutoRunTimes = 1;
- uAutoScanSend1Times = 0;
- if(uAutoSendTempAddr < 255)
- {
- uAutoSendTempAddr = uAutoSendTempAddr +1;
- }
- else
- {
- uAutoSendTempAddr = 255;
- bAutoFullExitFlag = TRUE;
- }
- }
- }
- }
- else
- {
- bAutoFirstFlag = FALSE;
- bAutoScanStartFlag = FALSE;
- bAutoScanEndFlag = FALSE;
- uAutoScanSend1Times = 0;
- uAutoScanSend2Times = 0;
- uAutoScanSendData1Time = 0;
- uAutoScanSendData2Time = 0;
-
- if(bAutoFullExitFlag)
- {
- uAutoSendTempAddr = 255;
- }
- else
- {
- uAutoSendTempAddr = uAutoSendTempAddr-1; //地址退出时要求减一
- }
-
- DE = 1;
- AutoStopPtzRunFun();
- DE = 0;
- bAutoFullExitFlag = FALSE;
-
- CD4053_A = 0; //chen++
- CD4053_B = 0; //视频信号输入
- CD4053_C = 0;
-
- //显示相关信息 比方 地址 波特率等
- TopLeftNew(2,8); //球机地址自动烧描
- BottomLeft(0,0x073); //空
- BottomRight(2,0x076); //返回
- AutoScanStopDisplay(1, uAutoSendTempAddr,uAutoBaudRateItem,uAutoControlRuleItem);//自动扫描 结束
- bAutoScanStopFlag = TRUE;
-
- uInterfaceNum = 7;
- bManualStopFlag = TRUE; //手动停止自动扫描
- }
- }
- //球机地址自动扫描的手动停止命令
- if(bAutoScanFlag && bAutoScanEndFlag && !bAutoScanStartFlag)//停止命令
- {
- bAutoFirstFlag = FALSE;
- bAutoScanStartFlag = FALSE;
- bAutoScanEndFlag = FALSE;
- uAutoScanSend1Times = 0;
- uAutoScanSend2Times = 0;
- uAutoScanSendData1Time = 0;
- uAutoScanSendData2Time = 0;
- bAutoFullExitFlag = FALSE;
- DE = 1;
- AutoStopPtzRunFun();
- DE = 0;
- //显示相关信息 比方 地址 波特率等
- TopLeftNew(2,8); //球机地址自动烧描
- BottomLeft(0,0x073); //空
- BottomRight(2,0x076); //返回
- if(!bManualStopFlag)
- {
- AutoScanStopDisplay(0, uAutoSendTempAddr,uAutoBaudRateItem,uAutoControlRuleItem);
- bManualStopFlag = FALSE; //手动停止自动扫描
- }
- else
- {
- AutoScanStopDisplay(1, uAutoSendTempAddr,uAutoBaudRateItem,uAutoControlRuleItem);
- bManualStopFlag = TRUE; //手动停止自动扫描
- }
- bAutoScanStopFlag = TRUE;
- uInterfaceNum = 7;
- }
- }//end if (!bPowerOnOffFlag)
- _nop_();
- _nop_();
- WDT_CONTR = 0x3D;
- _nop_();
- _nop_();
- WDT_CONTR = 0x3D;}
- ////////////////////////////////////////////////////////////////////////////////////////////////////
- }
- /****************************初始化函数****************************/
- /*函数原型:MainInit(void)
- /*函数功能:对CPU各IO口及变量做初始化
- /*输入参数:无
- /*输出参数:无
- /*调用模块:无
- /*建立时间:2009/06/20
- /*作者:zcq
- /*****************************************************************/
- void MainInit(void)
- {
- //CPU IO口配置
- P4SW = 0x70; //设置P4.4为IO口 P4.5为IO口 P4.6为IO口
-
- P0M0 = 0x00; //原来是F0
- P0M1 = 0x00; //P0为准双向口,用于4X4键盘检测
-
- // P1口设置在AD.C中 设置
-
- P2M0 = 0x0A; // P2.0 = BAT_FLAG 设置为高阻输入 (充电检测)
- P2M1 = 0x01; // P2.1 = LCD_ON (LCD电源开关)
- // P2.3 = OPEN 推挽输出 (MCU电源维持开关)
-
- P3M0 = 0xB8; // P3.3 = LCD_KEY2 开始为推挽输出(未用)
- // P3.4 = DE 开始为推挽输出(RS485)
- P3M1 = 0x40; // P3.5 = STATUS 开始为推挽输出(运行状态指示)
- // P3.6 = KEY_FLAG 设置为高阻输入(PowerOn按键检测)
- // P3.7 = IN_OUT 开始为推挽输出(继电器控制)
-
- P4M0 = 0x84; // P4.2 = CS 推挽输出(片选MB90092)
- P4M1 = 0x00; // P4.7 = LCD_KYE1 推挽输出(RST)量产要改成P4.3 P4M0 = 0xC0;
-
- P5M0 = 0x02; // P5.2 = DAT_164; P5.1 = SOUND 推挽输出
- P5M1 = 0x00; // P5.3 = CLK_164;
-
- IN_OUT = 0; //关闭继电器
- LCD_ON = 0; //先关闭LCD电源
- OPEN = 0; //先关闭电源
- SOUND = 0; //关闭BUZZ
- CLK = 1; //MB90092 CLK先置高
- /*
- //DelayX1ms(10);
- CLK = 1; //MB90092 CLK先置高
- MainScreen_Init (B_COLOR_WHITE); //MB90092初始化
- MB90092_ClearScreen (); //
- //DelayX1ms(10);
- MainLogo(); //测试LCD显示
- */
- //CD4053_A = 0; //该程序已经跳过线 登量产时改过来
-
- CD4053_A = 0; //chen++
- CD4053_C = 0;
- CD4053_B = 0;
- /*
- Init74HC164();
-
- AUXR = 0x00;
- InitTimer();
- InitAdRegister();
- uBaudRateItem = 3;
- SerialPortOneInitial(uBaudRateItem); //开始为2400 uBaudRateItem= 3
- SerialPortTwoInitial(uBaudRateItem); //开始为2400
- InitKeyData(); //初始化按键数据
- */
- //中断优先级设置 暂时省略
- ET1 =0; //关闭Timer1中断
-
- //EADC = 1;
- //EADC_SPI = 1;
- //IT1 = 0; //外部中断1为边沿触发 = 1 = 0电平触发 TCON 复位 =0x00
- //EX1 = 0; //关外部中断1
- //IT0 = 1; //外部中断0 下降沿触发 = 1 = 0电平触发
- //EX0 = 0; //开外部中断0
- RS1=0;
- RS0=0;
-
- //设置优先级
- //串口2中断最高
- IP2 = 0x01; //PS2H = 1;
- IPH2 = 0x01; //PS2 = 1;
-
- IE2 = 0x00; //关闭串口2中断
- ES = 0; //关闭串口1中断
-
- return;
- }
- /***************************************用户运行环境设置函数******************************************/
- /*函数原型:void UserSetup(void)
- /*函数功能:用户数据相关变量初始化
- /*输入参数:无
- /*输出参数:无
- /*调用模块:无
- /*建立时间:2009/06/20
- /*作者:zcq
- //*****************************************************************************************************/
- void UserSetup(void)
- {
- uPowerKeyTime = 0; //电源按键长按时间
-
- uInterfaceNum = 0;
-
- gPowerOnOffTimes = 0;
- gKeyNoPressTimes = 0;
- bPowerOnOffFlag = TRUE;
- bPowerOnFlag = FALSE; //开机标志 = TRUE 表示开机
- bPowerOffFlag= FALSE;
-
- uRcTimes = 0;
- gWorkLedTimes = 0; //初始化
- gBatFlagTimes = 0;
- bBatChargeFlag= FALSE;
-
- // uBatFullRunTimes = 0; //满电池状态下的充电图标循环次数
- // bBatFullFlag = FALSE; //电池满标志
- bBatEmptyFlag= FALSE;
- bFlashFlag = FALSE;
-
- uVolAdChangeTimes = 0;
- uKeyDelay = 0;
- bKeyFlag = FALSE;
- uLoop164 = 0;
- DE = 0;
- STATUS_LED = 0; //关闭状态灯
- IN_OUT = 0; //关闭继电器
-
- //菜单相关
- bLogoFlag = TRUE;
- bPowerOffMMIFlag = FALSE;
- bMainMenuFlag = FALSE;
- bSysSetupFlag = FALSE;
- bPreset_Page = 0;
- bPresetVideo_Flag = 0;
- bPresetSet_Flag = 0;
- uPtzOtherFunNum_Preset = 0;
-
- //2 PTZ云台合视频输入控制
- bModeKeyVideoFlag = FALSE;
-
- bPtzVideoFlag = FALSE; //主控制口
-
- bVideoSignInFlag = FALSE;
- bVideoSignInGenFlag = FALSE; //已经有视频信号 标志
-
- bOtherFunFlag = FALSE;
-
- bAutoScanFlag = FALSE;
- bAutoScanStartFlag= FALSE;
- bAutoScanEndFlag = FALSE;
- bAutoFirstFlag = FALSE;
- bAutoFullExitFlag = FALSE;
- bAutoScanStopFlag = FALSE;
- bManualStopFlag = FALSE; //手动停止自动扫描
-
- bNetSendBarFlag = FALSE;
- bNetSendRunFlag = FALSE;
- bVideoGenerationFlag = FALSE;
-
- bComuDataBarFlag = FALSE; //通信数据测试功能界面标志
- bComuStartRecFlag = FALSE;
- bComuStopRecFlag = FALSE;
- bComuDispDataFlag = FALSE;
-
- uDataLedLoop = 0;
- bComuRecLedFlashFlag = FALSE;
- bLedStartFlag = FALSE;
-
- bComuRunFlag = FALSE; //通信数据开始分析标志
- bPowerManageBarFlag = FALSE;
-
- bAboutHelpBarFlag = FALSE;
-
- uPowerManageBarTimes = 1;//默认为电源输入方式
-
- uMainMenuTimes = 1; //表示进入主菜单后是第几条bar
- uSysSetupTimes = 1; //表示进入系统参数设置后是第几条bar
- uControlRuleItem = 1;
- uComSereialItem = 2; //2表示485
- uBaudRateItem = 3; //默认2400bps
- uRunSpeedData = 0x30; //运行速度 0-3F
- uStandbyTime = 2; //待机时间 0到 30分钟 0表示不关机 2*5 = 10分钟
- uNetSpeed = 3; //网线速度 1到5 1表示慢 5表示快
- uLcdBright = 10; //屏幕亮度 1到15
- uVideoGenTimes = 0; //开始为0
-
- uPtzMainBarNum = 1; //云台球机和视频输入控制 界面的第几
- uPresetAddr = 0; //预置位地址
- uPtzOtherFunNum = 1;
-
- uAutoScanSetupTimes = 1; //表示进入AUTOSCAN菜单后是第几条bar
- uAutoBaudRateItem = 3; //自动扫描波特率 默认2400bps
- uAutoControlRuleItem = 1; //自动扫描控制协议是第几个
- uAutoStartAddr = 0; //开始地址
- uAutoEndAddr = 255; //结束地址
- uAutoSpaceTime = 3; //间隔时间
- uAutoScanSendData1Time = 0;
- uAutoScanSend1Times = 0;
- uAutoScanSendData2Time = 0;
- uAutoScanSend2Times = 0;
- uAutoSendTempAddr = 0;
- uAutoRunTimes = 1; //共4部执行 1 UP STOP DOWN STOP
-
-
- uVideoSignInAddr = 0x00; //视频输入时的 云台地址
- uVideoSignInType = 1; //视频格式 = 1 AUTO =2 PAL =3 NTSC
- uVideoSignInBarNum = 1; //选中的是数字 默认为0
- gNetSendRunTimes = 0; //网线发送测试时间基数 计数
- uNetSendRunLoop = 8;
- uNetMcuLedLoop = 1;
-
- bPowerInOutFlag = FALSE; //接口图标
- bKeyLockFlag = FALSE; //键盘锁图标 表示未锁
- bKeyIconFlag = FALSE;
- bAlarmSoundFlag = FALSE;
- bAlarmIconFlag = FALSE;
-
- // bSoundFindLineFlag = FALSE; //声音图标
- uBatGridNum = 0; //电池格式
- uBatGridNumTemp = 0; //电池格式零时存放
-
- uGetSerialDataNum = 0;
- uGetComDataTimes = 0;
- uComuPageNum = 0; //显示当前页数 ES
-
- uMinutesTime = 0;
- uMinutesNum = 0;
- bKeyNoPressFlag = TRUE;
-
- //键盘上锁标志
- bLockDisplayFlag = FALSE; //键盘上锁标志
- bLockTimeFlag = FALSE;
- uLockDisplayTime = 0;
- uLockDisplayTimes = 0;
-
- }
- /***************************************初始化定时器1函数*********************************************/
- /*函数原型:void InitTimer(void)
- /*函数功能:用户数据相关变量初始化
- /*输入参数:无
- /*输出参数:无
- /*调用模块:无
- /*建立时间:2009/10/20
- /*作者:zcq
- //*****************************************************************************************************/
- void InitTimer(void)
- {
- AUXR &= T0_12_DIV_AND; //TIME0's clock : fosc dived by 12.
- // AUXR |= T0_01_DIV_OR; //TIME0's clock : fosc dived by 1. 1T模式
-
- TMOD = 0x21; //time1 is mode 2(auto reload) timer0 is mode 1(16bits)
-
- TL0 = 0x00; //12/FOSC = 机器周期 TC= 5ms = 5000/0.65104166666666666666666666666667 = 7680 2^16 - 7680 =
- TH0 = 0xE2; //57856 = 0xE200;
-
- ET0 = 1; //打开定时器0中断
- TR0 = 1; //启动Timer0开始计数
- return;
- }
- //开机函数
- void PowerOn(void)
- {
- EA = 0; //初始化完成前,先关闭总中断
- IN_OUT = 0; //先关闭继电器
- LCD_ON = 0; //先关闭LCD电源
- OPEN = 0; //先关闭电源
- SOUND = 0; //关闭BUZZ
- STATUS_LED = 0; //关闭状态灯
- MainInit(); //相关寄存器初始化
- UserSetup(); //用户参数初始化
- EA = 0; //初始化完成前,先关闭总中断
- Delay100ms(10); //等等电源稳定
- CLK = 1; //MB90092 CLK先置高
- Delay100ms(10); //等等电源稳定
- WDT_CONTR = 0x3D;
- bPowerOnOffFlag = TRUE;
- EA = 0; //初始化完成前,先关闭总中断
- LCD_ON = 0; //先关闭LCD电源
- OPEN = 0; //先关闭电源
- LCD_ON = 0; //先关闭LCD电源
- WDT_CONTR = 0x3D;
- //检测是否有按键 //by zcq 2010 02 03
- do
- {
- _nop_();
- _nop_();
- Delay100ms(5); //等等电源稳定
- _nop_();
- if(KEY_FLAG)
- {
- Delay100ms(5); //等等电源稳定
- if(KEY_FLAG)
- {
- OPEN = 1;
- LCD_ON = 1; //打开LCD电源
-
- Init74HC164();
- AUXR = 0x00;
- InitTimer();
- InitAdRegister();
- uBaudRateItem = 3;
- SerialPortOneInitial(uBaudRateItem); //开始为2400 uBaudRateItem= 3
- SerialPortTwoInitial(uBaudRateItem); //开始为2400
- InitKeyData(); //初始化按键数据
- //DelayX1ms(10);
- CLK = 1; //MB90092 CLK先置高
- MainScreen_Init (B_COLOR_WHITE); //MB90092初始化
- MB90092_ClearScreen (); //
- //DelayX1ms(10);
- MainLogo(); //显示LOGO
- SOUND = SOUND_ON;
- uInterfaceNum = 1; //公司标志界面为1
- bPowerOffMMIFlag = FALSE;
- bLogoFlag = TRUE;
- bMainMenuFlag = FALSE;
- bSysSetupFlag = FALSE;
- bPtzVideoFlag = FALSE;
- bVideoSignInFlag = FALSE; //视频信号输入模式
- bVideoSignInGenFlag = FALSE; //已经有视频信号 标志
- bAutoScanFlag = FALSE;
- bOtherFunFlag = FALSE;
- bNetSendBarFlag = FALSE;
- bNetSendRunFlag = FALSE;
- bVideoGenerationFlag = FALSE;
- bComuDataBarFlag = FALSE;
- bPowerManageBarFlag = FALSE;
- bAboutHelpBarFlag = FALSE;
-
- bAutoScanStopFlag = FALSE;
-
-
- VolAdChangeOpen(); //得到电压
- DealWithVolAdDispBat(TRUE);
-
- uPowerKeyTime = 0;
- gPowerOnOffTimes = 0;
- gKeyNoPressTimes = 0;
-
- bPowerOnFlag = TRUE;
- bPowerOffFlag = TRUE;
- bPowerOnOffFlag = FALSE;
-
- LCD_ON = 1; //打开LCD电源
- Delay100ms(5);
- WDT_CONTR = 0x3D;
- OPEN = 1;
- LCD_ON = 1;
- Delay100ms(5);
- WDT_CONTR = 0x3D;
- OPEN = 1;
- LCD_ON = 1;
- Delay100ms(5);
- WDT_CONTR = 0x3D;
- OPEN = 1;
- LCD_ON = 1;
- Delay100ms(5);
- WDT_CONTR = 0x3D;
- SOUND = SOUND_OFF;
- //chen++1 自动从公司标识页进入主菜单页。
- Delay100ms(50);
- WDT_CONTR = 0x3D;
- Delay100ms(50);
- WDT_CONTR = 0x3D;
- RightSoftKeyFun();
- //chen++2
- _nop_();
- _nop_();
- }
- }
- _nop_();
- _nop_();
- WDT_CONTR = 0x3D;
- _nop_();
- _nop_();
- }
- while(bPowerOnOffFlag);
- return;
- }
- //关机函数
- void PowerOff(void)
- {
- bit bFlag;
- if(KEY_FLAG)
- {
- gKeyNoPressTimes = 0;
- }
- if(!KEY_FLAG && gKeyNoPressTimes >= 150) //表示弹起按键最少 100*5 = 500ms
- {
- bPowerOffFlag = FALSE;
- bPowerOnOffFlag = FALSE;
- gPowerOnOffTimes = 0;
- uPowerKeyTime = 0;
- gKeyNoPressTimes = 0;
- }
- if(!bPowerOffFlag && !bPowerOffMMIFlag)
- {
- if(gPowerOnOffTimes >= 50 && KEY_FLAG) //1秒 检测 当KEY_FLAG = 1 表示有按键按下
- {
- uPowerKeyTime = uPowerKeyTime+1;
- gPowerOnOffTimes = 0;
- }
- if(uPowerKeyTime >= 5 ) //3秒 长按
- {
- //切换到关机界面
- SOUND = SOUND_ON;
-
- CD4053_A = 0; //chen++
- CD4053_C = 0;
- CD4053_B = 0;
-
- if(uInterfaceNum != 1 && uInterfaceNum != 10 && uInterfaceNum != 11)
- {
- // TopLeft(0,0);
- bFlag = FALSE;
- }
- else
- {
- bFlag = TRUE;
- }
- BottomLeft(2,0x140); //确定
- BottomRight(2,0x076); //返回
- PowerOffMMI(bFlag);
- /* if(uMainMenuTimes == 4 && bVideoGenerationFlag)
- {
- TopRight(bAlarmSoundFlag, bKeyLockFlag, bPowerInOutFlag, uBatGridNumTemp); //1格电池
- }
- */
- bPowerOffMMIFlag = TRUE;
- bLogoFlag = FALSE;
- bMainMenuFlag = FALSE;
- bSysSetupFlag = FALSE;
- bPtzVideoFlag = FALSE;
-
- bModeKeyVideoFlag = FALSE;
-
- bVideoSignInFlag = FALSE; //视频信号输入模式
- bVideoSignInGenFlag = FALSE; //已经有视频信号 标志
-
- if(bAutoScanStopFlag) //有
- {
- bAutoScanFlag = bAutoScanFlag;
- }
- else
- {
- bAutoScanFlag = FALSE;
- }
- bOtherFunFlag = FALSE;
- bNetSendBarFlag = FALSE;
- bNetSendRunFlag = FALSE;
- bVideoGenerationFlag = FALSE;
- bComuDataBarFlag = FALSE;
- bPowerManageBarFlag = FALSE;
- bAboutHelpBarFlag = FALSE;
- bAutoScanStopFlag = FALSE;
- Delay100ms(5);
- WDT_CONTR = 0x3D;
- OPEN = 1;
- LCD_ON = 1;
- Delay100ms(5);
- WDT_CONTR = 0x3D;
- OPEN = 1;
- LCD_ON = 1;
- Delay100ms(5);
- WDT_CONTR = 0x3D;
- OPEN = 1;
- SOUND = SOUND_OFF;
- }
- }
- return;
- }
- //计时关机 函数
- void TimePowerOff(void)
- {
- uMinutesTime = uMinutesTime +1;
- if(uMinutesTime>= 60)
- {
- uMinutesNum = uMinutesNum +1;
- uMinutesTime = 0;
- }
- if(uMinutesNum >= uStandbyTime*5)
- {
- EA = 0;
- SOUND = SOUND_ON;
- uMinutesNum = 0;
- uMinutesNum = 0;
- uPowerKeyTime = 0;
- bPowerOnFlag = TRUE;
- bPowerOffFlag = FALSE;
- bPowerOnOffFlag = TRUE;
- WDT_CONTR = 0x3D;
- WDT_CONTR = 0x3D;
- Delay100ms(20);
- WDT_CONTR = 0x3D;
- Delay100ms(20);
- WDT_CONTR = 0x3D;
- Delay100ms(20);
- WDT_CONTR = 0x3D;
- LCD_ON = 0;
- Delay100ms(5);
- OPEN = 0;
- WDT_CONTR = 0x3D;
- Delay100ms(10);
- WDT_CONTR = 0x3D;
- SOUND = SOUND_OFF;
- OPEN = 0;
- LCD_ON = 0;
- OPEN = 0;
- while(1)
- {
- _nop_();
- _nop_();
- WDT_CONTR = 0x3D;
- _nop_();
- _nop_();
- OPEN = 0;
- LCD_ON = 0;
- OPEN = 0;
- }
- EA = 1;
- }
- }
- //处理电压 并显示电池格数
- void DealWithVolAdDispBat(bit bDispBar)
- {
- unsigned int iTemp = 0;
- unsigned int iResult = 0;
- float fResult = 0.0;
- unsigned char result[7];
-
-
- //计算并报警
- iTemp = 0;
- iTemp = (unsigned int)(AD_channel_result[0]-0x30)*1000;
- iTemp+= (unsigned int)(AD_channel_result[1]-0x30)*100;
- iTemp+= (unsigned int)(AD_channel_result[2]-0x30)*10;
- iTemp+= (unsigned int)(AD_channel_result[3]-0x30)*1;
- iTemp = iTemp;
- fResult = (float)(iTemp);
- iResult = (unsigned int)(fResult*2.681);
-
- /*
- SendBufferOne('*');
- SendBufferOne(AD_channel_result[0]);
- SendBufferOne(AD_channel_result[1]);
- SendBufferOne(AD_channel_result[2]);
- SendBufferOne(AD_channel_result[3]);
- SendBufferOne('*');
- */
- iResult = iResult + 700; //chen++ 修正,计入串联二极管的管压降 2013-01-30
-
- //转化成能识别的电压 0.373 (分压比) 当为 4.525时。12.13 3.333 是关闭 3.400为低电
- if(iResult<9800) //9V多
- {
- uBatGridNum = 0;
- bBatEmptyFlag = TRUE;
- // bBatFullFlag = FALSE;
- }
- if(iResult >= 9800 && iResult < 10800)
- {
- uBatGridNum = 1;
- bBatEmptyFlag = FALSE;
- // bBatFullFlag = FALSE;
-
- }
- if(iResult >= 10800 && iResult < 11200)
- {
- uBatGridNum = 2;
- bBatEmptyFlag = FALSE;
- // bBatFullFlag = FALSE;
- }
- if(iResult >= 11200 && iResult < 11500)
- {
- uBatGridNum = 3;
- bBatEmptyFlag = FALSE;
- // bBatFullFlag = FALSE;
- }
- if(iResult >= 11500 && iResult < 11800)
- {
- uBatGridNum = 4;
- bBatEmptyFlag = FALSE;
- // bBatFullFlag = FALSE;
- }
- if(iResult>= 11800)//>11800 表示电压满格
- {
- uBatGridNum = 5;
- bBatEmptyFlag = FALSE;
- // bBatFullFlag = TRUE;//电池满标志
- }
- if(uInterfaceNum != 1 && uInterfaceNum != 10 && uInterfaceNum != 11 && !BAT_FLAG && !bDispBar && !bLogoFlag && !bVideoGenerationFlag)
- {
- //chen++
- if(!bPreset_Page)
- {
- TopRight(bAlarmSoundFlag, bKeyLockFlag, bPowerInOutFlag, uBatGridNum); //?格电池
- }
- }
- //把采样值转化为有用电压信号
- uVolData = 0;
- result[0] = iResult/10000+0x30;
- result[1] = iResult%10000/1000+0x30;
- result[2] = iResult%1000/100+0x30;
- result[3] = iResult%100/10+0x30;
- result[4] = iResult%10+0x30;
- result[5] = '\m';
- result[6] = '\V';
- result[7] = '\0';
- uVolData = result;
-
- //如果在电源管理界面 刷新电池电压显示值
- if(uMainMenuTimes == 6 && !bMainMenuFlag && bPowerManageBarFlag)
- {
- PowerManageBarFun(uPowerManageBarTimes, uVolData); //网线连接测试功能 选择
- }
- return;
- }
- //按键处理函数
- void KeyDealwith(unsigned char uDealData, unsigned char uKeyType)
- {
- if(uKeyType == 0xAA)
- {
- bKeyNoPressFlag = FALSE;
- uMinutesNum = 0;
- uMinutesTime = 0;
- if(!bKeyLockFlag && uDealData != 0x81)
- {
- SOUND = 1;
- }
-
- switch (uDealData)
- {
- case 0x11://焦距近
- {
- if(bVideoSignInGenFlag || bPresetVideo_Flag)
- {
- DE = 1;
- PtzFocusNear(uControlRuleItem);
- DE = 0;
- }
- break;
- }
- case 0x12://光圈开
- {
- if(bVideoSignInGenFlag || bPresetVideo_Flag)
- {
- DE = 1;
- PtzIrisOpen(uControlRuleItem);
- DE = 0;
- }
- break;
- }
- case 0x14://左软键盘
- {
- LeftSoftKeyFun();
- break;
- }
- case 0x18://向上
- {
- if(bVideoSignInGenFlag || bPresetVideo_Flag)
- {
- DE = 1;
- PtzUp(uControlRuleItem);
- DE = 0;
- }
- else
- {
- DownUpItem(FALSE);
- }
- break;
- }
- case 0x21://焦距远
- {
- if(bVideoSignInGenFlag || bPresetVideo_Flag)
- {
- DE = 1;
- PtzFocusFar(uControlRuleItem);
- DE = 0;
- }
- break;
- }
- case 0x22://光圈关
- {
- if(bVideoSignInGenFlag || bPresetVideo_Flag)
- {
- DE = 1;
- PtzIrisClose(uControlRuleItem);
- DE = 0;
- }
- break;
- }
- case 0x24://主菜单
- {
- MainMenuKeyFun();
- break;
- }
- case 0x28://向左键
- {
- if(bVideoSignInGenFlag || bPresetVideo_Flag)
- {
- DE = 1;
- PtzLeft(uControlRuleItem);
- DE = 0;
- }
- else
- {
- LeftRightItem(FALSE);
- }
- break;
- }
- case 0x41://模式键 主要切换视频显示方式
- {
- if(bPreset_Page != 1)
- {
- ModeKeyFun();
- /*
- if(uInterfaceNum != 1 && !bLogoFlag && !bVideoGenerationFlag)
- {
- SOUND = 1;
- if(!bAlarmIconFlag)
- {
- bAlarmSoundFlag = TRUE;
- bAlarmIconFlag = TRUE;
- }
- else
- {
- bAlarmSoundFlag = FALSE;
- bAlarmIconFlag = FALSE;
- }
- TopRight(bAlarmSoundFlag, bKeyLockFlag, bPowerInOutFlag, uBatGridNum);
- }
- */
- }
- break;
- }
- case 0x42://放大 镜头近
- {
- if(bVideoSignInGenFlag || bPresetVideo_Flag)
- {
- DE = 1;
- PtzZoomWide(uControlRuleItem);
- DE = 0;
- }
- break;
- }
- case 0x44://向下键
- {
- //chen--g
- if(bVideoSignInGenFlag || bPresetVideo_Flag) //在视频输入或 预设值视频 界面下
- {
- DE = 1;
- PtzDown(uControlRuleItem);
- DE = 0;
- }
- else
- {
- DownUpItem(TRUE);
- }
- break;
- }
- case 0x48://确定键
- {
- LeftSoftKeyFun(); //确定键 有多个功能
- break;
- }
- case 0x81://锁定键 用于锁定键盘 或者关闭报警声音
- {
- SOUND = 1;
- if(!bKeyIconFlag)
- {
- bKeyLockFlag = TRUE;
- bKeyIconFlag = TRUE;
- }
- else
- {
- bKeyLockFlag = FALSE;
- bKeyIconFlag = FALSE;
- }
- if(uInterfaceNum != 1 && !bLogoFlag && !bVideoGenerationFlag)
- {
- TopRight(bAlarmSoundFlag, bKeyLockFlag, bPowerInOutFlag, uBatGridNum); //1格电池
- }
- break;
- }
- case 0x82://缩小 镜头远
- {
-
- if(bVideoSignInGenFlag || bPresetVideo_Flag)
- {
- DE = 1;
- PtzZoomTele(uControlRuleItem);
- DE = 0;
- }
- break;
- }
- case 0x84://向右键
- {
-
- if(bVideoSignInGenFlag || bPresetVideo_Flag)
- {
- DE = 1;
- PtzRight(uControlRuleItem);
- DE = 0;
- }
- else
- {
- LeftRightItem(TRUE);
- }
- break;
- }
- case 0x88://右软键盘 返回键
- {
- RightSoftKeyFun();
- break;
- }
- default: //无按键 或者同时按键无效
- break;
- }
- }
- else if(uKeyType == 0x55)
- {
- bKeyNoPressFlag = TRUE; //按键弹起后,球机工作停止
- uMinutesNum = 0;
- uMinutesTime = 0;
- switch (uDealData)
- {
- case 0x18://上
- case 0x44://下
- case 0x28://左
- case 0x84://右
- case 0x12://光圈开
- case 0x22://光圈关
- case 0x42://镜头近
- case 0x82://镜头远
- case 0x11://聚焦近
- case 0x21://聚焦远
- {
- if(bVideoSignInGenFlag || bPresetVideo_Flag)
- {
- DE = 1;
- StopPtzRunFun(); //停止PTZ命令
- DE = 0;
- }
- SOUND = 0;
- break;
- }
- case 0x14://左软键
- case 0x88://右软键
- case 0x48://确定
- case 0x24://主菜单
- case 0x41://模式键
- {
- SOUND = 0;
- break;
- }
- case 0x81://锁定键
- {
- SOUND = 0;
- break;
- }
- default: //无按键 或者同时按键无效
- break;
- }
- }
- else
- {
- _nop_();
- }
- return;
- }
- //模式按键函数
- void ModeKeyFun(void)
- {
- CD4053_A = 0; //chen++
- CD4053_B = 0; //OSD - LCD
- CD4053_C = 0;
- if(bAutoScanStartFlag) //球机地址自动扫描,跳出
- {
- return;
- }
- if(!bModeKeyVideoFlag)
- {
- TopRight(bAlarmSoundFlag, bKeyLockFlag, bPowerInOutFlag, uBatGridNumTemp);
- uInterfaceNum = 5;
- MMI_DisplayFun(7);
- uMainMenuTimes = 2;
- uPtzMainBarNum = 1;
- return;
- }
- if(uMainMenuTimes == 2 && uPtzMainBarNum == 1 && bVideoSignInGenFlag && !bVideoSignInFlag)
- {
- CD4053_B = 0; //OSD - LCD
- AddressSave = uVideoSignInAddr; //保存485 的发送地址
-
- bVideoSignInGenFlag = FALSE; //已经有视频信号
- bVideoSignInFlag = TRUE;
- return;
- }
- if(uMainMenuTimes == 2 && uPtzMainBarNum == 1 && !bVideoSignInGenFlag && bVideoSignInFlag)
- {
- CD4053_B = 1; //视频信号输入
- //保存485 的发送地址
- AddressSave = uVideoSignInAddr;
-
- bVideoSignInGenFlag = TRUE; //已经有视频信号
- bVideoSignInFlag = FALSE;
- return;
- }
- }
- //主菜单
- void MainMenuKeyFun(void)
- {
- if(!bMainMenuFlag && !bAutoScanStartFlag && !bVideoSignInGenFlag)
- {
- MB90092_ClearScreen();
-
- CD4053_A = 0; //chen++
- CD4053_B = 0; //OSD - LCD
- CD4053_C = 0;
-
- TopLeft(3, 0x070); //主菜单
- TopRight(bAlarmSoundFlag, bKeyLockFlag, bPowerInOutFlag, uBatGridNum); //1格电池
- //chen--g BottomLeft(2,0x074); //选择
- BottomLeft(2,0x140); //确定
- //chen--g BottomRight(2,0x076); //返回
- BottomRight(0,0x078); //chen++ ---
- MainMenu(uMainMenuTimes);
- bPowerOffMMIFlag = FALSE;
- bLogoFlag = FALSE;
- bMainMenuFlag = TRUE;
- bSysSetupFlag = FALSE;
- bPtzVideoFlag = FALSE;
- bVideoSignInFlag = FALSE; //视频信号输入模式
- bVideoSignInGenFlag = FALSE; //已经有视频信号 标志
- bAutoScanFlag = FALSE;
- bOtherFunFlag = FALSE;
- bNetSendBarFlag = FALSE;
- bNetSendRunFlag = FALSE;
- bVideoGenerationFlag = FALSE;
-
- bComuDataBarFlag = FALSE; //通信数据测试功能
- bComuStartRecFlag= FALSE;
- bComuStopRecFlag = FALSE;
- bComuDispDataFlag= FALSE;
-
- bPowerManageBarFlag = FALSE;
- bAboutHelpBarFlag = FALSE;
-
- //其他参数设置
- uNetSendRunLoop = 8;
- uNetMcuLedLoop = 1;
-
- uVideoGenTimes = 1;
-
- uInterfaceNum = 2;
- }
- }
- //右软件功能函数
- void RightSoftKeyFun(void)
- {
- //chen++ 预置界面 返回
- if(bPreset_Page == 1)
- {
- if(bPresetVideo_Flag ==1)
- {
- bPreset_Page = 0;
- bPresetVideo_Flag = 0;
- bPresetSet_Flag = 0;
- MB90092_WriteByte(0xA2|0);//command 4,内、外同步选择 SYN_INTERNAL = 0、4
- MB90092_WriteByte(0x2B);
- CD4053_A = 0;
- CD4053_B = 0;
- CD4053_C = 0;
- MB90092_ClearScreen();
-
- uInterfaceNum = 6;
- uPtzOtherFunNum = 13;
- MMI_DisplayFun(9);
- //chen test MB90092_DisChar (7,2,RingForm_adr,2,B_COLOR_CYAN,0,0);
- }
- else
- {
-
- bPreset_Page = 1;
- bPresetVideo_Flag = 1;
- bPresetSet_Flag = 0;
- MB90092_WriteByte(0xA2|4);//command 4,内、外同步选择 SYN_INTERNAL = 0内、4外
- MB90092_WriteByte(0x2B);
- CD4053_A = 0;
- CD4053_B = 0;
- CD4053_C = 1;
- MB90092_ClearScreen();
- uPtzOtherFunNum = 13;
- //chen test MB90092_DisChar (7,3,RoundForm_adr,2,B_COLOR_CYAN,0,0);
-
- }
- return;
- }
- //bit bFlag;
- if(uPtzMainBarNum == 3 && bAutoScanFlag && !bAutoScanEndFlag && bAutoScanStartFlag)
- {
- return;
- }
- //;从其他多个界面返回到主菜单
- if((bPowerOffMMIFlag && uInterfaceNum == 2 && !bPowerManageBarFlag) || bLogoFlag || bSysSetupFlag || bPtzVideoFlag || bVideoGenerationFlag || bComuDataBarFlag || bPowerManageBarFlag ||bAboutHelpBarFlag)
- {
- uInterfaceNum = 2;
- MMI_DisplayFun(2); //主菜单
- return;
- }
- //chen++ 从网线测试功能各界面返回到主菜单
- //chen++ bNetSendBarFlag 标志,=1代表返回到主菜单。 =0,不返回
- if(bNetSendBarFlag)
- {
- uNetSendRunLoop = 8;
- uNetMcuLedLoop = 1;
- SendOneData(0x00); //74HC164
- NetLineSendMode(0, uNetMcuLedLoop); //先静止
-
- MMI_EnableFlag();
-
- bNetSendBarFlag = TRUE;
- uInterfaceNum = 2;
- MMI_DisplayFun(2); //主菜单
- return;
- }
- //Logo
- //chen--g if((bPowerOffMMIFlag && uInterfaceNum == 1)|| bMainMenuFlag)
- //chen++1
- if(bPowerOffMMIFlag && uInterfaceNum == 1)
- //chen++2
- {
- uInterfaceNum = 1;
- MMI_DisplayFun(1); //Logo
- return;
- }
- //2 云台球机和视频输入控制
- if(bVideoSignInFlag || (!bPowerOffMMIFlag && bAutoScanFlag && !bAutoScanStopFlag) || bOtherFunFlag)
- {
- uInterfaceNum = 4;
- //chen--g MMI_DisplayFun(4); //4 视频二级菜单 (三行)
- MMI_DisplayFun(2); //2 主菜单
- return;
- }
- //球机地址自动停止
- if(bPowerOffMMIFlag && uInterfaceNum == 7)
- {
- uInterfaceNum = 7;
- MMI_DisplayFun(10);
- return;
- }
- //球机地址自动扫描
- if((bPowerOffMMIFlag && uInterfaceNum == 8) || (bAutoScanStopFlag && bAutoScanFlag))
- {
- uInterfaceNum = 8;
- MMI_DisplayFun(12);
-
- bManualStopFlag = FALSE; //手动停止自动扫描标志
- return;
- }
-
- if(bPowerOffMMIFlag && uInterfaceNum == 3)
- {
- uInterfaceNum = 3;
- MMI_DisplayFun(3);
- return;
- }
- if(bPowerOffMMIFlag && uInterfaceNum == 4)
- {
- uInterfaceNum = 4;
- MMI_DisplayFun(4);
- return;
- }
- if(bPowerOffMMIFlag && uInterfaceNum == 5)
- {
- uInterfaceNum = 5;
- MMI_DisplayFun(7);
- return;
- }
- if(bPowerOffMMIFlag && uInterfaceNum == 6)
- {
- uInterfaceNum = 6;
- MMI_DisplayFun(9);
- return;
- }
- //chen--??
- if(bPowerOffMMIFlag && uInterfaceNum == 9)
- {
- uInterfaceNum = 9;
- MMI_DisplayFun(14);
- return;
- }
- if(bPowerOffMMIFlag && uInterfaceNum == 10) //视频信号发生器
- {
- //TopRight(bAlarmSoundFlag, bKeyLockFlag, bPowerInOutFlag, uBatGridNumTemp); //1格电池
- uVideoGenTimes = uVideoGenTimes -1;
- uInterfaceNum = 10;
- MMI_DisplayFun(15);
- return;
- }
- if(bPowerOffMMIFlag && uInterfaceNum == 11)
- {
- //TopRight(bAlarmSoundFlag, bKeyLockFlag, bPowerInOutFlag, uBatGridNumTemp); //1格电池
- uInterfaceNum = 11;
- MMI_DisplayFun(16);
- return;
- }
- if(bPowerOffMMIFlag && uInterfaceNum == 12)
- {
- uInterfaceNum = 12;
- MMI_DisplayFun(17);
- return;
- }
- if(bPowerOffMMIFlag && uInterfaceNum == 13)
- {
- bComuStartRecFlag = ~bComuStartRecFlag;
- uInterfaceNum = 13;
- MMI_DisplayFun(18);
- return;
- }
- if(bPowerOffMMIFlag && uInterfaceNum == 14)
- {
- uInterfaceNum = 14;
- MMI_DisplayFun(19);
- return;
- }
- if(bPowerOffMMIFlag && uInterfaceNum == 15)
- {
- uInterfaceNum = 15;
- MMI_DisplayFun(20);
- return;
- }
- if(bPowerOffMMIFlag && uInterfaceNum == 16)
- {
- uInterfaceNum = 16;
- MMI_DisplayFun(21);
- return;
- }
- if(bPowerOffMMIFlag && uInterfaceNum == 17)
- {
- uInterfaceNum = 17;
- MMI_DisplayFun(22);
- return;
- }
- //chen++ 自动巡航 界面显示
- if(bPowerOffMMIFlag && uInterfaceNum == 19)
- {
- uInterfaceNum = 1;
- MMI_DisplayFun(1);
- return;
- }
- }
- //左软件功能函数 确认键功能
- void LeftSoftKeyFun(void)
- {
- unsigned char uPowerOffTimes = 0;
- if(bAutoScanStopFlag && !bPowerOffMMIFlag) //球机地址自动扫描 停止 后只有 右软件有用
- return;
- //关机实现功能
- if(bPowerOffMMIFlag && !bPowerOnOffFlag)
- {
- EA = 0;
- SOUND = SOUND_ON;
- STATUS_LED = 0;
- OPEN = 0;
- LCD_ON = 0;
- uPowerKeyTime = 0;
- gPowerOnOffTimes = 0;
- bPowerOnFlag = TRUE;
- bPowerOffFlag = TRUE;
- bPowerOnOffFlag = TRUE; //为下面执行运行其他程序作准备
- do
- {
- WDT_CONTR = 0x3D;
- DelayX1ms(25);
- uPowerOffTimes = uPowerOffTimes+1;
- if(uPowerOffTimes>=200)
- {
- SOUND = SOUND_OFF;
- }
- OPEN = 0;
- LCD_ON = 0;
- }
- while(1);
- }
- //主菜单
- if(uMainMenuTimes == 1 && !bMainMenuFlag && bSysSetupFlag)
- {
- uInterfaceNum = 2;
- MMI_DisplayFun(2); //主菜单 显示
- return;
- }
- //1 系统参数设置
- if(uMainMenuTimes == 1 && bMainMenuFlag && !bSysSetupFlag)
- {
- uInterfaceNum = 3;
- MMI_DisplayFun(3); //
- return;
- }
- //2 云台球机和视频输入控制
-
- /* chen--
- if(uMainMenuTimes == 2 && bMainMenuFlag && !bPtzVideoFlag)///
- {
- uInterfaceNum = 5;
- MMI_DisplayFun(5); //4 云台球机和视频输入控制 显示
- uPtzMainBarNum = 1;
- return;
- }
- */
- //>1:视频输入和云台控制
- if(uPtzMainBarNum == 1 && !bVideoSignInFlag && bVideoSignInGenFlag) //该语句一定在 AAAAA语句前
- {
- uInterfaceNum = 5;
- MMI_DisplayFun(5);
- return;
- }
- if( uPtzMainBarNum == 1 && bVideoSignInFlag && !bVideoSignInGenFlag) //该语句一定在 AAAAA语句前
- {
- uInterfaceNum = 5;
- MMI_DisplayFun(6);
- return;
- }
- if(uPtzMainBarNum == 1 && bPtzVideoFlag && !bVideoSignInFlag) //AAAAA
- {
- uInterfaceNum = 5;
- MMI_DisplayFun(7);
- return;
- }
- //chen++ 7 云台球机和视频输入控制 显
- if(uMainMenuTimes == 2 && bMainMenuFlag && !bPtzVideoFlag)///
- {
- uInterfaceNum = 5;
- MMI_DisplayFun(7); //7 云台球机和视频输入控制 显示
- uPtzMainBarNum = 1;
- return;
- }
- //>2云台其他功能操作
- if(uPtzMainBarNum == 2 && !bPtzVideoFlag && bOtherFunFlag)
- {
- uInterfaceNum = 6;
- if(bPresetVideo_Flag == 0)
- {
- MMI_DisplayFun(8); //进入预设页 视频界面
- return;
- }
- }
- if(uPtzMainBarNum == 2 && bPtzVideoFlag && !bOtherFunFlag) //CCCC
- {
- uInterfaceNum = 6;
- MMI_DisplayFun(9);
- return;
- }
- //chen++ 预设值功能有效
- if(bPresetSet_Flag == 1)
- {
- if((uPtzOtherFunNum == 10)||(uPtzOtherFunNum == 11)||(uPtzOtherFunNum == 12))
- {
- MMI_DisplayFun(8);
- }
- }
- //chen++ 预设值界面
- if(bPreset_Page == 1 && bPresetVideo_Flag == 1)
- {
- uPtzOtherFunNum_Preset = uPtzOtherFunNum;
- uPtzOtherFunNum = 9;
- MMI_DisplayFun(26); //进入预设 设置界面
- bPresetVideo_Flag = 0;
- bPresetSet_Flag = 1;
-
-
- }
- else
- {
- if(bPreset_Page == 1 && bPresetSet_Flag == 1)
- {
- MMI_DisplayFun(25); //进入预设 视频界面
- bPresetVideo_Flag = 1;
- bPresetSet_Flag = 0;
- }
- }
- //chen++ 其他
- if(uMainMenuTimes == 9 && bMainMenuFlag && !bPtzVideoFlag)
- {
- uInterfaceNum = 6; //其他 操作界面
- MMI_DisplayFun(9); //9 其他 显示界面
- uPtzMainBarNum = 2;
- return;
- }
-
- //>3球机地址自动扫描
- if(uPtzMainBarNum == 3 && bAutoScanFlag && !bAutoScanEndFlag && bAutoScanStartFlag) //BBBBB
- {
- uInterfaceNum = 7;
- MMI_DisplayFun(10); //10 球机自动扫描 开始界面
- return;
- }
- if(uPtzMainBarNum == 3 && bAutoScanFlag && !bAutoScanStartFlag && !bAutoScanEndFlag) //BBBBB
- {
- uInterfaceNum = 8;
- MMI_DisplayFun(11); //11 球机自动扫描 结束界面
- return;
- }
- if(uPtzMainBarNum == 3 && bPtzVideoFlag && !bAutoScanFlag) //BBBBB
- {
- uInterfaceNum = 8;
- MMI_DisplayFun(12); //12 球机地址自动扫描 界面显示、参数设定
- return;
- }
- //chen++ 2 寻址
- if(uMainMenuTimes == 8 && bMainMenuFlag && !bPtzVideoFlag)
- {
- uInterfaceNum = 8;
- MMI_DisplayFun(12); //12 球机地址自动扫描 界面显示、参数设定
- uPtzMainBarNum = 3; //chen++
- return;
- }
-
- //3 网线输出测试功能
- //chen++ 在网线测试功能界面下,按确定键,开始或者停止网线测试
- if(uMainMenuTimes == 3 && bNetSendBarFlag)
- {
- uInterfaceNum = 9;
- MMI_DisplayFun(13);
- return;
- }
- //chen++ 在主菜单界面下,按确定键,进入网线测试功能界面
- if(uMainMenuTimes == 3 && bMainMenuFlag && !bNetSendBarFlag)
- {
- uInterfaceNum = 9;
- MMI_DisplayFun(14);
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //4 视频信号发生器
- if(uMainMenuTimes == 4 && bVideoGenerationFlag)
- {
- uInterfaceNum = 10;
- MMI_DisplayFun(15);
- return;
- }
- if(uMainMenuTimes == 4 && bMainMenuFlag &&!bVideoGenerationFlag)
- {
- uInterfaceNum = 11;
- MMI_DisplayFun(16);
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //5 通信数据测试功能
- if(uMainMenuTimes == 5 && bComuDataBarFlag && bComuStopRecFlag && !bComuDispDataFlag)//显示数据
- {
- uInterfaceNum = 12;
- MMI_DisplayFun(17);
- return;
- }
- if(uMainMenuTimes == 5 && bComuDataBarFlag && !bComuDispDataFlag)
- {
- uInterfaceNum = 13;
- MMI_DisplayFun(18);
- return;
- }
- if(uMainMenuTimes == 5 && bMainMenuFlag && !bComuDataBarFlag && !bComuDispDataFlag)
- {
- uInterfaceNum = 14;
- MMI_DisplayFun(19);
- return;
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //6 电源管理功能
- if(uMainMenuTimes == 6 && !bMainMenuFlag && bPowerManageBarFlag)
- {
- uInterfaceNum = 15;
- MMI_DisplayFun(20);
- return;
- }
- if(uMainMenuTimes == 6 && bMainMenuFlag && !bPowerManageBarFlag)
- {
- uInterfaceNum = 16;
- MMI_DisplayFun(21);
- return;
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //7 关于帮助
- if(uMainMenuTimes == 7 && bMainMenuFlag && !bAboutHelpBarFlag)
- {
- uInterfaceNum = 17;
- MMI_DisplayFun(22);
- return;
- }
- }
- void MMI_EnableFlag(void)
- {
- bPowerOffMMIFlag = FALSE;
- bLogoFlag = FALSE;
- bMainMenuFlag = FALSE;
- bSysSetupFlag = FALSE;
- bPtzVideoFlag = FALSE;
- bVideoSignInFlag = FALSE; //视频信号输入模式
- bVideoSignInGenFlag = FALSE; //已经有视频信号 标志
- bAutoScanFlag = FALSE;
- bOtherFunFlag = FALSE;
- bNetSendBarFlag = FALSE;
- bNetSendRunFlag = FALSE;
- bVideoGenerationFlag = FALSE;
- bComuDataBarFlag = FALSE;
- bPowerManageBarFlag = FALSE;
- bAboutHelpBarFlag = FALSE;
-
- bAutoScanStopFlag = FALSE;
- bModeKeyVideoFlag = FALSE;
-
-
- return;
- }
- //所有显示函数在一起
- void MMI_DisplayFun(unsigned char uMMI_Num)
- {
- bit bFlag = FALSE;
- unsigned char uEndNum = 0;
- switch(uMMI_Num)
- {
- //显示LOGO
- case 1:
- {
- MainLogo();
- MMI_EnableFlag();
- bLogoFlag = TRUE;
- break;
- }
- //显示主菜单
- case 2:
- {
- CD4053_A = 0; //chen++
- CD4053_B = 0; //OSD - LCD
- CD4053_C = 0;
- MB90092_ClearScreen(); //chen++
- TopLeft(3, 0x070); //主菜单
- //chen-- TopLeft(0, 0x073); //chen++ _ _ _
- TopRight(bAlarmSoundFlag, bKeyLockFlag, bPowerInOutFlag, uBatGridNum); //1格电池
- //chen--BottomLeft(2,0x074); //选择
- BottomLeft(2,0x140); //确定
- //chen-- BottomRight(2,0x076); //返回
- BottomRight(0,0x078); //chen++ ---
- MainMenu(uMainMenuTimes);
- //保存数据到EEPROM 等待加入 。。。。。。
- uControlRuleItem = uControlRuleItem; //控制协议是第几个
- uComSereialItem = uComSereialItem; //串口选择
- uBaudRateItem = uBaudRateItem; //波特率选择
- uRunSpeedData = uRunSpeedData;//运行速度
- uStandbyTime = uStandbyTime;//待机时间
- uNetSpeed = uNetSpeed; //网线速度 其实忙也不用但是项目
- uLcdBright = uLcdBright; //屏幕亮度
-
- if(uComSereialItem == 1) //232
- SerialPortOneInitial(uBaudRateItem);
- if(uComSereialItem == 2) //485
- SerialPortTwoInitial(uBaudRateItem);
-
- MMI_EnableFlag();
- bMainMenuFlag = TRUE;
- bComuDataBarFlag = FALSE; //通信数据测试功能
- bComuStartRecFlag= FALSE;
- bComuStopRecFlag = FALSE;
- bComuDispDataFlag= FALSE;
- bComuRecLedFlashFlag = FALSE;
- uDataLedLoop = 0;
- uGetSerialDataNum = 0; //接收到数据个数
- ES = 0;
- IE2 = 0x00;
- break;
- }
- //显示 1 系统参数设置
- case 3:
- {
- TopLeft(6, 0x0F0);
- BottomLeft(2,0x14E); //保存
- BottomRight(2,0x076); //返回
- SysSetupLeft(6,0x150); //系统参数设置左边
- SysSetupBarFun(uSysSetupTimes);
- MMI_EnableFlag();
- bSysSetupFlag = TRUE;
- break;
- }
- //显示 2 云台球机和视频输入控制 显示界面(三列)
- case 4:
- {
- TopLeftNew(0,11); //云台球机和视频输入控制
- BottomLeft(2,0x140); //确定
- BottomRight(2,0x076); //返回
-
- PtzVideoControl(uPtzMainBarNum); //显示地址 视频格式
-
- MMI_EnableFlag();
- bPtzVideoFlag = TRUE;
- break;
- }
- //显示 >1:视频输入和云台控制
- case 5:
- {
- CD4053_A = 0; //chen++
- CD4053_B = 0; //OSD - LCD
- CD4053_C = 0;
- //保存485 的发送地址
- AddressSave = uVideoSignInAddr;
- bVideoSignInGenFlag = FALSE; //已经有视频信号
- bVideoSignInFlag = TRUE;
- bModeKeyVideoFlag = TRUE;
- break;
- }
- //显示 //>1:视频输入和云台控制 1
- //chen++ ;从视频输入和云台控制界面(地址、视频模式界面),进入到视频显示。
- case 6:
- {
- CD4053_A = 0; //chen++
- CD4053_B = 1; //视频信号直接输入到LCD
- CD4053_C = 0;
- //保存485 的发送地址
- AddressSave = uVideoSignInAddr;
- bVideoSignInGenFlag = TRUE; //已经有视频信号
- bVideoSignInFlag = FALSE;
- bModeKeyVideoFlag = TRUE;
- break;
- }
- //显示 //>1:视频输入和云台控制 2
- case 7:
- {
- SerialPortOneInitial(uBaudRateItem); //开始为2400 uBaudRateItem= 3
- SerialPortTwoInitial(uBaudRateItem); //开始为2400
-
- TopLeftNew(1, 9); //视频输入和云台控制
- BottomLeft(2,0x140); //确定
- BottomRight(2,0x076); //返回
- if(uVideoSignInBarNum == 1)
- {
- bFlag = TRUE;
- }
- else if(uVideoSignInBarNum == 2)
- {
- bFlag = FALSE;
- }
- else
- {
- _nop_();
- }
- VideoSignInMode(uVideoSignInAddr, uVideoSignInType, bFlag); //显示地址 视频格式
-
- MMI_EnableFlag();
- bVideoSignInGenFlag = FALSE; //已经有视频信号
- bVideoSignInFlag = TRUE; //视频信号输入模式
- bModeKeyVideoFlag = TRUE;
- break;
- }
- //显示 //>2云台其他功能操作
- case 8:
- {
- DE =1;
- PtzOtherFunSendOrder(uPtzOtherFunNum); //其他功能命令
- //PtzFunction2(uPtzOtherFunNum);
- DE =0;
- break;
- }
- //显示 //>2云台其他功能操作 1
- case 9:
- {
- SerialPortOneInitial(uBaudRateItem); //开始为2400 uBaudRateItem= 3
- SerialPortTwoInitial(uBaudRateItem); //开始为2400
- MB90092_ClearScreen();//chen++
- TopLeftNew(3,8); //云台其他功能操作
- BottomLeft(2,0x140); //确定
- if(!bPreset_Page)
- {
- TopRight(bAlarmSoundFlag, bKeyLockFlag, bPowerInOutFlag, uBatGridNum); //?格电池
- }
- BottomRight(2,0x076); //返回
- //chen-- PtzOtherFun(uPtzOtherFunNum,uPresetAddr);
- PtzFunction1(uPtzOtherFunNum);
- MMI_EnableFlag();
- bOtherFunFlag = TRUE;
- break;
- }
- //显示 //>3球机地址自动扫描 按确定键停止
- case 10:
- {
- MMI_EnableFlag();
- bAutoScanFlag = TRUE;
- bAutoScanEndFlag = TRUE;
- bAutoScanStartFlag = FALSE;
- CD4053_A = 0; //chen++
- CD4053_B = 0; //LCD显示 文字界面
- CD4053_C = 0;
- break;
- }
- //显示 ////>3球机地址自动扫描 1
- case 11:
- {
- MMI_EnableFlag();
- bAutoScanFlag = TRUE;
- bAutoScanStartFlag = TRUE;
- bAutoScanEndFlag = FALSE;
-
- CD4053_A = 0; //chen++
- CD4053_B = 1; //LCD显示 视频信号输入
- CD4053_C = 0;
- ScanStop_Interface = 1;
-
- if(uAutoStartAddr > uAutoEndAddr )
- {
- uAutoEndAddr = uAutoStartAddr;
- }
- uAutoSendTempAddr = uAutoStartAddr;
- //初始化串口
- SerialPortOneInitial(uAutoBaudRateItem); //开始为2400 uBaudRateItem= 3
- SerialPortTwoInitial(uAutoBaudRateItem); //开始为2400
- uAutoScanSend1Times = 0;
- uAutoScanSend2Times = 0;
- uAutoScanSendData1Time = 0;
- uAutoScanSendData2Time = 0;
- bAutoScanStopFlag = FALSE;
- break;
- }
- //显示//>3球机地址自动扫描 2
- case 12: //功能包括:设置页显示界面、参数设定
- {
- TopLeftNew(2,8); //球机地址自动扫描
- BottomLeft(2,0x144); //开始
- BottomRight(2,0x076); //返回
- AutoScanSetupLeft(); //球机地址自动扫描 设置页的左边 显示界面
-
- PtzAddrAutoScan(uAutoScanSetupTimes);
- bAutoScanStartFlag = FALSE;
- bAutoScanEndFlag = FALSE;
-
- MMI_EnableFlag();
-
- bAutoScanFlag = TRUE;
- ScanStop_Interface = 0; //chen++ 0:不在自动扫面停止界面;1:在自动扫面停止界面
- break;
- }
- //显示//3 网线连接测试功能
- //bNetSendRunFlag =1 含义: 网线信号输出已停止,可再执行网线输出测试功能。
- // =0 含义:网线信号输出正进行,网线接口有信号输出。
- case 13:
- {
- if(!bNetSendRunFlag)
- {
- BottomLeft(2,0x14A); //停止
- bNetSendRunFlag = TRUE;
- }
- else
- {
- BottomLeft(2,0x144); //开始
- bNetSendRunFlag = FALSE;
- }
- break;
- }
- //显示 //3 网线连接测试功能 1
- case 14:
- {
- TopLeft(8, 0x100); //网线输出测试功能
- BottomLeft(2,0x144); //开始
- BottomRight(2,0x076); //返回
-
- uNetSendRunLoop = 8;
- uNetMcuLedLoop = 1;
- SendOneData(0x00); //74HC164
- NetLineSendMode(0, uNetMcuLedLoop); //先静止
-
- MMI_EnableFlag();
-
- bNetSendBarFlag = TRUE;
- break;
- }
- //显示//4 视频信号发生器
- case 15:
- {
-
- CD4053_B = 0; //OSD - LCD
- //chen--g CD4053_C = 1;
- CD4053_C = 0;
- CD4053_A = 1; //chen++
-
- //按开始执行该视频信号模式
- uVideoGenTimes = uVideoGenTimes+1;
- if(uVideoGenTimes == 7)
- {
- uVideoGenTimes = 1;
- }
-
- VideoGeneration(uVideoGenTimes);
- MMI_EnableFlag();
- bVideoGenerationFlag = TRUE;
- break;
- }
- //显示 //4 视频信号发生器 2
- case 16:
- {
- CD4053_B = 0; //OSD - LCD
- //chen--g CD4053_C = 1;
- CD4053_A = 1; //chen++
- //按开始执行该视频信号模式
- uVideoGenTimes = 1;
-
- VideoGeneration(uVideoGenTimes);
-
- BottomLeft(3,0x2D0); //下一色
- BottomRight(2,0x14C); //结束
- MMI_EnableFlag();
- bVideoGenerationFlag = TRUE;
- break;
- }
- //显示//5 通信数据测试功能
- case 17:
- {
- TopLeft(8, 0x108); //
- BottomLeft(2,0x2EE); //结果
- BottomRight(2,0x076); //返回
-
- if(uGetSerialDataNum>0)
- {
- if(!bPowerOffMMIFlag) //如果重新来,刚开始为第一页
- uComuPageNum = 1; //表示显示第一页
- // uGetSerialDataNum = 2;
- if(uGetSerialDataNum < 7)
- {
- uEndNum = uGetSerialDataNum%7;
- }
- else
- {
- uEndNum = 7;
- }
- ComuDisplayData(uComuPageNum, uEndNum, uInbox); //显示收到数据
- ComuDisplayBarNum(uComuPageNum, uGetSerialDataNum); //显示下拉条
- }
- else //显示 Not Receive Data 表示没有收到一个字节
- {
- ComuDisplayNoData();
- }
- bComuDispDataFlag = TRUE; //表示进入显示数据界面
-
- MMI_EnableFlag();
- bComuDataBarFlag = TRUE;
- bComuRecLedFlashFlag = FALSE;
- uDataLedLoop = 0;
- break;
- }
- //显示 //5 通信数据测试功能 1
- case 18:
- {
- TopLeft(8, 0x108); //
- if(!bComuStartRecFlag)
- {
- BottomLeft(2,0x14A); //停止
- uDataLedLoop = 0;
- bComuRecLedFlashFlag = TRUE;
- uGetSerialDataNum = 0;
- //ES = 1; //打开串口1中断
- IE2= 0x01; //打开串口2中断 ES2 = 0;
- }
- else
- {
- BottomLeft(4,0x2EC); //查看结果
- bComuRecLedFlashFlag = FALSE;
- ES = 0; //关闭串口1中断
- IE2= 0x00; //打开串口2中断 ES2 = 0;
- uDataLedLoop = 0;
-
- }
- BottomRight(2,0x076);
-
- if(!bComuStartRecFlag)
- {
- ComuStartReceive();
- bComuStartRecFlag = TRUE;
- }
- else
- {
- ComuStopReceive();
- bComuStartRecFlag = FALSE;
- bComuStopRecFlag = TRUE;
- }
- MMI_EnableFlag();
- bComuDataBarFlag = TRUE;
- break;
- }
- //显示 //5 通信数据测试功能 2
- case 19:
- {
- TopLeft(8, 0x108); //
- BottomLeft(2,0x144); //开始
- BottomRight(2,0x076); //返回
-
- ComuDataBarFun();
- uGetSerialDataNum = 0;
- ES = 0;
- IE2 = 0x00;
-
- MMI_EnableFlag();
-
- bComuDataBarFlag = TRUE;
- bComuStartRecFlag = FALSE;
- bComuStopRecFlag = FALSE;
- bComuDispDataFlag = FALSE;
- bComuRecLedFlashFlag = FALSE;
- uDataLedLoop = 0;
- break;
- }
- //显示//6 电源管理功能
- case 20:
- {
- if(uPowerManageBarTimes == 2)
- {
- bPowerInOutFlag = TRUE;
- IN_OUT = 1;
- }
- else
- {
- bPowerInOutFlag = FALSE;
- IN_OUT = 0;
- }
- MB90092_ClearScreen(); //chen++
- TopLeft(3, 0x070); //主菜单
- if(!bPreset_Page)
- {
- TopRight(bAlarmSoundFlag, bKeyLockFlag, bPowerInOutFlag, uBatGridNum); //?格电池
- }
- BottomLeft(2,0x140); //chen++ 确定
- BottomRight(0,0x078); //chen++ ---
- MainMenu(uMainMenuTimes);
-
- //保存数据到EEPROM 等待加入 。。。。。。
- MMI_EnableFlag();
- bMainMenuFlag = TRUE;
- break;
- }
- //显示 //6 电源管理功能 1
- case 21:
- {
- TopLeft(6, 0x119); //电源管理功能
- if(!bPreset_Page)
- {
- TopRight(bAlarmSoundFlag, bKeyLockFlag, bPowerInOutFlag, uBatGridNum); //?格电池
- }
- //chen--gBottomLeft(2,0x074); //选择
- BottomLeft(2,0x140); //chen++ 确定
- BottomRight(2,0x076); //返回
-
- PowerManageBarFun(uPowerManageBarTimes, uVolData);
- VolAdChangeOpen(); //得到电压
- DealWithVolAdDispBat(FALSE);
- MMI_EnableFlag();
- bPowerManageBarFlag = TRUE;
- break;
- }
- //显示 //7 关于帮助
- case 22:
- {
- TopLeft(4, 0x0EC); //关于帮助
- BottomLeft(1,0x078); //----
- BottomRight(2,0x076); //返回
- uVerData = "Version-2.11.0";
- uSNData = "SN-B0A00B2123.12";
- uNetAddr = "www.hzshoup.com";
- uTelNum = "0571-85121925";
- AboutHelpBarFun(uVerData,uSNData,uNetAddr,uTelNum); //网线连接测试功能 选择
- MMI_EnableFlag();
- bAboutHelpBarFlag = TRUE;
- break;
- }
- //显示 //8 自动寻址 chen++
- case 23:
- {
- TopLeft(6, 0x119); //电源管理功能
- //chen--gBottomLeft(2,0x074); //选择
- BottomLeft(2,0x140); //chen++ 确定
- BottomRight(2,0x076); //返回
-
- PowerManageBarFun(uPowerManageBarTimes, uVolData);
- VolAdChangeOpen(); //得到电压
- DealWithVolAdDispBat(FALSE);
- MMI_EnableFlag();
- bPowerManageBarFlag = TRUE;
- break;
- }
- //显示 9 自动巡航 chen++
- case 24: //6 电源管理功能 1
- {
- TopLeft(6, 0x119); //电源管理功能
- //chen--gBottomLeft(2,0x074); //选择
- BottomLeft(2,0x140); //chen++ 确定
- BottomRight(2,0x076); //返回
-
- PowerManageBarFun(uPowerManageBarTimes, uVolData);
- VolAdChangeOpen(); //得到电压
- DealWithVolAdDispBat(FALSE);
- MMI_EnableFlag();
- bPowerManageBarFlag = TRUE;
- break;
- }
- //显示 预设值视频 界面 chen++
- case 25:
- {
- MB90092_ClearScreen();
- break;
- }
- //显示 预设值设置 界面 chen++
- case 26:
- {
- MB90092_ClearScreen();
- PtzOtherFun(uPtzOtherFunNum,uPresetAddr);
- break;
- }
- }
- return;
- }
- //左右选中数字 递减或者递加
- //bLeftRightFlag = FALSE;表示向右移动 递减
- //bLeftRightFlag = TRUE; 表示向左移动 递加
- void LeftRightItem(bit bLeftRightFlag)
- {
- //chen++1
- //主菜单
- if(bMainMenuFlag)
- {
- if(bLeftRightFlag)
- {
- switch(uMainMenuTimes)
- {
- case 1: uMainMenuTimes = 3; break;
- case 2: uMainMenuTimes = 4; break;
- case 3: uMainMenuTimes = 5; break;
- case 4: uMainMenuTimes = 6; break;
- case 5: uMainMenuTimes = 2; break;
- case 6: uMainMenuTimes = 8; break;
- case 8: uMainMenuTimes = 9; break;
- case 9: uMainMenuTimes = 1; break;
- default: uMainMenuTimes = 1;
- }
- }
- else
- { switch(uMainMenuTimes)
- {
- case 1: uMainMenuTimes = 9; break;
- case 2: uMainMenuTimes = 5; break;
- case 3: uMainMenuTimes = 1; break;
- case 4: uMainMenuTimes = 2; break;
- case 5: uMainMenuTimes = 3; break;
- case 6: uMainMenuTimes = 4; break;
- case 8: uMainMenuTimes = 6; break;
- case 9: uMainMenuTimes = 8; break;
- default: uMainMenuTimes = 1;
- }
- }
- MainMenu(uMainMenuTimes);
- }
- //chen++2
- //参数设置 界面
- if(bSysSetupFlag && uSysSetupTimes == 1) //控制协议
- {
- if(bLeftRightFlag)
- {
- if(uControlRuleItem == 10)
- uControlRuleItem = 1;
- else
- uControlRuleItem = uControlRuleItem+1;
- }
- else
- {
- if(uControlRuleItem == 1)
- uControlRuleItem = 10;
- else
- uControlRuleItem = uControlRuleItem-1;
- }
- SysSetupBarFun(uSysSetupTimes);
- }
- /*
- if(bSysSetupFlag && uSysSetupTimes == 2) //通信串口
- {
- if(bLeftRightFlag)
- {
- if(uComSereialItem == 2)
- uComSereialItem = 1;
- else
- uComSereialItem = uComSereialItem+1;
- }
- else
- {
- if(uComSereialItem == 1)
- uComSereialItem = 2;
- else
- uComSereialItem = uComSereialItem-1;
- }
- SysSetupBarFun(uSysSetupTimes);
- }
- */
- if(bSysSetupFlag && uSysSetupTimes == 3) //波特率
- {
- if(bLeftRightFlag)
- {
- if(uBaudRateItem == 8)
- uBaudRateItem = 1;
- else
- uBaudRateItem = uBaudRateItem+1;
- }
- else
- {
- if(uBaudRateItem == 1)
- uBaudRateItem = 8;
- else
- uBaudRateItem = uBaudRateItem-1;
- }
- SysSetupBarFun(uSysSetupTimes);
- }
- if(bSysSetupFlag && uSysSetupTimes == 4) //运行速度 0---255
- {
- if(bLeftRightFlag)
- {
- if(uRunSpeedData == 255) //0到3F
- uRunSpeedData = 0;
- else
- uRunSpeedData = uRunSpeedData+1;
- }
- else
- {
- if(uRunSpeedData == 0)
- uRunSpeedData = 255; //0到3F
- else
- uRunSpeedData = uRunSpeedData-1;
- }
- SysSetupBarFun(uSysSetupTimes);
- }
- if(bSysSetupFlag && uSysSetupTimes == 5) //待机时间 00 到30分钟 当为0时表示不待机
- {
- if(bLeftRightFlag)
- {
- if(uStandbyTime == 6) //uStandbyTime*5
- uStandbyTime = 0;
- else
- uStandbyTime = uStandbyTime+1;
- }
- else
- {
- if(uStandbyTime == 0)
- uStandbyTime = 6;
- else
- uStandbyTime = uStandbyTime-1;
- }
- SysSetupBarFun(uSysSetupTimes);
- }
- if(bSysSetupFlag && uSysSetupTimes == 6) //网线速度 1-5
- {
- if(bLeftRightFlag)
- {
- if(uNetSpeed == 5)
- uNetSpeed = 1;
- else
- uNetSpeed = uNetSpeed+1;
- }
- else
- {
- if(uNetSpeed == 1)
- uNetSpeed = 5;
- else
- uNetSpeed = uNetSpeed-1;
- }
- SysSetupBarFun(uSysSetupTimes);
- }
- /*
- if(bSysSetupFlag && uSysSetupTimes == 7) //屏幕亮度 1-15
- {
- if(bLeftRightFlag)
- {
- if(uLcdBright == 15)
- uLcdBright = 1;
- else
- uLcdBright = uLcdBright+1;
- }
- else
- {
- if(uLcdBright == 1)
- uLcdBright = 15;
- else
- uLcdBright = uLcdBright-1;
- }
- SysSetupBarFun(uSysSetupTimes);
-
- }
- */
- //chen
- //视频输入和云台控制
- if(bVideoSignInFlag && uVideoSignInBarNum == 1) //地址 选择
- {
- if(bLeftRightFlag)
- {
- if(uVideoSignInAddr == 255)
- uVideoSignInAddr = 0;
- else
- uVideoSignInAddr = uVideoSignInAddr+1;
- }
- else
- {
- if(uVideoSignInAddr == 0)
- uVideoSignInAddr = 255;
- else
- uVideoSignInAddr = uVideoSignInAddr-1;
- }
- VideoSignInMode(uVideoSignInAddr, uVideoSignInType, TRUE); //显示地址 视频格式
- }
- if(bVideoSignInFlag && uVideoSignInBarNum == 2) //视频制式 选择
- {
- if(bLeftRightFlag)
- {
- if(uVideoSignInType == 3)
- uVideoSignInType = 1;
- else
- uVideoSignInType = uVideoSignInType+1;
- }
- else
- {
- if(uVideoSignInType == 1)
- uVideoSignInType = 3;
- else
- uVideoSignInType = uVideoSignInType-1;
- }
- VideoSignInMode(uVideoSignInAddr, uVideoSignInType, FALSE); //显示地址 视频格式
- }
-
- //chen
- //预置位设置界面菜单选择
- // if(bOtherFunFlag == 1 && bPreset_Page ==1)
- if(bPreset_Page ==1)
- {
- //chen-- if(bLeftRightFlag)
- MB90092_DisChar (2,5,0x0B,2,B_COLOR_CYAN,0,0);
- switch(uPtzOtherFunNum)
- {
- case 9: uPtzOtherFunNum = 10; break;
- case 10:
- case 11:
- case 12: uPtzOtherFunNum = 9; break;
- default: break;
- }
- PtzOtherFun(uPtzOtherFunNum,uPresetAddr);
- }
- /*chen--取消左右按键功能,改左右按键为上下按键。
- if(bLeftRightFlag)
- {
- //横向的第1行
- if(uPtzOtherFunNum == 1)
- {
- uPtzOtherFunNum = 2;
- }
- else if(uPtzOtherFunNum == 2)
- {
- uPtzOtherFunNum = 3;
- }
- else if(uPtzOtherFunNum == 3)
- {
- uPtzOtherFunNum = 1;
- }
- //横向的第2行
- else if(uPtzOtherFunNum == 4)
- {
- uPtzOtherFunNum = 5;
- }
- else if(uPtzOtherFunNum == 5)
- {
- uPtzOtherFunNum = 6;
- }
- else if(uPtzOtherFunNum == 6)
- {
- uPtzOtherFunNum = 4;
- }
-
- //横向的第3行
- else if(uPtzOtherFunNum == 7)
- {
- uPtzOtherFunNum = 8;
- }
- else if(uPtzOtherFunNum == 8)
- {
- uPtzOtherFunNum = 7;
- }
-
- //横向的第4行
- else if(uPtzOtherFunNum == 10)
- {
- uPtzOtherFunNum = 11;
- }
- else if(uPtzOtherFunNum == 11)
- {
- uPtzOtherFunNum = 12;
- }
- else if(uPtzOtherFunNum == 12)
- {
- uPtzOtherFunNum = 3;
- }
- //数字改变
- else if(uPtzOtherFunNum == 9)
- {
- if(uPresetAddr == 255)
- uPresetAddr = 0;
- else
- uPresetAddr = uPresetAddr+1;
- }
- else
- {
- uPtzOtherFunNum =1;
- }
- }
- else
- {
- //横向的第1行
- if(uPtzOtherFunNum == 2)
- {
- uPtzOtherFunNum = 1;
- }
- else if(uPtzOtherFunNum == 3)
- {
- uPtzOtherFunNum = 2;
- }
- else if(uPtzOtherFunNum == 1)
- {
- uPtzOtherFunNum = 3;
- }
- //横向的第2行
- else if(uPtzOtherFunNum == 5)
- {
- uPtzOtherFunNum = 4;
- }
- else if(uPtzOtherFunNum == 6)
- {
- uPtzOtherFunNum = 5;
- }
- else if(uPtzOtherFunNum == 4)
- {
- uPtzOtherFunNum = 6;
- }
-
- //横向的第3行
- else if(uPtzOtherFunNum == 8)
- {
- uPtzOtherFunNum = 7;
- }
- else if(uPtzOtherFunNum == 7)
- {
- uPtzOtherFunNum = 8;
- }
-
- //横向的第4行
- else if(uPtzOtherFunNum == 12)
- {
- uPtzOtherFunNum = 11;
- }
- else if(uPtzOtherFunNum == 11)
- {
- uPtzOtherFunNum = 10;
- }
- else if(uPtzOtherFunNum == 10)
- {
- uPtzOtherFunNum = 9;
- }
- //数字改变
- else if(uPtzOtherFunNum == 9)
- {
- if(uPresetAddr == 255)
- uPresetAddr = 0;
- else
- uPresetAddr = uPresetAddr-1;
- }
- else
- {
- uPtzOtherFunNum =1;
- }
- }
- */
- //chen
- //球机地址自动扫描 设置界面
-
- //新增加内容 地址自动扫描
- if(!ScanStop_Interface) //chen++ 确定当前界面不是自动扫描停止界面。
- {
- if(bAutoScanFlag && uAutoScanSetupTimes == 1)//自动扫描波特率
- {
- if(bLeftRightFlag)
- {
- if(uAutoBaudRateItem == 8)
- uAutoBaudRateItem = 1;
- else
- uAutoBaudRateItem = uAutoBaudRateItem+1;
- }
- else
- {
- if(uAutoBaudRateItem == 1)
- uAutoBaudRateItem = 8;
- else
- uAutoBaudRateItem = uAutoBaudRateItem-1;
- }
- PtzAddrAutoScan(uAutoScanSetupTimes);
- }
- if(bAutoScanFlag && uAutoScanSetupTimes == 2) //自动扫描控制协议是第几个
- {
- if(bLeftRightFlag)
- {
- if(uAutoControlRuleItem == 10)
- uAutoControlRuleItem = 1;
- else
- uAutoControlRuleItem = uAutoControlRuleItem+1;
- }
- else
- {
- if(uAutoControlRuleItem == 1)
- uAutoControlRuleItem = 10;
- else
- uAutoControlRuleItem = uAutoControlRuleItem-1;
- }
- PtzAddrAutoScan(uAutoScanSetupTimes);
- }
- if(bAutoScanFlag && uAutoScanSetupTimes == 3) //开始地址
- {
- if(bLeftRightFlag)
- {
- if(uAutoStartAddr == 255)
- uAutoStartAddr = 0;
- else
- uAutoStartAddr = uAutoStartAddr+1;
- }
- else
- {
- if(uAutoStartAddr == 0)
- uAutoStartAddr = 255;
- else
- uAutoStartAddr = uAutoStartAddr-1;
- }
- PtzAddrAutoScan(uAutoScanSetupTimes);
- }
- if(bAutoScanFlag && uAutoScanSetupTimes == 4) //结束地址
- {
- if(bLeftRightFlag)
- {
- if(uAutoEndAddr == 255)
- uAutoEndAddr = 0;
- else
- uAutoEndAddr = uAutoEndAddr+1;
- }
- else
- {
- if(uAutoEndAddr == 0)
- uAutoEndAddr = 255;
- else
- uAutoEndAddr = uAutoEndAddr-1;
- }
- PtzAddrAutoScan(uAutoScanSetupTimes);
- }
- if(bAutoScanFlag && uAutoScanSetupTimes == 5) //间隔时间
- {
- if(bLeftRightFlag)
- {
- if(uAutoSpaceTime == 10)
- uAutoSpaceTime = 1;
- else
- uAutoSpaceTime = uAutoSpaceTime+1;
- }
- else
- {
- if(uAutoSpaceTime == 1)
- uAutoSpaceTime = 10;
- else
- uAutoSpaceTime = uAutoSpaceTime-1;
- }
- PtzAddrAutoScan(uAutoScanSetupTimes);
- }
- }
- return;
- }
- //选择项的移动
- //bDownUp = FALSE;表示向下移动
- //bDownUp = TRUE;表示向上移动
- void DownUpItem(bit bDownUp)
- {
- bit bFlag = FALSE;
- unsigned char uData[7] = {0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A};
- unsigned char i = 0;
- unsigned char uEndNumTemp = 0;
- unsigned char uTemp1 = 0;
- unsigned int uTemp2 = 0;
- //主菜单
- if(bMainMenuFlag)
- {
- if(bDownUp)
- {
- switch(uMainMenuTimes)
- {
- case 1: uMainMenuTimes = 4; break;
- case 2: uMainMenuTimes = 9; break;
- case 3: uMainMenuTimes = 6; break;
- case 4: uMainMenuTimes = 1; break;
- case 5: uMainMenuTimes = 8; break;
- case 6: uMainMenuTimes = 3; break;
- case 8: uMainMenuTimes = 5; break;
- case 9: uMainMenuTimes = 2; break;
- default: uMainMenuTimes = 1;
- }
- }
- else
- { switch(uMainMenuTimes)
- {
- case 1: uMainMenuTimes = 4; break;
- case 2: uMainMenuTimes = 9; break;
- case 3: uMainMenuTimes = 6; break;
- case 4: uMainMenuTimes = 1; break;
- case 5: uMainMenuTimes = 8; break;
- case 6: uMainMenuTimes = 3; break;
- case 8: uMainMenuTimes = 5; break;
- case 9: uMainMenuTimes = 2; break;
- default: uMainMenuTimes = 1;
- }
- }
- /*chen--g
- if(uMainMenuTimes == 6)
- {
- uMainMenuTimes = 1;
- }
- else
- {
- uMainMenuTimes = uMainMenuTimes+1;
- }
- }
- else
- {
- if(uMainMenuTimes == 1)
- {
- uMainMenuTimes = 6;
- }
- else
- {
- uMainMenuTimes = uMainMenuTimes-1;
- }
- }
- chen--g*/
- MainMenu(uMainMenuTimes);
- }
- //系统参数设置
- if(bSysSetupFlag)
- {
- if(bDownUp)
- {
- if(uSysSetupTimes == 6) //chen--g 7-->6 取消屏幕亮度调节
- {
- uSysSetupTimes = 1;
- }
- else
- {
- uSysSetupTimes = uSysSetupTimes+1;
- }
- }
- else
- {
- if(uSysSetupTimes == 1)
- {
- uSysSetupTimes = 6; //chen--g 7-->6 取消屏幕亮度调节
- }
- else
- {
- uSysSetupTimes = uSysSetupTimes-1;
- }
- }
- SysSetupBarFun(uSysSetupTimes);
- }
- //云台球机和视频输入控制
- if(bPtzVideoFlag)
- {
- if(bDownUp)
- {
- if(uPtzMainBarNum == 3)
- {
- uPtzMainBarNum = 1;
- }
- else
- {
- uPtzMainBarNum = uPtzMainBarNum+1;
- }
- }
- else
- {
- if(uPtzMainBarNum == 1)
- {
- uPtzMainBarNum = 3;
- }
- else
- {
- uPtzMainBarNum = uPtzMainBarNum-1;
- }
- }
- PtzVideoControl(uPtzMainBarNum); //显示地址 视频格式
- }
- //视频输入和云台控制
- if(bVideoSignInFlag)
- {
- if(uVideoSignInBarNum == 1)
- {
- uVideoSignInBarNum = 2;
- bFlag = FALSE;
- }
- else if(uVideoSignInBarNum == 2)
- {
- uVideoSignInBarNum = 1;
- bFlag = TRUE;
- }
- else
- {
- _nop_();
- }
- VideoSignInMode(uVideoSignInAddr, uVideoSignInType, bFlag); //显示地址 视频格式
- }
- //球机其他功能操作
- if(bOtherFunFlag)
- {
- if(bDownUp)
- {
- switch(uPtzOtherFunNum)
- {
- case 1: uPtzOtherFunNum = 2; break;
- case 2: uPtzOtherFunNum = 3; break;
- case 3: uPtzOtherFunNum = 7; break;
- case 7: uPtzOtherFunNum = 13; break;
- case 13: uPtzOtherFunNum = 1; break;
- //预设值界面下的三个坐标
- case 10: uPtzOtherFunNum = 11; break; //10 预设置
- case 11: uPtzOtherFunNum = 12; break; //11 预设调用
- case 12: uPtzOtherFunNum = 10; break; //12 预设清除
- default: break;
- }
- if(bPreset_Page == 1 && uPtzOtherFunNum == 9)
- {
- if(uPresetAddr == 255)
- uPresetAddr = 0;
- else
- uPresetAddr = uPresetAddr+1;
- }
- }
- else
- {
- switch(uPtzOtherFunNum)
- {
- case 1: uPtzOtherFunNum = 13; break; //1 雨刷
- case 2: uPtzOtherFunNum = 1; break; //2 灯光
- case 3: uPtzOtherFunNum = 2; break; //3 电源
- case 7: uPtzOtherFunNum = 3; break; //7 自动巡航
- case 13: uPtzOtherFunNum = 7; break; //13 预设值界面进入标志
- //预设值界面下的三个坐标
- case 10: uPtzOtherFunNum = 12; break; //10 预设置
- case 11: uPtzOtherFunNum = 10; break; //11 预设调用
- case 12: uPtzOtherFunNum = 11; break; //12 预设清除
- default: break;
- }
- if(bPreset_Page == 1 && uPtzOtherFunNum == 9)
- {
- if(uPresetAddr == 0)
- {uPresetAddr = 255;}
-
- else
- {uPresetAddr = uPresetAddr-1;}
- }
- }
- if(bPreset_Page == 0)
- PtzFunction2(uPtzOtherFunNum); //其他功能命令
- else
- PtzOtherFun(uPtzOtherFunNum,uPresetAddr); //在预设值页面
- }
-
- //地址自动扫描
- if((bAutoScanFlag)&&(!ScanStop_Interface))
- {
- if(bDownUp)
- {
- if(uAutoScanSetupTimes == 5)
- {
- uAutoScanSetupTimes = 1;
- }
- else
- {
- uAutoScanSetupTimes = uAutoScanSetupTimes+1;
- }
- }
- else
- {
- if(uAutoScanSetupTimes == 1)
- {
- uAutoScanSetupTimes = 5;
- }
- else
- {
- uAutoScanSetupTimes = uAutoScanSetupTimes-1;
- }
- }
- PtzAddrAutoScan(uAutoScanSetupTimes);
- }
- //电源管理
- if(bPowerManageBarFlag)
- {
- if(uPowerManageBarTimes == 1)
- {
- uPowerManageBarTimes = 2;
- }
- else
- {
- uPowerManageBarTimes = 1;
- }
- PowerManageBarFun(uPowerManageBarTimes, uVolData);
- }
- //串口数据接收
- if(bComuDispDataFlag)
- {
- uTemp1 = uGetSerialDataNum/7; //页数
- if(bDownUp)
- {
- if(uComuPageNum >= uTemp1+1)
- {
- uComuPageNum = 1;
- }
- else
- {
- uComuPageNum = uComuPageNum+1;
- }
- }
- else
- {
- if(uComuPageNum == 1)
- {
- uComuPageNum = uTemp1+1;
- }
- else
- {
- uComuPageNum = uComuPageNum-1;
- }
- }
-
- uTemp2 = (uComuPageNum-1)*7; //第uComuPageNum剩下
-
- if(uComuPageNum<= uTemp1)
- {
- uEndNumTemp = 7;
- }
- else
- {
- uEndNumTemp = uGetSerialDataNum-uTemp2;
- }
-
- for(i=0; i<uEndNumTemp; i++)
- {
- uData[i] = uInbox[uTemp2+i];
- }
-
- //处理得到uEndNumTemp 数据
- ComuDisplayData(uComuPageNum,uEndNumTemp,uData);
- ComuDisplayBarNum(uComuPageNum, uGetSerialDataNum);
- }
- return;
- }
- //>2云台其他功能操作 发送相关命令
- void PtzOtherFunSendOrder(unsigned char uPtzOtherFunNumTemp)
- {
- // unsigned char uTemp;
- // uPresetAddrTemp = uPresetAddrTemp;
- switch(uPtzOtherFunNumTemp)
- {
- case 1:
- if (Wipper_state == 0)
- {
- Wipper_state = 1;
- PtzBrushOpen(uControlRuleItem); //雨刷开
- MB90092_DisChar (12,2,Open_adr,2,B_COLOR_CYAN,C_COLOR_BLACK,1); //开
- //chen test MB90092_DisChar (15,2,RingForm_adr,2,B_COLOR_CYAN,C_COLOR_RED,1); //环
- }
- else
- {
- Wipper_state = 0;
- PtzBrushClose(uControlRuleItem); //雨刷关
- MB90092_DisChar (12,2,Close_adr,2,B_COLOR_CYAN,C_COLOR_BLACK,1); //关
- //chen test MB90092_DisChar (15,2,RoundForm_adr,2,B_COLOR_CYAN,C_COLOR_RED,1); //园
- }
- break;
- case 2:
- if(Light_state ==0)
- {
- Light_state = 1;
- PtzLightOpen(uControlRuleItem); //灯光开
- MB90092_DisChar (12,3,Open_adr,2,B_COLOR_CYAN,C_COLOR_BLACK,1); //开
- //chen test MB90092_DisChar (15,3,RingForm_adr,2,B_COLOR_CYAN,C_COLOR_RED,1); //环
- }
- else
- {
- Light_state = 0;
- PtzLightClose(uControlRuleItem); //灯光关
- MB90092_DisChar (12,3,Close_adr,2,B_COLOR_CYAN,C_COLOR_BLACK,1); //关
- //chen test MB90092_DisChar (15,3,RoundForm_adr,2,B_COLOR_CYAN,C_COLOR_RED,1); //园
- }
- break;
- case 3:
- if(Power_state == 0)
- {
- Power_state = 1;
- PtzPowerOpen(uControlRuleItem); //电源开
- MB90092_DisChar (12,4,Open_adr,2,B_COLOR_CYAN,C_COLOR_BLACK,1); //开
- //chen test MB90092_DisChar (15,4,RingForm_adr,2,B_COLOR_CYAN,C_COLOR_RED,1); //环
- }
- else
- {
- Power_state = 0;
- PtzPowerClose(uControlRuleItem); //电源关
- MB90092_DisChar (12,4,Close_adr,2,B_COLOR_CYAN,C_COLOR_BLACK,1); //关
- //chen test MB90092_DisChar (15,4,RoundForm_adr,2,B_COLOR_CYAN,C_COLOR_RED,1); //园
- }
- break;
- case 7:
- if(Cruise_state ==0)
- {
- Cruise_state =1;
- PtzAutoOpen(uControlRuleItem); //自动巡航开
- MB90092_DisChar (12,5,Open_adr,2,B_COLOR_CYAN,C_COLOR_BLACK,0); //开
- //chen test MB90092_DisChar (15,5,RingForm_adr,2,B_COLOR_CYAN,C_COLOR_RED,1); //环
- }
- else
- {
- Cruise_state = 0;
- PtzAutoClose(uControlRuleItem); //自动巡航关
- MB90092_DisChar (12,5,Close_adr,2,B_COLOR_CYAN,C_COLOR_BLACK,0); //开
- //chen test MB90092_DisChar (15,5,RoundForm_adr,2,B_COLOR_CYAN,C_COLOR_RED,1); //园
- }
- break;
- case 10:
- PtzSetPreset(uControlRuleItem); //设置预置点
- //chen test MB90092_DisChar (1,1,RingForm_adr,2,B_COLOR_CYAN,C_COLOR_RED,1); //环
- break;
- case 11:
- PtzCallPreset(uControlRuleItem); //调用预置点
- //chen test MB90092_DisChar (1,2,RingForm_adr,2,B_COLOR_CYAN,C_COLOR_RED,1); //环
- break;
- case 12:
- PtzDelPreset(uControlRuleItem); //清除预置点
- //chen test MB90092_DisChar (1,1,RoundForm_adr,2,B_COLOR_CYAN,C_COLOR_RED,1); //环
- //chen test MB90092_DisChar (1,2,RoundForm_adr,2,B_COLOR_CYAN,C_COLOR_RED,1); //环
- break;
- case 13:
- //chen++
- MB90092_ClearScreen();
- MB90092_WriteByte(0xA2|4);//command 4,内、外同步选择 SYN_INTERNAL = 0、4
- MB90092_WriteByte(0x2B);
- CD4053_A = 0;
- CD4053_B = 0;
- CD4053_C = 1;
- // PtzOtherFun(uPtzOtherFunNum,uPresetAddr);
- bPreset_Page = 1;
- bPresetVideo_Flag = 1;
- bPresetSet_Flag = 0;
- break;
- }
-
- }
- //>3球机地址自动扫描
- void PtzAddrAutoScan(unsigned char uAutoScanBarNum)
- {
- unsigned char *pData = 0;
- unsigned char uTemp = 0;
- unsigned char uData[6] = 0;
-
- switch(uAutoBaudRateItem)
- {
- //case 1:
- // pData = "300bps";
- // break;
- case 1:
- pData = "600bps";
- break;
- case 2:
- pData = "1200bps";
- break;
- case 3:
- pData = "2400bps";
- break;
- case 4:
- pData = "4800bps";
- break;
- case 5:
- pData = "9600bps";
- break;
- case 6:
- pData = "19200bps";
- break;
- case 7:
- pData = "38400bps";
- break;
- case 8:
- pData = "57600bps";
- break;
- // case 10:
- // pData = "115200bps";
- // break;
- }
- AutoScanSetupRight(pData,1,uAutoScanBarNum-1); //波特率:
- switch(uAutoControlRuleItem) //控制协议目前范围 1到10
- {
- case 1:
- pData = "PELCO-D";
- break;
- case 2:
- pData = "PELCO-P";
- break;
- case 3:
- pData = "KRE-302";
- break;
- case 4:
- pData = "Philips";
- break;
- case 5:
- pData = "Samsung";
- break;
- case 6:
- pData = "ADR8060";
- break;
- case 7:
- pData = "Dali";
- break;
- case 8:
- pData = "HIKVISION";
- break;
- case 9:
- pData = "Howell";
- break;
- case 10:
- pData = "Siemens";
- break;
- }
- AutoScanSetupRight(pData,2,uAutoScanBarNum-2); //控制协议: PELCO-P PELCO-D
-
-
- //把数字转换成字符 开始地址
- pData = 0;
- uData[0] = uAutoStartAddr/100+0x30;
- uData[1] = uAutoStartAddr%100/10+0x30;
- uData[2] = uAutoStartAddr%10+0x30;
- uData[3] = '\0';
- pData = uData;
- AutoScanSetupRight(pData,3,uAutoScanBarNum-3); //开始地址:
-
-
- //把数字转换成字符 结束地址
- pData = 0;
- uData[0] = uAutoEndAddr/100+0x30;
- uData[1] = uAutoEndAddr%100/10+0x30;
- uData[2] = uAutoEndAddr%10+0x30;
- uData[3] = '\0';
- pData = uData;
- AutoScanSetupRight(pData,4,uAutoScanBarNum-4); //结束地址:
-
- //关机机时间 1秒 2秒 3秒 4秒 5秒
- pData = 0;
- uData[5] = 0;
- uData[0] = (uAutoSpaceTime)%100/10+0x30;
- uData[1] = (uAutoSpaceTime)%10+0x30;
- uData[2] = '\S';
- uData[3] = '\0';
- pData = uData;
- AutoScanSetupRight(pData,5,uAutoScanBarNum-5); //待机时间:
- }
- //系统参数设置 界面
- void SysSetupBarFun(unsigned char uSysSetupTimes)
- {
- unsigned char *pData = 0;
- unsigned char uTemp = 0;
- unsigned char uData[6] = 0;
-
- switch(uControlRuleItem) //控制协议目前范围 1到10
- {
- case 1:
- pData = "PELCO-D";
- break;
- case 2:
- pData = "PELCO-P";
- break;
- case 3:
- pData = "KRE-302";
- break;
- case 4:
- pData = "Philips";
- break;
- case 5:
- pData = "Samsung";
- break;
- case 6:
- pData = "ADR8060";
- break;
- case 7:
- pData = "Dali";
- break;
- case 8:
- pData = "HIKVISION";
- break;
- case 9:
- pData = "Howell";
- break;
- case 10:
- pData = "Siemens";
- break;
- }
- SysSetupRight(pData,1,uSysSetupTimes-1); //控制协议: PELCO-P PELCO-D
- switch(uComSereialItem)
- {
- case 1:
- pData = "232";
- break;
- case 2:
- pData = "485";
- break;
- }
- SysSetupRight(pData,2,uSysSetupTimes-2); //通信串口:
- switch(uBaudRateItem)
- {
- //case 1:
- // pData = "300bps";
- // break;
- case 1:
- pData = "600bps";
- break;
- case 2:
- pData = "1200bps";
- break;
- case 3:
- pData = "2400bps";
- break;
- case 4:
- pData = "4800bps";
- break;
- case 5:
- pData = "9600bps";
- break;
- case 6:
- pData = "19200bps";
- break;
- case 7:
- pData = "38400bps";
- break;
- case 8:
- pData = "57600bps";
- break;
- //case 10:
- // pData = "115200bps";
- // break;
- }
-
- SysSetupRight(pData,3,uSysSetupTimes-3); //波特率:
- //把数字转换成字符 运行速度
- pData = 0;
- uData[0] = uRunSpeedData/100+0x30;
- uData[1] = uRunSpeedData%100/10+0x30;
- uData[2] = uRunSpeedData%10+0x30;
- uData[3] = '\@';
- uData[4] = '\#';
- uData[5] = '\0';
- pData = uData;
- SysSetupRight(pData,4,uSysSetupTimes-4); //运行速度:
-
- //关机机时间
- pData = 0;
- uData[5] = 0;
- uData[0] = (uStandbyTime*5)%100/10+0x30;
- uData[1] = (uStandbyTime*5)%10+0x30;
- uData[2] = '\
- ;
- uData[3] = '\%';
- uData[4] = '\0';
- pData = uData;
- SysSetupRight(pData,5,uSysSetupTimes-5); //待机时间:
-
- //网线速度
- pData = 0;
- uData[5] = 0;
- uData[0] = uNetSpeed%100/10+0x30;
- uData[1] = uNetSpeed%10+0x30;
- uData[2] = '\@';
- uData[3] = '\#';
- uData[4] = '\0';
- pData = uData;
- SysSetupRight(pData,6,uSysSetupTimes-6);
- /* chen-- 取消屏幕亮度显示
- //屏幕亮度
- pData = 0;
- uData[5] = 0;
- uData[0] = uLcdBright%100/10+0x30;
- uData[1] = uLcdBright%10+0x30;
- // uData[0] = '\(';
- // uData[1] = '\)';
- uData[2] = '\&'; //级
- uData[3] = '\0';
- pData = uData;
- SysSetupRight(pData,7,uSysSetupTimes-7); //屏幕亮度: 暂无
- */
- }
- /////////////////////////////////////////////PTZ///////////////////////////////////////////////////////
- //============================
- //函数名:ProtocolCalculation
- //作用:用于不同协议码地址的更新和校验码的计算
- //输入参数:无
- //输出参数:无
- //============================
- void ProtocolCalculation(unsigned char uSerialType)
- {
- if(uControlRuleItem == 1)
- {
- PELCO_D[1]=(unsigned char)AddressSave;
- PELCO_D[6]=(unsigned char)(PELCO_D[1]+PELCO_D[2]+PELCO_D[3]+PELCO_D[4]+PELCO_D[5]);
- if(uSerialType == 2) //485
- Send_UART_Two(PELCO_D,7); //发送串口数据
- if(uSerialType == 1) //232
- Send_UART_One(PELCO_D,7); //发送串口数据
- }
- if(uControlRuleItem == 2)
- {
- PELCO_P[1]=(unsigned char)AddressSave-1;
- PELCO_P[7]=(unsigned char)(PELCO_P[0]^PELCO_P[1]^PELCO_P[2]^PELCO_P[3]^PELCO_P[4]^PELCO_P[5]^PELCO_P[6]);
- if(uSerialType == 2) //485
- Send_UART_Two(PELCO_P,8); //发送串口数据
- if(uSerialType == 1) //232
- Send_UART_One(PELCO_P,8); //发送串口数据
- }
- if(uControlRuleItem == 3)
- {
- KRE_302[2]=(unsigned char)AddressSave;
- if(uSerialType == 2) //485
- Send_UART_Two(KRE_302,6); //发送串口数据
- if(uSerialType == 1) //232
- Send_UART_One(KRE_302,6); //发送串口数据
- }
- if(uControlRuleItem == 4)
- {
- Philips[2]=(unsigned char)AddressSave;
- Philips[7]=(unsigned char)(Philips[0]+Philips[1]+Philips[2]+Philips[3]+Philips[4]+Philips[5]+Philips[6]);
- if(uSerialType == 2) //485
- Send_UART_Two(Philips,8); //发送串口数据
- if(uSerialType == 1) //232
- Send_UART_One(Philips,8); //发送串口数据
- }
- if(uControlRuleItem == 5)
- {
- Samsung[1]=(unsigned char)AddressSave;
- Samsung[8]=(unsigned char)(~(Samsung[1]+Samsung[2]+Samsung[3]+Samsung[4]+Samsung[5]+Samsung[6]+Samsung[7]));
- if(uSerialType == 2) //485
- Send_UART_Two(Samsung,9); //发送串口数据
- if(uSerialType == 1) //232
- Send_UART_One(Samsung,9); //发送串口数据
- }
- if(uControlRuleItem == 6)
- {
- ADR8060[2]=(unsigned char)AddressSave;
- ADR8060[4]=(unsigned char)(ADR8060[0]+ADR8060[1]+ADR8060[2]+ADR8060[3]);
- if(uSerialType == 2) //485
- Send_UART_Two(ADR8060,5); //发送串口数据
- if(uSerialType == 1) //232
- Send_UART_One(ADR8060,5); //发送串口数据
- }
- if(uControlRuleItem == 7)
- {
- Dali[1]=(unsigned char)AddressSave;
- Dali[5]=(unsigned char)(Dali[0]^Dali[1]^Dali[2]^Dali[3]^Dali[4]);
- if(uSerialType == 2) //485
- Send_UART_Two(Dali,6); //发送串口数据
- if(uSerialType == 1) //232
- Send_UART_One(Dali,6); //发送串口数据
- }
- if(uControlRuleItem == 8)
- {
- HIKVISION[1]=(unsigned char)AddressSave;
- HIKVISION[7]=(unsigned char)(HIKVISION[0]+HIKVISION[1]+HIKVISION[2]+HIKVISION[3]+HIKVISION[4]+HIKVISION[5]+HIKVISION[6]);
- if(uSerialType == 2) //485
- Send_UART_Two(HIKVISION,8); //发送串口数据
- if(uSerialType == 1) //232
- Send_UART_One(HIKVISION,8); //发送串口数据
- }
- if(uControlRuleItem == 9)
- {
- Howell[1]=(unsigned char)AddressSave;
- if(uSerialType == 2) //485
- Send_UART_Two(Howell,4); //发送串口数据
- if(uSerialType == 1) //232
- Send_UART_One(Howell,4); //发送串口数据
- }
- if(uControlRuleItem == 10)
- {
- Siemens[1]=(unsigned char)AddressSave;
- if(KeyValueSave==0) //向上
- {
- Siemens[2]=0x84;
- }
- else if(KeyValueSave==3) //向左
- {
- Siemens[2]=0x81;
- }
- else if(KeyValueSave==4) //向右
- {
- Siemens[2]=0x82;
- }
- else if(KeyValueSave==7)//向下
- {
- Siemens[2]=0x85;
- }
- else
- {
- Siemens[2]=~(Siemens[0]+Siemens[1])+1;
- }
- Siemens[4]=~(Siemens[0]+Siemens[1]+Siemens[2]+Siemens[3])+1;
-
- if(uSerialType == 2) //485
- Send_UART_Two(Siemens,5); //发送串口数据
- if(uSerialType == 1) //232
- Send_UART_One(Siemens,5); //发送串口数据
- }
- }
- //============================
- //函数名:AutoProtocolCalculation
- //作用:用于不同协议码地址的更新和校验码的计算
- //输入参数:无
- //输出参数:无
- //============================
- void AutoProtocolCalculation(unsigned char uSerialType)
- {
- if(uAutoControlRuleItem == 1)
- {
- PELCO_D[1]=(unsigned char)uAutoSendTempAddr;
- PELCO_D[6]=(unsigned char)(PELCO_D[1]+PELCO_D[2]+PELCO_D[3]+PELCO_D[4]+PELCO_D[5]);
- if(uSerialType == 2) //485
- Send_UART_Two(PELCO_D,7); //发送串口数据
- if(uSerialType == 1) //232
- Send_UART_One(PELCO_D,7); //发送串口数据
- }
- if(uAutoControlRuleItem == 2)
- {
- PELCO_P[1]=(unsigned char)uAutoSendTempAddr-1;
- PELCO_P[7]=(unsigned char)(PELCO_P[0]^PELCO_P[1]^PELCO_P[2]^PELCO_P[3]^PELCO_P[4]^PELCO_P[5]^PELCO_P[6]);
- if(uSerialType == 2) //485
- Send_UART_Two(PELCO_P,8); //发送串口数据
- if(uSerialType == 1) //232
- Send_UART_One(PELCO_P,8); //发送串口数据
- }
- if(uAutoControlRuleItem == 3)
- {
- KRE_302[2]=(unsigned char)uAutoSendTempAddr;
- if(uSerialType == 2) //485
- Send_UART_Two(KRE_302,6); //发送串口数据
- if(uSerialType == 1) //232
- Send_UART_One(KRE_302,6); //发送串口数据
- }
- if(uAutoControlRuleItem == 4)
- {
- Philips[2]=(unsigned char)uAutoSendTempAddr;
- Philips[7]=(unsigned char)(Philips[0]+Philips[1]+Philips[2]+Philips[3]+Philips[4]+Philips[5]+Philips[6]);
- if(uSerialType == 2) //485
- Send_UART_Two(Philips,8); //发送串口数据
- if(uSerialType == 1) //232
- Send_UART_One(Philips,8); //发送串口数据
- }
- if(uAutoControlRuleItem == 5)
- {
- Samsung[1]=(unsigned char)uAutoSendTempAddr;
- Samsung[8]=(unsigned char)(~(Samsung[1]+Samsung[2]+Samsung[3]+Samsung[4]+Samsung[5]+Samsung[6]+Samsung[7]));
- if(uSerialType == 2) //485
- Send_UART_Two(Samsung,9); //发送串口数据
- if(uSerialType == 1) //232
- Send_UART_One(Samsung,9); //发送串口数据
- }
- if(uAutoControlRuleItem == 6)
- {
- ADR8060[2]=(unsigned char)uAutoSendTempAddr;
- ADR8060[4]=(unsigned char)(ADR8060[0]+ADR8060[1]+ADR8060[2]+ADR8060[3]);
- if(uSerialType == 2) //485
- Send_UART_Two(ADR8060,5); //发送串口数据
- if(uSerialType == 1) //232
- Send_UART_One(ADR8060,5); //发送串口数据
- }
- if(uAutoControlRuleItem == 7)
- {
- Dali[1]=(unsigned char)uAutoSendTempAddr;
- Dali[5]=(unsigned char)(Dali[0]^Dali[1]^Dali[2]^Dali[3]^Dali[4]);
- if(uSerialType == 2) //485
- Send_UART_Two(Dali,6); //发送串口数据
- if(uSerialType == 1) //232
- Send_UART_One(Dali,6); //发送串口数据
- }
- if(uAutoControlRuleItem == 8)
- {
- HIKVISION[1]=(unsigned char)uAutoSendTempAddr;
- HIKVISION[7]=(unsigned char)(HIKVISION[0]+HIKVISION[1]+HIKVISION[2]+HIKVISION[3]+HIKVISION[4]+HIKVISION[5]+HIKVISION[6]);
- if(uSerialType == 2) //485
- Send_UART_Two(HIKVISION,8); //发送串口数据
- if(uSerialType == 1) //232
- Send_UART_One(HIKVISION,8); //发送串口数据
- }
- if(uAutoControlRuleItem == 9)
- {
- Howell[1]=(unsigned char)uAutoSendTempAddr;
- if(uSerialType == 2) //485
- Send_UART_Two(Howell,4); //发送串口数据
- if(uSerialType == 1) //232
- Send_UART_One(Howell,4); //发送串口数据
- }
- if(uAutoControlRuleItem == 10)
- {
- Siemens[1]=(unsigned char)uAutoSendTempAddr;
- if(KeyValueSave==0) //向上
- {
- Siemens[2]=0x84;
- }
- else if(KeyValueSave==3) //向左
- {
- Siemens[2]=0x81;
- }
- else if(KeyValueSave==4) //向右
- {
- Siemens[2]=0x82;
- }
- else if(KeyValueSave==7)//向下
- {
- Siemens[2]=0x85;
- }
- else
- {
- Siemens[2]=~(Siemens[0]+Siemens[1])+1;
- }
- Siemens[4]=~(Siemens[0]+Siemens[1]+Siemens[2]+Siemens[3])+1;
-
- if(uSerialType == 2) //485
- Send_UART_Two(Siemens,5); //发送串口数据
- if(uSerialType == 1) //232
- Send_UART_One(Siemens,5); //发送串口数据
- }
- }
- //光圈关
- void PtzIrisClose(unsigned char uProtocolType)
- {
- if(uProtocolType == 1) //PELCO_D
- {
- PELCO_D[2]=0x04;
- PELCO_D[3]=0x00;
- PELCO_D[4]=0x00;
- PELCO_D[5]=0x00;
- }
- if(uProtocolType == 2)//PELCO_P
- {
- PELCO_P[2]=0x08;
- PELCO_P[3]=0x00;
- PELCO_P[4]=0x00;
- PELCO_P[5]=0x00;
- }
- if(uProtocolType == 3) //KRE_302
- {
- KRE_302[4]=0x07;
- }
- if(uProtocolType == 4) //Philips
- {
- Philips[3]=0x00;
- Philips[4]=0x00;
- Philips[5]=0x00;
- Philips[6]=0x00;
- }
- if(uProtocolType == 5) //Samsung
- {
- Samsung[4]=0x08;
- Samsung[5]=0x00;
- Samsung[6]=0x00;
- Samsung[7]=0x00;
- }
- if(uProtocolType == 6) //ADR8060
- {
- ADR8060[3]=0x60;
- }
- if(uProtocolType == 7) //Dali
- {
- Dali[3]=0x06;
- }
- if(uProtocolType == 8) //HIKVISION
- {
- HIKVISION[2]=0x0E;
- HIKVISION[3]=0x00;
- HIKVISION[4]=0x00;
- }
- if(uProtocolType == 9) //Howell
- {
- Howell[2]=0xB7;
- Howell[3]=0xF1;
- }
- if(uProtocolType == 10) // Siemens
- {
- Siemens[1]=0x91;
- Siemens[3]=0x00;
- }
- ProtocolCalculation(uComSereialItem);
- }
- //光圈开
- void PtzIrisOpen(unsigned char uProtocolType)
- {
- if(uProtocolType == 1) //PELCO_D
- {
- PELCO_D[2]=0x02;
- PELCO_D[3]=0x00;
- PELCO_D[4]=0x00;
- PELCO_D[5]=0x00;
- }
- if(uProtocolType == 2)//PELCO_P
- {
- PELCO_P[2]=0x04;
- PELCO_P[3]=0x00;
- PELCO_P[4]=0x00;
- PELCO_P[5]=0x00;
- }
- if(uProtocolType == 3) //KRE_302
- {
- KRE_302[4]=0x06;
- }
- if(uProtocolType == 4) //Philips
- {
- Philips[3]=0x00;
- Philips[4]=0x00;
- Philips[5]=0x00;
- Philips[6]=0x00;
- }
- if(uProtocolType == 5) //Samsung
- {
- Samsung[4]=0x10;
- Samsung[5]=0x00;
- Samsung[6]=0x00;
- Samsung[7]=0x00;
- }
- if(uProtocolType == 6) //ADR8060
- {
- ADR8060[3]=0x80;
- }
- if(uProtocolType == 7) //Dali
- {
- Dali[3]=0x05;
- }
- if(uProtocolType == 8) //HIKVISION
- {
- HIKVISION[2]=0x0F;
- HIKVISION[3]=0x00;
- HIKVISION[4]=0x00;
- }
- if(uProtocolType == 9) //Howell
- {
- Howell[2]=0xB6;
- Howell[3]=0xF1;
- }
- if(uProtocolType == 10) // Siemens
- {
- Siemens[1]=0x90;
- Siemens[3]=0x00;
- }
- ProtocolCalculation(uComSereialItem);
- }
- //焦距近
- void PtzFocusNear(unsigned char uProtocolType)
- {
- if(uProtocolType == 1) //PELCO_D
- {
- PELCO_D[2]=0x01;
- PELCO_D[3]=0x00;
- PELCO_D[4]=0x00;
- PELCO_D[5]=0x00;
- }
- if(uProtocolType == 2)//PELCO_P
- {
- PELCO_P[2]=0x02;
- PELCO_P[3]=0x00;
- PELCO_P[4]=0x00;
- PELCO_P[5]=0x00;
- }
- if(uProtocolType == 3) //KRE_302
- {
- KRE_302[4]=0x05;
- }
- if(uProtocolType == 4) //Philips
- {
- Philips[3]=0x00;
- Philips[4]=0x00;
- Philips[5]=0x00;
- Philips[6]=0x40;
- }
- if(uProtocolType == 5) //Samsung
- {
- Samsung[4]=0x02;
- Samsung[5]=0x00;
- Samsung[6]=0x00;
- Samsung[7]=0x00;
- }
- if(uProtocolType == 6) //ADR8060
- {
- ADR8060[3]=0x40;
- }
- if(uProtocolType == 7) //Dali
- {
- Dali[3]=0x09;
- }
- if(uProtocolType == 8) //HIKVISION
- {
- HIKVISION[2]=0x10;
- HIKVISION[3]=0x00;
- HIKVISION[4]=0x00;
- }
- if(uProtocolType == 9) //Howell
- {
- Howell[2]=0xB9;
- Howell[3]=0xF1;
- }
- if(uProtocolType == 10) // Siemens
- {
- Siemens[1]=0x87;
- Siemens[3]=0x00;
- }
- ProtocolCalculation(uComSereialItem);
- }
- //焦距远
- void PtzFocusFar(unsigned char uProtocolType)
- {
- if(uProtocolType == 1) //PELCO_D
- {
- PELCO_D[2]=0x00;
- PELCO_D[3]=0x80;
- PELCO_D[4]=0x00;
- PELCO_D[5]=0x00;
- }
- if(uProtocolType == 2)//PELCO_P
- {
- PELCO_P[2]=0x01;
- PELCO_P[3]=0x00;
- PELCO_P[4]=0x00;
- PELCO_P[5]=0x00;
- }
- if(uProtocolType == 3) //KRE_302
- {
- KRE_302[4]=0x04;
- }
- if(uProtocolType == 4) //Philips
- {
- Philips[3]=0x00;
- Philips[4]=0x00;
- Philips[5]=0x01;
- Philips[6]=0x00;
- }
- if(uProtocolType == 5) //Samsung
- {
- Samsung[4]=0x01;
- Samsung[5]=0x00;
- Samsung[6]=0x00;
- Samsung[7]=0x00;
- }
- if(uProtocolType == 6) //ADR8060
- {
- ADR8060[3]=0x30;
- }
- if(uProtocolType == 7) //Dali
- {
- Dali[3]=0x0A;
- }
- if(uProtocolType == 8) //HIKVISION
- {
- HIKVISION[2]=0x11;
- HIKVISION[3]=0x00;
- HIKVISION[4]=0x00;
- }
- if(uProtocolType == 9) //Howell
- {
- Howell[2]=0xB8;
- Howell[3]=0xF1;
- }
- if(uProtocolType == 10) // Siemens
- {
- Siemens[1]=0x88;
- Siemens[3]=0x00;
- }
- ProtocolCalculation(uComSereialItem);
- }
- //放大 变倍远
- void PtzZoomWide(unsigned char uProtocolType)
- {
- if(uProtocolType == 1) //PELCO_D
- {
- PELCO_D[2]=0x00;
- PELCO_D[3]=0x20;
- PELCO_D[4]=0x00;
- PELCO_D[5]=0x00;
- }
- if(uProtocolType == 2)//PELCO_P
- {
- PELCO_P[2]=0x00;
- PELCO_P[3]=0x20;
- PELCO_P[4]=0x00;
- PELCO_P[5]=0x00;
- }
- if(uProtocolType == 3) //KRE_302
- {
- KRE_302[4]=0x09;
- }
- if(uProtocolType == 4) //Philips
- {
- Philips[3]=0x00;
- Philips[4]=0x00;
- Philips[5]=0x00;
- Philips[6]=0x10;
- }
- if(uProtocolType == 5) //Samsung
- {
- Samsung[4]=0x20;
- Samsung[5]=0x00;
- Samsung[6]=0x00;
- Samsung[7]=0x00;
- }
- if(uProtocolType == 6) //ADR8060
- {
- ADR8060[3]=0x10;
- }
- if(uProtocolType == 7) //Dali
- {
- Dali[3]=0x07;
- }
- if(uProtocolType == 8) //HIKVISION
- {
- HIKVISION[2]=0x13;
- HIKVISION[3]=0x00;
- HIKVISION[4]=0x00;
- }
- if(uProtocolType == 9) //Howell
- {
- Howell[2]=0xBA;
- Howell[3]=0xF1;
- }
- if(uProtocolType == 10) // Siemens
- {
- Siemens[1]=0x8A;
- Siemens[3]=0x00;
- }
- ProtocolCalculation(uComSereialItem);
- }
- //缩小 变倍近
- void PtzZoomTele(unsigned char uProtocolType)
- {
- if(uProtocolType == 1) //PELCO_D
- {
- PELCO_D[2]=0x00;
- PELCO_D[3]=0x40;
- PELCO_D[4]=0x00;
- PELCO_D[5]=0x00;
- }
- if(uProtocolType == 2)//PELCO_P
- {
- PELCO_P[2]=0x00;
- PELCO_P[3]=0x40;
- PELCO_P[4]=0x00;
- PELCO_P[5]=0x00;
- }
- if(uProtocolType == 3) //KRE_302
- {
- KRE_302[4]=0x08;
- }
- if(uProtocolType == 4) //Philips
- {
- Philips[3]=0x00;
- Philips[4]=0x00;
- Philips[5]=0x00;
- Philips[6]=0x20;
- }
- if(uProtocolType == 5) //Samsung
- {
- Samsung[4]=0x40;
- Samsung[5]=0x00;
- Samsung[6]=0x00;
- Samsung[7]=0x00;
- }
- if(uProtocolType == 6) //ADR8060
- {
- ADR8060[3]=0x20;
- }
- if(uProtocolType == 7) //Dali
- {
- Dali[3]=0x08;
- }
- if(uProtocolType == 8) //HIKVISION
- {
- HIKVISION[2]=0x12;
- HIKVISION[3]=0x00;
- HIKVISION[4]=0x00;
- }
- if(uProtocolType == 9) //Howell
- {
- Howell[2]=0xBB;
- Howell[3]=0xF1;
- }
- if(uProtocolType == 10) // Siemens
- {
- Siemens[1]=0x8B;
- Siemens[3]=0x00;
- }
- ProtocolCalculation(uComSereialItem);
- }
- //云台向下
- void PtzDown(unsigned char uProtocolType)
- {
- if(uProtocolType == 1) //PELCO_D
- {
- PELCO_D[2]=0x00;
- PELCO_D[3]=0x10;
- PELCO_D[4]=0x00;
- PELCO_D[5]=uRunSpeedData;
- }
- if(uProtocolType == 2)//PELCO_P
- {
- PELCO_P[2]=0x00;
- PELCO_P[3]=0x10;
- PELCO_P[4]=0x00;
- PELCO_P[5]=uRunSpeedData;
- }
- if(uProtocolType == 3) //KRE_302
- {
- KRE_302[4]=0x01;
- }
- if(uProtocolType == 4) //Philips
- {
- Philips[3]=0x0E;
- Philips[4]=0x30;
- Philips[5]=0x00;
- Philips[6]=0x04;
- }
- if(uProtocolType == 5) //Samsung
- {
- Samsung[4]=0x00;
- Samsung[5]=0x08;
- Samsung[6]=0x00;
- Samsung[7]=uRunSpeedData;
- }
- if(uProtocolType == 6) //ADR8060
- {
- ADR8060[3]=0x02;
- }
- if(uProtocolType == 7) //Dali
- {
- Dali[3]=0x02;
- }
- if(uProtocolType == 8) //HIKVISION
- {
- HIKVISION[2]=0x07;
- HIKVISION[3]=0x1F;
- HIKVISION[4]=0x00;
- }
- if(uProtocolType == 9) //Howell
- {
- Howell[2]=0xB1;
- Howell[3]=0x10;
- }
- if(uProtocolType == 10) // Siemens
- {
- Siemens[1]=0xC0;
- Siemens[3]=0x32;
- }
- ProtocolCalculation(uComSereialItem);
- }
- //AUTO 云台向下
- void AutoPtzDown(unsigned char uProtocolType)
- {
- if(uProtocolType == 1) //PELCO_D
- {
- PELCO_D[2]=0x00;
- PELCO_D[3]=0x10;
- PELCO_D[4]=0x00;
- PELCO_D[5]=uRunSpeedData;
- }
- if(uProtocolType == 2)//PELCO_P
- {
- PELCO_P[2]=0x00;
- PELCO_P[3]=0x10;
- PELCO_P[4]=0x00;
- PELCO_P[5]=uRunSpeedData;
- }
- if(uProtocolType == 3) //KRE_302
- {
- KRE_302[4]=0x01;
- }
- if(uProtocolType == 4) //Philips
- {
- Philips[3]=0x0E;
- Philips[4]=0x30;
- Philips[5]=0x00;
- Philips[6]=0x04;
- }
- if(uProtocolType == 5) //Samsung
- {
- Samsung[4]=0x00;
- Samsung[5]=0x08;
- Samsung[6]=0x00;
- Samsung[7]=uRunSpeedData;
- }
- if(uProtocolType == 6) //ADR8060
- {
- ADR8060[3]=0x02;
- }
- if(uProtocolType == 7) //Dali
- {
- Dali[3]=0x02;
- }
- if(uProtocolType == 8) //HIKVISION
- {
- HIKVISION[2]=0x07;
- HIKVISION[3]=0x1F;
- HIKVISION[4]=0x00;
- }
- if(uProtocolType == 9) //Howell
- {
- Howell[2]=0xB1;
- Howell[3]=0x10;
- }
- if(uProtocolType == 10) // Siemens
- {
- Siemens[1]=0xC0;
- Siemens[3]=0x32;
- }
- AutoProtocolCalculation(uComSereialItem);
- }
- //云台向上
- void PtzUp(unsigned char uProtocolType)
- {
- if(uProtocolType == 1) //PELCO_D
- {
- PELCO_D[2]=0x00;
- PELCO_D[3]=0x08;
- PELCO_D[4]=0x00;
- PELCO_D[5]=uRunSpeedData;
- }
- if(uProtocolType == 2)//PELCO_P
- {
- PELCO_P[2]=0x00;
- PELCO_P[3]=0x08;
- PELCO_P[4]=0x00;
- PELCO_P[5]=uRunSpeedData;
- }
- if(uProtocolType == 3) //KRE_302
- {
- KRE_302[4]=0x00;
- }
- if(uProtocolType == 4) //Philips
- {
- Philips[3]=0x0E;
- Philips[4]=0x30;
- Philips[5]=0x00;
- Philips[6]=0x08;
- }
- if(uProtocolType == 5) //Samsung
- {
- Samsung[4]=0x00;
- Samsung[5]=0x04;
- Samsung[6]=0x00;
- Samsung[7]=uRunSpeedData;
- }
- if(uProtocolType == 6) //ADR8060
- {
- ADR8060[3]=0x01;
- }
- if(uProtocolType == 7) //Dali
- {
- Dali[3]=0x01;
- }
- if(uProtocolType == 8) //HIKVISION
- {
- HIKVISION[2]=0x06;
- HIKVISION[3]=0x1F;
- HIKVISION[4]=0x00;
- }
- if(uProtocolType == 9) //Howell
- {
- Howell[2]=0xB0;
- Howell[3]=0x10;
- }
- if(uProtocolType == 10) // Siemens
- {
- Siemens[1]=0xC0;
- Siemens[3]=0x32;
- }
- ProtocolCalculation(uComSereialItem);
- }
- //自动云台向上
- void AutoPtzUp(unsigned char uProtocolType)
- {
- if(uProtocolType == 1) //PELCO_D
- {
- PELCO_D[2]=0x00;
- PELCO_D[3]=0x08;
- PELCO_D[4]=0x00;
- PELCO_D[5]=0x30;
- }
- if(uProtocolType == 2)//PELCO_P
- {
- PELCO_P[2]=0x00;
- PELCO_P[3]=0x08;
- PELCO_P[4]=0x00;
- PELCO_P[5]=0x30;
- }
- if(uProtocolType == 3) //KRE_302
- {
- KRE_302[4]=0x00;
- }
- if(uProtocolType == 4) //Philips
- {
- Philips[3]=0x0E;
- Philips[4]=0x30;
- Philips[5]=0x00;
- Philips[6]=0x08;
- }
- if(uProtocolType == 5) //Samsung
- {
- Samsung[4]=0x00;
- Samsung[5]=0x04;
- Samsung[6]=0x00;
- Samsung[7]=uRunSpeedData;
- }
- if(uProtocolType == 6) //ADR8060
- {
- ADR8060[3]=0x01;
- }
- if(uProtocolType == 7) //Dali
- {
- Dali[3]=0x01;
- }
- if(uProtocolType == 8) //HIKVISION
- {
- HIKVISION[2]=0x06;
- HIKVISION[3]=0x1F;
- HIKVISION[4]=0x00;
- }
- if(uProtocolType == 9) //Howell
- {
- Howell[2]=0xB0;
- Howell[3]=0x10;
- }
- if(uProtocolType == 10) // Siemens
- {
- Siemens[1]=0xC0;
- Siemens[3]=0x32;
- }
- AutoProtocolCalculation(uComSereialItem);
- }
- //云台向左
- void PtzLeft(unsigned char uProtocolType)
- {
- if(uProtocolType == 1) //PELCO_D
- {
- PELCO_D[2]=0x00;
- PELCO_D[3]=0x04;
- PELCO_D[4]=uRunSpeedData;
- PELCO_D[5]=0x00;
- }
- if(uProtocolType == 2)//PELCO_P
- {
- PELCO_P[2]=0x00;
- PELCO_P[3]=0x04;
- PELCO_P[4]=uRunSpeedData;
- PELCO_P[5]=0x00;
- }
- if(uProtocolType == 3) //KRE_302
- {
- KRE_302[4]=0x02;
- }
- if(uProtocolType == 4) //Philips
- {
- Philips[3]=0x0E;
- Philips[4]=0x30;
- Philips[5]=0x00;
- Philips[6]=0x02;
- }
- if(uProtocolType == 5) //Samsung
- {
- Samsung[4]=0x00;
- Samsung[5]=0x01;
- Samsung[6]=uRunSpeedData;
- Samsung[7]=0x00;
- }
- if(uProtocolType == 6) //ADR8060
- {
- ADR8060[3]=0x04;
- }
- if(uProtocolType == 7) //Dali
- {
- Dali[3]=0x03;
- }
- if(uProtocolType == 8) //HIKVISION
- {
- HIKVISION[2]=0x09;
- HIKVISION[3]=0x00;
- HIKVISION[4]=0x1F;
- }
- if(uProtocolType == 9) //Howell
- {
- Howell[2]=0xAE;
- Howell[3]=0x10;
- }
- if(uProtocolType == 10) // Siemens
- {
- Siemens[1]=0xC0;
- Siemens[3]=0x32;
- }
- ProtocolCalculation(uComSereialItem);
- }
- //云台向右
- void PtzRight(unsigned char uProtocolType)
- {
- if(uProtocolType == 1) //PELCO_D
- {
- PELCO_D[2]=0x00;
- PELCO_D[3]=0x02;
- PELCO_D[4]=uRunSpeedData;
- PELCO_D[5]=0x00;
- }
- if(uProtocolType == 2)//PELCO_P
- {
- PELCO_P[2]=0x00;
- PELCO_P[3]=0x02;
- PELCO_P[4]=uRunSpeedData;
- PELCO_P[5]=0x00;
- }
- if(uProtocolType == 3) //KRE_302
- {
- KRE_302[4]=0x03;
- }
- if(uProtocolType == 4) //Philips
- {
- Philips[3]=0x0E;
- Philips[4]=0x30;
- Philips[5]=0x00;
- Philips[6]=0x01;
- }
- if(uProtocolType == 5) //Samsung
- {
- Samsung[4]=0x00;
- Samsung[5]=0x02;
- Samsung[6]=uRunSpeedData;
- Samsung[7]=0x00;
- }
- if(uProtocolType == 6) //ADR8060
- {
- ADR8060[3]=0x08;
- }
- if(uProtocolType == 7) //Dali
- {
- Dali[3]=0x04;
- }
- if(uProtocolType == 8) //HIKVISION
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
工程宝资料.rar
(91.57 KB, 下载次数: 73)
|