本帖最后由 那就地方iv 于 2015-11-30 09:22 编辑 感谢论坛赠送开发板,这段时间一直在忙,所以就晚上自己加加班搞搞这块L476RG的板子,说出来都是泪,首先自己装的STM32CubeMX老是闪退,自己准备用TIM进行捕捉解红外码,调试2个周末加3个晚上终于搞定了,ST推出的库一开始用感觉真不方便,很多地方多不懂。自己就这样硬着头皮慢慢啃了,后来在论坛上发现版主netlhx的《NUCLEO教程》真是新手的指路灯,再次感谢netlhx版主的资料分享。 我这次做的是用红外遥控可以使液晶显示多个画面,字库自己做的,可以用红外修改参数的数值并保存,有些比较重要的画面还有要求输入密码,只有密码正确才能进入,废话不多说了,看图吧。 添加一些代码,我觉得注释还是蛮多的,详情见附件源码。 //------------------------------------- // // 具体菜单选项定义,定义一个结构数组 // 存储在编码区,节省内存RAM // //------------------------------------- struct Option sOption[OPTIONMETE] = { {0,4,13, "基本设置 ",4}, //0 {0,18,13,"反馈设置 ",4}, //1 {0,46,13,"高级设置 ",4}, //2 {0,73,13,"故障诊断 ",4}, //3 {1,OPTIONMETE-1,0," ",0}, //4 {1,OPTIONMETE-1,0," 请输入基本密码",0}, //5 {1,OPTIONMETE-1,0," ",0}, //6 {1,OPTIONMETE-1,0," ",0}, //7 {2,OPTIONMETE-1,0,"关位确认 ",4}, //8 {2,OPTIONMETE-1,0,"开位确认 ",4}, //9 {2,OPTIONMETE-1,0,"调节死区 ",4}, //10 {2,OPTIONMETE-1,0,"丢信动作 ",4}, //11 {2,OPTIONMETE-1,0,"关过矩值 ",4}, //12 {2,OPTIONMETE-1,0,"开过矩值 ",4}, //13 {2,OPTIONMETE-1,0,"显示方向 ",4}, //14 {2,OPTIONMETE-1,0,"现场控制 ",4}, //15 {2,OPTIONMETE-1,0,"更改基本密码 ",6}, //16 {2,OPTIONMETE-1,0,"恢复出厂值 ",5}, //17 {3,OPTIONMETE-1,1," ",0}, //18 {3,OPTIONMETE-1,1," 请输入反馈密码",0}, //19 {3,OPTIONMETE-1,1," ",0}, //20 {3,OPTIONMETE-1,1," ",0}, //21 {4,OPTIONMETE-1,1,"低端微调 ",4}, //22 {4,OPTIONMETE-1,1,"高端微调 ",4}, //23 {4,27,1,"触点输出 ",4}, //24 {4,27,1,"扩展触点 ",4}, //25 {4,OPTIONMETE-1,1,"更改反馈密码 ",6}, //26 {5,OPTIONMETE-1,24,"关到位 ",3}, //27 {5,OPTIONMETE-1,24,"开到位 ",3}, //28 {5,OPTIONMETE-1,24,"关过矩 ",3}, //29 {5,OPTIONMETE-1,24,"开过矩 ",3}, //30 {5,OPTIONMETE-1,24,"过 矩 ",3}, //31 {5,OPTIONMETE-1,24,"正在关 ",3}, //32 {5,OPTIONMETE-1,24,"正在开 ",3}, //33 {5,OPTIONMETE-1,24,"正在运行 ",4}, //34 {5,39,24,"中间位置 ",4}, //35 {5,OPTIONMETE-1,24,"远方位置 ",4}, //36 {5,OPTIONMETE-1,24,"现场位置 ",4}, //37 {6,OPTIONMETE-1,35," 运行到达位置 ",0}, //38 {6,OPTIONMETE-1,35," ",0}, //39 {6,OPTIONMETE-1,35," ",0}, //40 {6,OPTIONMETE-1,35," ",0}, //41 {7,OPTIONMETE-1,24," 故障报警 ",0}, //42 {7,OPTIONMETE-1,24,"过矩报警 ",4}, //43 {7,OPTIONMETE-1,24,"远方报警 ",4}, //44 {7,OPTIONMETE-1,24," ",0}, //45 {8,OPTIONMETE-1,2," ",0}, //46 {8,OPTIONMETE-1,2," 请输入高级密码",0}, //47 {8,OPTIONMETE-1,2," ",0}, //48 {8,OPTIONMETE-1,2," ",0}, //49 {9,OPTIONMETE-1,2,"ESD 设置 ",4}, //50 {9,OPTIONMETE-1,2,"关闭方式 ",4}, //51 {9,OPTIONMETE-1,2,"关闭方向 ",4}, //52 {9,OPTIONMETE-1,2,"正反作用 ",4}, //53 {9,OPTIONMETE-1,2,"转矩显示 ",4}, //54 {9,OPTIONMETE-1,2,"反馈低端 ",4}, //55 {9,OPTIONMETE-1,2,"两线控制 ",4}, //56 {9,OPTIONMETE-1,2,"标定低信 ",4}, //57 {9,OPTIONMETE-1,2,"标定高信 ",4}, //58 {9,OPTIONMETE-1,2,"刹车制动 ",4}, //59 {9,OPTIONMETE-1,2,"停动时间 ",4}, //60 {9,OPTIONMETE-1,2,"间断运行 ",4}, //61 {9,OPTIONMETE-1,2,"更改高级密码 ",6}, //62 {9,OPTIONMETE-1,2,"基本密码查询 ",6}, //63 {9,OPTIONMETE-1,2,"反馈密码查询 ",6}, //64 {9,66,2,"保存出厂值 ",5}, //65 {10,OPTIONMETE-1,65," ",0}, //66 {10,OPTIONMETE-1,65,"请输入出厂密码 ",0}, //67 {10,OPTIONMETE-1,65," ",0}, //68 {10,OPTIONMETE-1,65," ",0}, //69 {11,OPTIONMETE-1,65,"保存出厂设置 ",6}, //70 {11,OPTIONMETE-1,65,"电源选项 ",4}, //71 {11,OPTIONMETE-1,65,"远方保持 ",4}, //72 {12,OPTIONMETE-1,3,"方式钮位置 ",5}, //73 {12,OPTIONMETE-1,3,"操作钮位置 ",5}, //74 {12,OPTIONMETE-1,3,"远方打开信号 ",6}, //75 {12,OPTIONMETE-1,3,"远方关闭信号 ",6}, //76 {12,OPTIONMETE-1,3,"远方保持信号 ",6}, //77 {12,OPTIONMETE-1,3,"远方自动信号 ",6}, //78 {12,OPTIONMETE-1,3,"远方ESD 信号 ",6}, //79 {12,OPTIONMETE-1,3,"控制电流 ",4}, //80 {13,OPTIONMETE-1,61,"开向始位 ",4}, //81 {13,OPTIONMETE-1,61,"开向终位 ",4}, //82 {13,OPTIONMETE-1,61,"开向动程 ",4}, //83 {13,OPTIONMETE-1,61,"开向停时 ",4}, //84 {13,OPTIONMETE-1,61,"关向始位 ",4}, //85 {13,OPTIONMETE-1,61,"关向终位 ",4}, //86 {13,OPTIONMETE-1,61,"关向动程 ",4}, //87 {13,OPTIONMETE-1,61,"关向停时 ",4}, //88 {14,OPTIONMETE-1,50,"ESD 动位 ",4}, //89 {14,OPTIONMETE-1,50,"ESD 有效电平 ",6}, //90 {14,OPTIONMETE-1,50,"ESD 超越过热 ",6}, //91 {14,OPTIONMETE-1,50,"ESD 超越停止 ",6}, //92 {14,OPTIONMETE-1,50,"ESD 超越间断 ",6}, //93 {14,OPTIONMETE-1,50,"ESD 超越过矩 ",6}, //94 {15,OPTIONMETE-1,56," 两线设置 ",0}, //95 {15,OPTIONMETE-1,56,"有信开,无信关 ",7}, //96 {15,OPTIONMETE-1,56,"有信关,无信开 ",7}, //97 {MENULEVEL-1,OPTIONMETE-1,0,"",0} //98 }; //---------------------------------------- // // 菜单上移一项函数 // 函数原形:void MenuUpOneOption (void); // 没有参数,没有返回值 // 调用方式:void MenuUpOneOption (void); // //---------------------------------------- void MenuUpOneOption (void) { if(MenuLevelStart()) //如果当前为表单第一项 { if(Level[sOption[SelectIndex].KeyLevel][2]>=4) //并且表单中选项数目大于等于4个 { FirstLineDisIndex = Level[sOption[SelectIndex].KeyLevel][1]-3; //第一行显示索引号为倒数第四项 SelectIndex = Level[sOption[SelectIndex].KeyLevel][1]; //选择索引为表单最后一项 SelectLine = 4; //标记选择行为第四行 DIS12864M(); //刷新屏幕显示 } else //如果选项数目并不大于四个 { SelectIndex = Level[sOption[SelectIndex].KeyLevel][1]; //选择索引为当前表单最后一个 SelectLine = Level[sOption[SelectIndex].KeyLevel][2]; //显示行表单数目(最后一个) DIS12864M(); //刷新屏幕显示 } } else //如果当前不是开始索引 { if(SelectLine==1) //并且已经在屏幕最上边一行 { FirstLineDisIndex--; //显示索引上移 SelectIndex--; //选择索引自减 SelectLine = 1; //选择行还是第一行 DIS12864M (); //刷新屏幕 } else //如果不是第一行 { SelectLine--; //选择行自减 SelectIndex--; //选择索引自减 DIS12864M (); //刷新屏幕显示 } } } //---------------------------------------- // // 菜单下移一项函数 // 函数原形:void MenuDownOneOption (void); // 没有参数,没有返回值 // 调用方式:void MenuDownOneOption (void); // //---------------------------------------- void MenuDownOneOption (void) { if(MenuLevelEnd()) //如果当前是表单最后一个索引 { FirstLineDisIndex = Level[sOption[SelectIndex].KeyLevel][0]; //第一行显示索引为表单第一个选项 SelectIndex = Level[sOption[SelectIndex].KeyLevel][0]; //选择索引为表单第一个选项索引 SelectLine = 1; //选择行为第一行 DIS12864M (); //刷新显示 } else //如果不是最后的索引 { if(SelectLine!=4) //如果当前不是屏幕最底行 { SelectIndex++; //选择索引自加 SelectLine++; //选择行下移 // SetALineReverse (SelectLine); //刷新选择行 DIS12864M (); //刷新显示 } else //如果是屏幕最低行 { FirstLineDisIndex++; //第一行显示下移 SelectIndex++; //选择索引自加 DIS12864M(); //刷新显示 } } } //---------------------------------------- // // 菜单退出功能函数 // 函数原形:void MenuCancelOption (void); // 没有参数,没有返回值 // 调用方式:void MenuCancelOption (void); // //---------------------------------------- void MenuCancelOption (void) { if(SelectIndex != OPTIONMETE-1) //如果不是从功能返回 { if(CancelIndex_flag == 1 && sOption[SelectIndex].KeyLevel == 5) { CancelIndex_flag = 0; SelectIndex = 25;} else SelectIndex = sOption[SelectIndex].CancelIndex; //选择索引为选项返回索引 } else //如果是从功能返回 SelectIndex = LastIndex;//索引等于进入前保存索引 if(Level[sOption[SelectIndex].KeyLevel][2]>=4) //如果返回表单选项数目大于4个 { if(SelectIndex > Level[sOption[SelectIndex].KeyLevel][1]-3) //根据返回选项确定显示首项 { FirstLineDisIndex = Level[sOption[SelectIndex].KeyLevel][1]-3; SelectLine = 4-(Level[sOption[SelectIndex].KeyLevel][1]-SelectIndex); DIS12864M (); //刷新显示 } else //一般显示方式 { FirstLineDisIndex = SelectIndex; //第一行显示索引 SelectLine = 1; //选择第一行 DIS12864M (); //刷新菜单 } } else //如果返回表单选项数目不足4个 { FirstLineDisIndex = Level[sOption[SelectIndex].KeyLevel][0]; //第一行显示索引为表单第一项 SelectLine = SelectIndex - Level[sOption[SelectIndex].KeyLevel][0]+1; //选择行标志为当前选择索引对应行 DIS12864M (); //刷新菜单 } } 因为之前的文件比较大,我就上传了源代码(未添加L4的库),现在我已经将整个开发工程上传到百度云(可直接编译)。 链接:https://pan.baidu.com/s/1gdHKxKB 密码:e173 |
在源码的“lcd12864_st7567.h”中有引脚对应的信息,我刚在附件里加了LCD的手册,另外我的代码是在STM32Cube_FW_L4_V1.1.0库里的列程。路径为:stm32cubel4\STM32Cube_FW_L4_V1.1.0\Projects\STM32L476RG-Nucleo\Examples\TIM\TIM_InputCapture。你只要将文件考到该目录下,在重新配置一下keil里引用库的路径即可。配置键附件配置图
å¼è对åºå¾
液æ¶èµæJLX12864G-330.pdf
2015-11-26 13:17 上传
点击文件名下载附件
下载积分: ST金币 -1722.48 KB, 下载次数: 9, 下载积分: ST金币 -1
液æ¶åå·
是的,背光是蓝色的,也就是蓝底白字
清楚显示区的白色区域能否去掉,只能留字?
谢谢
蓝底是不是你的液晶背光板是蓝颜色的啊,我的背光板是白色
谢谢
谢谢
谢谢
也是在别人的基础上延伸的
自己做的一个液晶显示画面
哈哈,厉害,帮顶