|
【开源】基于迪文屏的智能猫粮控制系统方案
一、介绍 最近做了一款猫粮控制系统,可以通过屏幕观察到猫粮情况,如温度、湿度、猫粮剩余情况以及猫咪吃粮记录。主要以水墨风为主题,还有点击时的水墨效果,增强触摸的视觉反馈,大家可以在结尾的视频中观看。
二、设计想法
首先是界面素材,从0到1都是自己设计的。主要最近学了AI,用AI工具直接画的,后续的一些素材可能也会自己用AI去画,因为这样后期想要修改也PS容易。其次就是点击特效,这个是我在思考挺久之后想出来的一个设计,因为单纯的显示一些温湿度、猫粮情况没有太大的观赏性,所以在此基础上我设计了点击特效,从视频上效果还是很不错的,点击时还有音效哦~
三、界面设计
这次素材文件比较多,如下图所示。 之后就是欢迎界面设计,欢迎界面就是一个点击特效图标+基础触摸,如下图所示。 接下来是状态界面设计,状态就比较多了,可以显示猫粮的剩余量,温湿度,投放克数以及当前时间,如下图所示。 记录页面主要就是显示猫咪吃粮的时间,加上两个基础触摸用于查看上下吃粮的时间,如下图所示。 之后就是设置页面了,这个页面的控件比较多,因为每个数值都需要能够进行设置,并且还有定时投放猫粮的模式设置,如下图所示。 最后就是调节页面了,所有关于数字调节的控件,在点击之后都会进入该页面,点击确定之后会自动更新对应的控件值,如下图所示。 四、代码设计 首先是点击特效和音效,51程序中会获取触摸的位置,然后移动特效变量到触摸的位置,然后开始进行动画播放,是不是很简单~ 检测触摸位置代码并播放音效: - void TouchDetect()
- {
- u16 Va[3] = 0;
- u8 i = 0;
- for(i = 0;i < 3;i++)
- {
- Va[i] = Read_Dgus(0x0016 + i);
- if(Va[0] == 0x5A01)
- {
- }
- else
- {
- break;
- }
- }
- if(i != 0) //第一次点击进入
- {
- u16 play[2] = {0x0001, 0x4000};
- touchAnimationFlag = 1;
- touchAnimationCnt = 0;
- touchPosX = Va[1];
- touchPosY = Va[2];
- write_dgus_vp(0x00A0, play, 2);
- }
- }
复制代码触摸特效显示的代码如下所示: - void TouchStart()
- {
- if(touchAnimationFlag == 1)
- {
- if(touchAnimationCnt == 0)
- {
- Write_Dgus(0x5011, touchPosX - 100);
- Write_Dgus(0x5012, touchPosY - 100);
- }
- Write_Dgus(0x5000, touchAnimationCnt);
- touchAnimationCnt++;
- if(touchAnimationCnt == 6)
- {
- touchAnimationFlag = 0;
- Write_Dgus(0x5011, 1024);
- Write_Dgus(0x5012, 600);
- }
- }
- }
复制代码接下来就是最核心的,触摸对应的数值,跳转到另一个页面时需要修改指定数值的功能,主要是通过触摸进行实现的,具体代码如下所示: - //获取按键状态
- void get_key_status()
- {
- int i = 0;
- //u16 Va=Read_Dgus(addr);
- u16 Va=Read_Dgus(0x1000);
- if(Va != 0x0000)
- {
- //状态页
- if(Va == 0x0103) //放置g数量
- {
- u16 switchpage[2] = {0x5A01, 19};
- setNum = placeGramNum;
- backPage = 1; //返回状态页
- Write_Dgus(0x4000 + 0, setNum % 10);
- Write_Dgus(0x4000 + 2, setNum / 10 % 10);
- Write_Dgus(0x4000 + 4, setNum / 100 % 10);
- Write_Dgus(0x4000 + 6, setNum / 1000 % 10);
- write_dgus_vp(0x0084, switchpage, 2);
- }
- else if(Va == 0x0102)
- {
- OneSendData3(placeGramNum); //放置一次粮
- }
- else if(Va == 0x0101) //设置页面
- {
- u16 switchpage[2] = {0x5A01, 3};
- for(i = 0;i < 6;i++)
- {
- if(i == 0)
- {
- Write_Dgus(0x3070 + i * 0x10 + 0, currentTime[i] % 10);
- Write_Dgus(0x3070 + i * 0x10 + 2, currentTime[i] / 10 % 10);
- Write_Dgus(0x3070 + i * 0x10 + 4, currentTime[i] / 100 % 10);
- Write_Dgus(0x3070 + i * 0x10 + 6, currentTime[i] / 1000 % 10);
- }
- else
- {
- Write_Dgus(0x3070 + i * 0x10 + 0, currentTime[i] % 10);
- Write_Dgus(0x3070 + i * 0x10 + 2, currentTime[i] / 10 % 10);
- }
- }
- write_dgus_vp(0x0084, switchpage, 2); //进入设置页
- }
- else if(Va == 0x0100) //记录页面
- {
- u16 switchpage[2] = {0x5A01, 2};
- for(i = 0;i < 6;i++)
- {
- if(i == 0)
- {
- Write_Dgus(0x2000 + i * 0x10 + 0, eatFeedList[0][i] % 10);
- Write_Dgus(0x2000 + i * 0x10 + 2, eatFeedList[0][i] / 10 % 10);
- Write_Dgus(0x2000 + i * 0x10 + 4, eatFeedList[0][i] / 100 % 10);
- Write_Dgus(0x2000 + i * 0x10 + 6, eatFeedList[0][i] / 1000 % 10);
- }
- else
- {
- Write_Dgus(0x2000 + i * 0x10 + 0, eatFeedList[0][i] % 10);
- Write_Dgus(0x2000 + i * 0x10 + 2, eatFeedList[0][i] / 10 % 10);
- }
- }
- write_dgus_vp(0x0084, switchpage, 2); //进入记录页
- }
- //记录页
- else if(Va == 0x0201) //记录页面上一个
- {
- if(lookEatCnt > 0)
- {
- lookEatCnt--;
- for(i = 0;i < 6;i++)
- {
- if(i == 0)
- {
- Write_Dgus(0x2000 + i * 0x10 + 0, eatFeedList[lookEatCnt][i] % 10);
- Write_Dgus(0x2000 + i * 0x10 + 2, eatFeedList[lookEatCnt][i] / 10 % 10);
- Write_Dgus(0x2000 + i * 0x10 + 4, eatFeedList[lookEatCnt][i] / 100 % 10);
- Write_Dgus(0x2000 + i * 0x10 + 6, eatFeedList[lookEatCnt][i] / 1000 % 10);
- }
- else
- {
- Write_Dgus(0x2000 + i * 0x10 + 0, eatFeedList[lookEatCnt][i] % 10);
- Write_Dgus(0x2000 + i * 0x10 + 2, eatFeedList[lookEatCnt][i] / 10 % 10);
- }
- }
- }
- }
- else if(Va == 0x0202) //记录页面下一个
- {
- if(lookEatCnt < eatCnt - 1)
- {
- lookEatCnt++;
- for(i = 0;i < 6;i++)
- {
- if(i == 0)
- {
- Write_Dgus(0x2000 + i * 0x10 + 0, eatFeedList[lookEatCnt][i] % 10);
- Write_Dgus(0x2000 + i * 0x10 + 2, eatFeedList[lookEatCnt][i] / 10 % 10);
- Write_Dgus(0x2000 + i * 0x10 + 4, eatFeedList[lookEatCnt][i] / 100 % 10);
- Write_Dgus(0x2000 + i * 0x10 + 6, eatFeedList[lookEatCnt][i] / 1000 % 10);
- }
- else
- {
- Write_Dgus(0x2000 + i * 0x10 + 0, eatFeedList[lookEatCnt][i] % 10);
- Write_Dgus(0x2000 + i * 0x10 + 2, eatFeedList[lookEatCnt][i] / 10 % 10);
- }
- }
- }
- }
- //设置页
- else if(Va == 0x0302)
- {
- if(timeMode == 1)
- {
- timeMode = 0;
- Write_Dgus(0x3A12, 139);
- }
- }
- else if(Va == 0x0303)
- {
- if(timeMode == 0)
- {
- timeMode = 1;
- Write_Dgus(0x3A12, 242);
- }
- }
- else if(Va >= 0x0304 && Va <= 0x0309)
- {
- u16 switchpage[2] = {0x5A01, 19};
- backPage = 3;
- backNum = Va;
- setNum = timrIntervalHour[Va - 0x0304];
- Write_Dgus(0x4000 + 0, setNum % 10);
- Write_Dgus(0x4000 + 2, setNum / 10 % 10);
- Write_Dgus(0x4000 + 4, setNum / 100 % 10);
- Write_Dgus(0x4000 + 6, setNum / 1000 % 10);
- write_dgus_vp(0x0084, switchpage, 2);
- }
- else if(Va >= 0x030A && Va <= 0x030F)
- {
- u16 switchpage[2] = {0x5A01, 19};
- backPage = 3;
- backNum = Va;
- setNum = currentTime[Va - 0x030A];
- Write_Dgus(0x4000 + 0, setNum % 10);
- Write_Dgus(0x4000 + 2, setNum / 10 % 10);
- Write_Dgus(0x4000 + 4, setNum / 100 % 10);
- Write_Dgus(0x4000 + 6, setNum / 1000 % 10);
- write_dgus_vp(0x0084, switchpage, 2);
- }
- //调节数据页
- else if(Va == 0x0400) //确定
- {
- u16 switchpage[2] = {0x5A01, 0x0000};
- switchpage[1] = backPage;
- if(backPage == 1) //返回状态页
- {
- placeGramNum = setNum;
- Write_Dgus(0x1140 + 0, placeGramNum % 10);
- Write_Dgus(0x1140 + 2, placeGramNum / 10 % 10);
- }
- else if(backPage == 3)
- {
- if(backNum >= 0x0304 && backNum <= 0x0309)
- {
- u16 select = 0;
- select = (backNum - 0x0304) * 0x10;
- timrIntervalHour[backNum - 0x0304] = setNum;
- Write_Dgus(0x3010 + select + 0, setNum % 10);
- Write_Dgus(0x3010 + select + 2, setNum / 10 % 10);
- }
- else if(backNum >= 0x030A && backNum <= 0x030F)
- {
- u16 select = 0;
- select = (backNum - 0x0304) * 0x10;
- currentTime[backNum - 0x030A] = setNum;
复制代码最后给大家展示一下效果。 首页效果图: 状态页效果图: 记录页效果图: 设置页效果图: |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
|