//----------------------------------------------------------------------
//EASTRISING TECHNOLOGY CO,.LTD.//
// Module    : ER-TFT050-10+ER-PCBA6304-1   720*1280
// Lanuage   : C51 Code
// Create    : JAVEN LIU
// Date      : 2025-11-26
// Drive IC  : Controller:7683+SSD2828     CTP  GT911       
// INTERFACE : 7683: 4 wire SPI   SSD2828:3 Wire SPI    GT911: I2C  
// MCU 		 : STC12LE5C60S2     1T MCU
// MCU VDD	 : 3.3V
// MODULE VDD : 5V OR 3.3V 
//----------------------------------------------------------------------

//===========================================================
#include <STC12C5A.H>
#include <math.h>
#include <stdio.h>
#include<stdlib.h>
#include <intrins.h>
#include"lcd.h" 
#include"demo.h" 
#include"SD.h"  
#include"TP.h"   
#include"2828.h"

//=============================================================


#define uchar      unsigned char
#define uint       unsigned int
#define ulong      unsigned long



/////////////////////main////////////////////
void main(void)
{  	 uchar brightness=10;
 

//	BL_ON=0;  //Backlight on when external signal control

  	delay_ms(100);//delay for ER power on

   	SSD2828_Reset();	  
	SSD2828_initial();  

    ER_HW_Reset();
	System_Check_Temp();
   	delay_ms(100);
	while(LCD_StatusRead()&0x02);	 //Initial_Display_test	and  set SW2 pin2 = 1
  	ER_initial();
	Display_ON();	


    /* 	SSD2828_Reset();	  
	SSD2828_initial(); 
  
    ER_HW_Reset();
	 while(LCD_StatusRead()&0x02);	 //Initial_Display_test	and  set SW2 pin2 = 1

  	ER_initial();
	 Display_ON();
	 delay_ms(50);*/
  



 while(1) 
 	{
   
 	Select_Main_Window_16bpp();
	Main_Image_Start_Address(layer1_start_addr);				
	Main_Image_Width(LCD_XSIZE_TFT);
	Main_Window_Start_XY(0,0);
	Canvas_Image_Start_address(layer1_start_addr);
	Canvas_image_width(LCD_XSIZE_TFT);
    Active_Window_XY(0,0);
	Active_Window_WH(LCD_XSIZE_TFT,LCD_YSIZE_TFT);	
    Foreground_color_65k(White);
	Line_Start_XY(0,0);
	Line_End_XY(LCD_XSIZE_TFT-1 ,LCD_YSIZE_TFT-1);
	Start_Square_Fill();
 
  
   
 	////////BackLight Brightness control test  whit ER's PWM0
	   brightness=10;
	Foreground_color_65k(White);
	Background_color_65k(Red);
	CGROM_Select_Internal_CGROM();  
 	Font_Select_8x16_16x16();
   	Goto_Text_XY(0,Line1); 
	Show_String( "BackLight Brightness control test");
	 while(brightness<=100)
	  {ER_PWM1(brightness);	
	  delay_ms(500);
	  brightness+=10;
	 }
 	///////////


	TPTEST();
 
	Text_Demo();
 	mono_Demo();	   
	gray();
   	Geometric();
 	NextStep();

//    Display_JPG_SDCARD();
	DMA_Demo();
  
	}
}




	
