12864液晶顯示display.h基于msp430單片機頭文件代碼最后的復制代碼保存到電腦的方式實現下載:
- uchar a=0,c=80;
- uint dianya[11];
- uchar dianliu[11];
- //uchar key_value;
- //uchar FLAG=0;
- void display_voltage(unsigned int result_zz1)//顯示電壓
- { DisplayCgrom(0x90," ");
- DisplayCgrom(0x90,"電壓: ");
- unsigned char temp_value[6];
- temp_value[0]=(result_zz1/1000)+0x30; //加(0x30)=48,‘0’,化int數字為char數字字符
- temp_value[1]=(result_zz1%1000/100)+0x30;
- temp_value[2]='.';
- temp_value[3]=(result_zz1%1000/10%10)+0x30;
- temp_value[4]=(result_zz1%10 )+0x30;
- temp_value[5]=' ';
- if(temp_value[0]==0)temp_value[0]=' ';
- LCD_write_str(0x03,1,temp_value);
- LCD_write_str(0x06,1,"v ");
- dianya[a]=result_zz1;
-
- }
- void display_current(unsigned int result_zz1)//顯示電流
- {
- unsigned char temp_value[4];
- temp_value[0]=(result_zz1/100)+0x30; //加(0x30)=48,‘0’,化int數字為char數字字符
- temp_value[1]='.';
- temp_value[2]=(result_zz1/10%10)+0x30;
- temp_value[3]=(result_zz1%10 )+0x30;
- LCD_write_str(0x04,0,temp_value);
- LCD_write_str(0x06,0,"A ");
- dianliu[a]=result_zz1;
- }
- void display_set(void)//設定電流
- {
- uchar b[4];
- b[0]=(a/10)+0x30;
- b[1]=(a%10)+0x30;
- if(a/10==0)b[0]=' ';
- b[2]=0+0x30;b[3]=0+0x30;
- if(a==0){b[1]=' ';b[2]=' ';}
- DisplayCgrom(0x88,"設定電流: ");
- LCD_write_str(0x05,2,b);
- LCD_write_str(0x07,2,"MA");
-
- }
- void display_caculate(void)//計算電源負載調整率
- { DisplayCgrom(0x98," ");
- DisplayCgrom(0x98,"負載調整率:");
- uchar d[4];
- d[0]=c/100+0x30;
- d[1]=c%100/10+0x30;
- d[2]=c%100%10+0x30;
- if(c/100==0)d[0]=':';
- d[3]=' ';
- LCD_write_str(0x05,3,d);
- LCD_write_str(0x07,3," %");
- }
- //
- void key_inint(void)
- { P1DIR=0X00;
- P1IE=0X30;
- P1IES=0X30;
- P1IFG=0X00;
- _EINT();
- }
- #pragma vector=PORT1_VECTOR
- __interrupt void port1(void)
- {
- switch(P1IFG)
- {
- case 0x10:a++;delay_ms(1);break;
- case 0x20:a--;delay_ms(1);break;
- default:P1IFG=0X00;break;
- }
- P1IFG=0X00;
- if(a>=11)a=0;
- //caculate1();
- }
- /*uchar readkey(void)
- {unsigned char shu;
- shu=P1IN&0xf0;
- if(shu!=0xf0)
- {delay_ms(10);
- if(shu!=0xf0)
- {FLAG=1;
- return shu;}
- else return 0xf0;
- }
- else return 0xf0;
- }
- void seta()
- { FLAG=0;
- a++;
- if(a>10)a=1;
- }
- void setb()
- { FLAG=0;
- a--;
- if(a<1)a=10;
- }
- void key()
- {unsigned key;
- key=readkey();
- switch(key)
- {case 0xe0:seta();break;//設定電流比例
- case 0xd0:setb();break;
- case 0xb0:break;
- case 0x70:break;
- case 0xf0:break;
- }
- }
- */
復制代碼
|