找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 4960|回復(fù): 4
打印 上一主題 下一主題
收起左側(cè)

stm32+st7920多級菜單源碼

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:153675 發(fā)表于 2016-12-10 13:56 | 只看該作者 |只看大圖 回帖獎勵 |倒序瀏覽 |閱讀模式
stm32+st7920多級菜單源碼的文件夾:


所有源碼下載:
LCD 多級菜單.rar (8.54 MB, 下載次數(shù): 103)


主程序預(yù)覽:
  1. #include "sys.h"
  2. #include "delay.h"
  3. #include "usart.h"
  4. #include "led.h"
  5. #include "key.h"
  6. #include "LCD12864.h"
  7. #include "fun.h"

  8. u8  func_index=3;//默認(rèn)初始畫面為fun15;
  9. //定義各個數(shù)據(jù)
  10. u16 UDC,IDC,Uab,Ubc,Uca,Ia,Ib,Ic,PowerHigh,PowerLow,ReactivePowerHigh,ReactivePowerLow,State,
  11.                 OutMode,Frequency,PF,CodeHigh,CodeLow,TEMP,TempA,
  12.     TempB,TempC,Version,DailyEnergyHigh,DailyEnergyLow,Reg27,Reg28,Reg29,Reg30,Reg31,
  13.     Reg32,Reg33,Reg34,Reg35,Reg36,Reg37,Reg38,Reg39,Reg40,Reg42,Reg43,Reg44,Reg45,Reg46,Reg47,Reg48,\
  14.     Reg49;
  15. u32 Power,ReactivePower,DailyEnergy;


  16. void (*current_operation_index)(); //執(zhí)行當(dāng)前顯示函數(shù)
  17. typedef struct
  18.    {
  19.         u8 current;        //當(dāng)前狀態(tài)號
  20.         u8  up;//向上翻索引號
  21.         u8 down;//向下翻索引號
  22.         u8 enter;//確認(rèn)索引號
  23.         u8 num_ent;//編碼器確認(rèn)鍵
  24.         void (*current_operation)(); //要執(zhí)行的函數(shù)
  25.         } key_table;


  26.          key_table table[21]=
  27. {
  28.   {0,3,1,4,15,(*fun1)},//運行狀態(tài)
  29.         {1,0,2,6,1,(*fun2)}, //歷史記錄
  30.         {2,1,3,10,2,(*fun3)},//版本信息
  31.         {3,2,0,11,3,(*fun4)},//功能設(shè)置
  32.         {4,5,5,15,4,(*fun5)},//運行參數(shù)
  33.         {5,4,4,0,5,(*fun6)}, //運行時間
  34.         {6,9,7,0,1,(*fun7)},//故障記錄
  35.         {7,6,8,0,1,(*fun8)},//7天記錄
  36.         {8,7,9,0,1,(*fun9)},//今年記錄
  37.         {9,8,6,0,1,(*fun10)}, //往年記錄
  38.         {10,0,0,0,2,(*fun11)},//版本信息
  39.         {11,14,12,19,3,(*fun12)},//設(shè)置通訊地址
  40.         {12,11,13,0,3,(*fun13)},//設(shè)置語言
  41.         {13,12,14,0,3,(*fun14)}, //設(shè)置時間
  42.         {14,13,11,0,3,(*fun15)},//更多
  43.         {15,18,16,0,15,(*fun16)},//主畫面
  44.         {16,15,17,0,15,(*fun17)},//輸入數(shù)據(jù)
  45.         {17,16,18,0,15,(*fun18)}, //輸出數(shù)據(jù)
  46.         {18,17,15,0,15,(*fun19)},//功率參數(shù)
  47.         {19,17,15,0,11,(*fun20)},//通訊地址
  48. };
  49.        








  50. int main(void)
  51. {
  52.         u8 Key_num;
  53.         NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//設(shè)置系統(tǒng)中斷優(yōu)先級分組2
  54.         delay_init(168);    //初始化延時函數(shù)
  55.         uart_init(115200);        //初始化串口波特率為115200
  56.        
  57.         LED_Init();                                        //初始化LED
  58.         KEY_Init();                                 //按鍵初始化
  59.        
  60.         LCD12864_InitPort();
  61.         LCD12864_Init();

  62. while(1)
  63. {       

  64. //        LED1=!LED1;

  65.                 Key_num=KEY_Scan(0);
  66.                 if(Key_num)
  67.                 {
  68.                         switch(Key_num)
  69.                         {
  70.                                 case 1:
  71.                                         func_index=table[func_index].up;        break;//向上翻
  72.                                 case 2:
  73.                                         func_index=table[func_index].down;        break;//向下翻
  74.                                 case 3:
  75.                                         func_index=table[func_index].enter;        break;//確定
  76.                                 case 4:
  77.                                         func_index=table[func_index].num_ent;        break;                       
  78.                         }
  79.                 LCD12864_Clr();//清屏
  80.                 }
  81.                 current_operation_index=table[func_index].current_operation;
  82.                 (*current_operation_index)();//執(zhí)行當(dāng)前操作函數(shù)
  83. }



  84. }
  85.        
復(fù)制代碼


評分

參與人數(shù) 1黑幣 +18 收起 理由
songhetai + 18

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏2 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

沙發(fā)
ID:166519 發(fā)表于 2017-2-24 23:49 | 只看該作者
我是初學(xué)者
回復(fù)

使用道具 舉報

板凳
ID:152322 發(fā)表于 2017-7-16 01:26 | 只看該作者
多循環(huán)出現(xiàn)的多級菜單。這個要是菜單比較多,就比較麻煩了。
回復(fù)

使用道具 舉報

地板
ID:660797 發(fā)表于 2019-12-10 17:11 | 只看該作者
不知道  工程  能不能直接通過編譯,沒有錯誤。
回復(fù)

使用道具 舉報

5#
ID:412814 發(fā)表于 2020-1-15 17:20 | 只看該作者
謝謝樓主分享,學(xué)習(xí)了。
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表