本帖最后由 下一个牛顿 于 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);//¼ÆËãÊʵ±µÄ·Å´ó±¶Êý
//else return;//¸ß¶È³¬¹ýÆÁÄ»ÏñËصã¸ß¶È
LCD_DrawLine(OriginalPoint_X,OriginalPoint_Y,240+OriginalPoint_X,OriginalPoint_Y);//» XÖá
if(OriginalPoint_Y>=High)
LCD_DrawLine(OriginalPoint_X,OriginalPoint_Y,OriginalPoint_X,OriginalPoint_Y-High);//» YÖá
else LCD_DrawLine(OriginalPoint_X,OriginalPoint_Y,OriginalPoint_X,0);//» YÖá
Y=(u16)((Volue-MIN)*High/Temp);
for(i=0,X=OriginalPoint_X;i<=X_temp;X++,i++)//»òÓÃLCD_Clear(WHITE);Õâ¸öʡʱ¼ä£¬Ö»Çå³ý» ¹ýµÄµã
{
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];//ºá×ø±êÒƶ¯
}
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
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>