?? oscillograph.c
字號:
/* * $Id: oscillograph.c,v 1.2 2003/08/29 03:13:17 casic Exp $ * * oscillograhp.c : draw interface of oscillograph * * Copyright (C) 2003 ynding ( haoanian@263.net ) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */#include "lcd.h"#include "color.h"#include "character.h"#include "graphic.h"#include "oscillograph.h"/* draw an interface, which looks like an oscillograph */void draw_interface(void){ int i = 0; static flag = 0; if ( flag == 0 ) { clear_lcd(); ++flag; } display_string(6, 0, "CASIC Waveform Display", GREEN); display_string(0, 7, "0", GREEN); draw_rectangle(10, 20, 260, 220, GREEN); /* draw vertical dasheds */ for ( i=0;i<9;++i ) { draw_vdashed(35+i*25, 20, 220, GREEN); } /* draw horizontal dasheds */ for ( i=0;i<7;++i ) { draw_hdashed(10, 260, 45+i*25, GREEN); } /* draw vertical scales */ /* left */ draw_vdashed(11, 20, 220, GREEN); draw_vdashed(12, 20, 220, GREEN); /* middle */ draw_vdashed(134, 20, 220, GREEN); draw_vdashed(135, 20, 220, GREEN); draw_vdashed(136, 20, 220, GREEN); /* right */ draw_vdashed(258, 20, 220, GREEN); draw_vdashed(259, 20, 220, GREEN); /* draw horizontal scales */ /* top */ draw_hdashed(10, 260, 21, GREEN); draw_hdashed(10, 260, 22, GREEN); /* middle */ draw_hdashed(10, 260, 119, GREEN); draw_hdashed(10, 260, 120, GREEN); draw_hdashed(10, 260, 121, GREEN); /* bottom */ draw_hdashed(10, 260, 218, GREEN); draw_hdashed(10, 260, 219, GREEN); return;}/* convert datas to coordinates */void data2pixel(unsigned char* buf, int count){ unsigned char average = 0; unsigned char max = 0; unsigned char min = 0; int temp = 0; int i = 0; /* find out the max & min value */ for ( i=0;i<count;++i ) { if ( min > buf[i]) min = buf[i]; if ( max < buf[i]) max = buf[i]; } /* calculate the middle value */ average = max/2 + min/2; /* change data to coordinates */ for ( i=0;i<count;++i ) { temp = (int)buf[i]; temp -= (int)average; temp = temp*200/256; temp = 220 -100 - temp; buf[i] = (unsigned char)(temp & 0xff); } return;}/* erase the waveform pre-drawn */void erase_wave(unsigned char* buf, int count){ int i = 0; for ( i=0;i<count;++i ) { draw_bigdot(10+i*5, buf[i], GRAY); } return;}/* draw waveform */void draw_wave(unsigned char* buf, int count){ int i = 0; for ( i=0;i<count;++i ) { draw_bigdot(10+i*5, buf[i], YELLOW); } return;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -