设为首页 加入收藏

TOP

一种灵活的嵌入式软件架构(三)
2014-11-24 03:26:55 】 浏览:1469
Tags:灵活 嵌入式 软件 架构
OnPaint(void) { DispClr(); DispSetStyle(DISP_CENTER | DISP_REVERSE | DISP_7x9); DispString(0, 0, " 数据上传 "); DispSetStyle(DISP_POSITION|DISP_NORMAL|DISP_7x9); DispString(0, 6, "[连接] [返回]"); } /************************************************************************* * 函数原型: * 功能描述: * 入口参数: * 出口参数: * 返 回 值: *************************************************************************/ void PagePclinOnKey(short key) { switch (key) { case KEY_F1: CommPclink(); break; case KEY_F3: WndPageEsc(); break; } }
#ifndef __PAGE_POWER_H_
#define __PAGE_POWER_H_

#include "pageWnd.h"

/*=====================================================
=	
=====================================================*/
extern const TypePage pagePower;

#endif

#include "PagePower.h"
#include "disp.h"

/*=====================================================
=	
=====================================================*/
void PagePowerOnPaint(void);
void PagePowerOnKey(short key);

const TypePage pagePower = {PagePowerOnPaint, PagePowerOnKey};

/*************************************************************************
* 函数原型:
* 功能描述:
* 入口参数:
* 出口参数:
* 返 回 值:
*************************************************************************/
void PagePowerOnPaint(void)
{
	DispClr();
	DispSetStyle(DISP_CENTER | DISP_REVERSE | DISP_7x9);
	DispString(0, 0, "    电源管理    ");
	DispSetStyle(DISP_POSITION|DISP_NORMAL|DISP_7x9);
	DispString(0, 2, "  [Enter] 关机  ");
	DispString(0, 4, "  [F3   ] 返回  ");
}


/*************************************************************************
* 函数原型:
* 功能描述:
* 入口参数:
* 出口参数:
* 返 回 值:
*************************************************************************/
void PagePowerOnKey(short key)
{
	switch (key)
	{
		case KEY_ENTER:
		case KEY_POWER:
			Halt_EH0218(4);
			SysInit();
			break;
		case KEY_F3:
			WndPageEsc();
			break;
	}
}

这样的一种结构,很灵活,在主函数中只需要这样调用:

int main(void)
{
	short key;
	typ_msg_word smw;
	
	SysInit();

	for ( ; ; )
	{
		/*
		  界面刷新
		*/
		WndOnPaint();

		/*
		  消息处理
		*/
		smw.s_word = sys_msg(SM_STAY_AWAKE);	//用SM_GOTO_SLEEP串口就不能用
		//按键处理
		if (smw.bits.key_available)	
		{
			LcdOffDelay(LCD_OFF_DELAY);
			
			key = KEY_read();
			if (key != -1)
			{
				WndOnKey(key);
			}
		}
		//插入充电电源
		if (smw.bits.charger_on)
		{
			LcdOffDelay(LCD_OFF_DELAY);
		}
		//断开充电电源
		if (smw.bits.charger_off)
		{
			LcdOffDelay(LCD_OFF_DELAY);
			RefreshBattery();
		}
		//串口
		if (smw.bits.comm_data)
		{
			CommReceive();
		}
		//实时任务
		if (smw.bits.time_out)
		{
			TimTaskProc();
		}
	}
}


首页 上一页 1 2 3 4 下一页 尾页 3/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇设计模式(4) 原型模式(Prototype) 下一篇Java基础-面向对象(封装、继承、..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目