菜鸟之示波函数!!!用LCD画坐标更直观显示ADC转换的电压值

2019-07-20 12:24发布

本帖最后由 下一个牛顿 于 2017-8-24 10:57 编辑

本人菜鸟,今天下午写了个示波函数,用LCD来显示ADC转化的值。




附上代码:


#include "showwavefun.h"
#include "lcd.h"
/*
MAX:×Ý×ø±ê×î´óÖµ
MIn:×Ý×ø±ê×îСֵ
OriginalPoint-X£ºÔ µãX×ø±ê£¨Ïà¶ÔÓÚÆÁÄ»ÏñËص㣩
OriginalPoint-Y£ºÔ µãY×ø±ê£¨Ïà¶ÔÓÚÆÁÄ»ÏñËص㣩
Volue:´«Êä´æ´¢×Ý×ø±êÖµ±äÁ¿
high:ÉèÖÃYÖá¸ß¶È

*/
void Show_Wave_Fun(float MAX,float MIN,u16 OriginalPoint_X,u16 OriginalPoint_Y,float Volue,u16 high)
{
  u16 X;u8 Y,i;
   float Temp=0;
   static u16 X_temp=0;
   static u16 High=0;
   static u16 Mode0_volue[240][1]={0};//ÊúÆÁģʽʹÓÃ
  POINT_COLOR=BLACK;


   Temp=MAX-MIN;
   High=high;
  //if(Temp>0)high=(Temp)*((float)40/(((u16)(Temp/5))+1));//¼ÆËãÊʵ±µÄ·Å´óËõС±¶Êý
  //else if(Temp<700) high=(Temp);//&frac14;&AElig;&Euml;&atilde;&Ecirc;&Ecirc;&micro;±&micro;&Auml;·&Aring;&acute;ó±&para;&Ecirc;&yacute;
  //else return;//&cedil;&szlig;&para;&Egrave;&sup3;&not;&sup1;&yacute;&AElig;&Aacute;&Auml;&raquo;&Iuml;&ntilde;&Euml;&Oslash;&micro;&atilde;&cedil;&szlig;&para;&Egrave;
    LCD_DrawLine(OriginalPoint_X,OriginalPoint_Y,240+OriginalPoint_X,OriginalPoint_Y);//&raquo; X&Ouml;á
  if(OriginalPoint_Y>=High)
    LCD_DrawLine(OriginalPoint_X,OriginalPoint_Y,OriginalPoint_X,OriginalPoint_Y-High);//&raquo; Y&Ouml;á
  else  LCD_DrawLine(OriginalPoint_X,OriginalPoint_Y,OriginalPoint_X,0);//&raquo; Y&Ouml;á
  
   Y=(u16)((Volue-MIN)*High/Temp);
    for(i=0,X=OriginalPoint_X;i<=X_temp;X++,i++)//&raquo;ò&Oacute;&Atilde;LCD_Clear(WHITE);&Otilde;&acirc;&cedil;&ouml;&Ecirc;&iexcl;&Ecirc;±&frac14;&auml;&pound;&not;&Ouml;&raquo;&Ccedil;&aring;&sup3;&yacute;&raquo; &sup1;&yacute;&micro;&Auml;&micro;&atilde;
  {   
    LCD_Fast_DrawPoint(X,OriginalPoint_Y-Mode0_volue[0],WHITE);
  }
  if(X_temp==240-1)
  for(i=0;i<=X_temp;i++)
  {
   if(i+1<240)
   Mode0_volue[0]=Mode0_volue[i+1][0];//&ordm;á×&oslash;±ê&Ograve;&AElig;&para;&macr;      
  }
    Mode0_volue[X_temp][0]=Y;
   
  for(i=0,X=OriginalPoint_X;i<=X_temp;X++,i++)
  {   
  LCD_Fast_DrawPoint(X,OriginalPoint_Y-Mode0_volue[0],RED);   
  }   
   
   
  
  if(X_temp<240-1)
    X_temp++;  
}


头文件:
#ifndef SHOW_WAVE_FUN_H
#define SHOW_WAVE_FUN_H
#include "sys.h"
void Show_Wave_Fun(float MAX,float MIN,u16 OriginalPoint_X,u16 OriginalPoint_Y,float Volue,u16 high);
#endif
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。