当前位置:首页 > 机械/制造/汽车 > 制造加工工艺 > 一种易于移植的单片机液晶显示多级菜单设计-王勇
2812Vol.28No.12201112ComputerApplicationsandSoftwareDec.20116100545238082010-10-15。。、。Windows。、、。FYD12864。TP311AAPORTABLEDESIGNOFMULTILEVELMENUDISPLAYONSINGLECHIPLCDWangYongUniversityofElectronicScienceandTechnologyofChinaChengdu610054SichuanChinaInstituteofElectronicandInformationEngineeringinDongguanUniversityofElectronicScienceandTechnologyofChinaDongguan523808GuangdongChinaAbstractLCDdisplayasahuman-computerinteractionisverypopularinvariousapplicationsituationsofembeddedmicrocontrollersystems.HowevergeneralLCDdisplaymenudesignisalittlebitcomplicatedanddoesnothavetheportabilitythereforethecomplexityindevelopmentandsystemmaintenanceandthecostareincreased.InthispaperweintroducethewindowandmessagemechanismsofWindowsOperatingSystemanddesignamultilevelmenu.Thecoreofthemenuisauniversalwindowenginewhichdoesnotdependonspecifichardwareandthecontentofmenu.Researchandapplicationshowthatthemenudesignhasthecharactersofsimplestructureeasytouselittleresourceconsumptionportableandsoon.IntheendofthepaperwepresentanapplicationexamplerunningintheFYD12864LCDmodule.KeywordsSinglechipLCDdisplayMenuWindowengine08。12。LED。。、、、、、。FYD12864-0402B3.3V128×644×84×16。KEY1~KEY4“”、“”、“”、“”。1。、、、1。12642011、。、。、。、、。。8。、、。。2Windows3。WINDOWMSGtypedefstructWNDPROCwndProc//HWNDhwndParent//uint16timer//WINDOW//typedefstructHWNDhwnd//UINTmsg//WPARAMwParam//1LPARAMlParam//2MSG//8typedefHWND、WPARAM、LPARAM、UINT8。1632。2.1。。。。#defineWM_CREATE1//#defineWM_CLOSE2//#defineWM_PAINT3//#defineWM_TIMER4//#defineWM_KEY15//1#defineWM_KEY26//2#defineWM_KEY37//3#defineWM_KEY48//4#defineWM_USER0x80//WM_CREATEWM_CLOSE。WM_PAINT。WM_TIMERWM_TIMER。WM_KEY1~WM_KEY4。WM_USERWM_MENU_ITEM#defineWM_MENU_ITEMWM_USER+1PostMessageDis-patchMessageDefWndProc。2。2PostMessagemsgQ。DispatchMessagemsgQ。。。DefWndProc。2.2WindowInitCreateWin-dowDestroyWindowGetTopWindowGetParentWindow。WindowInitwndStackmsgQ。GetTopWindowwndStackGet-ParentWindowWINDOWhwndPar-ent。CreateWindowDestroyWindowwnd-Stack。WINDOWwndStackhwndParentPostMessageWM_CREATE。WM_CREATE。。。。wndStackWINDOWhwndParentWM_PAINT。122653。32.3。SetTimer、KillTimerWindowTimer。WINDOWtimer。timer。WindowTimertimer1。WM_TIMER。4ms1000mstimer1000/4=250。WM_TIMERSetTimer。WM_TIMERWM_PAINT。3WM_MENU_ITEM。typedefstructconstchar*caption//WPARAMwParam//MenuItemtypedefstructMenuItem*root//uint8sel//uint8head//MENUMenuItemMENU。3.1typedefvoid*WNDPROCHWNDhwndUINTmsgWPARAMwParamLPARAMlParam。。3.24Menu-Itemm13m25m33。44。MENUroot。selhead。Item12Item143Item13.root=Item10sel=3Item13head=2Item12。MENUmStack。MENU。。4Item12Item14Item13。3.3“”、“”、“”、“”。3。。“”。2662011。“”。4、。———。4.1MENUcurMenu//MENUmenuMENU_DEPTH//STACKmStack//MenuItemmiMain=″1.″PARAM_INFO″2.″PARAM_REG″3.″PARAM_IN″4.″PARAM_OUT″5.″PARAM_SPECIAL0MenuItemmiSpecial=″1.″PARAM_STUDY″2.″PARAM_MAINTAIN0miMainmiSpecial5。0MenuItemcaption。。4.2CreateWindow。MainWndProc。voidCreateMainMenuvoidWINDOWwndwnd.wndProc=MainWndProcCreateWindow&wndMainWndProcstaticvoidMainWndProcHWNDhwndUINTmsgWPARAMwParamLPARAMlParamMenuItem*pWINDOWwnduint8indexswitchmsgcaseWM_CREATEcurMenu.root=miMaincurMenu.sel=0curMenu.head=0StackInit&mStackMENU_DEPTHPostMessagehwndWM_PAINT00breakcaseWM_PAINTLCDClearAllLCDDispString03″″LCDDispString23″″LCDDispString43″″LCDDispString63″″MenuDrawbreakcaseWM_MENU_ITEMswitchwParamcasePARAM_SPECIALmenuStackPush&mStack=curMenucurMenu.root=miSpecialcurMenu.head=0curMenu.sel=0MenuDrawbreakcasePARAM_INFOwnd.wndProc=InfoWndProcCreateWindow&wndbreak……breakcaseWM_KEY1//ifcurMenu.sel==0breakifcurMenu.sel==curMenu.head&&curMenu.head>0curMenu.head--//curMenu.sel--MenuDrawbreakcaseWM_KEY2//p=curMenu.root+curMenu.sel+1ifp->captionbreakifcurMenu.sel==curMenu.head+2curMenu.head++//curMenu.sel++MenuDrawbreakcaseWM_KEY3//p=curMenu.root+curMenu.selifp->wParamPostMessagehwndWM_MENU_ITEMp->wParam0breakcaseWM_KEY4//12267index=StackPop&mStackifindex=0xFFcurMenu=menuindexelsecurMenu.head=0curMenu.sel=0MenuDrawbreakLCDDispString。PARAM_INFOPARAM_SPECIAL。PARAM_INFOPARAM_SPECIALPA-RAM_SPECIALWM_KEY4。MenuDraw1curMenuroothead23MenuItemcaption4.1334。5。54.3PARAM_INFO。InfoWndProcstaticvoidInfoWndProcHWNDhwndUINTmsgWPARAMwParamLPARAMlParamswitchmsgcaseWM_CREATEPostMessagehwndWM_PAINT00breakcaseWM_PAINTLCDClearAllLCDDispString00″″……SetTimerhwnd200breakcaseWM_TIMERLCDDispString00GetCurFloorString……SetTimerhwnd200breakcaseWM_KEY4//KillTimerhwndDestroyWindowhwndbreak。———SetTimerWM_TIMERWM_TIMER。KillTimer。。DestroyWindow。KEY1~KEY3。6。6main。DispatchMessage。52682011。。WindowsWin-dows、。。8。。。。1.J.200720475-77.2.J.2007144391-394.3CharlesPetzold.ProgrammingWindowsM.SanFranciscoMicrosoftPress1998.1273DSS2.4Web。701UDDIJSP、Tomcat、J2SDKMySqljUDDI。02-0405-07。4。4。03publicintintAddintaintbreturna+bUDDIab。c。c=a+b。http//192.168.1.2/mathModel。intAddab。06“”5。。53Web、DSS。、。。。1.M.2005.2.J2EEJ.20052712119-121.3.Mathematica2J.2005393291-293.4.DSSM.2005.5.M.2004.6.WebServiceJ.200932138-40.
本文标题:一种易于移植的单片机液晶显示多级菜单设计-王勇
链接地址:https://www.777doc.com/doc-4144925 .html