º¯Êý¹¦ÄÜ£ºÖ¸¶¨Î»ÖÃÏÔʾÈÎÒâ´óСµÄµ¥¸ö×Ö·û(¿ÉÒÔÊǺº×Ö)
x,y:Æðʼ×Ö·ûµÄÏñËØµã x<lcddev.width_x; lcddev.height_y;
size_x,size_y:×ÖÌåÏñËØ´óС
*temp:×Ö¿âÊý×é
PColorΪÄÚÈÝÑÕÉ«£¬BColorΪ±³¾²ÑÕÉ«
*/
void LCD_ShowWordPx(u16 x,u16 y,u16 size_x,u16 size_y,u8 *temp,u16 PColor,u16 BColor)
{
u16 i,j,xCount=0;
u16 pxSize;
BlockSet(x,x+size_x-1,y,y+size_y-1); //ÉèÖÃÇøÓò
pxSize =(size_x/8+(size_x%8?1:0))*size_y; //µ¥¸ö×Ö·ûµÄÊý×é¸öÊý
for(j=0;j<pxSize;j++) //size_x*size_y/8Ϊ×Ö½Ú¸öÊý
{
for(i=0;i<8;i++) //¸ßλÔÚǰ£¬µÍλÔÚºó£¬È¡×ÖģʱƥÅä¾ÍOK
{
if(*temp&(0x80>>i)) //×î¸ßλΪ×óÒÆ7λ
{
// LCD_WR_DATA( LCD_BGR2RGB(PColor)); //¶ÔÓ¦ÓÚÈ¡×ÖģʱµÄÒõÂë
LCD_WR_DATA(RED);
}
else
{
// LCD_WR_DATA( LCD_BGR2RGB(BColor));
LCD_WR_DATA(BLACK);
}
++xCount;
if(xCount%size_x==0){xCount=0;break;} //¶ÔÓÚ×Ö·û¿í²»ÊÇ8±¶ÊýµÄ×Ö·û
}
temp++;
}
}
/*
* º¯Êý¹¦ÄÜ£ºÖ¸¶¨Î»ÖÃÏÔʾÏÔʾ×Ö·û´® ĬÈÏ×Ö·ûΪ8*16£¬ºº×ÖΪ16*16
* x,y:Æðʼ×Ö·ûµÄÐÐÁÐ x<lcddev.width_x/px; lcddev.height_y/px/2;
* size:×Ö¿â´úÂë1--6*12, 2--8*16, 3--12*24, 4--16*32 ¼Ó´Ö
* *ptr:ÏÔʾÄÚÈÝ
* PenColorΪÄÚÈÝÑÕÉ«£¬BackColorΪ±³¾²ÑÕÉ«
*/
void LCD_ShowString(u16 x,u16 y,u8 size,u8 *ptr,u16 PColor,u16 BColor)
{
u16 i=0,val=0; //Ò»¶¨Òª³õʼ»¯£¬²»È»xlenÔÚµÚ¶þ´Îµ÷ÓÃʱ»áÓÐÎÊÌâ
u16 px;
u8 temp[2]={0};
u16 xlen,ylen;
u16 max_ylen, max_xlen;
u8 *p,*p0;//p0Ϊ¿Õ°××Ö·ûµÄÊ×µØÖ·,pΪ±»ÏÔʾ×ÖµÄ×Ö¿âµØÖ·
u16 j=0;
if(size==2) px=16;
else if(size==2) px=16;
else if(size==3) px=24;
else if(size==4) px=32;
else return;
max_xlen=lcddev.width_x*2/px; //¸ù¾ÝȡģÈí¼þ
max_ylen=lcddev.height_y/px; //×î¶àÏÔʾÁÐÐÐ,ÁÐÏñËØÊÇÐÐÏñËØµÄ2±¶
for(i=0;i<strlen((char*)ptr);i++)
{
temp[0]=ptr[i];
temp[1]=ptr[i+1];
xlen =(x+i+val)%max_xlen;
ylen =((x+i+val)/max_xlen+y)%max_ylen;
if(size==1){ p=(u8*)ASCII_0612[temp[0]-0X20]; p0=(u8*)ASCII_0612[0];}
else if(size==2){ p=(u8*)ASCII_0816[temp[0]-0X20];p0=(u8*)ASCII_0816[0];}
else if(size==3){ p=(u8*)ASCII_1224[temp[0]-0X20];p0=(u8*)ASCII_1224[0];}
else if(size==4){ p=(u8*)ASCII_1632[temp[0]-0X20];p0=(u8*)ASCII_1632[0];}
if(temp[0]<128) //ΪASCIIÂë
{
LCD_ShowWordPx(xlen*px/2,ylen*px,px/2,px,p,PColor,BColor);
}
else if(temp[0]>0x80){ //Ϊºº×Ö
if(xlen==max_xlen-1) //×îºóÒ»Áв»ÄÜ·ÅÏÂÒ»¸öºº×Ö
{
LCD_ShowWordPx(xlen*px/2,ylen*px,px/2,px,p0,PColor,BColor); //ÏÔʾ¡° ¡±¿Õ°×Ìî²¹
val++;
i--;//Ö¸Õ뻹ÊÇÖ¸ÏòÔºº×Ö,ËùÒÔÒª¼õÒ»
}
else
{
for(j=0;j<sizeof(GB16)/35;j++) //²éÕÒºº×ֿ⣬34×Ö½ÚÒ»¸ö×Ö·û
{
if((temp[0]==GB16[j].Index[0])&&(temp[1]==GB16[j].Index[1]))//ÕÒµ½ÐèÒªµÄºº×Ö×Ö½Ú
{
break;
}
}
if(j<sizeof(GB16)/35)
LCD_ShowWordPx(xlen*px/2,ylen*px,px,px,(u8*)GB16[j].MSK,PColor,BColor);
i++;
}
}
}
}
int main(void) {
u16 lcd_init(u8 dir);
u8 wifi_ssid[] = "Wifi SSID:";
LCD_ShowString(0, 6, 2, wifi_ssid, YELLOW, WHITE);
while(1) {
}
}
/*
* º¯Êý¹¦ÄÜ£ºÔÚÖ¸¶¨ÏûÏ¢´òÓ¡µÄÇøÓò£¬ÓÃÓÚÒ»Ö±´òÓ¡×Ö·ûº¯Êý
* xStar,yStar,xEnd,yEnd:Æðʼ½áÊø×Ö·ûµÄÏñËØµã
* ÒªÇó£ºxEnd>xStar ; yEnd>yStar
*/
static u16 xPxStar=0,yPxStar=0,xPxEnd=0,yPxEnd=0;
void LCD_SetShowArea(u16 xStar,u16 yStar,u16 xEnd,u16 yEnd)
{
if(xEnd>xStar && yEnd>yStar)
{
xPxStar=xStar;
yPxStar=yStar;
xPxEnd=xEnd;
yPxEnd=yEnd;
}
}
static u16 wordPx=16,PenColor=BLACK,BackColor=WHITE;
void LCD_SetPen(u8 size,u16 PColor,u16 BColor)
{
if(size==1) wordPx=12;
else if(size==2) wordPx=16;
else if(size==3) wordPx=24;
else if(size==4) wordPx=32;
PenColor=PColor;
BackColor=BColor;
}
void Display_Number(void)
{
u16 lcd_init(u8 dir);
LCD_SetPen(2, YELLOW, WHITE);
LCD_SetShowArea(20, 20, 150, 40);
while(1)
{
}
}
/*
º¯Êý¹¦ÄÜ£ºÖ¸¶¨Î»ÖÃÏÔʾһ¸ö×Ö·û(asciiÂ룺1¸ö×Ö½Ú£¬ºº×Ö2×Ö½Ú)ÓëÉÏÃæµÄº¯ÊýÇø±ðÊǼÓÈëÁË×Ö¿â²éѯ
x,y:Æðʼ×Ö·ûµÄÏñËØµã x<lcddev.width_x; lcddev.height_y;
size:×Ö¿â´úÂë1--6*12, 2--8*16, 3--12*24, 4--16*32 ¼Ó´Ö
*temp:µ¥¸ö×ÖΪ2×Ö½ÚÊý×飨asciiÂëΪ1×Ö½Ú£¬ºº×ÖΪ2×Ö½Ú£©
PColorΪÄÚÈÝÑÕÉ«£¬BColorΪ±³¾²ÑÕÉ«
*/
void LCD_ShowWordZk(u16 x,u16 y,u8 *temp)
{
#ifdef USE_FLASH_ZK
u8 p[129]={0}; //32*32ºº×Ö4*32=128¸ö×Ö½Ú
u32 position=0;
u16 pxSize=0; //Êý×é¸öÊý
if(temp[0]<128) //ΪASCIIÂë
{
pxSize =(wordPx/16+(wordPx%16?1:0))*wordPx; //µ¥¸ö×Ö·ûµÄÊý×é¸öÊý
position=temp[0]*pxSize;
if(wordPx==12) { W25xFLASH_ReadBuffer(p, ftinfo.asc12_addr+position, pxSize); }
else if(wordPx==16){ W25xFLASH_ReadBuffer(p, ftinfo.asc16_addr+position, pxSize); }
else if(wordPx==24){ W25xFLASH_ReadBuffer(p, ftinfo.asc24_addr+position, pxSize); }
else if(wordPx==32){ W25xFLASH_ReadBuffer(p, ftinfo.asc32_addr+position, pxSize); }
LCD_ShowWordPx(x,y,wordPx/2,wordPx,p,PenColor,BackColor);
}
else if(temp[0]>0x80) { //Ϊºº×Ö
//µÚÒ»¸öºº×ÖGBK±àÂ뷶ΧΪ0x81~0xFE
//µÚ¶þ¸öºº×ÖGBK±àÂ뷶ΧΪ0x40~0x7E 0x80~0xFE
pxSize =(wordPx/8+(wordPx%8?1:0))*wordPx; //µ¥¸ö×Ö·ûµÄÊý×é¸öÊý
if(temp[1]>0x7F)
position=((temp[0]-0x81)*190+temp[1]-0x41)*pxSize;
else if(temp[1]<0x7F)
position=((temp[0]-0x81)*190+temp[1]-0x40)*pxSize;
else return;
if(wordPx==12) { W25xFLASH_ReadBuffer(p, ftinfo.gbk12_addr+position, pxSize); }
else if(wordPx==16){ W25xFLASH_ReadBuffer(p, ftinfo.gbk16_addr+position, pxSize); }
else if(wordPx==24){ W25xFLASH_ReadBuffer(p, ftinfo.gbk24_addr+position, pxSize); }
else if(wordPx==32){ W25xFLASH_ReadBuffer(p, ftinfo.gbk32_addr+position, pxSize); }
LCD_ShowWordPx(x,y,wordPx,wordPx,p,PenColor,BackColor);
}
#else
u8 *p; //pΪ±»ÏÔʾ×ÖµÄ×Ö¿âµØÖ·
u16 j=0;
if(wordPx==12){ p=(u8*)ASCII_0612[temp[0]-0X20];}
else if(wordPx==16){ p=(u8*)ASCII_0816[temp[0]-0X20];}
else if(wordPx==24){ p=(u8*)ASCII_1224[temp[0]-0X20];}
else if(wordPx==32){ p=(u8*)ASCII_1632[temp[0]-0X20];}
if(temp[0]<128) //ΪASCIIÂë
{
LCD_ShowWordPx(x,y,wordPx/2,wordPx,p,PenColor,BackColor);
}
else if(temp[0]>0x80){ //Ϊºº×Ö
for(j=0;j<sizeof(GB16)/35;j++) //²éÕÒºº×ֿ⣬34×Ö½ÚÒ»¸ö×Ö·û
{
if((temp[0]==GB16[j].Index[0])&&(temp[1]==GB16[j].Index[1]))//ÕÒµ½ÐèÒªµÄºº×Ö×Ö½Ú
{
break;
}
}
if(j<sizeof(GB16)/35) //ÕÒµ½ÁË×Ö¿â
LCD_ShowWordPx(x,y,wordPx,wordPx,(u8*)GB16[j].MSK,PenColor,BackColor);
}
#endif
}
/*
* º¯Êý¹¦ÄÜ£ºÔÚÖ¸¶¨ÇøÓòÄÚÒ»Ö±´òÓ¡×Ö·û
* xStar,yStar,xEnd,yEnd:Æðʼ×Ö·ûµÄÏñËØµã
* x<lcddev.width_x/px; lcddev.height_y/px/2;
* size:×Ö¿â´úÂë1--6*12, 2--8*16, 3--12*24, 4--16*32 ¼Ó´Ö
* *ptr:ÏÔʾÄÚÈÝ
* PenColorΪÄÚÈÝÑÕÉ«£¬BackColorΪ±³¾²ÑÕÉ«
*/
void LCD_ShowString_Area(u8 *ptr)
{
u16 i=0,val=0; //Ò»¶¨Òª³õʼ»¯£¬²»È»xlenÔÚµÚ¶þ´Îµ÷ÓÃʱ»áÓÐÎÊÌâ valÓÃÓÚ¼ÆÊý²¹µÄ¿Õ°××Ö·û
u8 temp[2]={0};
u16 xlen,ylen;
u8 newlen=255,oldlen=255;
u16 max_ylen, max_xlen;
static u8 yNum=0;
max_xlen=(xPxEnd-xPxStar)*2/wordPx; //¸ù¾ÝȡģÈí¼þ
max_ylen=(yPxEnd-yPxStar)/wordPx; //×î¶àÏÔʾÁÐÐÐ,ÁÐÏñËØÊÇÐÐÏñËØµÄ2±¶
for(i=0;i<strlen((char*)ptr);i++)
{
temp[0]=ptr[i];
temp[1]=ptr[i+1];
xlen =(i+val)%max_xlen;
ylen =((i+val)/max_xlen+yNum)%max_ylen;
newlen=ylen;
if(newlen !=oldlen)
{
oldlen=newlen;
//--Çå³ýÏÂÒ»ÐÐ
LCD_ColorBox(xPxStar,yPxStar+(ylen+1)%max_ylen*wordPx,xPxEnd-xPxStar,wordPx,BackColor);
}
if(temp[0]<128) //ΪASCIIÂë
{
LCD_ShowWordZk(xPxStar+xlen*wordPx/2,yPxStar+ylen*wordPx,temp);
}
else if(temp[0]>0x80)
{ //Ϊºº×Ö
if(xlen==max_xlen-1) //×îºóÒ»Áв»ÄÜ·ÅÏÂÒ»¸öºº×Ö
{
LCD_ShowWordZk(xPxStar+xlen*wordPx/2,yPxStar+ylen*wordPx," "); //ÏÔʾ¡° ¡±¿Õ°×Ìî²¹
val++; //valÓÃÓÚ¼ÆÊý²¹µÄ¿Õ°××Ö·û
i--;//Ö¸Õ뻹ÊÇÖ¸ÏòÔºº×Ö,ËùÒÔÒª¼õÒ»
}
else
{
LCD_ShowWordZk(xPxStar+xlen*wordPx/2,yPxStar+ylen*wordPx,temp);
i++;
}
}
}
yNum =ylen+1;
}
//
//m^nº¯Êý
//·µ»ØÖµ:m^n´Î·½.
u32 LCD_Pow(u8 m,u8 n)
{
u32 result=1;
while(n--)result*=m;
return result;
}
//x,y:ÆðʼÐÐÁÐ×ø±ê
//size:×ÖÌå´óС
//mode:¸ßλΪ0ÊÇ·ñÏÔʾ+Ê®½øÖÆ»¹ÊÇÊ®Áù½øÖÆ---0,²»ÏÔʾ0+Ê®½øÖÆ;1,ÏÔʾ0+Ê®½øÖÆ; 2,²»ÏÔʾ0+Ê®Áù½øÖÆ;1,ÏÔʾ0+Ê®Áù½øÖÆ.
//num: ÊýÖµ(0~4294967295) 0x0~0xFFFFFFFF;
//len:³¤¶È(¼´ÒªÏÔʾµÄλÊý)
void LCD_ShowxNum(u16 x,u16 y,u8 size,u8 mode,u32 num,u8 len,u16 PColor,u16 BColor)
{
u8 t;
u32 temp;
u8 enshow=0;
u8 show[11]={0};
for(t=0;t<len;t++)
{
if(mode<2) //Ê®½øÖÆ
{
temp=(num/LCD_Pow(10,len-t-1))%10;
if(enshow==0&&t<(len-1))
{
if(temp==0)
{
if(mode) show[t] ='0';
else show[t]=' ';
continue;
}else enshow=1;
}
show[t] ='0'+temp;
}
else //Ê®Áù½øÖÆ
{
if(t==0)
{
show[0] ='0';show[1] ='x';
}
temp=(num/LCD_Pow(2,(len-t-1)*4))%16;
if(enshow==0&&t<(len-1))
{
if(temp==0)
{
if(mode==3) show[t+2] ='0';
else show[t+2]=' ';
continue;
}else enshow=1;
}
if(temp<10)
show[t+2] ='0'+temp;
else show[t+2] ='7'+temp;
}
}
if(mode<2)
show[t]='\0';
else show[t+2]='\0';
LCD_ShowString(x,y,size,show,PColor,BColor) ;
}
void test_display(void)
{
delay_ms(1000);
LCD_Clear(GREEN);
delay_ms(1000);
LCD_Clear(YELLOW);
delay_ms(1000);
LCD_Clear(RED);
delay_ms(1000);
LCD_Clear(BLUE);
delay_ms(1000);
LCD_Clear(GRAY);
delay_ms(1000);
LCD_Clear(BLACK);
delay_ms(1000);
LCD_Clear(WHITE);
}
void show_head(void)
{
//ºº×Ö×Ö¿âfont.hÎļþÖ»ÓÐ16ºÅµÄºº×Ö
LCD_ColorBox(0,0,lcddev.width_x,20,WHITE);
LCD_ShowString(0,0,2,(u8*)"-----Î人Ò×˼´ï¿Æ¼¼ÓÐÏÞ¹«Ë¾»¶ÓÄú£¡-----",RED,GREEN);
LCD_DrawLine(0,20,lcddev.width_x,20,5,BLUE);
}
void sys_init(void)
{
u16 lcdId=0;
delay_init(); //ÑÓʱº¯Êý³õʼ»¯
NVIC_Configuration(); //ÉèÖÃNVICÖжϷÖ×é2:2λÇÀÕ¼ÓÅÏȼ¶£¬2λÏìÓ¦ÓÅÏȼ¶
usart_io_init(); //´®¿ÚIO³õʼ»¯
usart_config(USART1,115200);
usart_config(USART2,115200);
delay_ms(1500);
usart_printf(USART1,"2222\r\n"); //´®¿ÚÖúÊÖÉÏ´òÓ¡2222µÄº¯Êý¡£
delay_ms(1500);
// iic_init(0); //IIC³õʼ»¯ :Ó²¼þI2C
lcdId=lcd_init(0);
usart_printf(USART1,"LCD Drive Id:%x\r\n",lcdId);
TP_Init(0);
}
void atk_rm04_quit_trans(void)
{
delay_ms(15); //´óÓÚ´®¿Ú×é֡ʱ¼ä(10ms)
while((USART2->SR&0X40)==0); //µÈ´ý·¢ËÍ¿Õ
USART2->DR='+';
delay_ms(15); //´óÓÚ´®¿Ú×é֡ʱ¼ä(10ms)
while((USART2->SR&0X40)==0); //µÈ´ý·¢ËÍ¿Õ
USART2->DR='+';
delay_ms(15); //´óÓÚ´®¿Ú×é֡ʱ¼ä(10ms)
while((USART2->SR&0X40)==0); //µÈ´ý·¢ËÍ¿Õ
USART2->DR='+';
delay_ms(500); //µÈ´ý500ms
while((USART2->SR&0X40)==0); //µÈ´ý·¢ËÍ¿Õ
USART2->DR=0X1B;
delay_ms(15); //´óÓÚ´®¿Ú×é֡ʱ¼ä(10ms)
while((USART2->SR&0X40)==0); //µÈ´ý·¢ËÍ¿Õ
USART2->DR=0X1B;
delay_ms(15); //´óÓÚ´®¿Ú×é֡ʱ¼ä(10ms)
while((USART2->SR&0X40)==0); //µÈ´ý·¢ËÍ¿Õ
USART2->DR=0X1B;
delay_ms(15); //´óÓÚ´®¿Ú×é֡ʱ¼ä(10ms)
}
void touchmain(void) {
u8 set_flag = 0;
u8 touch = 0;
u8 pos1 = 0;
char passnum[15] = {'\0'};
atk_rm04_load_keyboard(0, 240);
LCD_ShowString(0, 7, 3, "WIFI SSID :", YELLOW, BLACK);
while(1)
{
tp_dev.scan(0);//ɨÃèÆÁÄ»×ø±ê
if(tp_dev.sta&TP_ONCE_PRES)//°´¼ü°´ÏÂ
{
tp_dev.sta&=~TP_ONCE_PRES;//±ê¼Ç°´¼üÒѾ±»´¦Àí¹ýÁË
if(tp_dev.touchY[1]>240 && tp_dev.touchY[1]<288)
{
if(tp_dev.touchX[1]>0 && tp_dev.touchX[1]<112) {touch=1;break;}
else if(tp_dev.touchX[1]>112 && tp_dev.touchX[1]<224){touch=2;break;}
else if(tp_dev.touchX[1]>224 && tp_dev.touchX[1]<380){touch=3;break;}
}
else if(tp_dev.touchY[1]>288 && tp_dev.touchY[1]<336)
{
if(tp_dev.touchX[1]>0 && tp_dev.touchX[1]<112) {touch=4;break;}
else if(tp_dev.touchX[1]>112 && tp_dev.touchX[1]<224){touch=5;break;}
else if(tp_dev.touchX[1]>224 && tp_dev.touchX[1]<380){touch=6;break;}
}
else if(tp_dev.touchY[1]>336 && tp_dev.touchY[1]<384)
{
if(tp_dev.touchX[1]>0 && tp_dev.touchX[1]<112) {touch=7;break;}
else if(tp_dev.touchX[1]>112 && tp_dev.touchX[1]<224){touch=8;break;}
else if(tp_dev.touchX[1]>224 && tp_dev.touchX[1]<380){touch=9;break;}
}
else if(tp_dev.touchY[1]>384 && tp_dev.touchY[1]<432)
{
if(tp_dev.touchX[1]>0 && tp_dev.touchX[1]<112) {touch=10;break;}
else if(tp_dev.touchX[1]>112 && tp_dev.touchX[1]<224){touch=11;break;}
else if(tp_dev.touchX[1]>224 && tp_dev.touchX[1]<380){touch=12;break;}
}
else if(tp_dev.touchY[1]>432 && tp_dev.touchY[1]<480)
{
if(tp_dev.touchX[1]>0 && tp_dev.touchX[1]<112) {touch=13;break;}
else if(tp_dev.touchX[1]>112 && tp_dev.touchX[1]<224){touch=14;break;}
else if(tp_dev.touchX[1]>224 && tp_dev.touchX[1]<380){touch=15;break;}
}
/*if(tp_dev.touchY[1]>192 && tp_dev.touchY[1]<240)
{
if(tp_dev.touchX[1]>0 && tp_dev.touchX[1]<112) {touchnum1=3;break;}
else if(tp_dev.touchX[1]>112 && tp_dev.touchX[1]<224){touchnum1=2;break;}
else if(tp_dev.touchX[1]>224 && tp_dev.touchX[1]<380){touchnum1=1;break;}
}
else if(tp_dev.touchY[1]>144 && tp_dev.touchY[1]<192)
{
if(tp_dev.touchX[1]>0 && tp_dev.touchX[1]<112) {touchnum1=6;break;}
else if(tp_dev.touchX[1]>112 && tp_dev.touchX[1]<224){touchnum1=5;break;}
else if(tp_dev.touchX[1]>224 && tp_dev.touchX[1]<380){touchnum1=4;break;}
}
else if(tp_dev.touchY[1]>96 && tp_dev.touchY[1]<144)
{
if(tp_dev.touchX[1]>0 && tp_dev.touchX[1]<112) {touchnum1=9;break;}
else if(tp_dev.touchX[1]>112 && tp_dev.touchX[1]<224){touchnum1=8;break;}
else if(tp_dev.touchX[1]>224 && tp_dev.touchX[1]<380){touchnum1=7;break;}
}
else if(tp_dev.touchY[1]>48 && tp_dev.touchY[1]<96)
{
if(tp_dev.touchX[1]>0 && tp_dev.touchX[1]<112) {touchnum1=12;break;}
else if(tp_dev.touchX[1]>112 && tp_dev.touchX[1]<224){touchnum1=11;break;}
else if(tp_dev.touchX[1]>224 && tp_dev.touchX[1]<380){touchnum1=10;break;}
}
else if(tp_dev.touchY[1]>0 && tp_dev.touchY[1]<48)
{
if(tp_dev.touchX[1]>0 && tp_dev.touchX[1]<112) {touchnum1=15;break;}
else if(tp_dev.touchX[1]>112 && tp_dev.touchX[1]<224){touchnum1=14;break;}
else if(tp_dev.touchX[1]>224 && tp_dev.touchX[1]<380){touchnum1=13;break;}
}
}
} */
switch(touch)
{
case 0: // ?0:"1"
LCD_ColorBox(0, 0, 53, 34, BLUE); // ??????(x1=0,y1=0,x2=53,y2=34)
LCD_ShowString(22, 9, 2, "1", GREEN, BLUE); // ????(x=22,y=9)
delay_ms(100);
LCD_ColorBox(0, 0, 53, 34, YELLOW); // ??????
LCD_ShowString(22, 9, 2, "1", GREEN, YELLOW);
strcat(passnum,"1");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK); // ??????
pos1++;
break;
case 1: // ?1:"2"
LCD_ColorBox(53, 0, 106, 34, BLUE);
LCD_ShowString(75, 9, 2, "2", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(53, 0, 106, 34, YELLOW);
LCD_ShowString(75, 9, 2, "2", GREEN, YELLOW);
strcat(passnum,"2");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 2: // ?2:"3"
LCD_ColorBox(106, 0, 159, 34, BLUE);
LCD_ShowString(128, 9, 2, "3", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(106, 0, 159, 34, YELLOW);
LCD_ShowString(128, 9, 2, "3", GREEN, YELLOW);
strcat(passnum,"3");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 3: // ?3:"A"
LCD_ColorBox(159, 0, 212, 34, BLUE);
LCD_ShowString(181, 9, 2, "A", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(159, 0, 212, 34, YELLOW);
LCD_ShowString(181, 9, 2, "A", GREEN, YELLOW);
strcat(passnum,"A");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 4: // ?4:"B"
LCD_ColorBox(212, 0, 265, 34, BLUE);
LCD_ShowString(234, 9, 2, "B", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(212, 0, 265, 34, YELLOW);
LCD_ShowString(234, 9, 2, "B", GREEN, YELLOW);
strcat(passnum,"B");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 5: // ?5:"C"(?55px)
LCD_ColorBox(265, 0, 320, 34, BLUE);
LCD_ShowString(290, 9, 2, "C", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(265, 0, 320, 34, YELLOW);
LCD_ShowString(290, 9, 2, "C", GREEN, YELLOW);
strcat(passnum,"C");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
// ====================== ?1?(row=1,y=34~68)======================
case 6: // ?0:"4"
LCD_ColorBox(0, 34, 53, 68, BLUE);
LCD_ShowString(22, 43, 2, "4", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(0, 34, 53, 68, YELLOW);
LCD_ShowString(22, 43, 2, "4", GREEN, YELLOW);
strcat(passnum,"4");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 7: // ?1:"5"
LCD_ColorBox(53, 34, 106, 68, BLUE);
LCD_ShowString(75, 43, 2, "5", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(53, 34, 106, 68, YELLOW);
LCD_ShowString(75, 43, 2, "5", GREEN, YELLOW);
strcat(passnum,"5");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 8: // ?2:"6"
LCD_ColorBox(106, 34, 159, 68, BLUE);
LCD_ShowString(128, 43, 2, "6", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(106, 34, 159, 68, YELLOW);
LCD_ShowString(128, 43, 2, "6", GREEN, YELLOW);
strcat(passnum,"6");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 9: // ?3:"D"
LCD_ColorBox(159, 34, 212, 68, BLUE);
LCD_ShowString(181, 43, 2, "D", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(159, 34, 212, 68, YELLOW);
LCD_ShowString(181, 43, 2, "D", GREEN, YELLOW);
strcat(passnum,"D");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 10: // ?4:"E"
LCD_ColorBox(212, 34, 265, 68, BLUE);
LCD_ShowString(234, 43, 2, "E", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(212, 34, 265, 68, YELLOW);
LCD_ShowString(234, 43, 2, "E", GREEN, YELLOW);
strcat(passnum,"E");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 11: // ?5:"F"
LCD_ColorBox(265, 34, 320, 68, BLUE);
LCD_ShowString(290, 43, 2, "F", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(265, 34, 320, 68, YELLOW);
LCD_ShowString(290, 43, 2, "F", GREEN, YELLOW);
strcat(passnum,"F");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
// ====================== ?2?(row=2,y=68~102)======================
case 12: // ?0:"7"
LCD_ColorBox(0, 68, 53, 102, BLUE);
LCD_ShowString(22, 77, 2, "7", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(0, 68, 53, 102, YELLOW);
LCD_ShowString(22, 77, 2, "7", GREEN, YELLOW);
strcat(passnum,"7");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 13: // ?1:"8"
LCD_ColorBox(53, 68, 106, 102, BLUE);
LCD_ShowString(75, 77, 2, "8", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(53, 68, 106, 102, YELLOW);
LCD_ShowString(75, 77, 2, "8", GREEN, YELLOW);
strcat(passnum,"8");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 14: // ?2:"9"
LCD_ColorBox(106, 68, 159, 102, BLUE);
LCD_ShowString(128, 77, 2, "9", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(106, 68, 159, 102, YELLOW);
LCD_ShowString(128, 77, 2, "9", GREEN, YELLOW);
strcat(passnum,"9");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 15: // ?3:"G"
LCD_ColorBox(159, 68, 212, 102, BLUE);
LCD_ShowString(181, 77, 2, "G", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(159, 68, 212, 102, YELLOW);
LCD_ShowString(181, 77, 2, "G", GREEN, YELLOW);
strcat(passnum,"G");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 16: // ?4:"H"
LCD_ColorBox(212, 68, 265, 102, BLUE);
LCD_ShowString(234, 77, 2, "H", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(212, 68, 265, 102, YELLOW);
LCD_ShowString(234, 77, 2, "H", GREEN, YELLOW);
strcat(passnum,"H");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 17: // ?5:"I"
LCD_ColorBox(265, 68, 320, 102, BLUE);
LCD_ShowString(290, 77, 2, "I", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(265, 68, 320, 102, YELLOW);
LCD_ShowString(290, 77, 2, "I", GREEN, YELLOW);
strcat(passnum,"I");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
// ====================== ?3?(row=3,y=102~136)======================
case 18: // ?0:"*"
LCD_ColorBox(0, 102, 53, 136, BLUE);
LCD_ShowString(22, 111, 2, "*", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(0, 102, 53, 136, YELLOW);
LCD_ShowString(22, 111, 2, "*", GREEN, YELLOW);
strcat(passnum,"*");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 19: // ?1:"0"
LCD_ColorBox(53, 102, 106, 136, BLUE);
LCD_ShowString(75, 111, 2, "0", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(53, 102, 106, 136, YELLOW);
LCD_ShowString(75, 111, 2, "0", GREEN, YELLOW);
strcat(passnum,"0");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 20: // ?2:"#"
LCD_ColorBox(106, 102, 159, 136, BLUE);
LCD_ShowString(128, 111, 2, "#", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(106, 102, 159, 136, YELLOW);
LCD_ShowString(128, 111, 2, "#", GREEN, YELLOW);
strcat(passnum,"#");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 21: // ?3:"J"
LCD_ColorBox(159, 102, 212, 136, BLUE);
LCD_ShowString(181, 111, 2, "J", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(159, 102, 212, 136, YELLOW);
LCD_ShowString(181, 111, 2, "J", GREEN, YELLOW);
strcat(passnum,"J");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 22: // ?4:"K"
LCD_ColorBox(212, 102, 265, 136, BLUE);
LCD_ShowString(234, 111, 2, "K", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(212, 102, 265, 136, YELLOW);
LCD_ShowString(234, 111, 2, "K", GREEN, YELLOW);
strcat(passnum,"K");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 23: // ?5:"L"
LCD_ColorBox(265, 102, 320, 136, BLUE);
LCD_ShowString(290, 111, 2, "L", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(265, 102, 320, 136, YELLOW);
LCD_ShowString(290, 111, 2, "L", GREEN, YELLOW);
strcat(passnum,"L");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
// ====================== ?4?(row=4,y=136~170)======================
case 24: // ?0:"."
LCD_ColorBox(0, 136, 53, 170, BLUE);
LCD_ShowString(22, 145, 2, ".", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(0, 136, 53, 170, YELLOW);
LCD_ShowString(22, 145, 2, ".", GREEN, YELLOW);
strcat(passnum,".");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 25: // ?1:"-"
LCD_ColorBox(53, 136, 106, 170, BLUE);
LCD_ShowString(75, 145, 2, "V", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(53, 136, 106, 170, YELLOW);
LCD_ShowString(75, 145, 2, "V", GREEN, YELLOW);
strcat(passnum,"V");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 26: // ?2:"+"
LCD_ColorBox(106, 136, 159, 170, BLUE);
LCD_ShowString(128, 145, 2, "Z", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(106, 136, 159, 170, YELLOW);
LCD_ShowString(128, 145, 2, "Z", GREEN, YELLOW);
strcat(passnum,"Z");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 27: // ?3:"M"
LCD_ColorBox(159, 136, 212, 170, BLUE);
LCD_ShowString(181, 145, 2, "M", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(159, 136, 212, 170, YELLOW);
LCD_ShowString(181, 145, 2, "M", GREEN, YELLOW);
strcat(passnum,"M");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 28: // ?4:"N"
LCD_ColorBox(212, 136, 265, 170, BLUE);
LCD_ShowString(234, 145, 2, "N", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(212, 136, 265, 170, YELLOW);
LCD_ShowString(234, 145, 2, "N", GREEN, YELLOW);
strcat(passnum,"N");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 29: // ?5:"O"
LCD_ColorBox(265, 136, 320, 170, BLUE);
LCD_ShowString(290, 145, 2, "O", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(265, 136, 320, 170, YELLOW);
LCD_ShowString(290, 145, 2, "O", GREEN, YELLOW);
strcat(passnum,"O");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
// ====================== ?5?(row=5,y=170~204)======================
case 30: // ?0:"/"
LCD_ColorBox(0, 170, 53, 204, BLUE);
LCD_ShowString(22, 179, 2, "Y", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(0, 170, 53, 204, YELLOW);
LCD_ShowString(22, 179, 2, "Y", GREEN, YELLOW);
strcat(passnum,"Y");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 31: // ?1:"×"
LCD_ColorBox(53, 170, 106, 204, BLUE);
LCD_ShowString(75, 179, 2, "X", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(53, 170, 106, 204, YELLOW);
LCD_ShowString(75, 179, 2, "X", GREEN, YELLOW);
strcat(passnum,"X");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 32: // ?2:"="
LCD_ColorBox(106, 170, 159, 204, BLUE);
LCD_ShowString(128, 179, 2, "W", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(106, 170, 159, 204, YELLOW);
LCD_ShowString(128, 179, 2, "W", GREEN, YELLOW);
strcat(passnum,"W");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 33: // ?3:"P"
LCD_ColorBox(159, 170, 212, 204, BLUE);
LCD_ShowString(181, 179, 2, "P", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(159, 170, 212, 204, YELLOW);
LCD_ShowString(181, 179, 2, "P", GREEN, YELLOW);
strcat(passnum,"P");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 34: // ?4:"Q"
LCD_ColorBox(212, 170, 265, 204, BLUE);
LCD_ShowString(234, 179, 2, "Q", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(212, 170, 265, 204, YELLOW);
LCD_ShowString(234, 179, 2, "Q", GREEN, YELLOW);
strcat(passnum,"Q");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 35: // ?5:"R"
LCD_ColorBox(265, 170, 320, 204, BLUE);
LCD_ShowString(290, 179, 2, "R", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(265, 170, 320, 204, YELLOW);
LCD_ShowString(290, 179, 2, "R", GREEN, YELLOW);
strcat(passnum,"R");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
// ====================== ?6?(row=6,y=204~240,?36px)======================
case 36: // ?0:"DEL"(??)
LCD_ColorBox(0, 204, 53, 240, BLUE);
LCD_ShowString(14, 216, 2, "DEL", GREEN, BLUE); // ?????
delay_ms(100);
LCD_ColorBox(0, 204, 53, 240, YELLOW);
LCD_ShowString(14, 216, 2, "DEL", GREEN, YELLOW);
if(pos1 > 0)
{
pos1--;
passnum[pos1] = '\0';
LCD_ColorBox(100 + pos1*8, 7, 100 + (pos1+1)*8, 23, BLACK); // ???????
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
}
break;
case 37: // ?1:"CLEAR"(??)
LCD_ColorBox(53, 204, 106, 240, BLUE);
LCD_ShowString(66, 216, 2, "CLEAR", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(53, 204, 106, 240, YELLOW);
LCD_ShowString(66, 216, 2, "CLEAR", GREEN, YELLOW);
pos1 = 0;
memset(passnum, '\0', sizeof(passnum));
LCD_ColorBox(100, 7, 310, 23, BLACK); // ??????
usart_printf(USART1,"\r\nClear all input!");
break;
case 38: // ?2:"OK"(??,????set)
LCD_ColorBox(106, 204, 159, 240, BLUE);
LCD_ShowString(119, 216, 2, "OK", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(106, 204, 159, 240, YELLOW);
LCD_ShowString(119, 216, 2, "OK", GREEN, YELLOW);
set_flag=1;
break;
case 39: // ?3:"S"
LCD_ColorBox(159, 204, 212, 240, BLUE);
LCD_ShowString(181, 216, 2, "S", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(159, 204, 212, 240, YELLOW);
LCD_ShowString(181, 216, 2, "S", GREEN, YELLOW);
strcat(passnum,"S");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 40: // ?4:"T"
LCD_ColorBox(212, 204, 265, 240, BLUE);
LCD_ShowString(234, 216, 2, "T", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(212, 204, 265, 240, YELLOW);
LCD_ShowString(234, 216, 2, "T", GREEN, YELLOW);
strcat(passnum,"T");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
case 41: // ?5:"U"
LCD_ColorBox(265, 204, 320, 240, BLUE);
LCD_ShowString(290, 216, 2, "U", GREEN, BLUE);
delay_ms(100);
LCD_ColorBox(265, 204, 320, 240, YELLOW);
LCD_ShowString(290, 216, 2, "U", GREEN, YELLOW);
strcat(passnum,"U");
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum);
LCD_ShowString(100, 7, 2, passnum, YELLOW, BLACK);
pos1++;
break;
default:break;
}
if(set_flag)
{set_flag=0;
strcat(passnum_pro,passnum);
usart_printf(USART1,"\r\n");
usart_printf(USART1,passnum_pro);
LCD_Clear(BLACK);
show_head();
}
}
}
// ??WIFI?AP???????
void configure_wifi_ap(uint16_t n, const char *extra_command) {
LCD_ShowString(0, 5, 2, "???AT???:", BLUE, BLACK);
send_at_command("at+netmode=3\r\n", 0, 6, n);
send_at_command("at+dhcpd=1\r\n", 0, 7, n);
send_at_command("at+dhcpd_ip=192.168.18.1,192.168.18.254,255.255.255.0,192.168.18.203\r\n", 0, 8, n);
send_at_command("at+dhcpd_dns=192.168.18.203,0.0.0.0\r\n", 0, 10, n);
send_at_command("at+dhcpd_time=86400\r\n", 0, 11, n);
if (extra_command != NULL) {
send_at_command(extra_command, 0, 12, n);
}
send_at_command("at+dhcpc=1\r\n", 0, 14, n);
send_at_command("at+net_ip=192.168.18.203,255.255.255.0,0.0.0.0\r\n", 0, 15, n);
send_at_command("at+net_dns=0.0.0.0,0.0.0.0\r\n", 0, 17, n);
send_at_command("at+remotepro=tcp\r\n", 0, 18, n);
send_at_command("at+mode=server\r\n", 0, 19, n);
send_at_command("at+remoteip=192.168.11.245\r\n", 0, 20, n);
send_at_command("at+remoteport=8080\r\n", 0, 21, n);
send_at_command("at+CLport=\r\n", 0, 22, n);
send_at_command("at+timeout=0\r\n", 0, 23, n);
send_at_command("at+uart=115200,8,n,1\r\n", 0, 24, n);
send_at_command("at+uartpacklen=64\r\n", 0, 25, n);
send_at_command("at+uartpacktimeout=10\r\n", 0, 26, n);
send_at_command("at+net_commit=1\r\n", 0, 27, n);
send_at_command("at+reconn=1\r\n", 0, 28, n);
}
// WIFI_aptest??
void WIFI_aptest(void) {
u16 n = 150;
configure_wifi_ap(n, ceshi_pro);
int retry_count = 0;
while (retry_count < 3) {
if (USART2_RX_STA & 0x8000) {
usart_printf(USART1, "\r\nFrom Usart1:");
usart_printf_len(USART1, USART2_RX_BUF, USART2_RX_STA & 0X3FFF);
LCD_ShowString(16, 5, 2, "ok AP?????", YELLOW, RED);
// Show AP ??
LCD_ColorBox(0, 80, 320, 400, BLACK);
LCD_ColorBox(32, 120, 256, 320, RED);
LCD_ColorBox(40, 128, 240, 304, WHITE);
LCD_SetShowArea(40, 128, 280, 348);
LCD_ShowString_Area("?????????");
LCD_ShowString_Area("WIFI??:");
LCD_ShowString_Area(ipnum_pro);
LCD_ShowString_Area("????:WPA/WPA2_AES");
LCD_ShowString_Area("WIFI??:");
LCD_ShowString_Area(passnum_pro);
LCD_ShowString_Area("???:8080");
USART2_RX_STA = 0;
break;
} else {
retry_count++;
if (retry_count < 3) {
configure_wifi_ap(n, ceshi_pro);
}
}
}
if (retry_count == 3) {
LCD_ShowString(16, 5, 2, "bad ????", YELLOW, RED);
}
delay_ms(n);
}
// WIFI_ap??
void WIFI_ap(void) {
u16 n = 150;
const char *wifi_conf = "at+wifi_conf=EasyStart,wpawpa2_aes,123456789\r\n";
configure_wifi_ap(n, wifi_conf);
int retry_count = 0;
while (retry_count < 3) {
if (USART2_RX_STA & 0x8000) {
usart_printf(USART1, "\r\nFrom Usart1:");
usart_printf_len(USART1, USART2_RX_BUF, USART2_RX_STA & 0X3FFF);
LCD_ShowString(16, 5, 2, "ok", YELLOW, RED);
USART2_RX_STA = 0;
break;
} else {
retry_count++;
if (retry_count < 3) {
configure_wifi_ap(n, wifi_conf);
}
}
}
if (retry_count == 3) {
LCD_ShowString(16, 5, 2, "bad", YELLOW, RED);
}
delay_ms(n);
}
/*
* ???:LCD_GPIO_Config
* ?? :??FSMC??LCD?I/O
* ?? :?
* ?? :?
* ?? :????
*/
void LCD_GPIO_Config(void) {
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable the FSMC Clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
/* config lcd gpio clock base on FSMC */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOE, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_14 | GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOE, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOE, &GPIO_InitStructure);
}
最新发布