Menu_Control_Uno.ino:249:2:错误:在'if'之前预期的unqualified-id错误compilin [英] Menu_Control_Uno.ino:249:2: error: expected unqualified-id before 'if' Error compilin

查看:108
本文介绍了Menu_Control_Uno.ino:249:2:错误:在'if'之前预期的unqualified-id错误compilin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




不太确定是否有人可以帮助我但..........


我目前正在尝试为20x4 LCD构建菜单布局。我最初让液晶显示器与键盘一起使用,标题屏幕和密码登录密码是非正确的屏幕。


我正在使用Arduino Uno,它通过I2C连接插入20x04 LCD(显示在fitzrig中的1602型号)。使用6-13针将4x4 Matrix键盘插入uno。


我掌握了LCD上的菜单布局后,我将添加一个时钟模块,用于时间和日期以及LED希望使用晶体管来控制Arduino使用的引脚数量。


添加菜单编码后,我一直遇到连续错误。大多数我已经能够解决,直到这一点改变H文件等,但现在我有点不知道接下来要改变什么,因为我是arduino和编码的初学者。问题发生在第249行。我收到的错误信息是:


Menu_Control_Uno.ino:249:2:错误:在''if''之前预期的不合格ID />
编译错误。


菜单程序似乎在没有键盘和LCD代码的情况下自行编译,只要我把它们放在一起我就不得不工作了通过错误。由于菜单不能用于我的液晶显示器,我无法确定代码的确切含​​义,因此我可以根据自己的需要进行更改。


任何帮助都非常感谢


Arduino代码如下:第249行是菜单循环的第一行,以if开头,



if(Serial.available()){

switch(Serial.read()){

case''w'':

if(menu.isCurrentSubMenu()){

subMenu.down(); //设置索引接近0

}

休息;

case''s'':

如果(menu.isCurrentSubMenu()){

subMenu.up(); //设置索引接近最大值

}

休息;

case''a'':

menu .down();

休息;

案例''d'':

menu.up();

break;

case'''':

menu.use();

休息;

case''0'':

menu.select(0);

break;

case''1'':

menu.select(1);

休息;

case''2'':

menu.select(2 );

休息;

}

}

}


void menuChanged(ItemChangeEvent event){

Serial.println(" menuChanged");

if(event ==& menuItem1){

Serial.println(" \ tmenuItem1 selected"); //用户反馈

}否则if(event ==& menuItemWithSubmenu){

Serial.println(" \tmenuItemWithSubmenu selected"); //用户反馈

}否则if(event ==& subMenuItem1){

Serial.println(" \tsubMenuItem1 selected"); //用户反馈

}否则if(event ==& subMenuItem2){

Serial.println(" \ tsubMenuItem2 selected"); //用户反馈

}否则if(event ==& subMenuItem3){

Serial.println(" \ bitsubMenuItem3 selected"); //用户反馈

}否则if(event ==& menuItem3){

Serial.println(" \tmenuItem3 selected"); //用户反馈

}

}


void menuUsed(ItemUseEvent event){

Serial .println(QUOT; menuUsed");

if(event ==& menuItem1){

Serial.println(" \tmenuItem1 used"); //用户反馈

}否则if(event ==& subMenuItem1){

Serial.println(" \tsubMenuItem1 used"); //用户反馈

}否则if(event ==& subMenuItem2){

Serial.println(" \tsubMenuItem2 used"); //用户反馈

}否则if(event ==& subMenuItem3){

Serial.println(" \tsubMenuItem3 used"); //用户反馈

}否则if(event ==& menuItem3){

Serial.println(" \tmenuItem3 used"); //用户反馈

}

}

解决方案

我看到了menuChanged(ItemChangeEvent)和for的函数定义menuUsed(ItemUseEvent),但你的菜单代码不在函数内。


菜单代码在函数内?是吗?


感谢您的回复weaknessforcats。我认为它应该在一个函数内部,所以我可能需要移动它。我基本上有一个displayCodeEntryScreen,它会引导你进入一个menuScreen。


从这个菜单屏幕我希望能够在键盘上选择适用的号码,带我到那个子菜单。


我在arduino网站上找到了菜单代码,但我没有太多运气,所以我最近刚从代码中删除了它。因为我一直试图通过反复试验把不同部分的代码放在不同的部分。当我进入menuScreen并输入键盘时,它总是假设我正在尝试重新输入代码并立即将我恢复为displayCodeEntryScreen。


感谢您的帮助,我附上了完整的代码

展开 | 选择 | Wrap | 行号


您可以尝试这样的事情:

展开 | 选择 | Wrap | 行号

Hi,

Not quite sure if someone will be able to help me but..........

I am currently trying to build a menu layout for a 20x4 LCD. I originally had the LCD working with the keypad to have a title screen and password login with password right and wrong screens.

I am using an Arduino Uno which is plugged into an 20x04 LCD (1602 model shown in fitzrig) via I2C Connection. The 4x4 Matrix keypad is plugged into the uno using pins 6-13.

After I have mastered the menu layout on the LCD I will add in a clock module for time and date and LED''s which will hopefully be controlled using a transistor to reduce the amount of pins used by the Arduino.

After adding the bits of menu coding I have been getting continuous errors. Most I have been able to solve up until this point changing H files etc, but now I am at a bit of a loss as to what to change next as I am a beginner to arduino and coding. the problem is occurring at line 249. The error message I am receiving is:

Menu_Control_Uno.ino:249:2: error: expected unqualified-id before ''if''
Error compiling.

The menu program seems to compile on its own without the keypad and LCD code, as soon as I put them all together I have had to work through errors. Because the menu isn''t working with my LCD I can not tell what exactly the code has done so I can alter it to suit my own needs.

any help out be greatly appreciated

The Arduino code is as follows: line 249 is the first line of the menu loop starting with the word "if"


if (Serial.available()){
switch (Serial.read()){
case ''w'':
if (menu.isCurrentSubMenu()){
subMenu.down(); //set index closer to 0
}
break;
case ''s'':
if (menu.isCurrentSubMenu()){
subMenu.up(); //set index closer to maximum
}
break;
case ''a'':
menu.down();
break;
case ''d'':
menu.up();
break;
case '' '':
menu.use();
break;
case ''0'':
menu.select(0);
break;
case ''1'':
menu.select(1);
break;
case ''2'':
menu.select(2);
break;
}
}
}

void menuChanged(ItemChangeEvent event){
Serial.println("menuChanged");
if( event == &menuItem1 ){
Serial.println("\tmenuItem1 selected"); //user feedback
}else if( event == &menuItemWithSubmenu ){
Serial.println("\tmenuItemWithSubmenu selected"); //user feedback
}else if( event == &subMenuItem1 ){
Serial.println("\tsubMenuItem1 selected"); //user feedback
}else if( event == &subMenuItem2 ){
Serial.println("\tsubMenuItem2 selected"); //user feedback
}else if( event == &subMenuItem3 ){
Serial.println("\tsubMenuItem3 selected"); //user feedback
}else if( event == &menuItem3 ){
Serial.println("\tmenuItem3 selected"); //user feedback
}
}

void menuUsed(ItemUseEvent event){
Serial.println("menuUsed");
if( event == &menuItem1 ){
Serial.println("\tmenuItem1 used"); //user feedback
}else if( event == &subMenuItem1 ){
Serial.println("\tsubMenuItem1 used"); //user feedback
}else if( event == &subMenuItem2 ){
Serial.println("\tsubMenuItem2 used"); //user feedback
}else if( event == &subMenuItem3 ){
Serial.println("\tsubMenuItem3 used"); //user feedback
}else if( event == &menuItem3 ){
Serial.println("\tmenuItem3 used"); //user feedback
}
}

解决方案

I see function definitions for menuChanged(ItemChangeEvent) and for menuUsed(ItemUseEvent) but your menu code is not inside a function.

The menu code is inside a function? Yes?


Thanks for your reply weaknessforcats. I think it is meant to be inside a function so I may need to move it. I basically have a displayCodeEntryScreen which leads you to a menuScreen.

From this menu screen I want to be able select the applicable number on the keypad to take me to that submenu.

I found the menu code on the arduino website, but I wasn''t having much luck with it so I just recently removed it from the code. Since I have been trying to put bits of code in different parts through trial and error. when I get to the menuScreen and input the keyboard, it always assumes that I am trying to re-enter the code and instantly reverts me back to the displayCodeEntryScreen.

Thanks for your help, I have attached the full code

Expand|Select|Wrap|Line Numbers


You might try something like this:

Expand|Select|Wrap|Line Numbers


这篇关于Menu_Control_Uno.ino:249:2:错误:在'if'之前预期的unqualified-id错误compilin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆