|
|
楼主 |
发表于 2014-12-8 20:07:27
|
显示全部楼层
本帖最后由 apachectlQQ 于 2014-12-8 20:22 编辑
- <p>//=============================================================================
- //文件名称:main.c
- //功能概要:key
- //版权所有:apachectl
- //淘宝网店:http://shop104540872.taobao.com/
- //版本更新:2014-04-12
- //=============================================================================
- //头文件
- #include "stm32f0xx.h"
- #include "stdio.h"
- #include "def.c"
- #include "init.c"
- #include "func.c"
- u8 isKeyDown(void); //检测是否有按键按下
- void u232out(char * buf1);
- void setup(void);
- void loop(void);
- void onkey(void);
- void showwin1(void);
- void showdebug(void);
- //=============================================================================
- //文件名称:main
- //功能概要:主函数
- //参数说明:无
- //函数返回:int
- //=============================================================================
- void gowin(u8 n)
- { winnum=n;
- setup();
- }
- int main(void)
- {
- system_init();
- USART_ENABLE_REV();
- Delayms(2000000);
- LoadROM();
- GpuSend("DR2;CLS(0);SPG(1);\r\n");
- winnum=1;
- cjs=0;
- iscmd=0;
- iscmdok=0;
- loopcount=0;
- iswaiting=0;
- setup();
-
- while(1)
- {
- if (iscmdok==1) {onkey();iscmdok=0;};
-
- loopcount++;
- if (loopcount==100000)
- { if (iswaiting==0) loop();
- loopcount=0;
- }
-
- }
- }
- void setup(void)
- { switch (winnum)
- { case 1:
- GpuSend("DR2;CLS(0);DS24(4,0,'锂电池电压',1);DS24(160,0,'总电压:',4);BOX(0,30,319,130,11);\r\n");
- break;
- case 2:
- GpuSend("DR2;CLS(0);SPG(2);\r\n");
- break;
- case 3:
- GpuSend("DR2;CLS(0);DS16(0,0,'Debug:',1);\r\n");
- break;
- }
- Delayms(200000);
- }
- void loop(void)
- { switch(winnum)
- { case 1:
- showwin1();
- break;
- case 3:
- showdebug();
- break;
- }
- }
- void onkey(void)
- { //BC:0001 BA:0001 BB:0000
-
- switch (winnum)
- { case 1:
- if ((cmd[0]=='B') &(cmd[1]=='C') &(cmd[6]=='1'))
- { //A按键单击
- gowin(3);
- }
- if ((cmd[0]=='B') &(cmd[1]=='A') &(cmd[6]=='1'))
- { //A按键长按击
- gowin(2);
- iswaiting=1; //进入按钮释放等待循环中
-
- }
- if ((cmd[0]=='B') &(cmd[1]=='B'))
- { iswaiting=0; //长按按键释放
- }
- break;
- case 2:
- if ((cmd[0]=='B') &(cmd[1]=='C') &(cmd[6]=='1'))
- { //A按键单击
- Set5VBase();
- SaveROM();
- gowin(1);
- }
- break;
- case 3:
- if ((cmd[0]=='B') &(cmd[1]=='C') &(cmd[6]=='1'))
- { //A按键单击
- gowin(1);
- }
- break;
-
- }
- //if(cmd[0]==
- }
- void showwin1(void)
- { u8 i,y,c;
- u16 x1,x2;
- CompADC();
- CompVol();
- CompLi();
- CompCellPer();
- min=99;max=0;argv=0;
- js=0;
- for (i=0;i<6;i++)
- { if (Li[i]>1)
- { argv+=Li[i];
- js++;
- if (Li[i]<=min) min=Li[i];
- if (Li[i]>max) max=Li[i];
- }
- }
- if (min==99) min=0;
- argv=argv/js;
- for (i=0;i<6;i++)
- { x1=i*54+10;x2=x1+30;
- if (Li[i]>1)
- { sprintf(buf,"ICON(%d,165,1,11,1,%d);DS16(%d,224,'%.2f',4);",54*i,CellPer[i],54*i+4,Li[i]);
- GpuSend(buf);
- y=(Li[i]-argv)*100;
- y=80-y;
- c=2;
- if (y>130) {y=130;c=1;};
- if (y<30) {y=30;c=1;};
- sprintf(buf,"BOXF(%d,31,%d,%d,0);BOXF(%d,%d,%d,129,%d);",x1,x2,y,x1,y,x2,c);
- GpuSend(buf);
- }
- else
- { sprintf(buf,"ICON(%d,165,1,11,1,10);DS16(%d,224,' --- ',4);BOXF(%d,31,%d,79,0);BOXF(%d,81,%d,129,0);",54*i,54*i+4,x1,x2,x1,x2);
- GpuSend(buf);
-
- }
- }
- sprintf(buf,"DS24(240,0,'%.2fV',4);DS16(10,140,'最高:%.2fV 平均:%.2fV 最低:%.2fV',3);",LV[js-1],max,argv,min);
- GpuSend(buf);
- GpuSend("PL(0,80,320,80,11);\r\n");
- Delayms(1000000);
- }
- void showdebug(void)
- { u8 i;
- CompADC();
- CompVol();
- for (i=0;i<M;i++)
- { sprintf(buf,"DS16(10,%d,'AD%d:%5d',4);",i*20+20,i,After_filter[i]);
- GpuSend(buf);
- }
- for (i=0;i<6;i++)
- { sprintf(buf,"DS16(100,%d,'V%d:%.2fV',15);",i*20+40,i,LV[i]);
- GpuSend(buf);
- }
-
- GpuSend("\r\n");
- }
- /*****END OF FILE****/
- </p>
复制代码
源代码工程文件下载:
源代码工程文件包:http://pan.baidu.com/s/1i3029Qd
gpumaker资源文件包:http://pan.baidu.com/s/1eQ7uuKa
编译好的CPU文件:http://pan.baidu.com/s/1Cmk26
淘宝链接:http://item.taobao.com/item.htm?id=42843185420
=============================================================================
截止到12月16日前,凡是购买备注“模友之吧”的,优惠10元,拍下改价
爆料下:我的航模初级,都是3S的,没有6S的电池,怎么办?
自己特制的用于测试用的6S,绝对独一份:
|
| |