#include "gd32e23x.h"
#include "systick.h"
#include <stdio.h>

#include <led.h>
#include <delay.h>
#include <usart.h>

#define u8 unsigned char
#define u16 unsigned int

uint32_t USART0_RECEIVE_Buf[100]; 
uint32_t USART1_RECEIVE_Buf[100]; 
char buf[128];


char row_max=2;
char col_max=3;
char row=1;
char col=1;
char cur=0;
char curpage=0;
char isbtn=0;
int shizhong=90;
int tx=0;


#define key_ok  gpio_input_bit_get(GPIOA,GPIO_PIN_0)		//ok键
#define key_up  gpio_input_bit_get(GPIOA,GPIO_PIN_1)		//方向上键
#define key_left  gpio_input_bit_get(GPIOA,GPIO_PIN_2)		//方向左键
#define key_down  gpio_input_bit_get(GPIOA,GPIO_PIN_3)		//方向下键
#define key_right  gpio_input_bit_get(GPIOA,GPIO_PIN_4)		//方向右键

#define KEY0_PRES 	1	//KEY0按下
#define KEY1_PRES		2	//KEY1按下
#define KEY2_PRES		3	//KEY2按下
#define KEY3_PRES		4	//KEY2按下
#define KEY4_PRES		5	//KEY2按下





int main(void)
{
		unsigned int i,k;
		int dly_page=400;
		int dly_key=50;
	
    systick_config(); 
		USART0_Init();
		//KEY_GPIOInit();
		Delay_ms(800);
	
		USART0_Send_Str("JUMP(0);\r\n");
		CheckBusy();


     while(1){
	
//						double sun=0;
//						int i;
						for(i=0;i<=100;i++)
//							p[1]=rand()%100;
			 
//							for(;;)
			 
							{
								
//								int i=0;i<=100;i++;
								int k=i; 
//								int j=0;j<=50;j++;
								
//								sprintf(buf,"SET_NUM(4,%d,2);\r\n",i);
//								UartSend(buf);
//								CheckBusy();
//								Delay_ms(200);
							
							if(i<=35)
								sprintf(buf,"SET_NUM(4,%d,2);SET_TXT(7,'%d');SET_TXT(5,'优');SET_TXT(8,'优');\r\n",i,k);
							else if(i>35&&i<75)
								sprintf(buf,"SET_NUM(4,%d,2);SET_TXT(7,'%d');SET_TXT(5,'良');SET_TXT(8,'良');\r\n",i,k);
//								UartSend(buf);
//								CheckBusy();
							else if(i>75)
							
								sprintf(buf,"SET_NUM(4,%d,2);SET_TXT(7,'%d');SET_TXT(5,'重度污染');SET_TXT(8,'重度污染');\r\n",i,k);
							
							
//							else if(j<5)
//								sprintf(buf,"SET_TXT(10,'%d');SET_TXT(12,'空气清新');\r\n",j);
//							
//							else if(j>5&&j<50)
//								sprintf(buf,"SET_TXT(10,'%d');SET_TXT(12,'质量超标');\r\n",j);
								UartSend(buf);
								CheckBusy();
							
							
								Delay_ms(50);
							
						}
				
	}
	

}
		
