main.c

来自「how to use display powertip PG 320x240」· C语言 代码 · 共 128 行

C
128
字号
/***********************************************************************
 *                                                                     *
 *      Project Name:   Demo board for graphic LCD PG320240WRF-JE8HY1  *
 *      Description:    Driving of the LCD PG320240WRF-JE8HY1  with	   * 
 						SED1374  driver								   *
 *                                                                     *
 *      Processor:      uPD78F0034                                     *
 *      Revision:       1.0                                            *
 *      Date:           13.01.2004                                     *
 *      Compiler:       IAR 3.0
 *                              *
 *                                                                     *
 ***********************************************************************/

#include "common.h"
#include "ports.h"
#include "LCD_pg320240.h"
#include "graphic.h"


//**************   Interrupts  ************************************************
interrupt(0x0022) void irq_T3(void)
{
   	BCLK = ~BCLK;						// bus clock
	T2 = 0xFFFE;						// register for T2 timer//
    BCLK = ~BCLK;						// bus clock
}
//**************   Functions   ************************************************
void init_timerBCLK(void)
{
	T2IC =0x0044 ;		// set for Timer T2 interrupt register - enable interrupt
	T2 = 0xFFFF;		// register for T2 timer
   	T2CON = 0x0041;     // set of configuration register of Timer T2 - start timer timig CPU_clock/8
    IEN = 1;			//enable global interrupts
}
//*****************************************************************************
void init_app(void)
{
    DP3 |= 0x00FF;			// set as output
    DP2 = 0xFDFF;			// set wire WAIT as input and other as output
    RESET = 0;
    WRITE = 1;
    READ = 1;
    CS = 1;
    ABH = 0;
    ABL = 0;
    init_timerBCLK();    
}
//*****************************************************************************
/**/
void draw1(void)
{
	coordinate Begin;
	Begin.x = 50;Begin.y = 50;
	box(Begin,160,0x0F);
	Begin.x = 70;Begin.y = 70;
	box(Begin,120,0x0A);
	Begin.x = 100;Begin.y = 100;
	box(Begin,60,0x07);
	Begin.x = 120;Begin.y = 120;
	box(Begin,20,0x03);	
}
//*****************************************************************************
void draw0(void)
{
	coordinate Begin;
	Begin.x = 30;Begin.y = 30;
	rectangle(Begin,100,150,0x0A);
	Begin.x = 40;Begin.y = 30;
	rectangle(Begin,80,140,0x0D);
	Begin.x = 70;Begin.y = 30;
	rectangle(Begin,20,110,0x07);
	
	Begin.x = 80;Begin.y = 180;
	rectangle(Begin,10,20,0x0F);
	Begin.x = 80;Begin.y = 200;
	rectangle(Begin,120,10,0x0F);
	Begin.x = 190;Begin.y = 160;
	rectangle(Begin,10,40,0x0F);
	
	Begin.x = 160;Begin.y = 100;
	rectangle(Begin,60,60,0x08);
	
	Begin.x = 220;Begin.y = 130;
	linex(Begin,80,0x0F);
	Begin.x = 190;Begin.y = 20;
	liney(Begin,80,0x0F);		
}
//*****************************************************************************
void grid(unsigned char Color)
{
	unsigned int i;
	coordinate Begin;
	Begin.x = 0;
	Begin.y = 0;
	for (i=0;i<240;i+=5) 
    {	 	
		linex(Begin,312,Color);	
		Begin.y +=5;
    }
	Begin.x = 0;
	Begin.y = 0;
	for (i=0;i<312;i+=5) 
    {	 	
		liney(Begin,240,Color);	
		Begin.x +=5;
    }
}


/*-----------------------------------------------------------------------*/
void main(void)
{
	init_app();                            // Peripheral settings
    RESET = 1;
    lcd_init();                            // Init LCD display    
  	lcd_clear();      	
    while (1)
    {          
	   shadow_boxs();
	   lcd_clear();
	   draw1();
	   lcd_clear();
	   draw0();
	   lcd_clear();
	   grid(0x0A);
    }
}

⌨️ 快捷键说明

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