📄 linechangepage.c
字号:
/****************************************************************
** *
** FILE : LineChangePage.c *
** *
** By : Cyb 2007.07.01 *
****************************************************************/
#define LINECHANGEPAGE_GLOBALS
#include "includes.h"
#include "timetask.h"
#include "almtask.h"
#include "message.h"
#include "errcode.h"
#include "errtask.h"
#include "public.h"
#include "uart_drv.h"
#include "LedDrv.h"
#include "DisplayTask.h"
#include "alarmer.h"
#include "Hardware.h"
#include "watchdog.h"
#include "audio.h"
#include "FormPage.h"
#include "WinStack.h"
#include "_keyboard.h"
#include "EditBox.h"
#include "Predictor.h"
#include "LineChangePage.h"
#include "Tools.h"
#define LINECHANGEPAGE_DEBUG 1
static FORMPAGE *LineChangePage;
static EDITBOX LineChangeEdit;
static TMR_TSK *ReqChangeLineTmr, *RefleshEditBoxTmr;
static INT8U Status;
static void ReqChangeLineProc(void)
{
if(Status & CHANGED)
{
StopTmr(ReqChangeLineTmr);
}
else
{
if(!(Status & CHANGING))
{
PlaySingleAudio(FALSE,TRUE,AD_linechange);
}
}
}
static void RefleshEditBoxProc(void)
{
RefleshEditBox(&LineChangeEdit);
}
static void LineChangePageInitFunc(void)
{
Status = 0;
ClearLedDisplay();
LineChangeEdit.editlen = 0;
PlaySingleAudio(FALSE,TRUE,AD_linechange); //请输入线路号
ReqChangeLineTmr = CreateTimer(ReqChangeLineProc,0);
RefleshEditBoxTmr = CreateTimer(RefleshEditBoxProc,0);
StartTmr(RefleshEditBoxTmr,MILTICK,10);
StartTmr(ReqChangeLineTmr,MINUTE,5);
}
static void LineChangingNow(INT8U* ptr,INT8U len)
{
INT8U result;
INT16U linenum;
linenum = AsciiToDec(ptr,len);
result = LayoutStation_Line(linenum);
switch(result)
{
case NOLINE:
OSQPost(AlmTaskMsgQue, MSG_LAYOUT_NOLINE, 0 ,0);
ClearLedDisplay();
LineChangeEdit.editlen = 0;
break;
case NOSTATION:
OSQPost(AlmTaskMsgQue, MSG_LAYOUT_NOSTA, 0 ,0);
ClearLedDisplay();
LineChangeEdit.editlen = 0;
break;
case SUCCESS:
OSQPost(AlmTaskMsgQue, MSG_LAYOUT_SUCCESS, linenum ,0);
if(!(Status & CHANGED))
{
Status |= CHANGED;
CloseFormPage(); // 关掉页面
}
break;
default:
break;
}
}
static void LineChangePageHdlKeyFunc(void)
{
INT8U key;
key = GetCurKey();
switch(key)
{
case KEY_CLR:
EditBoxDeleteChar(&LineChangeEdit);
break;
case KEY_OK:
if(LineChangeEdit.editlen == 0)
{
PlaySingleAudio(FALSE,TRUE,AD_lognochar);
return;
}
LineChangingNow(LineChangeEdit.editbuf,LineChangeEdit.editlen);
break;
case KEY_SHIFT:
#if LINECHANGEPAGE_DEBUG >0
PrintFromUART( DEBUG_UARTNo_DISPLAYTASK, "退出公交线路选择页面!!!\n");
#endif
CloseFormPage();
break;
default:
if(IsNumber(key))
{
if(!(Status & CHANGING))
{
Status |= CHANGING;
}
EditBox_HdlNumKey(&LineChangeEdit,key);
}
break;
}
}
static void LineChangePageDestroyFunc(void)
{
RemoveTmr(ReqChangeLineTmr);
StopTmr(RefleshEditBoxTmr);
RemoveTmr(RefleshEditBoxTmr);
}
void CreateLineChangePage(void)
{
#if LINECHANGEPAGE_DEBUG >0
PrintFromUART( DEBUG_UARTNo_DISPLAYTASK, "进入公交线路选择页面!!!\n");
#endif
LineChangePage = AllocateFormPage();
LineChangePage ->initfunc = LineChangePageInitFunc;
LineChangePage ->createfunc = NULL;
LineChangePage ->hdlkeyfunc = LineChangePageHdlKeyFunc;
LineChangePage ->resumefunc = NULL;
LineChangePage ->destroyfunc = LineChangePageDestroyFunc;
CreateFormPage();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -