Home > other >  Do the bluetooth to send, the program card to die in the while (! TI) that, to solve
Do the bluetooth to send, the program card to die in the while (! TI) that, to solve

Time:11-07

Doing with gesture recognition sensor sent via bluetooth gestures instruction, but the program always stuck in the while (! TI) loop, the death of his note gestures can recognize but bluetooth hair don't go out; Keep the gesture recognition directly if no response,,, the procedure is as follows, BBS typesetting
 # include "stc15f2k60s2. H" 
# include "GesturePAJ7620. H"
# include "oled. H"
C # include "GesturePAJ7620."
C # include "oled."
#include
# define uchar unsigned char
# define uint unsigned int
200//# define GES_REACTION_TIME You can adjust the reaction time "according to the actual circumstance.
500//# define GES_ENTRY_TIME the When you want to recognize the Forward/Backward gestures, your gestures' reaction time must less than GES_ENTRY_TIME (0.8 s).
# define GES_QUIT_TIME 1000
# define Delay_2us _nop_ () (); _nop_(); _nop_(); _nop_ ()
Uchar GestureValue=https://bbs.csdn.net/topics/0;
Unsigned char send_data;
Void GestureRecognition (void);
Void Delay_ms (uint ms);
Void send_init ();
//* * * * * * * * * * * * * * * * * * * * * * * the main program * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Void main (void)
{
OLED_Init ();//OLED initialization
OLED_Clear();//OLED screen clearing
Delay_ms (2000);
OLED_Clear();//OLED screen clearing
GestureValue=https://bbs.csdn.net/topics/0;
Gesture OLED_ShowString (8, 0, "* *");//
OLED_ShowString (8, 4, "Wating... ");//
Delay_ms (1000);
Paj7620Init ();//gestures module initialization
Send_init ();
Delay_ms (200);
While (1)
{
GestureRecognition ();
McU_led=~ McU_led;
SBUF=GestureValue;
while(! TI);//card died here,,,,,,,,,,,,,,,,,,
TI=0;
}
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Void send_init ()
{
TMOD=0 x20;//set the timer T1 works 2
TH1=0 XFD;//timer T1 with initial value
TL1=0 XFD;//timer T1 with initial value
TR1=1;//start the timer T1
SCON=0 x40;//SM0=0 SM1=1 1 serial port register work way, REN=1 allows a serial port receives
PCON=0 x00;//SMOD is set to 0
EA=1;//total break
ES=1;//a serial port interrupt
}

Void GestureRecognition (void)
{
X43 GestureData=https://bbs.csdn.net/topics/paj7620ReadReg (0, 1);//Read Bank_0_Reg_0x43/0 x44 for gesture result.
If (GestureData!=0 XFF)
{
The switch (GestureData)//the When marketers gestures be detected, the variable 'data' will be set to the company values by paj7620ReadReg (0 x43, 1, & amp; The data).
{
Case GES_RIGHT_FLAG:
Delay_ms (GES_ENTRY_TIME);
X43 GestureData=https://bbs.csdn.net/topics/paj7620ReadReg (0, 1);
If (GestureData=GES_FORWARD_FLAG https://bbs.csdn.net/topics/=
{
GestureValue=https://bbs.csdn.net/topics/5;
OLED_Clear();
Gesture OLED_ShowString (8, 0, "* *");//
OLED_ShowString (2, 3, "Forward");//
Delay_ms (GES_QUIT_TIME);
}
Else if (GestureData=GES_BACKWARD_FLAG https://bbs.csdn.net/topics/=
{
GestureValue=https://bbs.csdn.net/topics/6;
OLED_Clear();
Gesture OLED_ShowString (8, 0, "* *");//
OLED_ShowString (2, 3, "Backward");//
Delay_ms (GES_QUIT_TIME);
}
The else
{
GestureValue=https://bbs.csdn.net/topics/4;
OLED_Clear();
Gesture OLED_ShowString (8, 0, "* *");//
OLED_ShowString (2, 3, "Right");//
}
break;
Case GES_LEFT_FLAG:
Delay_ms (GES_ENTRY_TIME);
X43 GestureData=https://bbs.csdn.net/topics/paj7620ReadReg (0, 1);
If (GestureData=GES_FORWARD_FLAG https://bbs.csdn.net/topics/=
{
GestureValue=https://bbs.csdn.net/topics/5;
OLED_Clear();
Gesture OLED_ShowString (8, 0, "* *");//
OLED_ShowString (2, 3, "Forward");//
Delay_ms (GES_QUIT_TIME);
}
Else if (GestureData=GES_BACKWARD_FLAG https://bbs.csdn.net/topics/=
{
GestureValue=https://bbs.csdn.net/topics/6;
OLED_Clear();
Gesture OLED_ShowString (8, 0, "* *");//
OLED_ShowString (2, 3, "Backward");//
Delay_ms (GES_QUIT_TIME);
}
The else
{
GestureValue=https://bbs.csdn.net/topics/3;
OLED_Clear();
Gesture OLED_ShowString (8, 0, "* *");//
OLED_ShowString (2, 3, "Left");//
}
break;
Case GES_UP_FLAG:
Delay_ms (GES_ENTRY_TIME);
X43 GestureData=https://bbs.csdn.net/topics/paj7620ReadReg (0, 1);
If (GestureData=GES_FORWARD_FLAG https://bbs.csdn.net/topics/=
{
GestureValue=https://bbs.csdn.net/topics/5;
OLED_Clear();
Gesture OLED_ShowString (8, 0, "* *");//
OLED_ShowString (2, 3, "Forward");//
Delay_ms (GES_QUIT_TIME);
}
Else if (GestureData=GES_BACKWARD_FLAG https://bbs.csdn.net/topics/=
{
GestureValue=https://bbs.csdn.net/topics/6;
OLED_Clear();
Gesture OLED_ShowString (8, 0, "* *");//
OLED_ShowString (2, 3, "Backward");//
Delay_ms (GES_QUIT_TIME);
}
The else
{
GestureValue=https://bbs.csdn.net/topics/1;
OLED_Clear();
Gesture OLED_ShowString (8, 0, "* *");//
OLED_ShowString (2, 3, "Up");//
}
break;
Case GES_DOWN_FLAG:
Delay_ms (GES_ENTRY_TIME);
X43 GestureData=https://bbs.csdn.net/topics/paj7620ReadReg (0, 1);
If (GestureData=GES_FORWARD_FLAG https://bbs.csdn.net/topics/=
{
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related