完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
我使用的是18F46K22,试图用一个指向子菜单的主菜单来构建菜单结构。使用Switter和EnUM,我试图将(*Roop&*ScRoL2)指向一个列表,在LCD上滚动和显示,并指向基于*滚动选择的函数。当我在LCD上显示时,我得到“(NULL)”,我不能指向下一个枚举列表。
以上来自于百度翻译 以下为原文 I am using an 18F46K22 and trying to build a menu structure with a main menu that points to sub-menus. Using switch and enum I was trying to point (*scroll & *scroll2) to a list to scroll and display on a LCD and to point to a function based on the *scroll selection. When I display on LCD I get “(null)” and I am unable to point to the next enum list. volatile uint8_t *scroll,*scroll2; typedef enum { Time, Pump, Solar, Waterfall, Clean, }MainModes; typedef enum { Timer1, Timer2, Timer3, Timer4, Timer5, Timer6, Timer7, Timer8, }TimerModes; void UITimerSet(void) { PmpTmrSet.Set = On; TimerModes *scroll; while (ButtonStatus.Mode != On) { switch (*scroll) { case Timer1: { PmpTmrUsed.pmptmr0 = On; TimeSet(); break; } case Timer2: { PmpTmrUsed.pmptmr1 = On; TimeSet(); break; } case Timer3: { PmpTmrUsed.pmptmr2 = On; TimeSet(); break; } case Timer4: { PmpTmrUsed.pmptmr3 = On; TimeSet(); break; } case Timer5: { PmpTmrUsed.pmptmr4 = On; TimeSet(); break; } case Timer6: { PmpTmrUsed.pmptmr5 = On; TimeSet(); break; } case Timer7: { PmpTmrUsed.pmptmr6 = On; TimeSet(); break; } case Timer8: { PmpTmrUsed.pmptmr7 = On; TimeSet(); break; } default: if (ButtonStatus.Mode == On && ButtonStatus.Pushed == Off) { ButtonStatus.Pushed == On; return; } } } } void UIModeSet(void) { ModeDisplay(); switch(*scroll) { case Time: { UITimerSet(); } case Pump: { UIPumpSet(); } case Solar: { UISolarSet(); } case Waterfall: { } case Clean: { } } /*end of shift()*/ } void ModeDisplay(void) { MainModes *scroll; extern char buff[17]; do { *scroll2 = *scroll + 1; sprintf(buff, "%s", DisplayText[*scroll]); LineOne; //address on lcd putsXLCD(buff); sprintf(buff, "%s", DisplayText[*scroll2]); LineTwo; //address on lcd while(BusyXLCD()); putsXLCD(buff); if (ButtonStatus.Up == On && ButtonStatus.Pushed == Off) { ButtonStatus.Pushed = On; *scroll++; if (*scroll >= 5) *scroll = 0; else if (*scroll2 >= 5) *scroll2 = 0; } else if (ButtonStatus.Down == On && ButtonStatus.Pushed == Off) { ButtonStatus.Pushed = On; *scroll--; if (*scroll < 0)*scroll = 4; else if (*scroll2 < 0)*scroll2 = 4; } else if (ButtonStatus.Enter == On && ButtonStatus.Pushed == Off) { ButtonStatus.Pushed = On; } } |
|
相关推荐
19个回答
|
|
你有不同的声明*滚动在整个地方,我看不出其中的任何一个被初始化。文件范围中的UTI8*T*滚动被其他声明遮蔽。
以上来自于百度翻译 以下为原文 You've got different declarations of *scroll all over the place, and I can't see where any of them are initialized. And the uint8_t *scroll at file scope is shadowed by the other declarations. |
|
|
|
我怎样纠正这个问题,以便我可以指出不同的列表?当我通过该程序时,主模式列表显示在变量*滚动下,但它不显示在LCD上。
以上来自于百度翻译 以下为原文 How do I correct that so that I can point to the different lists? When I step through the program, the MainModes list is shown under the variable *scroll but it is not showing on the LCD |
|
|
|
这是你的真实密码吗?我不知道它是怎么做的,你期望它和一个有未知价值的卷轴一起做什么?我看不到它应该指向的任何菜单数据结构。
以上来自于百度翻译 以下为原文 Is this your real code? I don't know how it is doing anything. TimerModes *scroll; while (ButtonStatus.Mode != On) { switch (*scroll)What were you expecting that to do with scroll having an unknown value? I don't see any sort of menu data structure that it should be pointing to. |
|
|
|
是的,这是我的代码,你的权利不起作用,这就是为什么我发布它是为了得到帮助来解决它。我试图指向TimeMeLeEnEnter列表。
以上来自于百度翻译 以下为原文 yes this is my code and your right it doesn't work that's why I posted it was to get help on figuring it out. I was trying to point to the TimerModes enum list. |
|
|
|
你有C参考书吗?您似乎不理解“定义”和“声明”之间的区别。您正在使用TyPulf定义一些结构,并且声明一些指针指向该类型的变量,但实际上从未声明指针指向该类型的变量。这声明了一个指向“TimeMeLoad”类型变量的指针,但是在任何地方都没有创建该类型的变量。您的指针将为空。
以上来自于百度翻译 以下为原文 Do you have a C reference book? You don't seem to understand the difference between a "definition" and a "declaration". You are using typedef to define some structures, and you are declaring some pointers to point at a variable of that type, but you are NEVER actually declaring a variable of that type for the pointer to point to. i.e. TimerModes *scroll; This declares a pointer to a variable of type "TimerModes", but you have not created a variable of that type anywhere. Your pointer will just be NULL. |
|
|
|
我想我指的是EnUM列表,如果不是我该怎么做呢?
以上来自于百度翻译 以下为原文 I thought I was when I pointed to the enum list, if not how do I do that? |
|
|
|
“TyPulf”不为您创建变量。它创建一个新的“类型”,然后可以使用该类型来创建该类型的变量。你从来没有那样做过。
以上来自于百度翻译 以下为原文 "typedef" does NOT create a variable for you. It creates a new "type" which can then be used to create a variable of that type. You never do that. |
|
|
|
在该代码中,您没有指向任何地方,任何事件都不能指向枚举。你必须为指针指定一个值,以使它指向某个事物,例如,但不清楚为什么要这样做。TimeMod的值是什么意思?是否有一个对应的文本阵列显示在LCD上的每个模式?
以上来自于百度翻译 以下为原文 You're not pointing to anything anywhere in that code, and you can't point to an enum in any event. You have to assign a value to a pointer to make it point to something, e.g., TimerModes timer_mode; TimerModes *timer_ptr = &timer_mode;But it's not clear why you would want to do that. What do the values of TimerModes mean? Is there an array of corresponding text to display on the LCD for each mode? |
|
|
|
我认为问题是“滚动”不应该是一个指针,而只是一个在你的开关()中使用的枚举对象。但是你仍然需要初始化它。
以上来自于百度翻译 以下为原文 I think the issue is that "scroll" shouldn't be a pointer, just an enum object that you use in your switch(). But you still need to initialize it. |
|
|
|
感谢您的输入,它给了我一些“咀嚼”的好信息。
以上来自于百度翻译 以下为原文 qhb & jtemples thanks for your input, it gives me some good information to "chew on" |
|
|
|
因此,我已经做了大量的阅读,这是我提出的问题,我现在是,我不能滚动通过其余的字符串显示。
以上来自于百度翻译 以下为原文 So I have ben doing lot of reading and this what I have come up with #define MAX_TITLE 10 #define MAX_SUBMENUS 8 typedef struct MENU { char title[MAX_TITLE]; void (*command)(); char num_submenus; uint8_t idx; struct MENU *submenu[MAX_SUBMENUS]; }menu; static char MainMenu [7][11] = { {"Main Menu" }, {"Clock" }, {"Pump" }, {"Solar" }, {"Valve" }, {"Clean" }, {"Info" } }; void navigate_menu(menu *mnu) { if(mnu->num_submenus == 0) { /* Execute the command */ mnu->command(); return; } menu MainMenu = { "Main Menu", NULL, 4, 0, MainMenu }; } The issue that I have now is that I can't scroll through the remaining strings to display. |
|
|
|
您还没有显示任何代码可以做到这一点。你是在问怎么做,还是你写的代码不起作用?
以上来自于百度翻译 以下为原文 You haven't shown any code that could do that. Are you asking how to do it, or have you written code that doesn't work? |
|
|
|
我在问怎么做。我在另一个论坛上发现了这一点,当我使用模拟器的时候,它加载了“主菜单”,但没有一个跟随。
以上来自于百度翻译 以下为原文 I am asking how to do it. I actually found this on another forum and when I step through using the simulator it loads "Main Menu" but none that follow. |
|
|
|
这是我使用的菜单结构:const char const *项[] {“一”,“三”,“四”,“五”,“六”,“七”,“八”,null };在结尾总是空,这样菜单函数可以计算项目的数量,也可以得到字符或像素的最大宽度大小。在使用菜单之后,索引可以被重新排序。UnEnd或- 1超时。菜单必须打开,然后访问,然后关闭。
以上来自于百度翻译 以下为原文 Here is the menu structure I use: typedef struct{ Clip_t Clip; const char **Items; void *Background; bool (*timeoutfunc)(); int TotalItems; int DisplayableItems; int FontWidth; int FontHeight; int Flag; }Menu_t; const char const *items[]={"One","Two","Three","Four","Five","Six","Seven","Eight",NULL}; Always put null at the end so that your menu function can count the number of items and also get a max width size in characters or pixels. After using a menu, an index can be returned or -1 if timeout. The menu has to be opened, accessed then closed. |
|
|
|
@ GOTT2015只是为了澄清,你使用**项指向你的结构中的*项,对吗?你会用什么样的背景来说明?
以上来自于百度翻译 以下为原文 @Gort2015 just for clarification you are using the **Items to point to *items in your structure, is that correct? Also what would you use the *Background to point at? |
|
|
|
我建议你看一下ATM240313XLP 8位开发板。有演示应用软件的源代码。有一个菜单。你应该立即修改它以满足你的需要,你可以看到它是如何制作的,并且移植到你的PIC应该很容易。还有文档,它是FPIC18F8K22和PIC16LF1947。
以上来自于百度翻译 以下为原文 I suggest you look at DM240313 XLP 8-Bit Development Board. There is the sourcecode of DEMO APPLICATION SOFTWARE. There is a Menu. You should modify this in no time for your needs, you see how it is made and porting it to your PIC should be done easily. There is documentation, too. It's for PIC18F87K22 and PIC16LF1947. |
|
|
|
项是指向指针数组的指针。后台保存菜单所占用的背景。当菜单关闭时,后台恢复。通过菜单移动的逻辑非常简单。两个变量:当前项的索引和显示器上的位置。这里是C的一部分。通过菜单向下移动的颂歌。网格或实体网格在项目文本周围使用排他性或。当菜单底部到达时,菜单被滚动,下一个条目被绘制到空的空间中。像素滚动也可能是一个平滑的外观。
以上来自于百度翻译 以下为原文 Items is a pointer to an array of pointers. Background saves the background that will be occupied by the menu. When the menu is closed, the background is restored. The logic of moving through a menu is quite simple. Two variables: index of the current item and position on the display. Here is a part of code that moves through a menu downwards. A grid or solid grid is drawn around the item text using exclusive or. The menu is scrolled up when the bottom of the menu is reached and the next item is drawn into the empty space. Pixel scrolling also possible for a smooth look. //------------------------ if(x&STATUS_CW){ if(item lcd7920_srect(2,2+position*Menu->FontHeight,Menu->Clip.Width-4,Menu->FontHeight-1,COLOR_XOR); //off item++; if(position<(SHOW-1)) position++; else{ lcd7920_vscroll(2,2,Menu->Clip.Width-4,Menu->Clip.Height-4,Menu->FontHeight,COLOR_CLR); lcd7920_setcursor(2,2+(Menu->DisplayableItems-1)*Menu->FontHeight); lcd7920_gputs(Menu->Items[item]); } lcd7920_srect(2,2+position*Menu->FontHeight,Menu->Clip.Width-4,Menu->FontHeight-1,COLOR_XOR); //on } } //------------------------ |
|
|
|
CoppIt包含维度。通过智能编程,在剪辑之外没有任何东西可以绘制,允许星球大战从文本或图形滚动到任何位置上或关闭显示。像你可以推的部分,你可以推cliclisint int LCD7920VVROM(int XPos,int YPos,int宽度,int高度,int滚动,垂直滚动的像素,可以是消极的或积极的。
以上来自于百度翻译 以下为原文 Clip_t contains dimensions. By smart programming nothing can be drawn outside of the clip, allowing Star Wars scrolling with text and graphics from any position on or off display. Like you can push sections, you can push clips. int lcd7920_vscroll(int XPos, int YPos, int Width, int Height, int Scroll, int FillColor); Vertical Scroll by pixels, can be negative or positive. |
|
|
|
有两种不同类型的实体——一个菜单项和整个菜单。菜单项结构可以包含标题、在菜单命中时要执行的函数、可以传递给执行命令的某种信息、ID(如果需要的话)等。因为子菜单是由其他菜单项组成的实体,而不是菜单项的一部分。我建议你省略子菜单直到你的简单菜单工作。菜单是菜单项的某种有序集合。在最简单的形式中,这是一个菜单项数组。这也可以是菜单项或树的链表。开始创建菜单,通过创建集合,学习迭代项目并正确显示标题。这本身就是一项大工程。稍后添加菜单项的执行。不要尝试为菜单设计整个结构。从一个没有标题的简单菜单开始。以后再添加其他的东西——你的结构可能随着你的工作而增长。现在,重要的是菜单项如何组合,如何迭代它们,如何显示它们。不要试图同时做任何事情。拿一小块,一直呆到完成为止。然后进一步移动。
以上来自于百度翻译 以下为原文 There are two separate types of entities - a menu item and the whole menu. The menu item structure may contain the title, the function to execute when menu is hit, some sort of information which may be passed to the execute command, an id (if needed) etc. There is no place for submenus in this structure because submenus are entities which consist of other menu items, and not the part of the menu item. I suggest you omit submenus until your simple menu is working. The menu is some sort of ordered collection of the menu items. In the simplest form this is an array of menu item. This could also be a linked list of menu items, or a tree. Start building your menu by creating the collection, learning to iterate through items and displaying the titles correctly. This is a big work in itself. Add execution of menu items later. Don't try to design the whole struct for the menu. Start from a simple menu items which has nothing but title. Add everything else later - your struct may grow as you work. For now, it is important for you how the menu items come together, how you iterate through them, how you display them. Don't try to do everything at once. Get a tiny little piece and stay on it until it's done. Then move further. |
|
|
|
只有小组成员才能发言,加入小组>>
5161 浏览 9 评论
1999 浏览 8 评论
1928 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3171 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2226 浏览 5 评论
731浏览 1评论
613浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
503浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
629浏览 0评论
527浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 18:57 , Processed in 1.590454 second(s), Total 113, Slave 96 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号