📄 lcdstats.c
字号:
/***************************************************************************
*
* Module: LcdStats.c
*
* Description: Phone-On-A-Chip LCD Display and Menu Routines
*
* Author: Doug Oucharek
*
* Copyright 2000, Trillium Digital Systems, Inc., All rights reserved
*
*
* Change Log:
*
* Date By Description
* ======== === ====================================================
* 01/31/00 DSO Created
* 11/06/2000 mwb Revamped configuration, so eliminated dead code
*
***************************************************************************/
/*
* Application layer include files
*/
#include "stdioLib.h"
#include "strLib.h"
#include "ioLib.h"
#include "lcdStats.h"
#include "SysDep.h"
#include "DSPInterface.h"
#include "KlcInterface.h"
#include "bepCommon.h"
#include "event.h"
#ifdef HC
#include "h323event.h"
#endif
#ifdef SIP
#include "sipevent.h"
#endif
#ifdef MGCP
#include "mgcpevent.h"
#endif
/*
* Standard Includes
*/
#include <stdio.h>
/*
* Global variables
*/
extern char localID[];
extern char* ErrorStr[];
#define LCD_WIDTH 20
/***************************************************************************
*
* LcdShowRemote()
*
* Arguments
* Input: typ - type of remote id received.
* id - the remote id.
* length - number of bytes in remote id.
* localID - peer's local ID
*
* Returns: Nothing
*
* Description:
* 1. Display the remote id on the LCD display.
*
**************************************************************************/
void LcdShowRemote( id_type typ, char *id, int length ,char *localID, int flag)
{
char string[41];
char *ip_c;
int i, j, k;
char str1[LCD_WIDTH+1];
/*
#ifndef DEMO_TERSE
printf("\nLcdShowRemote() ---\n");
#endif *//* DEMO_TERSE */
/*
* no network address => clear LCD
* it's not on LCD, if there is, it's on LCD already
* don't clear it.
*/
if (length != 0)
{
ClearLcd();
}
if(localID != 0)
{
strncpy(str1,localID,LCD_WIDTH);
str1[LCD_WIDTH] = '\0';
WriteLcd(/*localID*/str1,0,0);
}
if (length == 0)
return;
for(i=0; i<41; i++)
string[i]=0;
if(typ == ip_id)
{
sprintf( string, "%d.%d.%d.%d", id[0], id[1], id[2],id[3] );
length = strlen(string);
}
else if(typ == dig_id)
{
string[0] = 0;
if (id[0] == '*')
{
strncat(string,&id[1],3);
strncat(string,".",1);
strncat(string,&id[4],3);
strncat(string,".",1);
strncat(string,&id[7],3);
strncat(string,".",1);
strncat(string,&id[10],3);
length = strlen(string);
}
else
{
/* slm: MR8849 fix lcd display for digits */
for (i=0,j=(id[0]=='#'); j<length; j++,i++)
string[i] = id[j];
string[i] = 0;
}
}
else
{
for (j = 0; j < length; j++)
string[j] = id[j] + '0';
string[j] = 0;
}
if(flag == FLAG_TRANSFERRED)
{
strncat(string, " (T)", 20-length);
}
else if(flag == FLAG_FORWARDED)
{
strncat(string, " (F)", 20-length);
}
WriteLcd(string, 1, 0);
} /* ends LcdShowRemote() */
/***************************************************************************
*
* LcdShowDigit()
*
* Arguments
* Input: digit - the digit to be displayed.
* reset_lcd - indicates if we should clear the LCD first.
*
* Returns: Nothing
*
* Description:
* 1. Display the given numeric digit on the LCD.
*
**************************************************************************/
void LcdShowDigit( char digit, char reset_lcd )
{
/*
#ifndef DEMO_TERSE
printf("\nLcdShowDigit()---\n");
#endif*/ /* DEMO_TERSE */
if (reset_lcd)
ClearLcd();
lcdPutCharRel( digit );
}
/***************************************************************************
*
* LcdShowString()
*
* Arguments
* Input: string - null terminated string to be displayed on the LCD.
*
* Returns: Nothing
*
* Description:
* 1. Display string on the LCD. Split it over two lines if necessary.
*
**************************************************************************/
void LcdShowString( char *string )
{
int i;
/*@@@@VBR*/
char * CopyBuffer;
CopyBuffer = malloc( strlen( string ) + 1 );
strcpy( CopyBuffer, string );
string = CopyBuffer;
if (strlen( string ) > LCD_WIDTH)
{
/* Find the last blank before the LCD_WIDTH position. */
for (i = LCD_WIDTH; i > 1; i--)
{
if (string[i] == ' ')
{
string[i] = 0;
WriteLcd( string, 0, 0 ); /* both row and column starts from "0" */
if( string[i+1] != '\0' )
WriteLcd( &string[i+1], 1, 0 );
/* slm: MR4026 free buffer to fix memory leak */
free( CopyBuffer );
return;
}
}
}
else
WriteLcd( string, 0, 0 );
free( CopyBuffer );
}
#if 0
/*
* Convert IP string to an unsigned int.
* parameters:
* str - IP string ending with #
* numIP - point to the result - unsigned int.
*
* return: 0 - OK
* -1 - not ok
*
*/
short LcdConvertIP(
char *str, /* must ending with '#' */
unsigned int *numIP)
{
int i,j,k,l;
char me[5];
unsigned int ip4=0;
#ifndef DEMO_TERSE
printf("ip str=[%s]\n",str);
#endif /* DEMO_TERSE */
k = 0;
for ( i=0;i<4;i++)
{
for(l=0,j=k;j<k+4;j++,l++)
{
if (str[j] <= '9' && str[j] >= '0')
{
me[l] = str[j];
}
else
{
j++;
break;
}
}
k = j;
if(j==(k+4))
return -1;
me[l] = 0;
ip4 = (ip4 << 8) + atoi(me);
}
*numIP = ip4;
#ifndef DEMO_TERSE
printf("IP num =[%d]\n",*numIP);
#endif /* DEMO_TERSE */
return 0;
}
/***************************************************************************
*
* LcdGetAction()
*
* Arguments
* Input: None
*
* Returns: action_type - the user selected action.
*
* Description:
* 1. Collect the action from the user. One of '*', '#', or '0'.
*
**************************************************************************/
action_type LcdGetAction( void )
{
char c;
char done = FALSE;
action_type next_action;
/*
* The only valid keys here are: '*' (10), '#' (11), and '0' (0).
* Ignore everything else
*/
do {
c = LcdGetKeyPress();
switch (c)
{
case 10:
next_action = menu_backward;
done = TRUE;
break;
case 11:
next_action = menu_forward;
done = TRUE;
break;
case 0:
next_action = menu_select;
done = TRUE;
break;
case 100:
next_action = menu_onhook;
done = TRUE;
break;
default:
#ifndef DEMO_TERSE
printf(">>>>> wrong key!- LcdGetAction()");
#endif /* DEMO_TERSE */
}
} while (!done);
return (next_action);
}
/***************************************************************************
*
* LcdGetKeyPress()
*
* Arguments
* Input: None
*
* Returns: char - digit pressed by the user.
*
* Description:
* 1. Get the next key pressed by the user.
*
**************************************************************************/
char LcdGetKeyPress( void )
{
char c;
char *rxBuffer, *rxParam = NULL;
event_type event = null_event;
while (((event != digit_event) || (rxParam == NULL)) &&
(event != local_on_hook_event) &&
#ifdef HC
(event != receive_terminate_event))
#endif
#ifdef SIP
(event != receive_bye))
#endif
#ifdef MGCP
(event != 0))
#endif
{
if ((rxBuffer = MQReceive( &event, WAIT_FOREVER)) != NULL)
{
rxParam = rxBuffer + sizeof(event_type);
}
}
if (event == local_on_hook_event ||
#ifdef HC
event == receive_terminate_event)
#endif
#ifdef SIP
event != receive_bye)
#endif
#ifdef MGCP
event != 0)
#endif
{
c = 100; /* as long as it's not a digit, a digit in phone has a range of [0,11] */
}
else
{
c = *rxParam;
}
MQBufFree( rxBuffer );
return (c);
}
/***************************************************************************
*
* LcdShowAlarm()
*
* Arguments
* Input: alarm_data - information about the alarm.
*
* Returns: 0 - normal; 1 - on-hook happens,
*
* Description:
* 1. Display information about the received alarm.
*
**************************************************************************/
#define AP_CANNOT_CONNECT_EVT 257 /* LHI_EVENT_INET_ERR: alarm code in h.323 stack */
#define AP_CANNOT_CONNECT_CAU 260 /* LHI_CAUSE_SOCK_CONN_ERR: alarm code in h.323 stack */
#define LHC_EVENT_H450_REJ_RCVD (256 + 33) /* H.450 Reject received */
#endif
/* end of file lcdstats.c */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -