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

📄 outbox.c

📁 在ARM7和UC/OSII的平台上实现了GPS自动报站的功能,涉及GPS模块LEA_4S的驱动,位置速寻算法,语音芯片ISD4004的录放音驱动,LED页面管理等等.从启动代码到操作系统的移植以及到业
💻 C
字号:
/*
******************************************************************
*                  XIAMEN YAXON NETWORK CO.LTD.  
*                   XINXI BUILDING,HULI,XIAMEN
*      (c) Copyright 2002,XIAMEN YAXON NETWORK CO.LTD. ,XIAMEN
*                     All Rights Reserved
*
* FileName     :  OutBox.C
* Programmer(s):  WuJingYu
* Description  : 
******************************************************************
*/

/*
*****************************************************************
*                  REVISION HISTORY
*                 
* Date:    2002-10-20
*****************************************************************
*/ 
#define OUTBOX_GLOBALS 

#include  "includes.h"
#include  "ErrTask.H"
#include  "Lcd.h"
#include  "UART_Drv.h"

static  INT16U Cursor,CharLen,MaxSize;
static  INT8U Row_Dot,Col_Dot,LenRow,LenCol,Space_Dot;
static  INT8U scrollbar,ArrowUp_row,ArrowUp_col,ArrowDown_row,ArrowDowm_col;
static  INT8U ArrowLeft_row,ArrowLeft_col,ArrowRight_row,ArrowRight_col;
static  INT8U updaterow,updatecol;
#if 0
static void CheckBoxSize(void)
{
     INT8U validflag;
     INT8U rowwidth_dot;
     
     validflag = TRUE;
     rowwidth_dot = 2*FONTROW + Space_Dot;
     if (LenCol == 0 || LenRow == 0) {
        validflag = FALSE;
     } else if (Row_Dot + rowwidth_dot * LenRow > DOTSIZEY) {
        validflag = FALSE;
     } else if (Col_Dot + LenCol*FONTCOL > DOTSIZEX) {
        validflag = FALSE;
     }      
     if (validflag == FALSE) {
         //PrintFromUART(DEBUG_UARTNo_SYSTEM, "<CheckBoxSize Err>\n");
//	 ErrExit(ERR_OUTBOX_BOX);
     }   
}

#endif 
static void GetUpdateDot(INT8U index)
{
     INT8U i,j;
     INT8U rowwidth_dot;
  
     if (index >= MaxSize) index = MaxSize - 1;
     i = index / LenCol;
     j = index % LenCol;
     rowwidth_dot = 2*FONTROW + Space_Dot;
     if (i >= LenRow) {
        updaterow = Row_Dot + (LenRow -1) * rowwidth_dot;
        updatecol = Col_Dot + LenCol * FONTCOL;
     } else {
        updaterow = Row_Dot + i * rowwidth_dot;
        updatecol = Col_Dot + j * FONTCOL;
     }   
 }
 
INT8U GetOutBoxTextLen(void)
{
     return CharLen;
}    
INT8U GetOutBoxCursor(void)
{
     return Cursor;
}

void LightOnOutBoxCursor(INT8U index)
{
     GetUpdateDot(index);
     FillArea(updaterow,updatecol,FONTROW*2,1);
//y     LcdUpdate_dots(updaterow,updatecol,FONTROW*2,1);
}    

void LightOffOutBoxCursor(INT8U index)
{
     GetUpdateDot(index);
     ClearArea(updaterow,updatecol,FONTROW*2,1);
//y     LcdUpdate_dots(updaterow,updatecol,FONTROW*2,1);
}    

void LightOnOutBox_Cursor(INT8U index)
{
     GetUpdateDot(index);
     FillArea_Cursor(updaterow,updatecol,FONTROW*2,1);
//y     LcdUpdate_dots(updaterow,updatecol,FONTROW*2,1);
}    

void LightOffOutBox_Cursor(INT8U index)
{
     GetUpdateDot(index);
     ClearArea_Cursor(updaterow,updatecol,FONTROW*2,1);
//y     LcdUpdate_dots(updaterow,updatecol,FONTROW*2,1);
}
void FlashOutBoxCursor(INT8U index)
{
     GetUpdateDot(index);
     ReverseArea(updaterow,updatecol,FONTROW*2,1);
     LcdUpdate_dots(updaterow,updatecol,FONTROW*2,1);
}    

BOOLEAN NeedRoundLine(INT8U *charptr,INT16U charlen)
{
     INT8U i;
     INT8U *ptr;
     
     ptr = charptr;
     ptr += charlen - 1;
     if ((*ptr & 0x80) == 0) {
        return FALSE;
     }
     for (i=charlen;i>0;i--) {
        if ((*ptr-- & 0x80) == 0) { 
           break;
        }
     }
     if ((charlen - i) % 2) {
        return TRUE;
     }/* else if ((i == charlen) && (charlen % 2)) {
        return TRUE;
     } */else {
        return FALSE;
     }      
}    

static void FilterChar(INT8U charcode)
{
      INT8U curline;
     
     if (Cursor > MaxSize) return;
     
     if (charcode == 0x0A) {
        if ((Cursor != 0) && (OutCharMem[Cursor-1] == 0x0D)) {
           OutCharMem[--Cursor] = ' ';
           curline = Cursor / LenCol;
           if (curline < LenRow) {
              Cursor = (curline + 1) * LenCol;
           }
           if (Cursor > CharLen) {
              CharLen = Cursor;
           }   
           return;
        } 
     }
     
     if (Cursor >= MaxSize) return;
     
     OutCharMem[Cursor++] = charcode;
     if (!(Cursor % LenCol)) {  
        if (NeedRoundLine(&OutCharMem[Cursor-LenCol],LenCol)) {
            OutCharMem[Cursor-1] = ' ';
            if (Cursor < MaxSize ) {
                OutCharMem[Cursor++] = charcode;
            } 
        }        
     }
     if (Cursor > CharLen) {
         CharLen = Cursor;
     }
}    

void LockOutBox(OUTBOX *boxptr)
{
       
     if (boxptr == NULL) return;
     Row_Dot = boxptr->row_dot;
     Col_Dot = boxptr->col_dot;
     LenRow  = boxptr->numrow;
     LenCol  = boxptr->numcol;
     Space_Dot = boxptr->space_dot;
   // CheckBoxSize();
     Cursor  = 0;
     //CharLen = 0;
     MaxSize = LenRow * LenCol;
     if (MaxSize > OUTMEMSIZE) MaxSize = OUTMEMSIZE;
     scrollbar = boxptr->scrollbar;
     if (scrollbar == SCROLLBAR_UPDOWN) {
        ArrowUp_row   =  Row_Dot;
        ArrowUp_col   =  Col_Dot + FONTCOL * LenCol + 4;
        ArrowDown_row =  Row_Dot + LenRow * (2*FONTROW + Space_Dot) - Space_Dot - 3;
        ArrowDowm_col =  ArrowUp_col;
     } else if (scrollbar == SCROLLBAR_LEFTRIGHT) {   
        ArrowLeft_row  = Row_Dot + 8;
        ArrowLeft_col  = Col_Dot - 4;
        ArrowRight_row = ArrowLeft_row;
        ArrowRight_col = Col_Dot + FONTCOL * LenCol + 3;
     } 
}

void UnLockOutBox(OUTBOX *boxptr)
{
     boxptr = boxptr;
}    

void ClearOutBox(void)
{
      Cursor  = 0;
      CharLen = 0;
      memset(OutCharMem,' ',MaxSize);

}    

void MovCursor(INT16U position)
{
   
     if (position > MaxSize ) {
        position = MaxSize - 1;
     }   
     Cursor = position;
     if (position > CharLen) {
        CharLen = position;
     }
}    

void Print_InPos(INT16U pos,INT8U charcode)
{
     MovCursor(pos);
     FilterChar(charcode);
}    

void Print_Text(INT8U *charptr,INT16U charlen)
{
     INT8U i;
     
     //??CharLen = 0;
     CharLen = 0;
     for (i=0;i<charlen;i++) {
        FilterChar(*charptr++);
     }   
}    

/*没有调试过*/
void Refresh_OnCursor(INT8U *charcode) 
{
     GetUpdateDot(Cursor);
     if (IsASCII(charcode) == TRUE) {
        Print_Text(charcode,1);
     	//OutTextSingle(updaterow,updatecol,Space_Dot,charcode);
     	LcdUpdate_Block(updaterow,updatecol,FONTROW*2,FONTCOL);
     } else {
     	Print_Text(charcode,2);
     	//OutTextSingle(updaterow,updatecol,Space_Dot,charcode);
     	LcdUpdate_Block(updaterow,updatecol,FONTROW*2,FONTCOL*2);
     }
}

/*
//将OutBox中的内容向上移动一行,光标移到新的一行的开头,新的一行内容为charptr

⌨️ 快捷键说明

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