/*************************************** ****************************
*
* Draws the background
*
**************************************** ****************************
*/
Static void drawbj (void)
{
Gui_setbkcolor (gui_yellow );
Gui_clear ();
Gui_setcolor (gui_red );
Gui_setfont (& gui_fonthz17x16 );
Gui_settextalign (gui_ta_hcenter );
Gui_dispstringat ("Name: daicheng", 160,160 );
Gui_setfont (& gui_fonthz12x12 );
Gui_settextalign (gui_ta_hcenter );
Gui_dispstringat ("Instructor:", 160,180 );
Gui_setfont (& gui_fonthz17x16 );
Gui_settextalign (gui_ta_hcenter );
Gui_dispstringat ("<please wait >>>>>>>>>>", 160,200 );
Gui_delay (2000 );
}
Static void jieshao (void)
{
Gui_setbkcolor (gui_black );
Gui_clear ();
Gui_setcolor (gui_yellow );
Gui_setfont (& gui_fonthz12x12 );
Gui_settextalign (gui_ta_hcenter );
Gui_dispstringat ("this design mainly refers to digital signal generation, display, adjustment and playback,", 160, 36 );
Gui_setfont (& gui_fonthz12x12 );
Gui_settextalign (gui_ta_hcenter );
Gui_dispstringat ("mainly completed the design of digital signal-Based Integrated System, which is", 160, 60 );
Gui_setfont (& gui_fonthz12x12 );
Gui_settextalign (gui_ta_hcenter );
Gui_dispstringat ("ARM-based embedded system applications, embedded medium wave", 160, 84 );
Gui_setfont (& gui_fonthz12x12 );
Gui_settextalign (gui_ta_hcenter );
Gui_dispstringat ("shape acquisition, LCD display, waveform storage, and adjustable", 160,106 );
Gui_setfont (& gui_fonthz12x12 );
Gui_settextalign (gui_ta_hcenter );
Gui_dispstringat ("square wave output, triangular wave output function, etc. ......", 160,130 );
Gui_setfont (& gui_fonthz17x16 );
Gui_settextalign (gui_ta_hcenter );
Gui_dispstringat ("Please select your operation", 160,154 );
Gui_setfont (& gui_fonthz12x12 );
Gui_settextalign (gui_ta_hcenter );
Gui_dispstringat ("1 Waveform Generation and adjustment 2 waveform acquisition, playback and adjustment", 160,178 );
Gui_delay (2000 );
}
/*************************************** ****************************
*
* Draws the graph Area
*
**************************************** ****************************
*/
Static void draw (void * P)
{
Int I;
Param * pparam = (Param *) P;
Gui_setbkcolor (gui_black );
Gui_setcolor (gui_darkgray );
Gui_clearrect (19, (lcdheight-20)-ysize, (lcdwidth-2), (lcdheight-21 ));
For (I = 0; I <(ysize/2); I + = 20)
{
Gui_drawhline (lcdheight-20)-(ysize/2) + I, 19, (lcdwidth-2 ));
If (I)
{
Gui_drawhline (lcdheight-20)-(ysize/2)-I, 19, (lcdwidth-2 ));//}
}
}
For (I = 40; I <(lcdwidth-20); I + = 40)
{
Gui_drawvline (18 + I, (lcdheight-20)-ysize, (lcdheight-21 ));
}
Gui_setcolor (color_graph0 );
Gui_drawgraph (pparam-> ay, (lcdwidth-20), 19, (lcdheight-20)-ysize );
Gui_setcolor (gui_yellow); // the color of the middle line
Gui_drawhline (LCD _ysize-20)-(ysize/2), 19, (LCD _xsize-2); // draw the midline
}
Static void draw2 (void * P)
{
Param * pparam = (Param *) P;
Draw (P );
Gui_setcolor (color_graph1 );
Gui_drawgraph (pparam-> Ay + 15, (LCD _xsize-20), 19, (LCD _ysize-20)-ysize );
}
/*************************************** ****************************
*
* Labels the X & Y-axis
*
**************************************** ****************************
*/
Static void label (void)
{
Int X, Y;
Gui_setbkcolor (gui_red );
Gui_clear ();
Gui_setpensize (1 );
Gui_clearrect (0, (lcdheight-21)-ysize, (lcdwidth-1), (lcdheight-1 ));
Gui_drawrect (18, (lcdheight-21)-ysize, (lcdwidth-1), (lcdheight-20 ));
Gui_setfont (& gui_font6x8 );
For (x = 0; x <(lcdwidth-20); x + = 40)
{
Int xpos = x + 18;
Gui_drawvline (xpos, (lcdheight-20), (lcdheight-14 ));
Gui_dispdecat (x/40, xpos-2, (lcdheight-9), 1 );
}
For (y = 0; y <ysize/2; y + = 20)
{
Int ypos = (lcdheight-20)-ysize/2 + Y;
Gui_drawhline (ypos, 13, 18 );
If (y)
{
Gui_gotoxy (1, ypos-4 );
Gui_dispsdec (-y/20, 2 );
Ypos = (lcdheight-20)-ysize/2-y;
Gui_drawhline (ypos, 13, 18 );
Gui_gotoxy (1, ypos-4 );
Gui_dispsdec (y/20, 2 );
}
Else
{
Gui_dispcharat ('0', 7, ypos-4 );
}
}
}
/*************************************** ****************************
*
* Draws a Random Wave
*
**************************************** ****************************
*/
Static void getrandom (I16 * pay, int time, int N)
{
Int adiff, I;
If (Time> 5000)
Time-= 5000;
If (Time> 2500)
Time= 5000-time;
Time/= 200;
Adiff = time * Time + 1;
For (I = 0; I <n; I ++)
{
If (! I)
{
Pay= Rand () % ysize;
}
Else
{
I16 ynew;
Int YD = adiff-(RAND () % adiff );
If (RAND () & 1)
{
Ynew = pay+ Yd;
}
Else
{
Ynew = pay-YD;
}
If (ynew> ysize)
{
Ynew-= YD;
}
Else
{If (ynew <0)
Ynew + = YD;
}
Pay= Ynew;
}
}
}
/*************************************** ****************************
*
* Draws a sine wave
*
**************************************** ****************************
*/
// Basic Waveform
Static void getsinedata (I16 * pay, int N)
{
Int I;
For (I = 0; I <n; I ++ ){
Float S = sin (I * deg2rad * 4); // 4 changes the waveform frequency;
Pay= S * ysize/2 + ysize/2;
}
}
Static void demosinewave (void)
{
Param;
I16 * pstart;
Int T0, CNT = 0;
Gui_rect rect = {19, (LCD _ysize-20)-ysize, (LCD _xsize-2), (LCD _ysize-21 )};
Gui_hmem hmem = gui_alloc_alloc (405 * sizeof (I16); // 405
Gui_setcolor (gui_red );
Gui_setbkcolor (gui_yellow );
Gui_clearrect (0, 0, LCD _xsize, 70 );
Gui_setfont (& gui_fonthz17x16 );
Gui_settextalign (gui_ta_hcenter );
Gui_dispstringat ("Digital Signal Synthesis System", 160, 20 );
Gui_setfont (& gui_fonthz12x12 );
Gui_dispstringat ("Sine Wave Display", 10, 60 );
Pstart = gui_alloc_h2p (hmem );
Getsinedata (pstart, 405); /// 405
Gui_setfont (& gui_font6x8 );
T0 = gui_gettime ();
While (gui_gettime ()-T0) <5000) // 10000 control the waveform duration;
{
Int T1, tdiff2;
If (CNT ++ % 90)
{
Param. Ay ++;
}
Else
{
Param. Ay = pstart;
}
T1 = gui_gettime ();
// Gui_memdev_draw (& rect, draw2, & Param, 0, 0 );
Gui_memdev_draw (& rect, draw, & Param, 0, 0 );
Tdiff2 = gui_gettime ()-T1;
If (tdiff2 <100) // 100 controls the waveform movement speed;
{
Gui_delay( 100-tdiff2 );
}
}
Gui_alloc_free (hmem );
}
/*************************************** ****************************
*
* Adds several waves
*
**************************************** ****************************
*/
Static void drawordata (gui_color color, I16 * Pay)
{
Gui_setcolor (color );
Gui_drawgraph (pay, (LCD _xsize-20), 19, (LCD _ysize-20)-ysize );
}
/*************************************** ****************************
*
* Draws a ad Wave
*
**************************************** ****************************
*/
Static void getrandomdata (I16 * pay, int time, int N)
{
Int adiff, I;
If (Time> 5000)
Time-= 5000;
If (Time> 2500)
Time= 5000-time;
Time/= 200;
Adiff = time * Time + 1;
For (I = 0; I <n; I ++)
{
Int A1, A2, A3, A4, A5;
Int Max, Min, sum, aver;
A1 = getadresult (0 );
A2 = getadresult (0 );
A3 = getadresult (0 );
A4 = getadresult (0 );
A5 = getadresult (0 );
Max = A1;
If (A1 <A2) max = a2;
If (max <A3) max = A3;
If (max <A4) max = A4;
If (max <A5) max = A5;
Min = A1;
If (A2 <min) min = a2;
If (A3 <min) min = A3;
If (A4 <min) min = A4;
If (A5 <min) min = A5;
Aver = (A1 + A2 + A3 + A4 + a5-max-min)/3;
Pay= (Aver * 140/1023 );
}
}
Static void demorandomgraph (void)
{
Param;
Int tdiff, t0;
Int;
Gui_rect rect = {19, (240-20)-ysize, (320-2), (240-21 )};
Gui_hmem hmem = gui_alloc_alloc (lcdwidth-20) * sizeof (I16 ));
Gui_setcolor (gui_red );
Gui_setbkcolor (gui_yellow );
Gui_clearrect (0, 0, LCD _xsize, 70 );
Gui_setfont (& gui_fonthz17x16 );
Gui_settextalign (gui_ta_hcenter );
Gui_dispstringat ("Digital Signal Synthesis System", 160, 20 );
Gui_setfont (& gui_fonthz12x12 );
Gui_dispstringat ("digital waveform display", 10, 60 );
Param. Ay = gui_alloc_h2p (hmem );
Gui_setfont (& gui_font6x8 );
T0 = gui_gettime ();
While (tdiff = (gui_gettime ()-T0) <100) // 10000
{
Int T1, tdiff2;
Getrandomdata (Param. Ay, tdiff, (lcdwidth-20 ));
T1 = gui_gettime ();
Gui_memdev_draw (& rect, draw, & Param, 0, 0 );
Tdiff2 = gui_gettime ()-T1;
If (tdiff2 <1, 100)
{
Gui_delay( 100-tdiff2 );
}
}
Gui_alloc_free (hmem );
}
// Continuous changing positive and negative waves
Static void getsinedatac (I16 * pay, int N)
{
Int I, T, L;
T = getadresult (1) * 8/1023 + 1;
L = getadresult (2) * 12/1023 + 1;
For (I = 0; I <n; I ++ ){
Float S = sin (I * deg2rad * T)/L; // 4. Change the waveform frequency;
Pay= S * ysize/2 + ysize/2;
}
}
Static int demosinewavec (void)
{
Param;
I16 * pstart;
Int T0, CNT = 0;
Gui_rect rect = {19, (LCD _ysize-20)-ysize, (LCD _xsize-2), (LCD _ysize-21 )};
Gui_hmem hmem = gui_alloc_alloc (405 * sizeof (I16); // 405
Gui_setcolor (gui_red );
Gui_setbkcolor (gui_yellow );
Gui_clearrect (0, 0, LCD _xsize, 70 );
Gui_setfont (& gui_fonthz17x16 );
Gui_settextalign (gui_ta_hcenter );
Gui_dispstringat ("Digital Signal Synthesis System", 160, 20 );
Gui_setfont (& gui_fonthz12x12 );
Gui_dispstringat ("waveform adjustment", 10, 60 );
Pstart = gui_alloc_h2p (hmem );
Getsinedatac (pstart, 405); // 405
Gui_setfont (& gui_font6x8 );
T0 = gui_gettime ();
While (gui_gettime ()-T0) <100) // 10000 control the waveform duration;
{
Int T1, tdiff2;
If (CNT ++ % 90)
{
Param. Ay ++;
}
Else
{
Param. Ay = pstart;
}
T1 = gui_gettime ();
Gui_memdev_draw (& rect, draw, & Param, 0, 0 );
Tdiff2 = gui_gettime ()-T1;
If (tdiff2 <100) // 100 controls the waveform movement speed;
{
Gui_delay( 100-tdiff2 );
}
}
Gui_alloc_free (hmem );
}
Static void getrandomdata2 (I16 * pay, int N)
{
I16 * PBY;
Int adiff, I;
For (I = 0; I <n; I ++)
{
Int A1, A2, A3, A4, A5, addh;
Int Max, Min, sum, aver;
A1 = getadresult (0 );
A2 = getadresult (0 );
A3 = getadresult (0 );
A4 = getadresult (0 );
A5 = getadresult (0 );
Addh = 0xf8000;
Max = A1;
If (A1 <A2) max = a2;
If (max <A3) max = A3;
If (max <A4) max = A4;
If (max <A5) max = A5;
Min = A1;
If (A2 <min) min = a2;
If (A3 <min) min = A3;
If (A4 <min) min = A4;
If (A5 <min) min = A5;
Aver = (A1 + A2 + A3 + A4 + a5-max-min)/3;
PBY= (Aver * 140/1023 );
Flash_sec_erase (34 );
Flash_single_write (adsid, PBY);
Adsid = adsid + 1;
}
Flash_read (0xf8000 );
}
Static void demorandomgraph2 (void)
{
Param;
Int tdiff, t0;
Int A, key;
Gui_rect rect = {19, (240-20)-ysize, (320-2), (240-21 )};
Gui_hmem hmem = gui_alloc_alloc (lcdwidth-20) * sizeof (I16 ));
Gui_setcolor (gui_red );
Gui_setbkcolor (gui_yellow );
Gui_clearrect (0, 0, LCD _xsize, 70 );
Gui_setfont (& gui_fonthz17x16 );
Gui_settextalign (gui_ta_hcenter );
Gui_dispstringat ("Digital Signal Synthesis System", 160, 20 );
Gui_setfont (& gui_fonthz12x12 );
Gui_dispstringat ("waveform playback", 10, 60 );
Param. Ay = gui_alloc_h2p (hmem );
Gui_setfont (& gui_font6x8 );
Flash_init ();
Getrandomdata2 (Param. Ay, (lcdwidth-20 ));
Gui_memdev_draw (& rect, draw, & Param, 0, 0 );
Gui_alloc_free (hmem );
}
This is only part of it!