Subversion Repositories HomeAutomation

Rev

Rev 1279 | Rev 1284 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1279 Rev 1280
Line 70... Line 70...
70
    uint8_t f7_tmp = 0, f7_sign = 0, f1_sign = 0, f3_yref = 0, f1 = 0, f2 = 0, f3 = 0, f4 = 0, f5 = 0, f6 = 0, f7 = 0, f8 = 0, f9 = 0, xMin, xMax, yMin, yMax;
70
    uint8_t f7_tmp = 0, f7_sign = 0, f1_sign = 0, f3_yref = 0, f1 = 0, f2 = 0, f3 = 0, f4 = 0, f5 = 0, f6 = 0, f7 = 0, f8 = 0, f9 = 0, xMin, xMax, yMin, yMax;
71
   
71
   
72
    /* Function 6 indicates the sign value of the y coordinates of the last point minus y coordinates of the first point */
72
    /* Function 6 indicates the sign value of the y coordinates of the last point minus y coordinates of the first point */
73
    if ((int16_t)touchBuffer[endIndex].y - (int16_t)touchBuffer[startIndex].y > 0)
73
    if ((int16_t)touchBuffer[endIndex].y - (int16_t)touchBuffer[startIndex].y > 0)
74
    {
74
    {
75
        f6 = CAN_MODULE_ENUM_TOUCH_GESTURE_F6_PLUS;
75
        f6 = CAN_MODULE_ENUM_TOUCH_GESTURE_F6_P;
76
    }
76
    }
77
    else
77
    else
78
    {
78
    {
79
        f6 = CAN_MODULE_ENUM_TOUCH_GESTURE_F6_MINUS;
79
        f6 = CAN_MODULE_ENUM_TOUCH_GESTURE_F6_M;
80
    }
80
    }
81
   
81
   
82
    xMin = touchBuffer[startIndex].x;
82
    xMin = touchBuffer[startIndex].x;
83
    xMax = touchBuffer[startIndex].x;
83
    xMax = touchBuffer[startIndex].x;
84
    yMin = touchBuffer[startIndex].y;
84
    yMin = touchBuffer[startIndex].y;
85
    yMax = touchBuffer[startIndex].y;
85
    yMax = touchBuffer[startIndex].y;
86
    f3_yref = (touchBuffer[startIndex].y + touchBuffer[endIndex].y)/2;
86
    f3_yref = (touchBuffer[startIndex].y + touchBuffer[endIndex].y)/2;
87
    f1_k = ((touchBuffer[endIndex].y-touchBuffer[startIndex].y)<<4)/(touchBuffer[endIndex].x-touchBuffer[startIndex].x);
87
    f1_k = ((touchBuffer[endIndex].y-touchBuffer[startIndex].y)<<4)/(touchBuffer[endIndex].x-touchBuffer[startIndex].x);
88
    f1_sign = CAN_MODULE_ENUM_TOUCH_GESTURE_F2_UNDEFINED;
88
    f1_sign = CAN_MODULE_ENUM_TOUCH_GESTURE_F2_U;
89
 
89
 
90
    for (uint8_t i = startIndex+1; i < endIndex-1; i++)
90
    for (uint8_t i = startIndex+1; i < endIndex-1; i++)
91
    {
91
    {
92
        /* Function 1 indicates the number of intersection points between an input gesture g(x) and the straight line f(x)
92
        /* Function 1 indicates the number of intersection points between an input gesture g(x) and the straight line f(x)
93
        which connects the first and last point of the gesture */
93
        which connects the first and last point of the gesture */
94
        if (((f1_k*(touchBuffer[i].x-touchBuffer[0].x))>>4) + touchBuffer[0].y < touchBuffer[i].y)
94
        if (((f1_k*(touchBuffer[i].x-touchBuffer[0].x))>>4) + touchBuffer[0].y < touchBuffer[i].y)
95
        {
95
        {
96
            if (f1_sign != CAN_MODULE_ENUM_TOUCH_GESTURE_F2_PLUS)
96
            if (f1_sign != CAN_MODULE_ENUM_TOUCH_GESTURE_F2_P)
97
            {
97
            {
98
                f1++;
98
                f1++;
99
            }
99
            }
100
            f1_sign = CAN_MODULE_ENUM_TOUCH_GESTURE_F2_PLUS;
100
            f1_sign = CAN_MODULE_ENUM_TOUCH_GESTURE_F2_P;
101
        }
101
        }
102
        else
102
        else
103
        {
103
        {
104
            if (f1_sign != CAN_MODULE_ENUM_TOUCH_GESTURE_F2_MINUS)
104
            if (f1_sign != CAN_MODULE_ENUM_TOUCH_GESTURE_F2_M)
105
            {
105
            {
106
                f1++;
106
                f1++;
107
            }
107
            }
108
            f1_sign = CAN_MODULE_ENUM_TOUCH_GESTURE_F2_MINUS;
108
            f1_sign = CAN_MODULE_ENUM_TOUCH_GESTURE_F2_M;
109
        }
109
        }
110
       
110
       
111
        /* Function 3 indicates the sign value of area gap between g(x) and f(x) */
111
        /* Function 3 indicates the sign value of area gap between g(x) and f(x) */
112
        if (touchBuffer[i].x > min(touchBuffer[startIndex].x, touchBuffer[endIndex].x) && touchBuffer[i].x < max(touchBuffer[startIndex].x, touchBuffer[endIndex].x))
112
        if (touchBuffer[i].x > min(touchBuffer[startIndex].x, touchBuffer[endIndex].x) && touchBuffer[i].x < max(touchBuffer[startIndex].x, touchBuffer[endIndex].x))
113
        {
113
        {
Line 175... Line 175...
175
    /* Function 2 checks if the y coordinates of the points which exist between the intersection point and the last point are
175
    /* Function 2 checks if the y coordinates of the points which exist between the intersection point and the last point are
176
    greater than the y coordinates of the intersection point */
176
    greater than the y coordinates of the intersection point */
177
    f2 = f1_sign;
177
    f2 = f1_sign;
178
    if (f1 == 0)
178
    if (f1 == 0)
179
    {
179
    {
180
        f2 = 2;
180
        f2 = CAN_MODULE_ENUM_TOUCH_GESTURE_F2_U;
181
    }
181
    }
182
   
182
   
183
    /* Function 3 indicates the sign value of area gap between g(x) and f(x) */
183
    /* Function 3 indicates the sign value of area gap between g(x) and f(x) */
184
    f3 = CAN_MODULE_ENUM_TOUCH_GESTURE_F3_PLUS;
184
    f3 = CAN_MODULE_ENUM_TOUCH_GESTURE_F3_P;
185
    if (f3_tmp > 0)
185
    if (f3_tmp > 0)
186
    {
186
    {
187
        f3 = CAN_MODULE_ENUM_TOUCH_GESTURE_F3_MINUS;
187
        f3 = CAN_MODULE_ENUM_TOUCH_GESTURE_F3_M;
188
    }
188
    }
189
       
189
       
190
    /* Function 9 represents the sign value of the multiplication of x coordinates of the first point and the last point
190
    /* Function 9 represents the sign value of the multiplication of x coordinates of the first point and the last point
191
    minus the mediate value of x coordinates of all the points */
191
    minus the mediate value of x coordinates of all the points */
192
    f9_tmp = ((touchBuffer[startIndex].x - (xMax+xMin)/2)*(touchBuffer[endIndex].x - (xMax+xMin)/2));
192
    f9_tmp = ((touchBuffer[startIndex].x - (xMax+xMin)/2)*(touchBuffer[endIndex].x - (xMax+xMin)/2));
193
    f9 = CAN_MODULE_ENUM_TOUCH_GESTURE_F9_MINUS;
193
    f9 = CAN_MODULE_ENUM_TOUCH_GESTURE_F9_M;
194
    if (f9_tmp > 0)
194
    if (f9_tmp > 0)
195
    {
195
    {
196
        f9 = CAN_MODULE_ENUM_TOUCH_GESTURE_F9_PLUS;
196
        f9 = CAN_MODULE_ENUM_TOUCH_GESTURE_F9_P;
197
    }
197
    }
198
   
198
   
199
    /* Function 5 checks the sign value of the sum of the x coordinates of all the points that constitute strokes
199
    /* Function 5 checks the sign value of the sum of the x coordinates of all the points that constitute strokes
200
    minus x coordinates of the first point */
200
    minus x coordinates of the first point */
201
    f5 = CAN_MODULE_ENUM_TOUCH_GESTURE_F5_MINUS;
201
    f5 = CAN_MODULE_ENUM_TOUCH_GESTURE_F5_M;
202
    if (f5_tmp > 0)
202
    if (f5_tmp > 0)
203
    {
203
    {
204
        f5 = CAN_MODULE_ENUM_TOUCH_GESTURE_F5_PLUS;
204
        f5 = CAN_MODULE_ENUM_TOUCH_GESTURE_F5_P;
205
    }
205
    }
206
   
206
   
207
    /* Function 4 represents the sign value of the sum of the x coordinates of all the points that constitute strokes
207
    /* Function 4 represents the sign value of the sum of the x coordinates of all the points that constitute strokes
208
    minus the x coordinates of the last point */
208
    minus the x coordinates of the last point */
209
    f4 = CAN_MODULE_ENUM_TOUCH_GESTURE_F4_MINUS;
209
    f4 = CAN_MODULE_ENUM_TOUCH_GESTURE_F4_M;
210
    if (f4_tmp > 0)
210
    if (f4_tmp > 0)
211
    {
211
    {
212
        f4 = CAN_MODULE_ENUM_TOUCH_GESTURE_F4_PLUS;
212
        f4 = CAN_MODULE_ENUM_TOUCH_GESTURE_F4_P;
213
    }
213
    }
214
   
214
   
215
    /* Function 8 checks whether or not x coordinates of all the points except for the first point and the last point is between x0 and xn */
215
    /* Function 8 checks whether or not x coordinates of all the points except for the first point and the last point is between x0 and xn */
216
    f8 = CAN_MODULE_ENUM_TOUCH_GESTURE_F8_MINUS;
216
    f8 = CAN_MODULE_ENUM_TOUCH_GESTURE_F8_M;
217
    if (xMin < min(touchBuffer[startIndex].x,touchBuffer[endIndex].x) || xMax > max(touchBuffer[startIndex].x,touchBuffer[endIndex].x))
217
    if (xMin < min(touchBuffer[startIndex].x,touchBuffer[endIndex].x) || xMax > max(touchBuffer[startIndex].x,touchBuffer[endIndex].x))
218
    {
218
    {
219
        f8 = CAN_MODULE_ENUM_TOUCH_GESTURE_F8_PLUS;
219
        f8 = CAN_MODULE_ENUM_TOUCH_GESTURE_F8_P;
220
    }
220
    }
221
       
221
       
222
    //printf("1%u2%c3%c4%c5%c6%c7%u8%c9%c\n", f1, f2, f3, f4, f5, f6, f7, f8, f9);
222
    //printf("1%u2%c3%c4%c5%c6%c7%u8%c9%c\n", f1, f2, f3, f4, f5, f6, f7, f8, f9);
223
 
223
 
224
    StdCan_Msg_t txMsg;
224
    StdCan_Msg_t txMsg;