/************************** Copyright (c) **********************************
|
** FUZHOU FUGUANG ELECTRONICS Co.,LTD.
|
** ¸£Öݸ£¹âµç×ÓÓÐÏÞ¹«Ë¾
|
** http://www.fuguang.com
|
**
|
**-------------- File Info -------------------------------------------------
|
** File name: MessageBox.c
|
** Last modified Date: 2008-11-16
|
** Last Version: 1.0
|
** Descriptions: Display a message box contented some message and buttons
|
**
|
**--------------------------------------------------------------------------
|
** Created by: mxpopstar
|
** Created date: 2008-11-16
|
** Version: 1.0
|
** Descriptions: The original version
|
**
|
**--------------------------------------------------------------------------
|
** Modified by: mxpopstar
|
** Modified date: 2008-11-20
|
** Version:
|
** Descriptions: Display a message box contented some message and buttons
|
**
|
***************************************************************************/
|
//
|
#include "MessageBox.h"
|
#include "Define.h"
|
#include "TFT_Driver.h"
|
#include "NRF905_Driver.h"
|
#include "WorkingPage.h"
|
#include "AD7843_Driver.h"
|
#include "SYSSetPage.h"
|
#include "main.h"
|
#include "Buzzer_Driver.h"
|
|
extern SYS_State GB_SYS_State;
|
|
#if(SoftLanguage == CN)
|
const prog_uchar MSGBoxBMP[1][1] =
|
{
|
{21},
|
};
|
//
|
#else
|
const prog_uchar MSGBoxBMP[1][1] =
|
{
|
{0},
|
};
|
//
|
#endif
|
//
|
|
#if(SoftLanguage == CN)
|
const prog_uchar MSGBoxButton[2][2] =
|
{
|
{45, 46},//È·¶¨
|
{97, 98},//È¡Ïû
|
};
|
//
|
#else
|
const prog_uchar MSGBoxButton[2][8] =
|
{
|
{94,61,74,63}, //È·¶¨4
|
{107,78,72,64,73,59}, //È¡Ïû6
|
};
|
//
|
#endif
|
//
|
|
|
static unsigned char (*MSGBoxParentPage)(void) = DSPMessageBoxNull;
|
static unsigned char MSGBoxBTNPress = ButtonNull;
|
static unsigned char ButtonType = MB_YESNO;
|
static unsigned char MSGBoxTerminated = 0;
|
static unsigned int FirstCharPOS = 0;
|
|
static unsigned char MSGPosted = 0;
|
static const unsigned char *MSGAddr = 0;
|
static unsigned char MSGLength = 0;
|
|
unsigned char DSPMessageBoxNull(void)
|
{
|
return 0;
|
}
|
//
|
|
unsigned int GetFirstCharPOS(void)
|
{
|
return FirstCharPOS;
|
}
|
void SetFirstCharPOS(unsigned int *pos, const unsigned char *text,
|
const unsigned char interval, const unsigned char count)
|
{
|
unsigned char tmp = 0;
|
unsigned char textcount = count;
|
unsigned int showlen = 0;
|
#if(SoftLanguage == CN)
|
while(textcount--)
|
{
|
tmp = pgm_read_byte(text++);
|
if(tmp < 36){showlen += 12;}
|
else {showlen += interval;}
|
}
|
#else
|
textcount = count;
|
/*
|
do
|
{
|
tmp = pgm_read_byte(text++);
|
if((tmp>0) && (tmp<=0x5a))
|
showlen += 16;
|
else if(tmp > 0x5a)
|
showlen += 12;
|
}
|
while(tmp);*/
|
while(textcount--)
|
{
|
tmp = pgm_read_byte(text++);
|
showlen += interval;
|
}
|
#endif
|
|
*pos = (512-showlen-40)/2 + 64;
|
}
|
//
|
|
unsigned char DSPMessageBox(const unsigned char *caption, unsigned char captionlen,
|
const unsigned char btn, const unsigned char alarmtype)
|
{
|
unsigned char n;
|
|
DisableCustomInput();
|
|
if(MSGBoxParentPage == DSPMessageBoxNull)
|
{
|
MSGBoxParentPage = GB_SYS_State.CurrentPage;//±£´æ¸¸Ò³ÃæÖ¸Õë
|
}
|
GB_SYS_State.CurrentPage = DSPMessageBoxNull;
|
GB_SYS_State.GetInput = GetMSGBoxButtonDown;
|
|
ButtonType = btn;
|
MSGBoxBTNPress = ButtonNull;
|
MSGBoxTerminated = 0;
|
|
DrawLine(64, 144, 64, 0, gray0, gray0, linebold, 192); //»¾ØÐÎ
|
for(n=0; n<4; n++)
|
DrawLine(576+n, 144+n+1, 24, 1, gray2, gray2, linebold, 1);//»´¹Ö±ÒõÓ°
|
for(n=0; n<4; n++)
|
DrawLine(64+n+1, 336+n, 64, 0, gray2, gray2, linebold, 1); //»Ë®Æ½ÒõÓ°
|
|
SetFirstCharPOS(&FirstCharPOS, caption, 13, captionlen);
|
DSP32x32Str(MSGBoxBMP[0], 1, 32, GetFirstCharPOS(), 174, gray0, yellow);
|
DSP16x24Str(caption, captionlen, 13, GetFirstCharPOS()+40, 178, gray0, yellow);
|
|
if(btn == MB_YESNO)
|
{
|
DrawButtonH48(2, MSGBoxButton[0], 4, 16, 16, 149, 264, gray1, white);//È·¶¨
|
DrawButtonH48(2, MSGBoxButton[1], 6, 14, 6, 399, 264, gray1, white);//È¡Ïû
|
}
|
else
|
{
|
DrawButtonH48(2, MSGBoxButton[0], 4, 16, 12, 274, 264, gray1, white);//È·¶¨
|
}
|
|
StartAlarmBeep(alarmtype);//¿ªÆôÉùÒô¸æ¾¯
|
while(1)
|
{
|
RunMainTask();
|
|
AppendBoxMessage();
|
|
if(MSGBoxTerminated == 1)
|
{
|
StopAlarmBeep();//¹Ø±ÕÉùÒô¸æ¾¯
|
cli();//--------¿ª×ÜÖжÏ
|
BackColorCH();
|
MSGBoxParentPage();
|
sei();//--------¿ª×ÜÖжÏ
|
MSGBoxParentPage = DSPMessageBoxNull;//»Ö¸´¸¸Ö¸ÕëΪָÏò×Ô¼º
|
return MSGBoxBTNPress;
|
}
|
|
if(GB_SYS_State.CurrentPage != DSPMessageBoxNull)//Èç¹ûϵͳÒÑÍ˳ö±¾Ò³Ãæ
|
{
|
MSGBoxParentPage = DSPMessageBoxNull;//»Ö¸´¸¸Ö¸ÕëΪָÏò×Ô¼º
|
StopAlarmBeep();//¹Ø±ÕÉùÒô¸æ¾¯
|
return ButtonNull;
|
}
|
}
|
}
|
//
|
unsigned char DSPMessageBox1(const unsigned char *caption, unsigned char captionlen,
|
const unsigned char btn, const unsigned char alarmtype)
|
{
|
unsigned char n;
|
|
DisableCustomInput();
|
|
if(MSGBoxParentPage == DSPMessageBoxNull)
|
{
|
MSGBoxParentPage = GB_SYS_State.CurrentPage;//±£´æ¸¸Ò³ÃæÖ¸Õë
|
}
|
GB_SYS_State.CurrentPage = DSPMessageBoxNull;
|
GB_SYS_State.GetInput = GetMSGBoxButtonDown;
|
|
ButtonType = btn;
|
MSGBoxBTNPress = ButtonNull;
|
MSGBoxTerminated = 0;
|
|
DrawLine(64, 144, 64, 0, gray0, gray0, linebold, 192); //»¾ØÐÎ
|
for(n=0; n<4; n++)
|
DrawLine(576+n, 144+n+1, 24, 1, gray2, gray2, linebold, 1);//»´¹Ö±ÒõÓ°
|
for(n=0; n<4; n++)
|
DrawLine(64+n+1, 336+n, 64, 0, gray2, gray2, linebold, 1); //»Ë®Æ½ÒõÓ°
|
|
SetFirstCharPOS(&FirstCharPOS, caption, 10, captionlen);
|
DSP32x32Str(MSGBoxBMP[0], 1, 32, GetFirstCharPOS(), 174, gray0, yellow);
|
DSP12x16Str(caption, captionlen, 10, GetFirstCharPOS()+40, 178, gray0, yellow);
|
|
if(btn == MB_YESNO)
|
{
|
DrawButtonH48(2, MSGBoxButton[0], 4, 16, 16, 149, 264, gray1, white);//È·¶¨
|
DrawButtonH48(2, MSGBoxButton[1], 6, 14, 6, 399, 264, gray1, white);//È¡Ïû
|
}
|
else
|
{
|
DrawButtonH48(2, MSGBoxButton[0], 4, 16, 12, 274, 264, gray1, white);//È·¶¨
|
}
|
|
StartAlarmBeep(alarmtype);//¿ªÆôÉùÒô¸æ¾¯
|
while(1)
|
{
|
RunMainTask();
|
|
AppendBoxMessage();
|
|
if(MSGBoxTerminated == 1)
|
{
|
StopAlarmBeep();//¹Ø±ÕÉùÒô¸æ¾¯
|
cli();//--------¿ª×ÜÖжÏ
|
BackColorCH();
|
MSGBoxParentPage();
|
sei();//--------¿ª×ÜÖжÏ
|
MSGBoxParentPage = DSPMessageBoxNull;//»Ö¸´¸¸Ö¸ÕëΪָÏò×Ô¼º
|
return MSGBoxBTNPress;
|
}
|
|
if(GB_SYS_State.CurrentPage != DSPMessageBoxNull)//Èç¹ûϵͳÒÑÍ˳ö±¾Ò³Ãæ
|
{
|
MSGBoxParentPage = DSPMessageBoxNull;//»Ö¸´¸¸Ö¸ÕëΪָÏò×Ô¼º
|
StopAlarmBeep();//¹Ø±ÕÉùÒô¸æ¾¯
|
return ButtonNull;
|
}
|
}
|
}
|
|
void TerminateMSGBox(void)
|
{
|
MSGBoxBTNPress = ButtonNull;
|
MSGBoxTerminated = 1;
|
}
|
//
|
|
void PostBoxMessage(const unsigned char *msg, const unsigned char len)
|
{
|
MSGPosted = 1;
|
MSGAddr = msg;
|
MSGLength = len;
|
}
|
void AppendBoxMessage(void)
|
{
|
if(MSGPosted == 1)
|
{
|
MSGPosted = 0;
|
if(MSGAddr == 0)
|
return;
|
|
DSP24x24Str(MSGAddr, MSGLength, 24, 188, 216, gray0, yellow);
|
if(GetChargeWaitCountDown() < 60)
|
{
|
PrintValue(3, 0, GetChargeWaitCountDown(), "", 16, 196, 216, gray0, yellow);
|
}
|
|
MSGAddr = 0;
|
}
|
}
|
//
|
unsigned char DSPMessageBox2(const unsigned char *caption, unsigned char captionlen,
|
const unsigned char btn, const unsigned char alarmtype)
|
{
|
unsigned char n;
|
|
DisableCustomInput();
|
|
if(MSGBoxParentPage == DSPMessageBoxNull)
|
{
|
MSGBoxParentPage = GB_SYS_State.CurrentPage;//±£´æ¸¸Ò³ÃæÖ¸Õë
|
}
|
GB_SYS_State.CurrentPage = DSPMessageBoxNull;
|
GB_SYS_State.GetInput = GetMSGBoxButtonDown;
|
|
ButtonType = btn;
|
MSGBoxBTNPress = ButtonNull;
|
MSGBoxTerminated = 0;
|
|
DrawLine(64, 144, 64, 0, gray0, gray0, linebold, 192); //»¾ØÐÎ
|
for(n=0; n<4; n++)
|
DrawLine(576+n, 144+n+1, 24, 1, gray2, gray2, linebold, 1);//»´¹Ö±ÒõÓ°
|
for(n=0; n<4; n++)
|
DrawLine(64+n+1, 336+n, 64, 0, gray2, gray2, linebold, 1); //»Ë®Æ½ÒõÓ°
|
|
SetFirstCharPOS(&FirstCharPOS, caption, 16, captionlen);
|
DSP32x32Str(MSGBoxBMP[0], 1, 32, GetFirstCharPOS(), 174, gray0, yellow);
|
DSP16x24Str(caption, captionlen, 16, GetFirstCharPOS()+40, 178, gray0, yellow);
|
|
if(btn == MB_YESNO)
|
{
|
DrawButtonH48(2, MSGBoxButton[0], 4, 16, 16, 149, 264, gray1, white);//È·¶¨
|
DrawButtonH48(2, MSGBoxButton[1], 6, 14, 6, 399, 264, gray1, white);//È¡Ïû
|
}
|
else
|
{
|
DrawButtonH48(2, MSGBoxButton[0], 4, 16, 12, 274, 264, gray1, white);//È·¶¨
|
}
|
|
StartAlarmBeep(alarmtype);//¿ªÆôÉùÒô¸æ¾¯
|
while(1)
|
{
|
RunMainTask();
|
|
AppendBoxMessage();
|
|
if(MSGBoxTerminated == 1)
|
{
|
StopAlarmBeep();//¹Ø±ÕÉùÒô¸æ¾¯
|
cli();//--------¿ª×ÜÖжÏ
|
BackColorCH();
|
MSGBoxParentPage();
|
sei();//--------¿ª×ÜÖжÏ
|
MSGBoxParentPage = DSPMessageBoxNull;//»Ö¸´¸¸Ö¸ÕëΪָÏò×Ô¼º
|
return MSGBoxBTNPress;
|
}
|
|
if(GB_SYS_State.CurrentPage != DSPMessageBoxNull)//Èç¹ûϵͳÒÑÍ˳ö±¾Ò³Ãæ
|
{
|
MSGBoxParentPage = DSPMessageBoxNull;//»Ö¸´¸¸Ö¸ÕëΪָÏò×Ô¼º
|
StopAlarmBeep();//¹Ø±ÕÉùÒô¸æ¾¯
|
return ButtonNull;
|
}
|
}
|
}
|
|
void GetMSGBoxButtonDown(void)
|
{
|
//------------------ ´¦Àí°´¼ü --------------------
|
if(MSGBoxTerminated == 0)
|
{
|
MSGBoxBTNPress = GetTouchLocal();
|
|
if((ButtonType==MB_YESNO) && ((MSGBoxBTNPress==ButtonOK)||(MSGBoxBTNPress==ButtonCancel)))
|
{
|
MSGBoxTerminated = 1;
|
if(GetButtonIsBeep(0) == BeepIsWork)
|
BuzzerBeep(100);
|
|
}
|
else if((ButtonType==MB_OK) && (MSGBoxBTNPress==ButtonSingleOK))
|
{
|
if(GetButtonIsBeep(0) == BeepIsWork)
|
BuzzerBeep(100);
|
MSGBoxTerminated = 1;
|
}
|
}
|
}
|
unsigned char DSPMessageBox3(const unsigned char *caption, unsigned char captionlen,
|
const unsigned char btn, const unsigned char alarmtype)
|
{
|
unsigned char n;
|
|
DisableCustomInput();
|
|
if(MSGBoxParentPage == DSPMessageBoxNull)
|
{
|
MSGBoxParentPage = GB_SYS_State.CurrentPage;//±£´æ¸¸Ò³ÃæÖ¸Õë
|
}
|
GB_SYS_State.CurrentPage = DSPMessageBoxNull;
|
GB_SYS_State.GetInput = GetMSGBoxButtonDown;
|
|
ButtonType = btn;
|
MSGBoxBTNPress = ButtonNull;
|
MSGBoxTerminated = 0;
|
|
DrawLine(64, 144, 64, 0, gray0, gray0, linebold, 192); //»¾ØÐÎ
|
for(n=0; n<4; n++)
|
DrawLine(576+n, 144+n+1, 24, 1, gray2, gray2, linebold, 1);//»´¹Ö±ÒõÓ°
|
for(n=0; n<4; n++)
|
DrawLine(64+n+1, 336+n, 64, 0, gray2, gray2, linebold, 1); //»Ë®Æ½ÒõÓ°
|
|
SetFirstCharPOS(&FirstCharPOS, caption, 13, captionlen);
|
DSP32x32Str(MSGBoxBMP[0], 1, 32, GetFirstCharPOS(), 174, gray0, yellow);
|
DSP16x24Str(caption, captionlen, 14, GetFirstCharPOS()+40, 178, gray0, yellow);
|
|
if(btn == MB_YESNO)
|
{
|
DrawButtonH48(2, MSGBoxButton[0], 4, 16, 16, 149, 264, gray1, white);//È·¶¨
|
DrawButtonH48(2, MSGBoxButton[1], 6, 14, 6, 399, 264, gray1, white);//È¡Ïû
|
}
|
else
|
{
|
DrawButtonH48(2, MSGBoxButton[0], 4, 16, 12, 274, 264, gray1, white);//È·¶¨
|
}
|
|
StartAlarmBeep(alarmtype);//¿ªÆôÉùÒô¸æ¾¯
|
while(1)
|
{
|
RunMainTask();
|
|
AppendBoxMessage();
|
|
if(MSGBoxTerminated == 1)
|
{
|
StopAlarmBeep();//¹Ø±ÕÉùÒô¸æ¾¯
|
cli();//--------¿ª×ÜÖжÏ
|
BackColorCH();
|
MSGBoxParentPage();
|
sei();//--------¿ª×ÜÖжÏ
|
MSGBoxParentPage = DSPMessageBoxNull;//»Ö¸´¸¸Ö¸ÕëΪָÏò×Ô¼º
|
return MSGBoxBTNPress;
|
}
|
|
if(GB_SYS_State.CurrentPage != DSPMessageBoxNull)//Èç¹ûϵͳÒÑÍ˳ö±¾Ò³Ãæ
|
{
|
MSGBoxParentPage = DSPMessageBoxNull;//»Ö¸´¸¸Ö¸ÕëΪָÏò×Ô¼º
|
StopAlarmBeep();//¹Ø±ÕÉùÒô¸æ¾¯
|
return ButtonNull;
|
}
|
}
|
}
|
//
|
unsigned char DSPMessageBox4(const unsigned char *caption, unsigned char captionlen,
|
const unsigned char btn,
|
const unsigned char alarmtype,unsigned char index1,unsigned char index2)
|
{
|
unsigned char n;
|
unsigned char *p = (unsigned char *)caption;
|
DisableCustomInput();
|
|
if(MSGBoxParentPage == DSPMessageBoxNull)
|
{
|
MSGBoxParentPage = GB_SYS_State.CurrentPage;//±£´æ¸¸Ò³ÃæÖ¸Õë
|
}
|
GB_SYS_State.CurrentPage = DSPMessageBoxNull;
|
GB_SYS_State.GetInput = GetMSGBoxButtonDown;
|
|
ButtonType = btn;
|
MSGBoxBTNPress = ButtonNull;
|
MSGBoxTerminated = 0;
|
|
DrawLine(64, 144, 64, 0, gray0, gray0, linebold, 192); //»¾ØÐÎ
|
for(n=0; n<4; n++)
|
DrawLine(576+n, 144+n+1, 24, 1, gray2, gray2, linebold, 1);//»´¹Ö±ÒõÓ°
|
for(n=0; n<4; n++)
|
DrawLine(64+n+1, 336+n, 64, 0, gray2, gray2, linebold, 1); //»Ë®Æ½ÒõÓ°
|
|
DSP32x32Str(MSGBoxBMP[0], 1, 32, 170, 174, gray0, yellow);
|
// DSP12x16Str(p, captionlen, 13, 70+40, 200, gray0, yellow);
|
if(captionlen > index1)
|
{
|
DSP16x24Str(p, index1, 13, 170+40, 178, gray0, yellow);
|
|
if(captionlen-index1>=index2)
|
{
|
//DSP12x16Str(p, index1, 15, 70+40, 178, gray0, yellow);
|
DSP16x24Str(p+index1, index2, 13, 170+40, 200, gray0, yellow);
|
DSP16x24Str(p+index1+index2, captionlen-index1-index2, 13, 170+40, 222, gray0,
|
|
yellow);
|
}
|
else
|
{
|
DSP16x24Str(p+index1, captionlen-index1, 13, 170+40, 200, gray0, yellow);
|
}
|
|
}
|
else
|
DSP16x24Str(p, captionlen, 13, 170+40, 178, gray0, yellow);
|
|
if(btn == MB_YESNO)
|
{
|
DrawButtonH48(2, MSGBoxButton[0], 4, 16, 16, 149, 264, gray1, white);//È·¶¨
|
DrawButtonH48(2, MSGBoxButton[1], 6, 14, 6, 399, 264, gray1, white);//È¡Ïû
|
}
|
else
|
{
|
DrawButtonH48(2, MSGBoxButton[0], 4, 16, 12, 274, 264, gray1, white);//È·¶¨
|
}
|
|
StartAlarmBeep(alarmtype);//¿ªÆôÉùÒô¸æ¾¯
|
while(1)
|
{
|
RunMainTask();
|
|
AppendBoxMessage();
|
|
if(MSGBoxTerminated == 1)
|
{
|
StopAlarmBeep();//¹Ø±ÕÉùÒô¸æ¾¯
|
cli();//--------¿ª×ÜÖжÏ
|
BackColorCH();
|
MSGBoxParentPage();
|
sei();//--------¿ª×ÜÖжÏ
|
MSGBoxParentPage = DSPMessageBoxNull;//»Ö¸´¸¸Ö¸ÕëΪָÏò×Ô¼º
|
return MSGBoxBTNPress;
|
}
|
|
if(GB_SYS_State.CurrentPage != DSPMessageBoxNull)//Èç¹ûϵͳÒÑÍ˳ö±¾Ò³Ãæ
|
{
|
MSGBoxParentPage = DSPMessageBoxNull;//»Ö¸´¸¸Ö¸ÕëΪָÏò×Ô¼º
|
StopAlarmBeep();//¹Ø±ÕÉùÒô¸æ¾¯
|
return ButtonNull;
|
}
|
}
|
}
|
|
/********************** END OF FILE (MessageBox.c)*************************/
|