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

📄 displaytask.c

📁 在ARM7和UC/OSII的平台上实现了GPS自动报站的功能,涉及GPS模块LEA_4S的驱动,位置速寻算法,语音芯片ISD4004的录放音驱动,LED页面管理等等.从启动代码到操作系统的移植以及到业
💻 C
字号:
/****************************************************************
**                                                              *
**  FILE         : DisPlayTask.c                                *
**                                                              *
**  By : Cyb 2007.07.01                                         *
****************************************************************/

#define  DISPLAYTASK_GLOBALS

#include "includes.h"
#include "timetask.h"
#include "systask.h"
#include "message.h"
#include "errcode.h"
#include "errtask.h"
#include "uart_drv.h"
#include "hardware.h"
#include "DisplayTask.h"
#include "alarmer.h"
#include "watchdog.h"
#include "Predictor.h"
#include "StartupPage.h"
#include "FormPage.h"
#include "WinStack.h"
#include "audio.h"
#include "public.h"
#include "LedDrv.h"



#define   SIZE_MSGQUEBUF      20

static   INT8U       CurKey;
static   OS_QMSG     MsgQueBuf[SIZE_MSGQUEBUF];
static   OS_STK      DisplayTaskStack[STACK_DISPAYTASK];
static   INT8U       wdgid;
static   INT8U       StationPotID;
static   INT8U       WorkStatus;

static   INT8U       KeyMapTal[]  = {
                     0x01, KEY_1,      0x02,KEY_5,    0x03,KEY_9,
                     0x04, KEY_IN,     0x05,KEY_2,    0x06,KEY_6,
                     0x07, KEY_0,      0x08,KEY_OUT,  0x09,KEY_3,
                     0x0a, KEY_7,      0x0b,KEY_OK,   0x0c,KEY_REPEAT,
                     0x0d, KEY_4,      0x0e,KEY_8,    0x0f,KEY_CLR,
                     0x90, KEY_SHIFT,  0x8a,KEY_SOUND,0x8f,KEY_LINE
                                           
};

static INT8U  QueryKeyTbl(INT8U recvkey)
{
     INT8U i;
     
     for(i=0;i<sizeof(KeyMapTal)/2;i++)
     {
         if(recvkey  == KeyMapTal[2*i])
         {
             return KeyMapTal[2*i+1];
         }
     }
     
     return  KEY_INVALID;
}

static void  SinglekeyRing(void)
{
     PlaySingleAudio(FALSE,TRUE,AD_tishiyin0);
}
static void  HdlKey(void)
{
     if(KeySound_Swtich.keysound_switch == ON)
     {
         SinglekeyRing();      //按键发音
     }
     
     WinStackEntry();
}

static void  RecevStationPotID(INT8U index)
{
    StationPotID = index;
}

static void RecevWorkStatus(INT8U stat)
{
    WorkStatus  = stat;
}
static void InitDisplayTask(void)
{
      InitLed();
      InitFormStack();
      
      if(!PubParaValid(KEYSOUND_))
      {
          KeySound_Swtich.keysound_switch = ON;
          StorePubPara(KEYSOUND_);
      }  
}


static void DisplayTask(void *pd)
{
     INT8U tempkey;
     
     pd = pd;
#if  DEBUG_UARTNo_SYSTEM <=1 
     PrintFromUART( DEBUG_UARTNo_SYSTEM, "启动DisplayTask......\n");
#endif
     InitDisplayTask();
     
     ActivateStartupPage();
          
     wdgid  = ApplyWatchDogID();
     
     while(1)
     {
         if(OSQPend(DisplayTaskQ,20,&DisplayCurMsg)==OS_NO_ERR)
         {
             switch(DisplayCurMsg.MsgID)
             {
                case MSG_DISPLAYTASK_KEY:
                tempkey = DisplayCurMsg.LMsgPara;
                CurKey  = QueryKeyTbl(tempkey);
                HdlKey();
                break;
                case MSG_DISPLAYTASK_ID:
                RecevStationPotID(DisplayCurMsg.LMsgPara);
                break;
                case MSG_DISPLAYTASK_STS:
                RecevWorkStatus(DisplayCurMsg.LMsgPara);
                break;
                default:
                break;
                
             }
         }
         
         ResetWatchDog(wdgid);
     }
     
}

void CreateDisplayTask(void)
{
     DisplayTaskQ = OSQCreate(MsgQueBuf, sizeof(MsgQueBuf)/sizeof(MsgQueBuf[0]));
     OSTaskCreate(DisplayTask,(void*)0,&DisplayTaskStack[STACK_DISPAYTASK],PRIO_DISPLAYTASK);

}



INT8U  GetCurKey(void)
{
     return CurKey;
}   

INT8U GetStationPotID(void)
{
    return StationPotID;
}

INT8U GetWorkStauts(void)
{
    return WorkStatus;
}

BOOLEAN IsKeySound_ON(void)
{
   if(KeySound_Swtich.keysound_switch == ON)
   {
      return TRUE;
   }
   else
   {
      return FALSE;
   }
}

void SwitchKeySound_OFF(void)
{
   KeySound_Swtich.keysound_switch = OFF;
   StorePubPara(KEYSOUND_); 
}

void SwitchKeySound_ON(void)
{
   KeySound_Swtich.keysound_switch = ON;
   StorePubPara(KEYSOUND_);  
}

⌨️ 快捷键说明

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