OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 3245|回复: 3

关于oled多级菜单系统,一直报错main.c(83): error: #29: expected an expression

[复制链接]

1

主题

4

帖子

0

精华

初级会员

Rank: 2

积分
50
金钱
50
注册时间
2020-8-14
在线时间
5 小时
发表于 2020-8-15 11:01:00 | 显示全部楼层 |阅读模式
6金钱
一直报错,main.c(83): error:  #29: expected an expression程序如下

#include "led.h"
#include "delay.h"
#include "sys.h"
#include "usart.h"
#include "lcd.h"
//#include "adc.h"
//#include "timer.h"
//#include "pwm.h"
//#include "key.h"
//#include "pid.h"
#include "remote.h"
struct MenuItem
{
    short MenuCount;
    u8 *DisplayString;
    void(*Subs)();
    struct MenuItem *ChildrenMenus;
    struct MenuItem *ParentMenus;
};
struct MenuItem MainMenu[3] = {
    { 3,"set1",NULL,NULL,NULL },
    { 3,"set2",NULL,NULL,NULL },
    { 3,"set3",NULL,NULL,NULL }
};
struct MenuItem Setmenu1[2]={
{ 2,"timeset1",NULL,NULL,MainMenu },
{ 2,"Voiceset1",NULL,NULL,MainMenu }};
struct MenuItem Setmenu2[2] = {
    { 2,"timeset2",NULL,NULL,MainMenu },
    { 2,"Voiceset2",NULL,NULL,MainMenu } };
struct MenuItem Setmenu11[2]={
{ 2,"timeset1.1",NULL,NULL,Setmenu1 },
{ 2,"Voiceset1.1",NULL,NULL,Setmenu1 }};
struct MenuItem* MenuPoint = MainMenu;
short selectItem;
        void display(struct MenuItem * MenuPoint,short selectItem)
{
       int i;
       int j;
       u16 x=30;
       u16 y=30;
        for ( i = 0; i < (selectItem-1); i++)
        {
            LCD_ShowString(x,y,200,16,16,MenuPoint[i].DisplayString);
            y+=30;
        }
        POINT_COLOR=BLACK;
        LCD_DrawRectangle(x-5,y-10,x+60,y+20);
        LCD_ShowString(x,y,200,16,16,MenuPoint[selectItem-1].DisplayString);
        y+=30;
        for ( j= selectItem; j < MenuPoint->MenuCount; j++)
        {
            LCD_ShowString(x,y,200,16,16,MenuPoint[j].DisplayString);
            y+=30;
        }
}
int main(void)
{
    u8 key=0;
    delay_init();                 
    uart_init(9600);         
     LCD_Init();
    Remote_Init();   
    POINT_COLOR=RED;//   
    MainMenu[0].ChildrenMenus = Setmenu1;
    MainMenu[1].ChildrenMenus = Setmenu2;
    Setmenu1[0].ChildrenMenus=Setmenu11;
    selectItem =1;
    display(MenuPoint,selectItem);
    while(1)
    {
        key=Remote_Scan();
        delay_ms(10);
      switch(key)
    {
        case 98:{//?
          LCD_Clear(WHITE);
                if (selectItem == 1) selectItem = MenuPoint->MenuCount;
                else selectItem--;
                display(MenuPoint, selectItem);
            key=0;
                };break;      
        case 168:{/                                (就是这里报错~就是这里报错~就是这里报错)
            LCD_Clear(WHITE);
                if (selectItem == MenuPoint->MenuCount) selectItem = 1;
                 else selectItem++;
                 display(MenuPoint, selectItem);
                 key=0;
                  };break;
         case 194:{
             if (MenuPoint[selectItem - 1].ChildrenMenus != NULL)
                 {
                      LCD_Clear(WHITE);
                     MenuPoint = MenuPoint[selectItem - 1].ChildrenMenus;
                     selectItem = 1;
                     display(MenuPoint, selectItem);
                 }
                 key=0;
         };break;
         case 34:{//?  ??
         if (MenuPoint[selectItem - 1].ParentMenus != NULL)
                 {
                      LCD_Clear(WHITE);
                     MenuPoint = MenuPoint[selectItem - 1].ParentMenus;
                     selectItem = 1;
                     display(MenuPoint, selectItem);
                 }
                 key=0;
         };break;         
     }

     delay_ms(10);     
  }
}


最佳答案

查看完整内容[请看2#楼]

case 168:{/ 改成 case 168:{ 试试
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

6

主题

279

帖子

0

精华

高级会员

Rank: 4

积分
750
金钱
750
注册时间
2015-3-27
在线时间
98 小时
发表于 2020-8-15 11:01:01 | 显示全部楼层
    case 168:{/        改成    case 168:{   试试
回复

使用道具 举报

1

主题

4

帖子

0

精华

初级会员

Rank: 2

积分
50
金钱
50
注册时间
2020-8-14
在线时间
5 小时
 楼主| 发表于 2020-8-15 11:09:39 | 显示全部楼层
本帖最后由 潜水的学徒 于 2020-8-15 11:14 编辑

压缩包无法上传
回复

使用道具 举报

1

主题

4

帖子

0

精华

初级会员

Rank: 2

积分
50
金钱
50
注册时间
2020-8-14
在线时间
5 小时
 楼主| 发表于 2020-8-16 19:34:16 | 显示全部楼层
弦子的弦 发表于 2020-8-16 14:57
case 168:{/        改成    case 168:{   试试

删掉之后就可以了,因为我的软件打不了中文,导致出现“/?”,所以报错,已解决了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-9 01:03

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表