Mar. 14. 2018

Dependencies:   GraphicsFramework GR-PEACH_video LCD_shield_config AsciiFont R_BSP USBHost_custom

Committer:
dkato
Date:
Tue Sep 26 09:19:48 2017 +0000
Revision:
7:85ba09eb46b3
Parent:
0:f5de229c9a00
The number of STB retries has been changed

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 0:f5de229c9a00 1 #include "mbed.h"
dkato 0:f5de229c9a00 2 #include "DisplayBace.h"
dkato 0:f5de229c9a00 3 #include "rtos.h"
dkato 0:f5de229c9a00 4 #include "LCD_shield_config_4_3inch.h"
dkato 0:f5de229c9a00 5 #include "RGA.h"
dkato 0:f5de229c9a00 6 #include "BinaryImage_RZ_A1H.h"
dkato 0:f5de229c9a00 7 #include "recognition_proc.h"
dkato 0:f5de229c9a00 8
dkato 0:f5de229c9a00 9 /*! Frame buffer stride: Frame buffer stride should be set to a multiple of 32 or 128
dkato 0:f5de229c9a00 10 in accordance with the frame buffer burst transfer mode. */
dkato 0:f5de229c9a00 11 /* TOUCH BUFFER Parameter GRAPHICS_LAYER_2 */
dkato 0:f5de229c9a00 12 #define TOUCH_BUFFER_BYTE_PER_PIXEL (4u)
dkato 0:f5de229c9a00 13 #define TOUCH_BUFFER_STRIDE (((LCD_PIXEL_WIDTH * TOUCH_BUFFER_BYTE_PER_PIXEL) + 31u) & ~31u)
dkato 0:f5de229c9a00 14
dkato 0:f5de229c9a00 15 /* Disp mode */
dkato 0:f5de229c9a00 16 #define DISP_MODE_NORMAL (0)
dkato 0:f5de229c9a00 17 #define DISP_MODE_SETTING_1 (1)
dkato 0:f5de229c9a00 18 #define DISP_MODE_SETTING_2 (2)
dkato 0:f5de229c9a00 19 #define DISP_MODE_SETTING_3 (3)
dkato 0:f5de229c9a00 20
dkato 0:f5de229c9a00 21 /* Setting range */
dkato 0:f5de229c9a00 22 #define THRESHOLD_MIN (1)
dkato 0:f5de229c9a00 23 #define THRESHOLD_MAX (1000)
dkato 0:f5de229c9a00 24 #define SIZE_RANGE_MIN (20)
dkato 0:f5de229c9a00 25 #define SIZE_RANGE_MAX (1000)
dkato 0:f5de229c9a00 26 #define POSE_MIN (0)
dkato 0:f5de229c9a00 27 #define POSE_MAX (2)
dkato 0:f5de229c9a00 28 #define ANGLE_MIN (0)
dkato 0:f5de229c9a00 29 #define ANGLE_MAX (1)
dkato 0:f5de229c9a00 30
dkato 0:f5de229c9a00 31 /* slide bar */
dkato 0:f5de229c9a00 32 #define POS_SLIDE_BAR_X (185)
dkato 0:f5de229c9a00 33 #define SLIDE_BAR_LENGTH (200)
dkato 0:f5de229c9a00 34 #define POS_PROGRESS_0_X (POS_SLIDE_BAR_X + 15)
dkato 0:f5de229c9a00 35
dkato 0:f5de229c9a00 36 /* func_code */
dkato 0:f5de229c9a00 37 #define TOUCH_KEY_CLOSE (1)
dkato 0:f5de229c9a00 38 #define TOUCH_KEY_SETTING_1 (2)
dkato 0:f5de229c9a00 39 #define TOUCH_KEY_SETTING_2 (3)
dkato 0:f5de229c9a00 40 #define TOUCH_KEY_SETTING_3 (4)
dkato 0:f5de229c9a00 41 #define TOUCH_KEY_REGISTRATION (5)
dkato 0:f5de229c9a00 42 #define TOUCH_KEY_THRESHOLD_BODY (6)
dkato 0:f5de229c9a00 43 #define TOUCH_KEY_THRESHOLD_FACE (7)
dkato 0:f5de229c9a00 44 #define TOUCH_KEY_THRESHOLD_RECO (8)
dkato 0:f5de229c9a00 45 #define TOUCH_KEY_RANGE_BODY_MIN (9)
dkato 0:f5de229c9a00 46 #define TOUCH_KEY_RANGE_BODY_MAX (10)
dkato 0:f5de229c9a00 47 #define TOUCH_KEY_RANGE_FACE_MIN (11)
dkato 0:f5de229c9a00 48 #define TOUCH_KEY_RANGE_FACE_MAX (12)
dkato 0:f5de229c9a00 49 #define TOUCH_KEY_FACE_POSE (13)
dkato 0:f5de229c9a00 50 #define TOUCH_KEY_FACE_ANGLE (14)
dkato 0:f5de229c9a00 51 #define TOUCH_KEY_BODY_DETECTION (15)
dkato 0:f5de229c9a00 52 #define TOUCH_KEY_FACE_DETECTION (16)
dkato 0:f5de229c9a00 53 #define TOUCH_KEY_AGE_ESTIMATION (17)
dkato 0:f5de229c9a00 54 #define TOUCH_KEY_GENDER_ESTIMATION (18)
dkato 0:f5de229c9a00 55 #define TOUCH_KEY_EXPRESSION_ESTIMATION (19)
dkato 0:f5de229c9a00 56 #define TOUCH_KEY_SETTING_LAST (20)
dkato 0:f5de229c9a00 57 #define TOUCH_KEY_RESET_SETTING (21)
dkato 0:f5de229c9a00 58
dkato 0:f5de229c9a00 59 typedef struct {
dkato 0:f5de229c9a00 60 uint32_t pic_pos_x; /* X position of the key picture. */
dkato 0:f5de229c9a00 61 uint32_t pic_pos_y; /* Y position of the key picture. */
dkato 0:f5de229c9a00 62 uint32_t pic_width; /* Width of the key picture. */
dkato 0:f5de229c9a00 63 uint32_t pic_height; /* Height of the key picture. */
dkato 0:f5de229c9a00 64 uint32_t func_code; /* func code of the key picture. */
dkato 0:f5de229c9a00 65 } key_pic_info_t;
dkato 0:f5de229c9a00 66
dkato 0:f5de229c9a00 67 static const key_pic_info_t touch_key_tbl_normal[] = {
dkato 0:f5de229c9a00 68 /* X Y Width Height Func code */
dkato 0:f5de229c9a00 69 { 330, 10, 140, 36, TOUCH_KEY_BODY_DETECTION },
dkato 0:f5de229c9a00 70 { 330, 56, 140, 36, TOUCH_KEY_FACE_DETECTION },
dkato 0:f5de229c9a00 71 { 330, 102, 140, 36, TOUCH_KEY_AGE_ESTIMATION },
dkato 0:f5de229c9a00 72 { 330, 148, 140, 36, TOUCH_KEY_GENDER_ESTIMATION },
dkato 0:f5de229c9a00 73 { 330, 194, 140, 36, TOUCH_KEY_EXPRESSION_ESTIMATION },
dkato 0:f5de229c9a00 74 { 448, 240, 32, 32, TOUCH_KEY_SETTING_LAST },
dkato 0:f5de229c9a00 75 { 0, 0, 320, 240, TOUCH_KEY_REGISTRATION },
dkato 0:f5de229c9a00 76 { 0, 0, 0, 0, 0 } /* table end */
dkato 0:f5de229c9a00 77 };
dkato 0:f5de229c9a00 78
dkato 0:f5de229c9a00 79 static const key_pic_info_t touch_key_tbl_setting_1[] = {
dkato 0:f5de229c9a00 80 /* X Y Width Height Func code */
dkato 0:f5de229c9a00 81 { 127, 220, 80, 34, TOUCH_KEY_RESET_SETTING },
dkato 0:f5de229c9a00 82 { 273, 220, 80, 34, TOUCH_KEY_CLOSE },
dkato 0:f5de229c9a00 83 { 21, 20, 146, 34, TOUCH_KEY_SETTING_1 },
dkato 0:f5de229c9a00 84 { 167, 20, 146, 34, TOUCH_KEY_SETTING_2 },
dkato 0:f5de229c9a00 85 { 313, 20, 146, 34, TOUCH_KEY_SETTING_3 },
dkato 0:f5de229c9a00 86 { POS_SLIDE_BAR_X-20, 80-8, 281, 30, TOUCH_KEY_THRESHOLD_BODY },
dkato 0:f5de229c9a00 87 { POS_SLIDE_BAR_X-20, 120-8, 281, 30, TOUCH_KEY_THRESHOLD_FACE },
dkato 0:f5de229c9a00 88 { POS_SLIDE_BAR_X-20, 160-8, 281, 30, TOUCH_KEY_THRESHOLD_RECO },
dkato 0:f5de229c9a00 89 { 0, 0, 0, 0, 0 } /* table end */
dkato 0:f5de229c9a00 90 };
dkato 0:f5de229c9a00 91
dkato 0:f5de229c9a00 92 static const key_pic_info_t touch_key_tbl_setting_2[] = {
dkato 0:f5de229c9a00 93 /* X Y Width Height Func code */
dkato 0:f5de229c9a00 94 { 127, 220, 80, 34, TOUCH_KEY_RESET_SETTING },
dkato 0:f5de229c9a00 95 { 273, 220, 80, 34, TOUCH_KEY_CLOSE },
dkato 0:f5de229c9a00 96 { 21, 20, 146, 34, TOUCH_KEY_SETTING_1 },
dkato 0:f5de229c9a00 97 { 167, 20, 146, 34, TOUCH_KEY_SETTING_2 },
dkato 0:f5de229c9a00 98 { 313, 20, 146, 34, TOUCH_KEY_SETTING_3 },
dkato 0:f5de229c9a00 99 { POS_SLIDE_BAR_X-20, 80-8, 281, 30, TOUCH_KEY_RANGE_BODY_MIN },
dkato 0:f5de229c9a00 100 { POS_SLIDE_BAR_X-20, 110-8, 281, 30, TOUCH_KEY_RANGE_BODY_MAX },
dkato 0:f5de229c9a00 101 { POS_SLIDE_BAR_X-20, 150-8, 281, 30, TOUCH_KEY_RANGE_FACE_MIN },
dkato 0:f5de229c9a00 102 { POS_SLIDE_BAR_X-20, 180-8, 281, 30, TOUCH_KEY_RANGE_FACE_MAX },
dkato 0:f5de229c9a00 103 { 0, 0, 0, 0, 0 } /* table end */
dkato 0:f5de229c9a00 104 };
dkato 0:f5de229c9a00 105
dkato 0:f5de229c9a00 106 static const key_pic_info_t touch_key_tbl_setting_3[] = {
dkato 0:f5de229c9a00 107 /* X Y Width Height Func code */
dkato 0:f5de229c9a00 108 { 127, 220, 80, 34, TOUCH_KEY_RESET_SETTING },
dkato 0:f5de229c9a00 109 { 273, 220, 80, 34, TOUCH_KEY_CLOSE },
dkato 0:f5de229c9a00 110 { 21, 20, 146, 34, TOUCH_KEY_SETTING_1 },
dkato 0:f5de229c9a00 111 { 167, 20, 146, 34, TOUCH_KEY_SETTING_2 },
dkato 0:f5de229c9a00 112 { 313, 20, 146, 34, TOUCH_KEY_SETTING_3 },
dkato 0:f5de229c9a00 113 { POS_SLIDE_BAR_X-20, 80-8, 281, 30, TOUCH_KEY_FACE_POSE },
dkato 0:f5de229c9a00 114 { POS_SLIDE_BAR_X-20, 120-8, 281, 30, TOUCH_KEY_FACE_ANGLE },
dkato 0:f5de229c9a00 115 { 0, 0, 0, 0, 0 } /* table end */
dkato 0:f5de229c9a00 116 };
dkato 0:f5de229c9a00 117
dkato 0:f5de229c9a00 118 static const key_pic_info_t * p_touch_key_tbl[] = {
dkato 0:f5de229c9a00 119 touch_key_tbl_normal, /* DISP_MODE_NORMAL */
dkato 0:f5de229c9a00 120 touch_key_tbl_setting_1, /* DISP_MODE_SETTING_1 */
dkato 0:f5de229c9a00 121 touch_key_tbl_setting_2, /* DISP_MODE_SETTING_2 */
dkato 0:f5de229c9a00 122 touch_key_tbl_setting_3, /* DISP_MODE_SETTING_3 */
dkato 0:f5de229c9a00 123 NULL
dkato 0:f5de229c9a00 124 };
dkato 0:f5de229c9a00 125
dkato 0:f5de229c9a00 126 static TouckKey_LCD_shield touch(P4_0, P2_13, I2C_SDA, I2C_SCL);
dkato 0:f5de229c9a00 127 static Semaphore sem_touch_int(0);
dkato 0:f5de229c9a00 128
dkato 0:f5de229c9a00 129 #if defined(__ICCARM__)
dkato 0:f5de229c9a00 130 /* 32 bytes aligned */
dkato 0:f5de229c9a00 131 #pragma data_alignment=32
dkato 0:f5de229c9a00 132 static uint8_t user_frame_buffer_touch0[TOUCH_BUFFER_STRIDE * LCD_PIXEL_HEIGHT];
dkato 0:f5de229c9a00 133 #pragma data_alignment=32
dkato 0:f5de229c9a00 134 static uint8_t user_frame_buffer_touch1[TOUCH_BUFFER_STRIDE * LCD_PIXEL_HEIGHT];
dkato 0:f5de229c9a00 135 #else
dkato 0:f5de229c9a00 136 /* 32 bytes aligned */
dkato 0:f5de229c9a00 137 static uint8_t user_frame_buffer_touch0[TOUCH_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]__attribute((aligned(32)));
dkato 0:f5de229c9a00 138 static uint8_t user_frame_buffer_touch1[TOUCH_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]__attribute((aligned(32)));
dkato 0:f5de229c9a00 139 #endif
dkato 0:f5de229c9a00 140
dkato 0:f5de229c9a00 141 static volatile int32_t vsync_count = 0;
dkato 0:f5de229c9a00 142 static recognition_setting_t * p_setting;
dkato 0:f5de229c9a00 143 static int disp_mode;
dkato 0:f5de229c9a00 144
dkato 0:f5de229c9a00 145 /****** Touch panel ******/
dkato 0:f5de229c9a00 146 static uint32_t Scan_Key(const key_pic_info_t * key_tbl, const uint32_t pos_x, const uint32_t pos_y) {
dkato 0:f5de229c9a00 147 uint32_t ret = 0;
dkato 0:f5de229c9a00 148
dkato 0:f5de229c9a00 149 while (ret == 0) {
dkato 0:f5de229c9a00 150 if (key_tbl->func_code == 0) {
dkato 0:f5de229c9a00 151 break;
dkato 0:f5de229c9a00 152 }
dkato 0:f5de229c9a00 153 /* Check the range of the X position */
dkato 0:f5de229c9a00 154 if ((pos_x >= key_tbl->pic_pos_x) && (pos_x <= (key_tbl->pic_pos_x + key_tbl->pic_width))) {
dkato 0:f5de229c9a00 155 /* Check the range of the Y position */
dkato 0:f5de229c9a00 156 if ((pos_y >= key_tbl->pic_pos_y) && (pos_y <= (key_tbl->pic_pos_y + key_tbl->pic_height))) {
dkato 0:f5de229c9a00 157 /* Decide the func code. */
dkato 0:f5de229c9a00 158 ret = key_tbl->func_code;
dkato 0:f5de229c9a00 159 }
dkato 0:f5de229c9a00 160 }
dkato 0:f5de229c9a00 161 key_tbl++;
dkato 0:f5de229c9a00 162 }
dkato 0:f5de229c9a00 163
dkato 0:f5de229c9a00 164 return ret;
dkato 0:f5de229c9a00 165 }
dkato 0:f5de229c9a00 166
dkato 0:f5de229c9a00 167 static void draw_button(Canvas2D_ContextClass * p_canvas2d) {
dkato 0:f5de229c9a00 168 const graphics_image_t* p_wk;
dkato 0:f5de229c9a00 169
dkato 0:f5de229c9a00 170 /* Draw background */
dkato 0:f5de229c9a00 171 p_canvas2d->drawImage(background, 320, 0);
dkato 0:f5de229c9a00 172
dkato 0:f5de229c9a00 173 /* Draw "HUMAN BODY" button */
dkato 0:f5de229c9a00 174 if ((p_setting->execFlag & HVC_ACTIV_BODY_DETECTION) == 0) {
dkato 0:f5de229c9a00 175 p_wk = button_off;
dkato 0:f5de229c9a00 176 } else {
dkato 0:f5de229c9a00 177 p_wk = button_on;
dkato 0:f5de229c9a00 178 }
dkato 0:f5de229c9a00 179 p_canvas2d->drawImage(p_wk, 330, 10);
dkato 0:f5de229c9a00 180 p_canvas2d->drawImage(str_human_body, 330 + 19, 10 + 11);
dkato 0:f5de229c9a00 181
dkato 0:f5de229c9a00 182 /* Draw "FACE" or "RECOGNITION" button */
dkato 0:f5de229c9a00 183 if ((p_setting->execFlag & HVC_ACTIV_FACE_RECOGNITION) == 0) {
dkato 0:f5de229c9a00 184 if ((p_setting->execFlag & HVC_ACTIV_FACE_DETECTION) == 0) {
dkato 0:f5de229c9a00 185 p_wk = button_off;
dkato 0:f5de229c9a00 186 } else {
dkato 0:f5de229c9a00 187 p_wk = button_on;
dkato 0:f5de229c9a00 188 }
dkato 0:f5de229c9a00 189 p_canvas2d->drawImage(p_wk, 330, 56);
dkato 0:f5de229c9a00 190 p_canvas2d->drawImage(str_face, 330 + 51, 56 + 11);
dkato 0:f5de229c9a00 191 } else {
dkato 0:f5de229c9a00 192 p_canvas2d->drawImage(button_on2, 330, 56);
dkato 0:f5de229c9a00 193 p_canvas2d->drawImage(str_recognition, 330 + 19, 56 + 11);
dkato 0:f5de229c9a00 194 }
dkato 0:f5de229c9a00 195
dkato 0:f5de229c9a00 196 /* Draw "AGE" button */
dkato 0:f5de229c9a00 197 if ((p_setting->execFlag & HVC_ACTIV_FACE_DETECTION) == 0) {
dkato 0:f5de229c9a00 198 p_wk = button_inv;
dkato 0:f5de229c9a00 199 } else if ((p_setting->execFlag & HVC_ACTIV_AGE_ESTIMATION) == 0) {
dkato 0:f5de229c9a00 200 p_wk = button_off;
dkato 0:f5de229c9a00 201 } else {
dkato 0:f5de229c9a00 202 p_wk = button_on;
dkato 0:f5de229c9a00 203 }
dkato 0:f5de229c9a00 204 p_canvas2d->drawImage(p_wk, 330, 102);
dkato 0:f5de229c9a00 205 p_canvas2d->drawImage(str_age, 330 + 54, 102 + 11);
dkato 0:f5de229c9a00 206
dkato 0:f5de229c9a00 207 /* Draw "GENDER" button */
dkato 0:f5de229c9a00 208 if ((p_setting->execFlag & HVC_ACTIV_FACE_DETECTION) == 0) {
dkato 0:f5de229c9a00 209 p_wk = button_inv;
dkato 0:f5de229c9a00 210 } else if ((p_setting->execFlag & HVC_ACTIV_GENDER_ESTIMATION) == 0) {
dkato 0:f5de229c9a00 211 p_wk = button_off;
dkato 0:f5de229c9a00 212 } else {
dkato 0:f5de229c9a00 213 p_wk = button_on;
dkato 0:f5de229c9a00 214 }
dkato 0:f5de229c9a00 215 p_canvas2d->drawImage(p_wk, 330, 148);
dkato 0:f5de229c9a00 216 p_canvas2d->drawImage(str_gender, 330 + 39, 148 + 11);
dkato 0:f5de229c9a00 217
dkato 0:f5de229c9a00 218 /* Draw "EXPRESSION" button */
dkato 0:f5de229c9a00 219 if ((p_setting->execFlag & HVC_ACTIV_FACE_DETECTION) == 0) {
dkato 0:f5de229c9a00 220 p_wk = button_inv;
dkato 0:f5de229c9a00 221 } else if ((p_setting->execFlag & HVC_ACTIV_EXPRESSION_ESTIMATION) == 0) {
dkato 0:f5de229c9a00 222 p_wk = button_off;
dkato 0:f5de229c9a00 223 } else {
dkato 0:f5de229c9a00 224 p_wk = button_on;
dkato 0:f5de229c9a00 225 }
dkato 0:f5de229c9a00 226 p_canvas2d->drawImage(p_wk, 330, 194);
dkato 0:f5de229c9a00 227 p_canvas2d->drawImage(str_expression, 330 + 23, 194 + 11);
dkato 0:f5de229c9a00 228
dkato 0:f5de229c9a00 229 /* Draw setting icon */
dkato 0:f5de229c9a00 230 p_canvas2d->drawImage(icon_setting, LCD_PIXEL_WIDTH - 32, LCD_PIXEL_HEIGHT - 32);
dkato 0:f5de229c9a00 231 }
dkato 0:f5de229c9a00 232
dkato 0:f5de229c9a00 233 static void draw_number(Canvas2D_ContextClass * p_canvas2d, int x, int y, int number) {
dkato 0:f5de229c9a00 234 int wk_num;
dkato 0:f5de229c9a00 235 bool disp_flg = false;
dkato 0:f5de229c9a00 236 const graphics_image_t * p_num_tbl[] = {
dkato 0:f5de229c9a00 237 char_0, char_1, char_2, char_3, char_4, char_5, char_6, char_7, char_8, char_9
dkato 0:f5de229c9a00 238 };
dkato 0:f5de229c9a00 239
dkato 0:f5de229c9a00 240 wk_num = (number / 1000) % 10;
dkato 0:f5de229c9a00 241 if ((wk_num != 0) || (disp_flg != false)) {
dkato 0:f5de229c9a00 242 p_canvas2d->drawImage(p_num_tbl[wk_num], x + 9 * 0, y);
dkato 0:f5de229c9a00 243 R_OSPL_CLEAR_ERROR();
dkato 0:f5de229c9a00 244 disp_flg = true;
dkato 0:f5de229c9a00 245 }
dkato 0:f5de229c9a00 246 wk_num = (number / 100) % 10;
dkato 0:f5de229c9a00 247 if ((wk_num != 0) || (disp_flg != false)) {
dkato 0:f5de229c9a00 248 p_canvas2d->drawImage(p_num_tbl[wk_num], x + 9 * 1, y);
dkato 0:f5de229c9a00 249 R_OSPL_CLEAR_ERROR();
dkato 0:f5de229c9a00 250 disp_flg = true;
dkato 0:f5de229c9a00 251 }
dkato 0:f5de229c9a00 252 wk_num = (number / 10) % 10;
dkato 0:f5de229c9a00 253 if ((wk_num != 0) || (disp_flg != false)) {
dkato 0:f5de229c9a00 254 p_canvas2d->drawImage(p_num_tbl[wk_num], x + 9 * 2, y);
dkato 0:f5de229c9a00 255 R_OSPL_CLEAR_ERROR();
dkato 0:f5de229c9a00 256 }
dkato 0:f5de229c9a00 257 wk_num = number % 10;
dkato 0:f5de229c9a00 258 p_canvas2d->drawImage(p_num_tbl[wk_num], x + 9 * 3, y);
dkato 0:f5de229c9a00 259 R_OSPL_CLEAR_ERROR();
dkato 0:f5de229c9a00 260 }
dkato 0:f5de229c9a00 261
dkato 0:f5de229c9a00 262 static void draw_slide_bar(Canvas2D_ContextClass * p_canvas2d, int y, INT32 data, int min, int max) {
dkato 0:f5de229c9a00 263 p_canvas2d->globalAlpha = 0.7f;
dkato 0:f5de229c9a00 264 p_canvas2d->fillStyle = "#D9C3E6";
dkato 0:f5de229c9a00 265 p_canvas2d->fillRect(POS_PROGRESS_0_X, y + 6, SLIDE_BAR_LENGTH + 10, 2);
dkato 0:f5de229c9a00 266 p_canvas2d->globalAlpha = 1.0f;
dkato 0:f5de229c9a00 267 p_canvas2d->drawImage(char_left, POS_SLIDE_BAR_X, y);
dkato 0:f5de229c9a00 268 p_canvas2d->drawImage(char_rigth, POS_PROGRESS_0_X + SLIDE_BAR_LENGTH + 10 + 1, y);
dkato 0:f5de229c9a00 269 p_canvas2d->fillStyle = "#5B9BD5";
dkato 0:f5de229c9a00 270 p_canvas2d->fillRect(POS_PROGRESS_0_X + (int)(SLIDE_BAR_LENGTH * ((float)(data - min) / (max - min))), y, 10, 14);
dkato 0:f5de229c9a00 271 }
dkato 0:f5de229c9a00 272
dkato 0:f5de229c9a00 273 static void draw_setting_menu(Canvas2D_ContextClass * p_canvas2d) {
dkato 0:f5de229c9a00 274 if (disp_mode == DISP_MODE_NORMAL) {
dkato 0:f5de229c9a00 275 return;
dkato 0:f5de229c9a00 276 }
dkato 0:f5de229c9a00 277
dkato 0:f5de229c9a00 278 p_canvas2d->globalAlpha = 0.95f;
dkato 0:f5de229c9a00 279 p_canvas2d->drawImage(background_setting, 0, 0);
dkato 0:f5de229c9a00 280
dkato 0:f5de229c9a00 281 /* Tab */
dkato 0:f5de229c9a00 282 if (disp_mode == DISP_MODE_SETTING_1) {
dkato 0:f5de229c9a00 283 p_canvas2d->globalAlpha = 0.9f;
dkato 0:f5de229c9a00 284 p_canvas2d->fillStyle = "#5B9BD5";
dkato 0:f5de229c9a00 285 p_canvas2d->fillRect(21, 20, 146, 34);
dkato 0:f5de229c9a00 286 p_canvas2d->globalAlpha = 1.0f;
dkato 0:f5de229c9a00 287 } else {
dkato 0:f5de229c9a00 288 p_canvas2d->globalAlpha = 0.3f;
dkato 0:f5de229c9a00 289 }
dkato 0:f5de229c9a00 290 p_canvas2d->drawImage(str_threshold_value, 23, 30);
dkato 0:f5de229c9a00 291
dkato 0:f5de229c9a00 292 if (disp_mode == DISP_MODE_SETTING_2) {
dkato 0:f5de229c9a00 293 p_canvas2d->globalAlpha = 0.9f;
dkato 0:f5de229c9a00 294 p_canvas2d->fillStyle = "#5B9BD5";
dkato 0:f5de229c9a00 295 p_canvas2d->fillRect(167, 20, 146, 34);
dkato 0:f5de229c9a00 296 p_canvas2d->globalAlpha = 1.0f;
dkato 0:f5de229c9a00 297 } else {
dkato 0:f5de229c9a00 298 p_canvas2d->globalAlpha = 0.3f;
dkato 0:f5de229c9a00 299 }
dkato 0:f5de229c9a00 300 p_canvas2d->drawImage(str_detection_size, 181, 30);
dkato 0:f5de229c9a00 301
dkato 0:f5de229c9a00 302 if (disp_mode == DISP_MODE_SETTING_3) {
dkato 0:f5de229c9a00 303 p_canvas2d->globalAlpha = 0.9f;
dkato 0:f5de229c9a00 304 p_canvas2d->fillStyle = "#5B9BD5";
dkato 0:f5de229c9a00 305 p_canvas2d->fillRect(313, 20, 146, 34);
dkato 0:f5de229c9a00 306 p_canvas2d->globalAlpha = 1.0f;
dkato 0:f5de229c9a00 307 } else {
dkato 0:f5de229c9a00 308 p_canvas2d->globalAlpha = 0.3f;
dkato 0:f5de229c9a00 309 }
dkato 0:f5de229c9a00 310 p_canvas2d->drawImage(str_face, 342, 30);
dkato 0:f5de229c9a00 311 p_canvas2d->drawImage(str_angle, 383, 30);
dkato 0:f5de229c9a00 312
dkato 0:f5de229c9a00 313 /* Setting */
dkato 0:f5de229c9a00 314 p_canvas2d->globalAlpha = 1.0f;
dkato 0:f5de229c9a00 315 if (disp_mode == DISP_MODE_SETTING_1) {
dkato 0:f5de229c9a00 316 p_canvas2d->drawImage(str_human_body, 30, 80);
dkato 0:f5de229c9a00 317 p_canvas2d->drawImage(str_face, 30, 120);
dkato 0:f5de229c9a00 318 p_canvas2d->drawImage(str_recognition, 30, 160);
dkato 0:f5de229c9a00 319
dkato 0:f5de229c9a00 320 draw_slide_bar(p_canvas2d, 80, p_setting->threshold.bdThreshold, THRESHOLD_MIN, THRESHOLD_MAX);
dkato 0:f5de229c9a00 321 draw_slide_bar(p_canvas2d, 120, p_setting->threshold.dtThreshold, THRESHOLD_MIN, THRESHOLD_MAX);
dkato 0:f5de229c9a00 322 draw_slide_bar(p_canvas2d, 160, p_setting->threshold.rsThreshold, THRESHOLD_MIN, THRESHOLD_MAX);
dkato 0:f5de229c9a00 323
dkato 0:f5de229c9a00 324 draw_number(p_canvas2d, 430, 80, p_setting->threshold.bdThreshold);
dkato 0:f5de229c9a00 325 draw_number(p_canvas2d, 430, 120, p_setting->threshold.dtThreshold);
dkato 0:f5de229c9a00 326 draw_number(p_canvas2d, 430, 160, p_setting->threshold.rsThreshold);
dkato 0:f5de229c9a00 327 } else if (disp_mode == DISP_MODE_SETTING_2) {
dkato 0:f5de229c9a00 328 p_canvas2d->drawImage(str_human_body, 30, 80);
dkato 0:f5de229c9a00 329 p_canvas2d->drawImage(str_min, 140, 80);
dkato 0:f5de229c9a00 330 p_canvas2d->drawImage(str_max, 140, 110);
dkato 0:f5de229c9a00 331 p_canvas2d->drawImage(str_face, 30, 150);
dkato 0:f5de229c9a00 332 p_canvas2d->drawImage(str_min, 140, 150);
dkato 0:f5de229c9a00 333 p_canvas2d->drawImage(str_max, 140, 180);
dkato 0:f5de229c9a00 334
dkato 0:f5de229c9a00 335 draw_slide_bar(p_canvas2d, 80, p_setting->sizeRange.bdMinSize, SIZE_RANGE_MIN, SIZE_RANGE_MAX);
dkato 0:f5de229c9a00 336 draw_slide_bar(p_canvas2d, 110, p_setting->sizeRange.bdMaxSize, SIZE_RANGE_MIN, SIZE_RANGE_MAX);
dkato 0:f5de229c9a00 337 draw_slide_bar(p_canvas2d, 150, p_setting->sizeRange.dtMinSize, SIZE_RANGE_MIN, SIZE_RANGE_MAX);
dkato 0:f5de229c9a00 338 draw_slide_bar(p_canvas2d, 180, p_setting->sizeRange.dtMaxSize, SIZE_RANGE_MIN, SIZE_RANGE_MAX);
dkato 0:f5de229c9a00 339
dkato 0:f5de229c9a00 340 draw_number(p_canvas2d, 430, 80, p_setting->sizeRange.bdMinSize);
dkato 0:f5de229c9a00 341 draw_number(p_canvas2d, 430, 110, p_setting->sizeRange.bdMaxSize);
dkato 0:f5de229c9a00 342 draw_number(p_canvas2d, 430, 150, p_setting->sizeRange.dtMinSize);
dkato 0:f5de229c9a00 343 draw_number(p_canvas2d, 430, 180, p_setting->sizeRange.dtMaxSize);
dkato 0:f5de229c9a00 344 } else {
dkato 0:f5de229c9a00 345 int wk_data;
dkato 0:f5de229c9a00 346
dkato 0:f5de229c9a00 347 p_canvas2d->drawImage(str_yaw, 30, 80);
dkato 0:f5de229c9a00 348 p_canvas2d->drawImage(str_angle, 30 + 41, 80);
dkato 0:f5de229c9a00 349 p_canvas2d->drawImage(str_roll, 30, 120);
dkato 0:f5de229c9a00 350 p_canvas2d->drawImage(str_angle, 30 + 42, 120);
dkato 0:f5de229c9a00 351
dkato 0:f5de229c9a00 352 if (p_setting->pose == 0) {
dkato 0:f5de229c9a00 353 wk_data = 30;
dkato 0:f5de229c9a00 354 } else if (p_setting->pose == 1) {
dkato 0:f5de229c9a00 355 wk_data = 60;
dkato 0:f5de229c9a00 356 } else {
dkato 0:f5de229c9a00 357 wk_data = 90;
dkato 0:f5de229c9a00 358 }
dkato 0:f5de229c9a00 359 draw_slide_bar(p_canvas2d, 80, p_setting->pose, POSE_MIN , POSE_MAX);
dkato 0:f5de229c9a00 360 p_canvas2d->drawImage(char_plus_minus, 426, 80);
dkato 0:f5de229c9a00 361 draw_number(p_canvas2d, 420, 80, wk_data); /* 30 60 90 */
dkato 0:f5de229c9a00 362 p_canvas2d->drawImage(char_angle, 457, 80);
dkato 0:f5de229c9a00 363
dkato 0:f5de229c9a00 364 if (p_setting->angle == 0) {
dkato 0:f5de229c9a00 365 wk_data = 15;
dkato 0:f5de229c9a00 366 } else {
dkato 0:f5de229c9a00 367 wk_data = 45;
dkato 0:f5de229c9a00 368 }
dkato 0:f5de229c9a00 369 draw_slide_bar(p_canvas2d, 120, p_setting->angle, ANGLE_MIN, ANGLE_MAX);
dkato 0:f5de229c9a00 370 p_canvas2d->drawImage(char_plus_minus, 426, 120);
dkato 0:f5de229c9a00 371 draw_number(p_canvas2d, 420, 120, wk_data); /* 15 45 */
dkato 0:f5de229c9a00 372 p_canvas2d->drawImage(char_angle, 457, 120);
dkato 0:f5de229c9a00 373 }
dkato 0:f5de229c9a00 374 p_canvas2d->drawImage(str_reset, 144, 230);
dkato 0:f5de229c9a00 375 p_canvas2d->drawImage(str_close, 290, 230);
dkato 0:f5de229c9a00 376 }
dkato 0:f5de229c9a00 377
dkato 0:f5de229c9a00 378 static void draw_touch_layer(DisplayBase * p_display, frame_buffer_t * frmbuf_info, Canvas2D_ContextClass * p_canvas2d) {
dkato 0:f5de229c9a00 379 while (vsync_count > 0) {
dkato 0:f5de229c9a00 380 Thread::wait(1);
dkato 0:f5de229c9a00 381 }
dkato 0:f5de229c9a00 382
dkato 0:f5de229c9a00 383 /* Swap the frame buffer */
dkato 0:f5de229c9a00 384 if (frmbuf_info->draw_buffer_index == 1) {
dkato 0:f5de229c9a00 385 frmbuf_info->draw_buffer_index = 0;
dkato 0:f5de229c9a00 386 } else {
dkato 0:f5de229c9a00 387 frmbuf_info->draw_buffer_index = 1;
dkato 0:f5de229c9a00 388 }
dkato 0:f5de229c9a00 389
dkato 0:f5de229c9a00 390 /* Clear */
dkato 0:f5de229c9a00 391 p_canvas2d->clearRect(0, 0, frmbuf_info->width, frmbuf_info->height);
dkato 0:f5de229c9a00 392
dkato 0:f5de229c9a00 393 /* Draw button */
dkato 0:f5de229c9a00 394 draw_button(p_canvas2d);
dkato 0:f5de229c9a00 395
dkato 0:f5de229c9a00 396 /* Draw setting menu */
dkato 0:f5de229c9a00 397 draw_setting_menu(p_canvas2d);
dkato 0:f5de229c9a00 398
dkato 0:f5de229c9a00 399 /* Complete drawing */
dkato 0:f5de229c9a00 400 R_GRAPHICS_Finish(p_canvas2d->c_LanguageContext);
dkato 0:f5de229c9a00 401 p_display->Graphics_Read_Change(DisplayBase::GRAPHICS_LAYER_2,
dkato 0:f5de229c9a00 402 (void *)frmbuf_info->buffer_address[frmbuf_info->draw_buffer_index]);
dkato 0:f5de229c9a00 403 vsync_count = 1;
dkato 0:f5de229c9a00 404 }
dkato 0:f5de229c9a00 405
dkato 0:f5de229c9a00 406 static void set_progress(int x, INT32 * p_data, int min, int max, bool * p_slide, int last_key) {
dkato 0:f5de229c9a00 407 int now_pos = POS_PROGRESS_0_X + (int)(SLIDE_BAR_LENGTH * (float)(*p_data - min) / (max - min));
dkato 0:f5de229c9a00 408
dkato 0:f5de229c9a00 409 x -= 5;
dkato 0:f5de229c9a00 410 if ((last_key == 0) && (x > (now_pos - 10)) && (x < (now_pos + 20))) {
dkato 0:f5de229c9a00 411 *p_slide = true;
dkato 0:f5de229c9a00 412 }
dkato 0:f5de229c9a00 413 if (x < POS_PROGRESS_0_X) {
dkato 0:f5de229c9a00 414 x = POS_PROGRESS_0_X;
dkato 0:f5de229c9a00 415 }
dkato 0:f5de229c9a00 416 if (x > (POS_PROGRESS_0_X + SLIDE_BAR_LENGTH)) {
dkato 0:f5de229c9a00 417 x = (POS_PROGRESS_0_X + SLIDE_BAR_LENGTH);
dkato 0:f5de229c9a00 418 }
dkato 0:f5de229c9a00 419 if (*p_slide) {
dkato 0:f5de229c9a00 420 *p_data = ((float)(x - POS_PROGRESS_0_X) / (float)SLIDE_BAR_LENGTH * (float)(max - min)) + min;
dkato 0:f5de229c9a00 421 } else if ((x > now_pos) && (*p_data < max)) {
dkato 0:f5de229c9a00 422 *p_data += 1;
dkato 0:f5de229c9a00 423 } else if ((x < now_pos) && (*p_data > min)) {
dkato 0:f5de229c9a00 424 *p_data -= 1;
dkato 0:f5de229c9a00 425 } else {
dkato 0:f5de229c9a00 426 /* do nothing */
dkato 0:f5de229c9a00 427 }
dkato 0:f5de229c9a00 428 }
dkato 0:f5de229c9a00 429
dkato 0:f5de229c9a00 430 static void init_touch_layer(DisplayBase * p_display, frame_buffer_t * frmbuf_info, Canvas2D_ContextClass * p_canvas2d) {
dkato 0:f5de229c9a00 431 errnum_t err;
dkato 0:f5de229c9a00 432 Canvas2D_ContextConfigClass config;
dkato 0:f5de229c9a00 433 DisplayBase::rect_t rect;
dkato 0:f5de229c9a00 434
dkato 0:f5de229c9a00 435 /* The layer by which the buttons is drawn */
dkato 0:f5de229c9a00 436 memset(user_frame_buffer_touch0, 0, sizeof(user_frame_buffer_touch0));
dkato 0:f5de229c9a00 437 memset(user_frame_buffer_touch1, 0, sizeof(user_frame_buffer_touch1));
dkato 0:f5de229c9a00 438 frmbuf_info->buffer_address[0] = user_frame_buffer_touch0;
dkato 0:f5de229c9a00 439 frmbuf_info->buffer_address[1] = user_frame_buffer_touch1;
dkato 0:f5de229c9a00 440 frmbuf_info->buffer_count = 2;
dkato 0:f5de229c9a00 441 frmbuf_info->show_buffer_index = 0;
dkato 0:f5de229c9a00 442 frmbuf_info->draw_buffer_index = 0;
dkato 0:f5de229c9a00 443 frmbuf_info->width = LCD_PIXEL_WIDTH;
dkato 0:f5de229c9a00 444 frmbuf_info->byte_per_pixel = TOUCH_BUFFER_BYTE_PER_PIXEL;
dkato 0:f5de229c9a00 445 frmbuf_info->stride = TOUCH_BUFFER_STRIDE;
dkato 0:f5de229c9a00 446 frmbuf_info->height = LCD_PIXEL_HEIGHT;
dkato 0:f5de229c9a00 447 frmbuf_info->pixel_format = PIXEL_FORMAT_ARGB8888;
dkato 0:f5de229c9a00 448
dkato 0:f5de229c9a00 449 rect.vs = 0;
dkato 0:f5de229c9a00 450 rect.vw = LCD_PIXEL_HEIGHT;
dkato 0:f5de229c9a00 451 rect.hs = 0;
dkato 0:f5de229c9a00 452 rect.hw = LCD_PIXEL_WIDTH;
dkato 0:f5de229c9a00 453 p_display->Graphics_Read_Setting(
dkato 0:f5de229c9a00 454 DisplayBase::GRAPHICS_LAYER_2,
dkato 0:f5de229c9a00 455 (void *)frmbuf_info->buffer_address[frmbuf_info->draw_buffer_index],
dkato 0:f5de229c9a00 456 TOUCH_BUFFER_STRIDE,
dkato 0:f5de229c9a00 457 DisplayBase::GRAPHICS_FORMAT_ARGB8888,
dkato 0:f5de229c9a00 458 DisplayBase::WR_RD_WRSWA_32BIT,
dkato 0:f5de229c9a00 459 &rect
dkato 0:f5de229c9a00 460 );
dkato 0:f5de229c9a00 461 p_display->Graphics_Start(DisplayBase::GRAPHICS_LAYER_2);
dkato 0:f5de229c9a00 462
dkato 0:f5de229c9a00 463 /* Drawing buttons */
dkato 0:f5de229c9a00 464 config.frame_buffer = frmbuf_info;
dkato 0:f5de229c9a00 465 *p_canvas2d = R_RGA_New_Canvas2D_ContextClass(config);
dkato 0:f5de229c9a00 466 err = R_OSPL_GetErrNum();
dkato 0:f5de229c9a00 467 if (err != 0) {
dkato 0:f5de229c9a00 468 printf("Line %d, err %d\n", __LINE__, err);
dkato 0:f5de229c9a00 469 mbed_die();
dkato 0:f5de229c9a00 470 }
dkato 0:f5de229c9a00 471 }
dkato 0:f5de229c9a00 472
dkato 0:f5de229c9a00 473 static void touch_int_callback(void) {
dkato 0:f5de229c9a00 474 sem_touch_int.release();
dkato 0:f5de229c9a00 475 }
dkato 0:f5de229c9a00 476
dkato 0:f5de229c9a00 477 void touch_lcd_int(DisplayBase::int_type_t int_type) {
dkato 0:f5de229c9a00 478 /* Interrupt callback function for Vsync interruption */
dkato 0:f5de229c9a00 479 if (int_type == DisplayBase::INT_TYPE_S0_LO_VSYNC) {
dkato 0:f5de229c9a00 480 if (vsync_count > 0) {
dkato 0:f5de229c9a00 481 vsync_count--;
dkato 0:f5de229c9a00 482 }
dkato 0:f5de229c9a00 483 }
dkato 0:f5de229c9a00 484 }
dkato 0:f5de229c9a00 485
dkato 0:f5de229c9a00 486 void touch_task(DisplayBase * p_display) {
dkato 0:f5de229c9a00 487 frame_buffer_t frame_buffer_info;
dkato 0:f5de229c9a00 488 Canvas2D_ContextClass canvas2d;
dkato 0:f5de229c9a00 489 TouchKey::touch_pos_t touch_pos[1];
dkato 0:f5de229c9a00 490 int touch_num = 0;
dkato 0:f5de229c9a00 491 int touch_num_last = 0;
dkato 0:f5de229c9a00 492 bool key_rep = false;
dkato 0:f5de229c9a00 493 int func_code;
dkato 0:f5de229c9a00 494 int func_code_last = 0;
dkato 0:f5de229c9a00 495 bool slide = false;
dkato 0:f5de229c9a00 496 Timer key_time;
dkato 0:f5de229c9a00 497 int wait_time;
dkato 0:f5de229c9a00 498 int last_setting_mode = DISP_MODE_SETTING_1;
dkato 0:f5de229c9a00 499
dkato 0:f5de229c9a00 500 p_setting = GetRecognitionSettingPointer();
dkato 0:f5de229c9a00 501 disp_mode = DISP_MODE_NORMAL;
dkato 0:f5de229c9a00 502
dkato 0:f5de229c9a00 503 /* Initializing Touch layer */
dkato 0:f5de229c9a00 504 init_touch_layer(p_display, &frame_buffer_info, &canvas2d);
dkato 0:f5de229c9a00 505 draw_touch_layer(p_display, &frame_buffer_info, &canvas2d);
dkato 0:f5de229c9a00 506
dkato 0:f5de229c9a00 507 /* Callback setting */
dkato 0:f5de229c9a00 508 touch.SetCallback(&touch_int_callback);
dkato 0:f5de229c9a00 509
dkato 0:f5de229c9a00 510 /* Reset touch IC */
dkato 0:f5de229c9a00 511 touch.Reset();
dkato 0:f5de229c9a00 512
dkato 0:f5de229c9a00 513 key_time.reset();
dkato 0:f5de229c9a00 514 key_time.start();
dkato 0:f5de229c9a00 515
dkato 0:f5de229c9a00 516 while (1) {
dkato 0:f5de229c9a00 517 /* Wait touch event */
dkato 0:f5de229c9a00 518 sem_touch_int.wait();
dkato 0:f5de229c9a00 519
dkato 0:f5de229c9a00 520 /* Get touch coordinates */
dkato 0:f5de229c9a00 521 touch_num = touch.GetCoordinates(1, touch_pos);
dkato 0:f5de229c9a00 522
dkato 0:f5de229c9a00 523 if (slide) {
dkato 0:f5de229c9a00 524 wait_time = 80;
dkato 0:f5de229c9a00 525 } else {
dkato 0:f5de229c9a00 526 wait_time = 250;
dkato 0:f5de229c9a00 527 }
dkato 0:f5de229c9a00 528 if ((key_time.read_ms() > wait_time) || (touch_num != touch_num_last)) {
dkato 0:f5de229c9a00 529 key_time.reset();
dkato 0:f5de229c9a00 530 key_time.start();
dkato 0:f5de229c9a00 531 if ((touch_num != 0) && ((touch_num_last == 0) || (key_rep == true))) {
dkato 0:f5de229c9a00 532 key_rep = false;
dkato 0:f5de229c9a00 533 func_code = Scan_Key(p_touch_key_tbl[disp_mode], touch_pos[0].x, touch_pos[0].y);
dkato 0:f5de229c9a00 534 if (slide) {
dkato 0:f5de229c9a00 535 func_code = func_code_last;
dkato 0:f5de229c9a00 536 }
dkato 0:f5de229c9a00 537 if (func_code != 0) {
dkato 0:f5de229c9a00 538 switch (func_code) {
dkato 0:f5de229c9a00 539 case TOUCH_KEY_SETTING_LAST:
dkato 0:f5de229c9a00 540 disp_mode = last_setting_mode;
dkato 0:f5de229c9a00 541 break;
dkato 0:f5de229c9a00 542 case TOUCH_KEY_CLOSE:
dkato 0:f5de229c9a00 543 disp_mode = DISP_MODE_NORMAL;
dkato 0:f5de229c9a00 544 SetSettingReq();
dkato 0:f5de229c9a00 545 break;
dkato 0:f5de229c9a00 546 case TOUCH_KEY_SETTING_1:
dkato 0:f5de229c9a00 547 disp_mode = DISP_MODE_SETTING_1;
dkato 0:f5de229c9a00 548 last_setting_mode = DISP_MODE_SETTING_1;
dkato 0:f5de229c9a00 549 break;
dkato 0:f5de229c9a00 550 case TOUCH_KEY_SETTING_2:
dkato 0:f5de229c9a00 551 disp_mode = DISP_MODE_SETTING_2;
dkato 0:f5de229c9a00 552 last_setting_mode = DISP_MODE_SETTING_2;
dkato 0:f5de229c9a00 553 break;
dkato 0:f5de229c9a00 554 case TOUCH_KEY_SETTING_3:
dkato 0:f5de229c9a00 555 disp_mode = DISP_MODE_SETTING_3;
dkato 0:f5de229c9a00 556 last_setting_mode = DISP_MODE_SETTING_3;
dkato 0:f5de229c9a00 557 break;
dkato 0:f5de229c9a00 558 case TOUCH_KEY_REGISTRATION:
dkato 0:f5de229c9a00 559 if ((p_setting->execFlag & HVC_ACTIV_FACE_RECOGNITION) != 0) {
dkato 0:f5de229c9a00 560 SetRegistrationrReq();
dkato 0:f5de229c9a00 561 }
dkato 0:f5de229c9a00 562 break;
dkato 0:f5de229c9a00 563 case TOUCH_KEY_THRESHOLD_BODY:
dkato 0:f5de229c9a00 564 set_progress(touch_pos[0].x, &p_setting->threshold.bdThreshold,
dkato 0:f5de229c9a00 565 THRESHOLD_MIN, THRESHOLD_MAX, &slide, touch_num_last);
dkato 0:f5de229c9a00 566 key_rep = true;
dkato 0:f5de229c9a00 567 break;
dkato 0:f5de229c9a00 568 case TOUCH_KEY_THRESHOLD_FACE:
dkato 0:f5de229c9a00 569 set_progress(touch_pos[0].x, &p_setting->threshold.dtThreshold,
dkato 0:f5de229c9a00 570 THRESHOLD_MIN, THRESHOLD_MAX, &slide, touch_num_last);
dkato 0:f5de229c9a00 571 key_rep = true;
dkato 0:f5de229c9a00 572 break;
dkato 0:f5de229c9a00 573 case TOUCH_KEY_THRESHOLD_RECO:
dkato 0:f5de229c9a00 574 set_progress(touch_pos[0].x, &p_setting->threshold.rsThreshold,
dkato 0:f5de229c9a00 575 THRESHOLD_MIN, THRESHOLD_MAX, &slide, touch_num_last);
dkato 0:f5de229c9a00 576 key_rep = true;
dkato 0:f5de229c9a00 577 break;
dkato 0:f5de229c9a00 578 case TOUCH_KEY_RANGE_BODY_MIN:
dkato 0:f5de229c9a00 579 set_progress(touch_pos[0].x, &p_setting->sizeRange.bdMinSize,
dkato 0:f5de229c9a00 580 SIZE_RANGE_MIN, SIZE_RANGE_MAX, &slide, touch_num_last);
dkato 0:f5de229c9a00 581 if (p_setting->sizeRange.bdMinSize > p_setting->sizeRange.bdMaxSize) {
dkato 0:f5de229c9a00 582 p_setting->sizeRange.bdMaxSize = p_setting->sizeRange.bdMinSize;
dkato 0:f5de229c9a00 583 }
dkato 0:f5de229c9a00 584 key_rep = true;
dkato 0:f5de229c9a00 585 break;
dkato 0:f5de229c9a00 586 case TOUCH_KEY_RANGE_BODY_MAX:
dkato 0:f5de229c9a00 587 set_progress(touch_pos[0].x, &p_setting->sizeRange.bdMaxSize,
dkato 0:f5de229c9a00 588 SIZE_RANGE_MIN, SIZE_RANGE_MAX, &slide, touch_num_last);
dkato 0:f5de229c9a00 589 if (p_setting->sizeRange.bdMaxSize < p_setting->sizeRange.bdMinSize) {
dkato 0:f5de229c9a00 590 p_setting->sizeRange.bdMinSize = p_setting->sizeRange.bdMaxSize;
dkato 0:f5de229c9a00 591 }
dkato 0:f5de229c9a00 592 key_rep = true;
dkato 0:f5de229c9a00 593 break;
dkato 0:f5de229c9a00 594 case TOUCH_KEY_RANGE_FACE_MIN:
dkato 0:f5de229c9a00 595 set_progress(touch_pos[0].x, &p_setting->sizeRange.dtMinSize,
dkato 0:f5de229c9a00 596 SIZE_RANGE_MIN, SIZE_RANGE_MAX, &slide, touch_num_last);
dkato 0:f5de229c9a00 597 if (p_setting->sizeRange.dtMinSize > p_setting->sizeRange.dtMaxSize) {
dkato 0:f5de229c9a00 598 p_setting->sizeRange.dtMaxSize = p_setting->sizeRange.dtMinSize;
dkato 0:f5de229c9a00 599 }
dkato 0:f5de229c9a00 600 key_rep = true;
dkato 0:f5de229c9a00 601 break;
dkato 0:f5de229c9a00 602 case TOUCH_KEY_RANGE_FACE_MAX:
dkato 0:f5de229c9a00 603 set_progress(touch_pos[0].x, &p_setting->sizeRange.dtMaxSize,
dkato 0:f5de229c9a00 604 SIZE_RANGE_MIN, SIZE_RANGE_MAX, &slide, touch_num_last);
dkato 0:f5de229c9a00 605 if (p_setting->sizeRange.dtMaxSize < p_setting->sizeRange.dtMinSize) {
dkato 0:f5de229c9a00 606 p_setting->sizeRange.dtMinSize = p_setting->sizeRange.dtMaxSize;
dkato 0:f5de229c9a00 607 }
dkato 0:f5de229c9a00 608 key_rep = true;
dkato 0:f5de229c9a00 609 break;
dkato 0:f5de229c9a00 610 case TOUCH_KEY_FACE_POSE:
dkato 0:f5de229c9a00 611 set_progress(touch_pos[0].x, &p_setting->pose,
dkato 0:f5de229c9a00 612 POSE_MIN, POSE_MAX, &slide, touch_num_last);
dkato 0:f5de229c9a00 613 if (slide) {
dkato 0:f5de229c9a00 614 key_rep = true;
dkato 0:f5de229c9a00 615 }
dkato 0:f5de229c9a00 616 break;
dkato 0:f5de229c9a00 617 case TOUCH_KEY_FACE_ANGLE:
dkato 0:f5de229c9a00 618 set_progress(touch_pos[0].x, &p_setting->angle,
dkato 0:f5de229c9a00 619 ANGLE_MIN, ANGLE_MAX, &slide, touch_num_last);
dkato 0:f5de229c9a00 620 if (slide) {
dkato 0:f5de229c9a00 621 key_rep = true;
dkato 0:f5de229c9a00 622 }
dkato 0:f5de229c9a00 623 break;
dkato 0:f5de229c9a00 624 case TOUCH_KEY_BODY_DETECTION:
dkato 0:f5de229c9a00 625 if ((p_setting->execFlag & HVC_ACTIV_BODY_DETECTION) != 0) {
dkato 0:f5de229c9a00 626 p_setting->execFlag &= ~HVC_ACTIV_BODY_DETECTION;
dkato 0:f5de229c9a00 627 } else {
dkato 0:f5de229c9a00 628 p_setting->execFlag |= HVC_ACTIV_BODY_DETECTION;
dkato 0:f5de229c9a00 629 }
dkato 0:f5de229c9a00 630 break;
dkato 0:f5de229c9a00 631 case TOUCH_KEY_FACE_DETECTION:
dkato 0:f5de229c9a00 632 if ((p_setting->execFlag & HVC_ACTIV_FACE_DETECTION) == 0) {
dkato 0:f5de229c9a00 633 p_setting->execFlag |= HVC_ACTIV_FACE_DETECTION;
dkato 0:f5de229c9a00 634 } else if ((p_setting->execFlag & HVC_ACTIV_FACE_RECOGNITION) == 0) {
dkato 0:f5de229c9a00 635 p_setting->execFlag |= HVC_ACTIV_FACE_RECOGNITION;
dkato 0:f5de229c9a00 636 } else {
dkato 0:f5de229c9a00 637 p_setting->execFlag &= ~(HVC_ACTIV_FACE_DETECTION | HVC_ACTIV_FACE_RECOGNITION);
dkato 0:f5de229c9a00 638 }
dkato 0:f5de229c9a00 639 break;
dkato 0:f5de229c9a00 640 case TOUCH_KEY_AGE_ESTIMATION:
dkato 0:f5de229c9a00 641 if ((p_setting->execFlag & HVC_ACTIV_FACE_DETECTION) == 0) {
dkato 0:f5de229c9a00 642 /* do nothing */
dkato 0:f5de229c9a00 643 } else if ((p_setting->execFlag & HVC_ACTIV_AGE_ESTIMATION) != 0) {
dkato 0:f5de229c9a00 644 p_setting->execFlag &= ~HVC_ACTIV_AGE_ESTIMATION;
dkato 0:f5de229c9a00 645 } else {
dkato 0:f5de229c9a00 646 p_setting->execFlag |= HVC_ACTIV_AGE_ESTIMATION;
dkato 0:f5de229c9a00 647 }
dkato 0:f5de229c9a00 648 break;
dkato 0:f5de229c9a00 649 case TOUCH_KEY_GENDER_ESTIMATION:
dkato 0:f5de229c9a00 650 if ((p_setting->execFlag & HVC_ACTIV_FACE_DETECTION) == 0) {
dkato 0:f5de229c9a00 651 /* do nothing */
dkato 0:f5de229c9a00 652 } else if ((p_setting->execFlag & HVC_ACTIV_GENDER_ESTIMATION) != 0) {
dkato 0:f5de229c9a00 653 p_setting->execFlag &= ~HVC_ACTIV_GENDER_ESTIMATION;
dkato 0:f5de229c9a00 654 } else {
dkato 0:f5de229c9a00 655 p_setting->execFlag |= HVC_ACTIV_GENDER_ESTIMATION;
dkato 0:f5de229c9a00 656 }
dkato 0:f5de229c9a00 657 break;
dkato 0:f5de229c9a00 658 case TOUCH_KEY_EXPRESSION_ESTIMATION:
dkato 0:f5de229c9a00 659 if ((p_setting->execFlag & HVC_ACTIV_FACE_DETECTION) == 0) {
dkato 0:f5de229c9a00 660 /* do nothing */
dkato 0:f5de229c9a00 661 } else if ((p_setting->execFlag & HVC_ACTIV_EXPRESSION_ESTIMATION) != 0) {
dkato 0:f5de229c9a00 662 p_setting->execFlag &= ~HVC_ACTIV_EXPRESSION_ESTIMATION;
dkato 0:f5de229c9a00 663 } else {
dkato 0:f5de229c9a00 664 p_setting->execFlag |= HVC_ACTIV_EXPRESSION_ESTIMATION;
dkato 0:f5de229c9a00 665 }
dkato 0:f5de229c9a00 666 break;
dkato 0:f5de229c9a00 667 case TOUCH_KEY_RESET_SETTING:
dkato 0:f5de229c9a00 668 if (disp_mode == DISP_MODE_SETTING_1) {
dkato 0:f5de229c9a00 669 p_setting->threshold.bdThreshold = BODY_THRESHOLD_DEFAULT;
dkato 0:f5de229c9a00 670 p_setting->threshold.hdThreshold = HAND_THRESHOLD_DEFAULT;
dkato 0:f5de229c9a00 671 p_setting->threshold.dtThreshold = FACE_THRESHOLD_DEFAULT;
dkato 0:f5de229c9a00 672 p_setting->threshold.rsThreshold = REC_THRESHOLD_DEFAULT;
dkato 0:f5de229c9a00 673 } else if (disp_mode == DISP_MODE_SETTING_2) {
dkato 0:f5de229c9a00 674 p_setting->sizeRange.bdMinSize = BODY_SIZE_RANGE_MIN_DEFAULT;
dkato 0:f5de229c9a00 675 p_setting->sizeRange.bdMaxSize = BODY_SIZE_RANGE_MAX_DEFAULT;
dkato 0:f5de229c9a00 676 p_setting->sizeRange.hdMinSize = HAND_SIZE_RANGE_MIN_DEFAULT;
dkato 0:f5de229c9a00 677 p_setting->sizeRange.hdMaxSize = HAND_SIZE_RANGE_MAX_DEFAULT;
dkato 0:f5de229c9a00 678 p_setting->sizeRange.dtMinSize = FACE_SIZE_RANGE_MIN_DEFAULT;
dkato 0:f5de229c9a00 679 p_setting->sizeRange.dtMaxSize = FACE_SIZE_RANGE_MAX_DEFAULT;
dkato 0:f5de229c9a00 680 } else if (disp_mode == DISP_MODE_SETTING_3) {
dkato 0:f5de229c9a00 681 p_setting->pose = FACE_POSE_DEFAULT;
dkato 0:f5de229c9a00 682 p_setting->angle = FACE_ANGLE_DEFAULT;
dkato 0:f5de229c9a00 683 } else {
dkato 0:f5de229c9a00 684 /* do nothing */
dkato 0:f5de229c9a00 685 }
dkato 0:f5de229c9a00 686 break;
dkato 0:f5de229c9a00 687 default:
dkato 0:f5de229c9a00 688 break;
dkato 0:f5de229c9a00 689 }
dkato 0:f5de229c9a00 690 draw_touch_layer(p_display, &frame_buffer_info, &canvas2d);
dkato 0:f5de229c9a00 691 }
dkato 0:f5de229c9a00 692 func_code_last = func_code;
dkato 0:f5de229c9a00 693 } else {
dkato 0:f5de229c9a00 694 slide = false;
dkato 0:f5de229c9a00 695 }
dkato 0:f5de229c9a00 696 }
dkato 0:f5de229c9a00 697 touch_num_last = touch_num;
dkato 0:f5de229c9a00 698 }
dkato 0:f5de229c9a00 699 }