⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stdoi.c

📁 2005年全国大学生电子设计大赛 频谱仪 题 源代码。作品获国家一等奖
💻 C
字号:
#include "aduc841.h"
#include "keyboard.h"
#include "240128.h"
#include "stdoi.h"
#include "absacc.h"
#include "math.h"

unsigned int scanfu(unsigned char idata mode,unsigned char dx,unsigned char dy)
{
 unsigned char tmp;
 unsigned int idata rkey=0;
 if(mode=='i')
  {
   while(1)
   {
    while(!readkey(&tmp));
    switch(tmp)
     {
      case key1:
        rkey=rkey*10+1;
        break;
      case key2:
        rkey=rkey*10+2;
        break;
      case key3:
        rkey=rkey*10+3;
        break;
      case key5:
        rkey=rkey*10+4;
        break;
      case key6:
        rkey=rkey*10+5;
        break;
      case key7:
        rkey=rkey*10+6;
        break;
      case key9:
        rkey=rkey*10+7;
        break;
      case key10:
        rkey=rkey*10+8;
        break;
      case key11:
        rkey=rkey*10+9;
        break;
      case key14:
        rkey=rkey*10;
        break;
      case key16:
        return(rkey);
      case key15:
        rkey=rkey/10;
        break;

     }
   displaychar("     ",dy,dx);
   displayint(rkey,dy,dx);
   }
  }



}

void lcdclear(unsigned char idata mode,float idata pstart,float idata pend,unsigned char setcls) // a:all,t:text,g:graphic
{
 unsigned int idata tmp,tmp1,tmp2;
 if (mode=='a')
  {
   tmp1=6000;
   tmp2=0;
  }
 if (mode=='t')
  {
   tmp2=text_area+480*pstart;
   tmp1=text_area+480*pend;
  }
 if (mode=='g')
  {
   tmp2=graph_area+4096*pstart;
   tmp1=graph_area+4096*pend;
  }
 set_ram_pointer(tmp2,0,0);

 while(((LCD_inst)&0x03)!=0x03);    //check STA1
 LCD_inst=0xb0;
 for(tmp=tmp2;tmp<tmp1;tmp++)
 {
  while(!((LCD_inst)&0x08));    //check STA3
  LCD_data=(unsigned char)setcls;
 }

 while(!((LCD_inst)&0x08));    //check STA3
 LCD_inst=0xb2;
}
void displaychar(unsigned char *text,unsigned char idata row,unsigned char idata col)
{
 unsigned char idata tmp;
 set_ram_pointer(text_area,col,row);
 for(tmp=0;tmp<255;tmp++)
 {
  if (*(text+tmp)=='\0') break;

 }
  write_ramautoc(text,tmp);

}

void displayint(unsigned int idata disp,unsigned char idata row,unsigned char idata col)
{
 unsigned char idata tmp[5];
 unsigned char idata i,l;
 unsigned int idata k,tmp1;
 bit j=0;
    k=10000;
    l=0;
    tmp1=disp/10;
    while(k!=1)
      {
       i=(tmp1%k)/(k/10);
       if (i==0xff) i=0;
       if (i==0&&j==0)
        {
         k=k/10;
         continue;
        }
       j=1;
       tmp[l]=i+48;
       l++;
       k=k/10;

      }
    tmp1=(disp%10)+48;
    tmp[l]=tmp1;
    tmp[l+1]='\0';
    displaychar(tmp,row,col);

}

void displayfloat(float idata disp,unsigned char idata row,unsigned char idata col)
{
 unsigned char idata tmp[7];
 unsigned char idata i;
 unsigned int idata k,tmp1;
 volatile unsigned char idata l;
 bit j=0;
    k=10000;
    l=0;
    tmp1=disp/10;
    while(k!=1)
      {
       i=((tmp1)%k)/(k/10);
       if (i==0xff) i=0;
       if (i==0&&j==0)
        {
         k=k/10;
         continue;
        }
       j=1;
       tmp[l]=i+48;
       l++;
       k=k/10;

      }
    tmp[l]=(((unsigned int)disp)%10)+48;
    l++;
    tmp[l]='.';
    l++;
    k=10;
    while(k!=1000)
      {
       i=((unsigned int)(disp*k))%10;
       if (i==0xff) i=0;
       tmp[l]=i+48;
       l++;
       k=k*10;

      }

     tmp[l+1]='\0';


    displaychar(tmp,row,col);

}

void box(unsigned char idata x1,unsigned char idata y1,unsigned char idata x2,unsigned char idata y2)
{
 linev(x1,y1,y2,1);
 lineh(x1,x2,y2,1);
 linev(x2,y1,y2,1);
 lineh(x1,x2,y1,1);

}

void displaywaved(unsigned char waved[],unsigned char idata num,unsigned char idata start)
{
 unsigned char idata tmp;
 for(tmp=0;tmp<num;tmp++)
 {
  if ((tmp+start)>239) break;
  set_ram_pointer(graph_area,(tmp+start)/8,127-waved[tmp]/2);
  write_rambit(1,7-(tmp+start)%8);


 }

}

void line(unsigned char idata x1,unsigned char idata y1,unsigned char idata x2,unsigned char idata y2,unsigned char idata mode)
{
 unsigned char idata tmp1,tmp2,tmp3,tmp4,tmp5,tmp6,tmp7;
 float idata tempo1;
 tmp2=x2-x1;
 tempo1=(float)(y2-y1)/tmp2;
 tmp6=abs(tempo1);

 for(tmp1=0;tmp1<tmp2;tmp1=tmp1+mode)
 {
  tmp3=(tmp1+x1)/8;
  tmp5=y1+(unsigned char)(tempo1*tmp1);
  tmp7=7-(tmp1+x1)%8;
  set_ram_pointer(graph_area,tmp3,tmp5);
  write_rambit(1,tmp7);

  if (y2>y1)
  {

   for(tmp4=0;tmp4<tmp6;tmp4=tmp4+mode)
   {
    set_ram_pointer(graph_area,tmp3,tmp5+tmp4);
    write_rambit(1,tmp7);

   }

  }
  if (y2<y1)
  {
   for(tmp4=0;tmp4<tmp6;tmp4=tmp4+mode)
   {
    set_ram_pointer(graph_area,tmp3,tmp5-tmp4);
    write_rambit(1,tmp7);

   }

  }
 }

}

void displaywavel(unsigned char waved[],unsigned char idata num,unsigned char idata start)
{
 unsigned char idata tmp,tmp1,tmp3,temp1,temp2,temp3;

 for(tmp=0;tmp<num;tmp++)
 {
  if ((tmp+start)>239) break;
  temp1=(tmp+start)/8;
  temp2=127-waved[tmp]/2;
  temp3=127-waved[tmp+1]/2;
  set_ram_pointer(graph_area,temp1,temp2);
  write_rambit(1,7-(tmp+start)%8);
  tmp1=temp2;
  if (temp2>temp3)
  {
   for(tmp3=0;tmp3<temp2-temp3;tmp3++)
   {
    set_ram_pointer(graph_area,temp1,temp2-tmp3);
    write_rambit(1,7-(tmp+start)%8);

   }

  }
  if (temp2<temp3)
  {
   for(tmp3=0;tmp3<temp3-temp2;tmp3++)
   {
    set_ram_pointer(graph_area,temp1,temp2+tmp3);
    write_rambit(1,7-(tmp+start)%8);

   }

  }

 }

}

void lineh(unsigned char idata x1,unsigned char idata x2,unsigned char idata y,unsigned char setcls)
{

 unsigned char idata tmp1,tmp2,tmp3,tmp4;
 tmp1=x1/8;
 tmp3=x2/8;
 set_ram_pointer(graph_area,tmp1+1,y);
 while(((LCD_inst)&0x03)!=0x03);    //check STA1
 LCD_inst=0xb0;
 for(tmp2=tmp1+1;tmp2<tmp3;tmp2++)
 {
  while(!((LCD_inst)&0x08));    //check STA3
  LCD_data=(0xff)*(unsigned char)(setcls);

 }
 while(!((LCD_inst)&0x08));    //check STA3
 LCD_inst=0xb2;

 set_ram_pointer(graph_area,tmp1,y);
 tmp4=8-x1%8;
 while(tmp4--) write_rambit(setcls,tmp4);

 set_ram_pointer(graph_area,tmp3,y);
 tmp4=x2%8+1;
 while(tmp4--) write_rambit(setcls,7-tmp4);

}



void linev(unsigned char idata x,unsigned char idata y1,unsigned char idata y2,unsigned char setcls)
{
 unsigned char idata tmp1;
 for(tmp1=y1;tmp1<=y2;tmp1++)
 {
    set_ram_pointer(graph_area,x/8,tmp1);
    write_rambit(setcls,7-x%8);
  }
}

void popup(unsigned char x1,unsigned char y1,unsigned char x2,unsigned char y2)
{
  unsigned char tmp;
  lineh(x1,x2-2,y1,1);
  linev(x1,y1,y1+2,1);
  linev(x2,y1+2,y1+4,1);
  linev(x2-1,y1+2,y1+4,1);
  linev(x2-2,y1,y1+2,1);
  for(tmp=y1+2;tmp<=y2;tmp++)
    {
     linev(x1,tmp-1,tmp,1);
     linev(x2,tmp+1,tmp+2,1);
     linev(x2-1,tmp+1,tmp+2,1);
     linev(x2-2,tmp-1,tmp+2,1);
     lineh(x1,x2,tmp,1);
     lineh(x1+2,x2,tmp+2,1);
     lineh(x1,x2-2,tmp,0);
  
    }
  lineh(x1,x2,y2,1);
 
}

void initlcd()
{


 set_text_ramstart(text_area);
 set_graph_ramstart(graph_area);
 //set_cgram_ramstart(cgram_area);
 set_text_area(30);
 set_graph_area(30);
 set_mode('x',0);
 //set_mode('x',1);
 //transferhz(cgram_area);
 set_onoff(0,0,1,1);
 //set_cursor_shape(5);
 //set_cursor_1(0,0);
 }

 void select(unsigned char idata x1,unsigned char idata y1,unsigned char idata x2,unsigned char idata y2,unsigned char setclr)
{
 unsigned char tmp;
 for(tmp=y1;tmp<y2;tmp++)
  {
   lineh(x1,x2,tmp,setclr);


  }


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -