📄 commoninterface.c
字号:
#include "typedef.h"
#include "global.h"
#include "commoninterface.h"
#include <string.h>
#include "common_function.h"
#include "systemmanager.h"
#include "nvram.h"
#include "menubuffer.h"
#include "glitter.h"
#include "menuprocess.h"
#include "nf_config.h"
#include "playsound.h"
extern xdata SYSTEM_INFO systemInfo;
extern xdata DEVICEINFO deviceInfo;
extern xdata BUS_INFO busInfo;//线路当前信息
extern xdata SIMCARD_INFO simInfo;
extern Uchar volatile xdata D12_Y1;
extern idata Uchar D16CS;//D12_Y1的寄存器
/*获取服务器IP和端口,主机func1*/
void get_serverIp(unsigned char *ptr)
{
char *tmpPtr;
tmpPtr = ptr;
*tmpPtr++ = systemInfo.ipAddr[0];
*tmpPtr++ = systemInfo.ipAddr[1];
*tmpPtr++ = systemInfo.ipAddr[2];
*tmpPtr++ = systemInfo.ipAddr[3];
*tmpPtr++ = systemInfo.ipAddr[4];
*tmpPtr++ = systemInfo.ipAddr[5];
return;
}
/*func2*/
void get_device_id(unsigned char *value)
{
memcpy(value, deviceInfo.deviceId, DEVICEID_LEN);
}
void get_bus_id(unsigned char *value)
{
memcpy(value, busInfo.busId, BUSID_LEN);
}
/*向指定的3字节内存填入当前时间,顺序为时分秒;func2*/
void get_term_time(unsigned char *value)
{
unsigned char *ptr;
ptr = value;
*ptr++ = bin2bcd(systemInfo.hour);
*ptr++ = bin2bcd(systemInfo.min);
*ptr++ = bin2bcd(systemInfo.sec);
}
/*func2*/
void get_cur_direction(unsigned char *value)
{
*value = busInfo.direction;
}
/*func2*/
void get_driver_id(unsigned char *value)
{
memcpy(value, busInfo.driverID, DRIVERID_LEN);
}
/*原主机中定义,获取主机软件版本信息,func2*/
void get_device_info(unsigned char *value)
{
value[0] = deviceInfo.softDate[0];
value[1] = deviceInfo.softDate[1];
value[2] = deviceInfo.softDate[2];
value[3] = deviceInfo.softVer;
}
/*当前运行模式:包车等,func2*/
void get_cur_runmode(unsigned char *value)
{
*value = systemInfo.runMode;
}
/*当前线路模式,模式1等,func2*/
void get_cur_mode(unsigned char *value)
{
*value = busInfo.modeNum;
}
/*主机获取软件的版本号(只有版本没有版本日期),func2*/
void get_software_version(unsigned char *value)
{
*value = deviceInfo.softVer;
}
void get_gpsStatus(unsigned char* value)
{
*value = systemInfo.gpsState;
}
void get_gprsStatus(unsigned char* value)
{
*value = systemInfo.gprsState;
}
/***设置SIM卡号,func3****/
void setSimCard(unsigned char* pBuf, unsigned char nLen)
{
simInfo.validFlag = TERM_PARA_VALID;
memcpy(simInfo.card, pBuf, nLen);
}
/*到站距离,func2*/
void get_arrive_meter(unsigned char *value)
{
*value = systemInfo.arriveMeter;
}
/*出站距离,func2*/
void get_left_meter(unsigned char *value)
{
*value = systemInfo.leftMeter;
}
/*获取电话本,func2*/
void get_telephone_list(unsigned char *value)
{
//需要确定电话号码保存在什么为?E2/Flash?
nvram_read(NVRAM_TELEPHONE_LIST, value);
}
/************&&&&&%%%%%%%%%%%%%%%%%%%&&&&&&&*****************/
/***********************************************************
*背光处理模块
***************************************************************/
bit gLightStatus;//值为1表示要求背光打开,值为0表示要求背光关闭
/****************************************
*value:1 开背光
0 关背光
*****************************************/
/***背光控制****/
void backlight_control(char value)
{
if (1 == gLightStatus)
{
D16CS |= 0x40;
D12_Y1 = D16CS;
}
else
{
if( value )
{
D16CS |= 0x40;
D12_Y1 = D16CS;
}
else
{
D16CS &= 0xbf;
D12_Y1 = D16CS;
}
}
}
void set_lightstatus()
{
if (1 == gLightStatus)
{
//长时间光背光
gLightStatus = 0;
backlight_control(0);
}
else
{
//长时间开背光
gLightStatus = 1;
backlight_control(1);
}
}
/* flag 1:振铃 2:对方挂机 3:对方摘机 */
void voice_indication(char flag, char *ptr)
{
FORMAT_BUFFER* buffer;
buffer = get_format_buffer();
if( flag == 1 )
{
buffer->id = PHONE_DIALED;
//陈剑修改,需要在此添加记时功能
start_phonering();
//添加结束
callMenuPopUp();
//声音提示
// tts("soundd", 6);
play_littlespeaker(LITTLESPEAKER_KEY);
}
else if( flag == 2 )
{
buffer->id = PHONE_CLOSE;
}
else if( flag == 3 )
{
buffer->id = PHONE_CONNECTTED;
}
strcpy(buffer->buf, ptr);
buffer->status = RESPONSE_VALID;
}
void set_device_id(unsigned char *value)
{
memcpy(deviceInfo.deviceId, value, DEVICEID_LEN);
nf_configWrite(NF_DEVICEID_ID, value);
// nf_configWriteAll();
}
void date_increment(void)
{
systemInfo.day++;
switch(systemInfo.mon)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
if( systemInfo.day <= 31 )
return;
break;
case 2:
if( (systemInfo.year%4) == 0 )
{
if( systemInfo.day <= 29 )
return;
}
else
{
if( systemInfo.day <= 28 )
return;
}
break;
case 4:
case 6:
case 9:
case 11:
if( systemInfo.hour <= 30 )
return;
break;
}
systemInfo.day = 1;
systemInfo.mon++;
if( systemInfo.mon < 13 )
return;
systemInfo.mon = 1;
systemInfo.year++;
}
void time_process(void)
{
systemInfo.sec++;
if( systemInfo.sec < 60 )
return;
systemInfo.sec = 0;
systemInfo.min++;
if( systemInfo.min < 60 )
return;
systemInfo.min = 0;
systemInfo.hour++;
if( systemInfo.hour < 24 )
return;
systemInfo.hour = 0;
date_increment();
}
extern Byte gbMenuInMain;//是否在运行界面上
extern Byte gnMainMenuTimeout;
#define PLANORALARM_TIMEOUT 10
void isPlanorAlarm_coming()
{
if (VALID_DATA == gbMenuInMain)
{
gnMainMenuTimeout++;
if (gnMainMenuTimeout > PLANORALARM_TIMEOUT)
{
gnMainMenuTimeout = 0;
if ((TRUE == is_msg_incoming()) || (TRUE == is_alarm()))
play_littlespeaker(LITTLESPEAKER_KEY);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -