专家
公告
财富商城
电子网
旗下网站
首页
问题库
专栏
标签库
话题
专家
NEW
门户
发布
提问题
发文章
STM32
LCD上制作人机界面(带有菜单式的)
2019-10-15 03:57
发布
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
站内问答
/
STM32/STM8
2630
23
1280
我做了文字显示,还有图片显示,我现在想在LCD上做一个人机的界面,比如我用按键KEY0的时候,它会弹出他的子菜单,这方面资料太少,尤其是关于ALIENTEk MiniSTM32这个开发板,希望哪位大侠或者原子大哥能够指点一下,不甚感激,真的很感激~
友情提示:
此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
23条回答
淋哥儿
2019-10-15 08:31
给楼主一个思路吧!用结构体,我看到群里面的好多人采用上下键,对应着数字,对应着某一个函数,这个方案好理解,但是一旦需要中间再加一个菜单,整体的结构等于再写一遍,比较复杂。我提供的方案就是任意添加函数功能,菜单深度可以通过宏定义改,手头项目多,不能整理。楼主仅供参考。
#ifndef _MENU_H
#define _MENU_H
#include "stm32f10x.h"
//=================================================
#ifndef NULL
#define NULL ((void*)0)
#endif
//逻辑状态
#ifndef FALSE
#define FALSE (0)
#endif
#ifndef TRUE
#define TRUE (0)
#endif
//==================================================
typedef struct MENU_ITEM_tag
{
unsigned char menu_count ; //当前菜单数目
unsigned char menu_enable; //当前菜单使能
char *display_string; //菜单标题
void (*subs)(); //菜单函数
struct MENU_ITEM_tag* children_menus; //子菜单
}MENU_ITEM_t;
//===================================================
//菜单结构体定义
MENU_ITEM_t *pmenu_point;
//====================================================
struct
{
MENU_ITEM_t *pparent_menu[4]; //指向父菜单的指针,最高为四级菜单
unsigned char parent_count;//菜单层次,第二项为零,则该项菜单灰掉
unsigned char menu_select[4];//上层次选择的菜单,进入下一级菜单前,记录本级菜单的显示位置
unsigned char menu_display_start[4];//上层选择的菜单
}parent_manage;
//===========================================================================
//函数声明
void dtmb_freq_set(void);
void dtmb_vol_set(void);
void cable_freq_set(void);
void cable_symbol_set(void);
void cable_vol_set(void);
void fm1_freq_set(void);
void fm1_vol_set(void);
void fm2_freq_set(void);
void fm2_vol_set(void);
void area_set(void);
void device_num_set(void);
void dtmb_freq_read(void);
void dtmb_vol_read(void);
void cable_freq_read(void);
void cable_symbol_read(void);
void cable_vol_read(void);
void fm1_freq_read(void);
void fm1_vol_read(void);
void fm2_freq_read(void);
void fm2_vol_read(void);
void area_read(void);
void device_num_read(void);
void status_check(void);
void version_check(void);
//===========================================================================
//函数声明
//===========================================================================
MENU_ITEM_t dtmb_para[3] =
{// menu_count DisplayString subs childrenmenu
{3,1, "2-1-1 频率设置", dtmb_freq_set, NULL},
{3,1, "2-1-2 音量设置", dtmb_vol_set, NULL},
{3,1, "<<返回", NULL, NULL}
};
//============================================================================
//cable 参数设置菜单
MENU_ITEM_t cable_para[4]=
{// menu_count DisplayString subs childrenmenu
{4,1, "2-2-1 频率设置", cable_freq_set, NULL},
{4,1, "2-2-2 符号设置", cable_symbol_set, NULL},
{4,1, "2-2-3 音量设置", cable_vol_set, NULL},
{4,1, "<<返回", NULL, NULL}
};
//============================================================================
MENU_ITEM_t fm_para[5] =
{// menu_count DisplayString subs childrenmenu
{5,1, "2-3-1 FM1频率", fm1_freq_set, NULL},
{5,1, "2-3-2 FM1音量", fm1_vol_set, NULL},
{5,1, "2-3-3 FM2频率", fm2_freq_set, NULL},
{5,1, "2-3-4 FM2音量", fm2_vol_set, NULL},
{5,1, "<<返回", NULL, NULL}
};
//============================================================================
MENU_ITEM_t area_para[3] =
{
{3,1, "2-4-1 地址设置", area_set, NULL},
{3,1, "2-4-2 编号设置", device_num_set, NULL},
{3,1, "<<返回", NULL, NULL}
};
//============================================================================
//设置参数菜单
MENU_ITEM_t para_set[5]=
{ // menu_count DisplayString subs childrenmenu
{5,1, "2-1 地数设置", NULL, dtmb_para },
{5,1, "2-2 有线设置", NULL, cable_para},
{5,1, "2-3 调频设置", NULL, fm_para },
{5,1, "2-4 地址设置", NULL, area_para },
{5,1, "<<返回", NULL, NULL},
};
//=============================================================================
//地数参数读取
MENU_ITEM_t read_dtmb_para[3] =
{
{3,1, "1-1-1 地数频率", dtmb_freq_read, NULL },
{3,1, "1-1-2 地数音量", dtmb_vol_read, NULL },
{3,1, "<< 返回", NULL, NULL },
};
//=============================================================================
MENU_ITEM_t read_cable_para[4] =
{
{4,1, "1-2-1 有线频率", cable_freq_read, NULL},
{4,1, "1-2-2 符号率", cable_symbol_read, NULL},
{4,1, "1-2-3 有线音量", cable_vol_read, NULL},
{4,1, "1-2-4 <<返回", NULL, NULL},
};
//=============================================================================
MENU_ITEM_t read_fm_para[5] =
{
{5,1, "1-3-1 FM1频率", fm1_freq_read , NULL},
{5,1, "1-3-2 FM1音量", fm1_vol_read, NULL},
{5,1, "1-3-3 FM2频率", fm2_freq_read, NULL},
{5,1, "1-3-4 FM2音量", fm2_vol_read, NULL},
{5,1, "1-3-5 <<返回", NULL, NULL}
};
//=============================================================================
MENU_ITEM_t read_area_para[3] =
{
{3,1, "1-4-1 地址读取", area_read, NULL},
{3,1, "1-4-2 编号读取", device_num_read, NULL},
{3,1, "<<返回", NULL, NULL}
};
//=============================================================================
//读取参数菜单
MENU_ITEM_t read_para[5] =
{
{5,1, "1-1 地数参数", NULL, read_dtmb_para },
{5,1, "1-2 有线参数", NULL, read_cable_para },
{5,1, "1-3 调频参数", NULL, read_fm_para },
{5,1, "1-4 地址读取", NULL, read_area_para },
{5,1, "<<返回", NULL, NULL }
};
//=============================================================================
//主菜单定义
MENU_ITEM_t main_menu[4] =
{ // menu_count DisplayString subs childrenmenu
{4,1, "1 读取参数", NULL, read_para },
{4,1, "2 设置参数", NULL, para_set },
{4,1, "3 状态查看", status_check, NULL},
{4,1, "4 <<返回", NULL, NULL}
};
加载中...
查看其它23个回答
一周热门
更多
>
相关问题
STM32F4上I2C(在PROTEUS中模拟)调试不通的问题
6 个回答
芯片供应紧张,准备换个MCU,MM32L系列替换STM32L系列的怎么样?
7 个回答
STM32同时使用两个串口进行数据收发时数据丢包的问题
5 个回答
STM32F103串口通信死机问题
4 个回答
STM32WLE5CC连接SX1268在LoRa模式下能与 SX1278互通吗?
2 个回答
相关文章
ST公司第一款无线低功耗单片机模块有效提高物联网设计生产效率
0个评论
如何实现对单片机寄存器的访问
0个评论
通过USB用STM32片内自带Bootloader下载程序及注意事项
0个评论
欲练此功必先自宫之STM32汇编启动,放慢是为了更好的前行
0个评论
×
关闭
采纳回答
向帮助了您的知道网友说句感谢的话吧!
非常感谢!
确 认
×
关闭
编辑标签
最多设置5个标签!
STM32
保存
关闭
×
关闭
举报内容
检举类型
检举内容
检举用户
检举原因
广告推广
恶意灌水
回答内容与提问无关
抄袭答案
其他
检举说明(必填)
提交
关闭
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
×
付费偷看金额在0.1-10元之间
确定
×
关闭
您已邀请
0
人回答
查看邀请
擅长该话题的人
回答过该话题的人
我关注的人
#ifndef _MENU_H
#define _MENU_H
#include "stm32f10x.h"
//=================================================
#ifndef NULL
#define NULL ((void*)0)
#endif
//逻辑状态
#ifndef FALSE
#define FALSE (0)
#endif
#ifndef TRUE
#define TRUE (0)
#endif
//==================================================
typedef struct MENU_ITEM_tag
{
unsigned char menu_count ; //当前菜单数目
unsigned char menu_enable; //当前菜单使能
char *display_string; //菜单标题
void (*subs)(); //菜单函数
struct MENU_ITEM_tag* children_menus; //子菜单
}MENU_ITEM_t;
//===================================================
//菜单结构体定义
MENU_ITEM_t *pmenu_point;
//====================================================
struct
{
MENU_ITEM_t *pparent_menu[4]; //指向父菜单的指针,最高为四级菜单
unsigned char parent_count;//菜单层次,第二项为零,则该项菜单灰掉
unsigned char menu_select[4];//上层次选择的菜单,进入下一级菜单前,记录本级菜单的显示位置
unsigned char menu_display_start[4];//上层选择的菜单
}parent_manage;
//===========================================================================
//函数声明
void dtmb_freq_set(void);
void dtmb_vol_set(void);
void cable_freq_set(void);
void cable_symbol_set(void);
void cable_vol_set(void);
void fm1_freq_set(void);
void fm1_vol_set(void);
void fm2_freq_set(void);
void fm2_vol_set(void);
void area_set(void);
void device_num_set(void);
void dtmb_freq_read(void);
void dtmb_vol_read(void);
void cable_freq_read(void);
void cable_symbol_read(void);
void cable_vol_read(void);
void fm1_freq_read(void);
void fm1_vol_read(void);
void fm2_freq_read(void);
void fm2_vol_read(void);
void area_read(void);
void device_num_read(void);
void status_check(void);
void version_check(void);
//===========================================================================
//函数声明
//===========================================================================
MENU_ITEM_t dtmb_para[3] =
{// menu_count DisplayString subs childrenmenu
{3,1, "2-1-1 频率设置", dtmb_freq_set, NULL},
{3,1, "2-1-2 音量设置", dtmb_vol_set, NULL},
{3,1, "<<返回", NULL, NULL}
};
//============================================================================
//cable 参数设置菜单
MENU_ITEM_t cable_para[4]=
{// menu_count DisplayString subs childrenmenu
{4,1, "2-2-1 频率设置", cable_freq_set, NULL},
{4,1, "2-2-2 符号设置", cable_symbol_set, NULL},
{4,1, "2-2-3 音量设置", cable_vol_set, NULL},
{4,1, "<<返回", NULL, NULL}
};
//============================================================================
MENU_ITEM_t fm_para[5] =
{// menu_count DisplayString subs childrenmenu
{5,1, "2-3-1 FM1频率", fm1_freq_set, NULL},
{5,1, "2-3-2 FM1音量", fm1_vol_set, NULL},
{5,1, "2-3-3 FM2频率", fm2_freq_set, NULL},
{5,1, "2-3-4 FM2音量", fm2_vol_set, NULL},
{5,1, "<<返回", NULL, NULL}
};
//============================================================================
MENU_ITEM_t area_para[3] =
{
{3,1, "2-4-1 地址设置", area_set, NULL},
{3,1, "2-4-2 编号设置", device_num_set, NULL},
{3,1, "<<返回", NULL, NULL}
};
//============================================================================
//设置参数菜单
MENU_ITEM_t para_set[5]=
{ // menu_count DisplayString subs childrenmenu
{5,1, "2-1 地数设置", NULL, dtmb_para },
{5,1, "2-2 有线设置", NULL, cable_para},
{5,1, "2-3 调频设置", NULL, fm_para },
{5,1, "2-4 地址设置", NULL, area_para },
{5,1, "<<返回", NULL, NULL},
};
//=============================================================================
//地数参数读取
MENU_ITEM_t read_dtmb_para[3] =
{
{3,1, "1-1-1 地数频率", dtmb_freq_read, NULL },
{3,1, "1-1-2 地数音量", dtmb_vol_read, NULL },
{3,1, "<< 返回", NULL, NULL },
};
//=============================================================================
MENU_ITEM_t read_cable_para[4] =
{
{4,1, "1-2-1 有线频率", cable_freq_read, NULL},
{4,1, "1-2-2 符号率", cable_symbol_read, NULL},
{4,1, "1-2-3 有线音量", cable_vol_read, NULL},
{4,1, "1-2-4 <<返回", NULL, NULL},
};
//=============================================================================
MENU_ITEM_t read_fm_para[5] =
{
{5,1, "1-3-1 FM1频率", fm1_freq_read , NULL},
{5,1, "1-3-2 FM1音量", fm1_vol_read, NULL},
{5,1, "1-3-3 FM2频率", fm2_freq_read, NULL},
{5,1, "1-3-4 FM2音量", fm2_vol_read, NULL},
{5,1, "1-3-5 <<返回", NULL, NULL}
};
//=============================================================================
MENU_ITEM_t read_area_para[3] =
{
{3,1, "1-4-1 地址读取", area_read, NULL},
{3,1, "1-4-2 编号读取", device_num_read, NULL},
{3,1, "<<返回", NULL, NULL}
};
//=============================================================================
//读取参数菜单
MENU_ITEM_t read_para[5] =
{
{5,1, "1-1 地数参数", NULL, read_dtmb_para },
{5,1, "1-2 有线参数", NULL, read_cable_para },
{5,1, "1-3 调频参数", NULL, read_fm_para },
{5,1, "1-4 地址读取", NULL, read_area_para },
{5,1, "<<返回", NULL, NULL }
};
//=============================================================================
//主菜单定义
MENU_ITEM_t main_menu[4] =
{ // menu_count DisplayString subs childrenmenu
{4,1, "1 读取参数", NULL, read_para },
{4,1, "2 设置参数", NULL, para_set },
{4,1, "3 状态查看", status_check, NULL},
{4,1, "4 <<返回", NULL, NULL}
};
一周热门 更多>