高中生
最后登录1970-1-1
在线时间 小时
注册时间2015-3-13
|
void even_process(void)
{
char lcd_char[20];
switch(even)
{
case E_BUTTON1: //LED1
if(red_button == S_OFF)
{
Lcd_show_bmp(38, 184,"/led/ui_r_button.bmp");
//red_button = S_ON;
LED1_TOGGLE;
//Delay_ms(1000);
}
else
{
red_button = S_OFF;
}
Lcd_show_bmp(38, 184,"/led/ui_rb_button.bmp");
LED1_TOGGLE;
even = E_NULL;
break;
case E_BUTTON2: //LED2
if(green_button == S_OFF)
{
Lcd_show_bmp(38, 95,"/led/ui_g_button.bmp");
green_button = S_ON;
}
else
{
Lcd_show_bmp(38, 95,"/led/ui_gb_button.bmp");
green_button = S_OFF;
}
LED2_TOGGLE;
even = E_NULL;
break;
case E_BUTTON3: //LED3
if(yellow_button == S_OFF)
{
Lcd_show_bmp(38, 11,"/led/ui_y_button.bmp");
yellow_button = S_ON;
}
else
{
Lcd_show_bmp(38, 11,"/led/ui_yb_button.bmp");
yellow_button = S_OFF;
}
LED3_TOGGLE;
even = E_NULL;
break;
case E_GETCHAR:
if(recv_char == 0)
{
Lcd_GramScan( 1 );
LCD_DispEnCh(20,180,"ûóD½óêÕμ½′®¿úêy¾Y",BLUE);
}
else
{
Lcd_GramScan( 1 );
LCD_Clear(20,180,180,16,BACKGROUND) ;
sprintf(lcd_char,"′®¿úêy¾Y:%c",recv_char);
LCD_DispEnCh(20,180,lcd_char,BLUE);
}
even = E_NULL;
break;
default:
break;
}
}
/**
* @brief touch_processÖ
* @param ÎT
* @retval ÎT
*/
void touch_process(void)
{
if(touch_flag == 1)
{
if(Get_touch_point(&display, Read_2046_2(), &touch_para ) !=DISABLE)
{
printf("\r\n x=%d,y=%d",display.x,display.y);
if(display.x>=34 && display.x<=76)
{
if(display.y>=15 && display.y<=46) // LED1
{
even = E_BUTTON1;
printf("\r\n LED1");
}
else if(display.y>=100 && display.y<=135) // LED2
{
even = E_BUTTON2;
printf("\r\n LED2");
}
else if(display.y>=182 && display.y<=216) // LED3
{
even = E_BUTTON3;
printf("\r\n LED3");
}
}
}
}
}
中断
void EXTI9_5_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line9) != RESET)
{
//Delay_ms(1000);
touch_flag=1;
touch_process();
EXTI_ClearITPendingBit(EXTI_Line9);
}
}
以上是LCD触摸屏控制LED灯的案例(点一次LED灯开,点一次LED灭).我想实现点动的方式,(一直点LED亮,松开就灭了),求大神指教怎么修改程序!!!
|
|