T168_Debug222\appl\Display文件:独立.c文件

DspStatus.c   

/******************************************************************************
 *                                                                            *
 *                         M O D U L E   D E F I N E                          *
 *                                                                            *
 ******************************************************************************/

#define DSPSTATUS_C

/******************************************************************************
 *                                                                            *
 *        C O M P I L E R   D E F I N E D   I N C L U D E   F I L E S         *
 *                                                                            *
 ******************************************************************************/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>

/******************************************************************************
 *                                                                            *
 *            U S E R   D E F I N E D   I N C L U D E   F I L E S             *
 *                                                                            *
 ******************************************************************************/

#include "Common.h"
#include "XCore.h"
#include "XLCD.h"
#include "XTimer.h"
#include "XVarBank.h"
#include "XProFile.h"
#include "XAppVer.h"
#include "Display.h"

/******************************************************************************
 *                                                                            *
 *                         L O C A L   D E F I N E S                          *
 *                                                                            *
 ******************************************************************************/

#if defined(LCD_MODEL)

/******************************************************************************
 *                                                                            *
 *                        L O C A L   T Y P E D E F S                         *
 *                                                                            *
 ******************************************************************************/

#define DISPLAY_CYCLE        (100 / PERIOD_TIMES)    // 100 ms

/******************************************************************************
 *                                                                            *
 *             L O C A L   F U N C T I O N   P R O T O T Y P E S              *
 *                                                                            *
 ******************************************************************************/

/******************************************************************************
 *                                                                            *
 *    L O C A L   I N I T I A L I Z E D   D A T A   D E F I N I T I O N S     *
 *                                                                            *
 ******************************************************************************/

/******************************************************************************
 *                                                                            *
 *    L O C A L   U N I T I A L I Z E D   D A T A   D E F I N I T I O N S     *
 *                                                                            *
 ******************************************************************************/

STATIC _PrintCfg *pDspCfg;

STATIC ULONG DspStatus;
STATIC BOOL  DspStatusRefresh;

// Over heat
STATIC INT DspOverTemp;

// Reprint key
STATIC INT DspReprintTotal;
STATIC INT DspReprintCount;

// Print remain
STATIC FLOAT DspRemainRate;
STATIC INT   DspPrintTotal;
STATIC INT   DspPrintRemain;

// Input function
STATIC CHAR DspInputPrompt[DSP_LINE_CHARS + 1];
STATIC CHAR DspInputData[DSP_LINE_CHARS + 1];
STATIC BOOL DspInputNumber;
STATIC INT  DspInputCursor;
STATIC INT  DspInputLength;
STATIC BOOL DspInputFlash;
STATIC BOOL DspShowCursor;

// Image
STATIC UCHAR DspImage[(LCD_HEIGHT + 7) / 8 * LCD_WIDTH];


STATIC VOID DisplayStatus(VOID)
{
    STATIC INT DspInputTimeNum = DELAY_TIME_NULL;
    STATIC INT DspCycle = 0;
    STATIC ULONG LastStaus = 0L;
    CHAR Buf[64];

    if (DspCycle++ % DISPLAY_CYCLE)
        return;

    // input cursor twinkle
    if ((DspStatus & DIS_INPUT_FUNC) && DspInputFlash && !CheckDelayTimer(DspInputTimeNum))
        DspStatusRefresh = TRUE;

    // force refresh
    if (DspStatusRefresh)
        DspStatusRefresh = FALSE;

    // status change
    else if (LastStaus == DspStatus)
        return;

    LastStaus = DspStatus;

    //--- System Message ---//
    if (DspStatus & DIS_INITIAL)
    {
        DspClearDisplay();
        ShowMessage(0, 0, MSG_INITIAZING, 0);
    }
    else if (DspStatus & DIS_UPDATE)
    {
        DspClearDisplay();
        ShowMessage(0, 0, MSG_UPDATE, 0);
    }
    else if (DspStatus & DIS_ERASING)
    {
        DspClearDisplay();
        ShowMessage(0, 0, MSG_ERASING, 0);
    }
    else if (DspStatus & DIS_OUT_OF_MEMORY)
    {
        DspClearDisplay();
        ShowMessage(0, 0, MSG_OUT_OF_MEMORY, 0);
    }
    else if (DspStatus & DIS_DOWNLOADING)
    {
        DspClearDisplay();
        ShowMessage(0, 0, MSG_DOWNLOADING, 0);
    }
#if defined(MENU_TSPL_2)
    else if (DspStatus & DIS_CUTTER_CLEAR)
    {
        DspClearDisplay();
        ShowMessage(0, 0, MSG_MENU_FWD, 0);
        ShowMessage(0, 1, MSG_PAUSE_REV, 0);
    }
#elif defined(MENU_TSPL_3)
    else if (DspStatus & DIS_CUTTER_CLEAR)
    {
        DspClearDisplay();
        sprintf(Buf, "UP:%13s", LCDMessage[MSG_FWD][pDspCfg->Language]);
        ShowLCDString(0, 0, Buf, 0);
        sprintf(Buf, "DOWN:%11s", LCDMessage[MSG_REV][pDspCfg->Language]);
        ShowLCDString(0, 1, Buf, 0);
        sprintf(Buf, "MENU:%11s", LCDMessage[MSG_EXIT][pDspCfg->Language]);
        ShowLCDString(0, 3, Buf, 0);
    }
#endif

    //--- Error Message ---//
    else if (DspStatus & DIS_OVER_HEAT)
    {
        DspClearDisplay();
        ShowMessage(0, 0, MSG_OVER_HEAT, 0);
#if defined(MENU_TSPL_4)
        sprintf(Buf, "%10d'C", DspOverTemp);
#else
        sprintf(Buf, "%12d'C", DspOverTemp);
#endif
        ShowLCDString(0, 1, Buf, 0);
    }
    else if (DspStatus & DIS_CUTTER_ERROR)
    {
        DspClearDisplay();
        ShowMessage(0, 0, MSG_CUTTER_ERR, 0);
    }
    else if (DspStatus & DIS_CARRIAGE_RECOVER)
    {
        DspClearDisplay();
        ShowMessage(0, 0, MSG_PRESS_FEED_KEY, 0);
    }
    else if (DspStatus & DIS_CARRIAGE_OPEN)
    {
        DspClearDisplay();
        ShowMessage(0, 0, MSG_CARRIAGE_OPEN, 0);
    }
    else if (DspStatus & DIS_RIBBON_EMPTY)
    {
        DspClearDisplay();
        ShowMessage(0, 0, MSG_RIBBON_EMPTY, 0);
    }
    else if (DspStatus & DIS_PAPER_EMPTY)
    {
        DspClearDisplay();
        ShowMessage(0, 0, MSG_PAPER_EMPTY, 0);
    }
    else if (DspStatus & DIS_PAPER_JAM)
    {
        DspClearDisplay();
        ShowMessage(0, 0, MSG_PAPER_JAM, 0);
    }

    //--- Motion Message ---//
    else if (DspStatus & DIS_PAUSE)
    {
        DspClearLine(0, LCD_LANG_ENG);
        ShowMessage(0, 0, MSG_PAUSE, 0);
    }
    else if (DspStatus & DIS_DUMP_MODE)
    {
        DspClearDisplay();
        ShowMessage(0, 0, MSG_DUMPMODE, 0);
    }
    else if (DspStatus & DIS_SELFTEST)
    {
        DspClearDisplay();
        ShowMessage(0, 0, MSG_SELFTEST, 0);
    }
    else if (DspStatus & DIS_CALIBRATION)
    {
        DspClearDisplay();
        ShowMessage(0, 0, MSG_CALIBRATING, 0);
    }
    else if (DspStatus & DIS_PRINTKEY)
    {
        DspClearLine(0, LCD_LANG_ENG);
        ShowMessage(0, 0, MSG_PRESS_FEED_KEY, 0);
    }
#if defined(MENU_TSPL_3)
    else if (DspStatus & DIS_REPRINTKEY)
    {
        DspClearDisplay();
        strcpy(Buf, "Reprint");
        if (DspReprintTotal)
            sprintf(Buf, "Reprint %d/%d", DspReprintTotal - DspReprintCount, DspReprintTotal);
        ShowLCDString(((16 - strlen(Buf)) / 2), 0, Buf, 0);
        sprintf(Buf, "%6d/%d", DspPrintRemain, DspPrintTotal);
        ShowLCDString(0, 1, Buf, 0);
        ShowLCDString(0, 2, "DOWN:      PRINT", 0);
        if (DspReprintTotal == 0 || DspReprintTotal > DspReprintCount)
            ShowLCDString(0, 3, "SELECT:  REPRINT", 0);
    }
#endif
    else if (DspStatus & DIS_TAKE_LABEL)
    {
        DspClearLine(0, LCD_LANG_ENG);
        ShowMessage(0, 0, MSG_TAKE_LABEL, 0);
    }
    else if (DspStatus & DIS_PRINT_REMAIN)
    {
        DspClearDisplay();
        ShowMessage(0, 0, MSG_PRINTING, 0);
#if defined(MENU_TSPL_4)
        sprintf(Buf, "%5d/%d", DspPrintRemain, DspPrintTotal);
        if (strlen(Buf) > DSP_LINE_CHARS)
            sprintf(Buf, "%12d", DspPrintRemain);
        ShowLCDString(0, 1, Buf, 0);
#else
        sprintf(Buf, "%6d/%d", DspPrintRemain, DspPrintTotal);
        ShowLCDString(0, 1, Buf, 0);
#endif
    }

    //--- User Message ---//
    else if (DspStatus & DIS_INPUT_FUNC)
    {
        DspClearDisplay();
        ShowPromptString(0, 0, DspInputPrompt, 0);
        ShowInputString(0, 1, DspInputData, 0);
#if defined(MENU_TSPL_3)
        sprintf(Buf, "%16s", DspInputNumber ? "Number" : "String");
        ShowLCDString(0, DSP_LINES - 1, Buf, 1);
#elif defined(MENU_TSPL_4)
        strcpy(Buf, DspInputNumber ? "Number" : "String");
        ShowLCDString(DSP_LINE_CHARS - strlen(Buf), DSP_LINES - 1, Buf, 0);
#endif
        if (DspShowCursor)
        {
            CHAR Cursor[DSP_LINE_CHARS + 1];
            memset(Cursor, 0, sizeof(Cursor));
            if (DspInputLength)
            {
                INT Length = strlen(DspInputData + DspInputCursor);
                memset(Cursor, ' ', DspInputLength);
                memcpy(Cursor, DspInputData + DspInputCursor, MIN(Length, DspInputLength));
                ShowInputString(DspInputCursor, 1, Cursor, 1);
            }
            else
            {
                LcdPut(DspInputCursor * DSP_FONT_WIDTH, DSP_FONT_HEIGHT, 1, DSP_FONT_HEIGHT, (UCHAR *)Cursor, 1);
            }
        }
        if (DspInputFlash)
        {
            DspShowCursor = !DspShowCursor;
            ClrDelayTime(DspInputTimeNum);
            DspInputTimeNum = SetDelayTime(500);
        }
    }
    else if (DspStatus & DIS_IMAGE)
    {
        DspClearDisplay();
        LcdPut(0, 0, LCD_WIDTH, LCD_HEIGHT, DspImage, 0);
    }
#if defined(MENU_TSPL_1)
    else if (DspStatus & DIS_READY)
    {
        DspClearDisplay();
        ShowMessage(0, 0, MSG_READY, 0);
        ShowLCDString(DSP_LINE_CHARS - strlen(LCDExtName), 0, LCDExtName, 0);
    }
#elif defined(MENU_TSPL_2)
    else if (DspStatus & DIS_READY)
    {
        DspClearDisplay();
        ShowMessage(0, 0, MSG_READY, 0);
        ShowLCDString(DSP_LINE_CHARS - strlen(LCDExtName), 0, LCDExtName, 0);
        sprintf(Buf, (strlen(VerName) > 6) ? "%-7s %s" : "%-7s V%s", ModelName, VerName);
        ShowLCDString(0, 1, Buf, 0);
    }
#elif defined(MENU_TSPL_3)
    else if (DspStatus & DIS_READY)
    {
        DspClearDisplay();
        ShowMessage(0, 0, MSG_READY, 0);
        ShowLCDString(15 - strlen(LCDExtName), 0, LCDExtName, 0);
        sprintf(Buf, (strlen(VerName) > 6) ? "%-8s %s" : "%-8s V%s", ModelName, VerName);
        if (strlen(Buf) > DSP_LINE_CHARS)
        {
            ShowLCDString(0, 2, ModelName, 0);
            sprintf(Buf, "%15s", VerName);
            *(strchr(Buf, 0) - 1 - strlen(VerName)) = 'V';
        }
        ShowLCDString(0, 3, Buf, 0);
    }
#elif defined(MENU_TSPL_4)
    else if (DspStatus & DIS_READY)
    {
        DspClearDisplay();
        ShowMessage(0, 0, MSG_READY, 0);
        ShowLCDString(DSP_LINE_CHARS - strlen(LCDExtName), 0, LCDExtName, 0);
        sprintf(Buf, "V%s", VerName);
        ShowLCDString(DSP_LINE_CHARS - strlen(Buf), DSP_LINES - 1, Buf, 0);
    }
#endif
}

VOID InitialDspStatus(VOID)
{
    FLOAT data;

    pDspCfg          = GrabPrintConfig();
    DspStatus        = 0L;
    DspStatusRefresh = FALSE;
    memset(DspInputPrompt, 0, sizeof(DspInputPrompt));
    memset(DspInputData, 0, sizeof(DspInputData));

    DspRemainRate = 1;
    if (GetProfileInt("REMAIN RATE DISPLAY", &data))
        DspRemainRate = data;

    StartPeriodFunc(DisplayStatus);
}

VOID SetDspRemainRate(FLOAT Rate)
{
    DspRemainRate = Rate;
}

ULONG GetDisplayStatus(VOID)
{
    return DspStatus;
}

VOID SetDisplayStatus(ULONG state)
{
    DspStatus |= state;
}

VOID ClrDisplayStatus(ULONG state)
{
    DspStatus &= ~state;
}

VOID SetDisplayOverTemp(INT temp)
{
    SetDisplayStatus(DIS_OVER_HEAT);
    DspOverTemp      = temp;
    DspStatusRefresh = TRUE;
}

VOID SetDisplayReprintKey(INT total, INT count)
{
    SetDisplayStatus(DIS_REPRINTKEY);
    DspReprintTotal  = total;
    DspReprintCount  = count;
    DspStatusRefresh = TRUE;
}

VOID SetDisplayRemain(INT total, INT remain)
{
    SetDisplayStatus(DIS_PRINT_REMAIN);
    DspPrintTotal    = total  * DspRemainRate;
    DspPrintRemain   = remain * DspRemainRate;
    DspStatusRefresh = TRUE;
}

VOID SetDisplayInputFunc(CHAR *prompt, CHAR *data, BOOL number, INT cursor, INT length, BOOL flash)
{
    SetDisplayStatus(DIS_INPUT_FUNC);
    strncpy(DspInputPrompt, prompt, sizeof(DspInputPrompt) - 1);
    strncpy(DspInputData, data, sizeof(DspInputData) - 1);
    DspInputNumber   = number;
    DspInputCursor   = cursor;
    DspInputLength   = length;
    DspInputFlash    = flash;
    DspShowCursor    = TRUE;
    DspStatusRefresh = TRUE;
}

VOID SetDisplayImage(UCHAR *image)
{
    SetDisplayStatus(DIS_IMAGE);
    memcpy(DspImage, image, sizeof(DspImage));
    DspStatusRefresh = TRUE;
}

#endif

  • 15
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值