Send the data of GR-PEACH_HVC-P2_sample to the cloud.

Dependencies:   AsciiFont GR-PEACH_video GraphicsFramework LCD_shield_config R_BSP USBHost_custom easy-connect-gr-peach

Fork of mbed-os-example-client by mbed-os-examples

Note at the time of sample import

Please not check the "Update all libraries to the latest version" at the time of import.

Warning!

When exporting and using it, increase the following stack size.

mbed-os/features/FEATURE_LWIP/lwip-interface/lwipopts.h

#define TCPIP_THREAD_STACKSIZE      1024
->
#define TCPIP_THREAD_STACKSIZE      2048

Overview

This is a sample to send the analysis result of GR-PEACH_HVC-P2_sample to the cloud using mbed-client. Please refer to following for operation of HVC-P2.

Import programGR-PEACH_HVC-P2_sample

Sample to operate omron HVC-P2 on GR-PEACH.


Required hardware

Application setup

Client credentials

To register the application to mbed Device Connector, you need to create and set the client side certificate.

  1. Go to https://connector.mbed.com/ and log in with your mbed account
  2. On mbed Device Connector, go to https://connector.mbed.com/#credentials and click the Get my device security credentials button to get new credentials for your device.
  3. Replace the contents in security.h of this example with content copied above.

Ethernet settings

This sample uses Ethernet as the default connection type. To change the connection type, set WIFI_BP3595 in mbed_app.json:

mbed_app.json

"network-interface":{
    "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_BP3595",
    "value": "ETHERNET"
},


To specify MAC address, add fllowing function to main.cpp. (When using Wifi, setting of MAC address is not necessary.)

Specify MAC address

// set mac address
void mbed_mac_address(char *mac) {
    mac[0] = 0x00;
    mac[1] = 0x02;
    mac[2] = 0xF7;
    mac[3] = 0xF0;
    mac[4] = 0x00;
    mac[5] = 0x00;
}


Wifi settings

This example can use BP3595 Wifi Interface for managing the wireless connectivity. To run this example using Wifi, you need:

  1. A BP3595 Wifi module ( https://developer.mbed.org/components/BP3595-for-GR-PEACH/ )
  2. Mount BP3595 onto GR-PEACH
  3. Close GR-PEACH's JP21 (https://developer.mbed.org/teams/Renesas/wiki/Jumper-settings-of-GR-PEACH)
  4. In the mbed_app.json file, change

mbed_app.json

"network-interface":{
    "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_BP3595",
    "value": "WIFI_BP3595"
},


Provide your Wifi SSID and password here and leave \" in the beginning and end of your SSID and password as shown in the example below:

mbed_app.json

"wifi-ssid": {
    "help": "WiFi SSID",
    "value": "\"SSID\""
},
"wifi-password": {
    "help": "WIFI Password",
    "value": "\"Password\""
}


Specify the security type for connection to be used. When the security type is WPA2, you need to specify NSAPI_SECURITY_WAP as follows:

mbed_app.json

"wifi-security":{
    "help": "Options are NSAPI_SECURITY_WEP, NSAPI_SECURITY_WPA, NSAPI_SECURITY_WPA2, NSAPI_SECURITY_WPA_WPA2",
    "value": "NSAPI_SECURITY_WEP"
},

By default, NSAPI_SECURITY_WPA_WPA2 is specified here.

Application resources

This example exposes four resources listed below:

  1. 3202/0/5700. Recognition result from HVC-P2 (GET).
  2. 3201/0/5850. Blink function, blinks LED when executed (POST).
  3. 3201/0/5853. Blink pattern, used by the blink function to determine how to blink. In the format of 1000:500:1000:500:1000:500 (PUT).
  4. 3201/0/5855. Blink color, used by the blink function. Any of red, green, blue, cyan, yellow and magenta is acceptable (PUT).

For more info on how to get notifications when resource 1 changes, or how to use resource 2, 3 and 4, please look at

Import programGR-PEACH_mbed-connector-ZXingSample-node

Node.js based Web Application for mbed Device Connector specific to GR-PEACH_mbed-os-client-ZXingSample

# This is a Web Application for GR-PEACH_mbed-os-client-ZXingSample, but it can also be used for this sample.

Committer:
dkato
Date:
Tue Mar 14 05:59:09 2017 +0000
Revision:
74:bf6d9bd511bd
Parent:
73:fbc0212c2eaf
Changed initial setting of mbed_app.json to ETHERNET.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 73:fbc0212c2eaf 1 #include "mbed.h"
dkato 73:fbc0212c2eaf 2 #include "DisplayBace.h"
dkato 73:fbc0212c2eaf 3 #include "rtos.h"
dkato 73:fbc0212c2eaf 4 #include "AsciiFont.h"
dkato 73:fbc0212c2eaf 5 #include "USBHostSerial.h"
dkato 73:fbc0212c2eaf 6 #include "LCD_shield_config_4_3inch.h"
dkato 73:fbc0212c2eaf 7 #include "recognition_proc.h"
dkato 73:fbc0212c2eaf 8
dkato 73:fbc0212c2eaf 9 #define UART_SETTING_TIMEOUT 1000 /* HVC setting command signal timeout period */
dkato 73:fbc0212c2eaf 10 #define UART_REGIST_EXECUTE_TIMEOUT 7000 /* HVC registration command signal timeout period */
dkato 73:fbc0212c2eaf 11 #define UART_EXECUTE_TIMEOUT 4000 /* HVC execute command signal timeout period */
dkato 73:fbc0212c2eaf 12
dkato 73:fbc0212c2eaf 13 #define SENSOR_ROLL_ANGLE_DEFAULT 0 /* Camera angle setting (0属) */
dkato 73:fbc0212c2eaf 14 #define USER_ID_NUM_MAX 10
dkato 73:fbc0212c2eaf 15
dkato 73:fbc0212c2eaf 16 #define ERROR_02 "Error: Number of detected faces is 2 or more"
dkato 73:fbc0212c2eaf 17
dkato 73:fbc0212c2eaf 18 #define DISP_PIXEL_WIDTH (320)
dkato 73:fbc0212c2eaf 19 #define DISP_PIXEL_HEIGHT (240)
dkato 73:fbc0212c2eaf 20
dkato 73:fbc0212c2eaf 21 /*! Frame buffer stride: Frame buffer stride should be set to a multiple of 32 or 128
dkato 73:fbc0212c2eaf 22 in accordance with the frame buffer burst transfer mode. */
dkato 73:fbc0212c2eaf 23 /* FRAME BUFFER Parameter GRAPHICS_LAYER_0 */
dkato 73:fbc0212c2eaf 24 #define FRAME_BUFFER_BYTE_PER_PIXEL (2u)
dkato 73:fbc0212c2eaf 25 #define FRAME_BUFFER_STRIDE (((DISP_PIXEL_WIDTH * FRAME_BUFFER_BYTE_PER_PIXEL) + 31u) & ~31u)
dkato 73:fbc0212c2eaf 26
dkato 73:fbc0212c2eaf 27 /* RESULT BUFFER Parameter GRAPHICS_LAYER_1 */
dkato 73:fbc0212c2eaf 28 #define RESULT_BUFFER_BYTE_PER_PIXEL (2u)
dkato 73:fbc0212c2eaf 29 #define RESULT_BUFFER_STRIDE (((DISP_PIXEL_WIDTH * RESULT_BUFFER_BYTE_PER_PIXEL) + 31u) & ~31u)
dkato 73:fbc0212c2eaf 30
dkato 73:fbc0212c2eaf 31 static bool registrationr_req = false;
dkato 73:fbc0212c2eaf 32 static bool setting_req = false;
dkato 73:fbc0212c2eaf 33 static recognition_setting_t setting = {
dkato 73:fbc0212c2eaf 34 0,
dkato 73:fbc0212c2eaf 35 { BODY_THRESHOLD_DEFAULT, HAND_THRESHOLD_DEFAULT, FACE_THRESHOLD_DEFAULT, REC_THRESHOLD_DEFAULT},
dkato 73:fbc0212c2eaf 36 { BODY_SIZE_RANGE_MIN_DEFAULT, BODY_SIZE_RANGE_MAX_DEFAULT, HAND_SIZE_RANGE_MIN_DEFAULT,
dkato 73:fbc0212c2eaf 37 HAND_SIZE_RANGE_MAX_DEFAULT, FACE_SIZE_RANGE_MIN_DEFAULT, FACE_SIZE_RANGE_MAX_DEFAULT},
dkato 73:fbc0212c2eaf 38 FACE_POSE_DEFAULT,
dkato 73:fbc0212c2eaf 39 FACE_ANGLE_DEFAULT
dkato 73:fbc0212c2eaf 40 };
dkato 73:fbc0212c2eaf 41 static USBHostSerial serial;
dkato 73:fbc0212c2eaf 42 static InterruptIn button(USER_BUTTON0);
dkato 73:fbc0212c2eaf 43
dkato 73:fbc0212c2eaf 44 #if defined(__ICCARM__)
dkato 73:fbc0212c2eaf 45 /* 32 bytes aligned */
dkato 73:fbc0212c2eaf 46 #pragma data_alignment=32
dkato 73:fbc0212c2eaf 47 static uint8_t user_frame_buffer0[FRAME_BUFFER_STRIDE * DISP_PIXEL_HEIGHT]@ ".mirrorram";
dkato 73:fbc0212c2eaf 48 #pragma data_alignment=32
dkato 73:fbc0212c2eaf 49 static uint8_t user_frame_buffer_result[RESULT_BUFFER_STRIDE * DISP_PIXEL_HEIGHT]@ ".mirrorram";
dkato 73:fbc0212c2eaf 50 #else
dkato 73:fbc0212c2eaf 51 /* 32 bytes aligned */
dkato 73:fbc0212c2eaf 52 static uint8_t user_frame_buffer0[FRAME_BUFFER_STRIDE * DISP_PIXEL_HEIGHT]__attribute((section("NC_BSS"),aligned(32)));
dkato 73:fbc0212c2eaf 53 static uint8_t user_frame_buffer_result[RESULT_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]__attribute((section("NC_BSS"),aligned(32)));
dkato 73:fbc0212c2eaf 54 #endif
dkato 73:fbc0212c2eaf 55
dkato 73:fbc0212c2eaf 56 static AsciiFont ascii_font(user_frame_buffer_result, DISP_PIXEL_WIDTH, LCD_PIXEL_HEIGHT,
dkato 73:fbc0212c2eaf 57 RESULT_BUFFER_STRIDE, RESULT_BUFFER_BYTE_PER_PIXEL, 0x00000090);
dkato 73:fbc0212c2eaf 58 static INT32 imageNo_setting = HVC_EXECUTE_IMAGE_QVGA_HALF;
dkato 73:fbc0212c2eaf 59 static int str_draw_x = 0;
dkato 73:fbc0212c2eaf 60 static int str_draw_y = 0;
dkato 73:fbc0212c2eaf 61
dkato 73:fbc0212c2eaf 62 #if(1) //mbed client
dkato 73:fbc0212c2eaf 63 extern void HVCSendData(char * addr, int size);
dkato 73:fbc0212c2eaf 64
dkato 73:fbc0212c2eaf 65 static char send_cloud_buf[1024 * 4];
dkato 73:fbc0212c2eaf 66 #endif
dkato 73:fbc0212c2eaf 67
dkato 73:fbc0212c2eaf 68 /****** Image Recognition ******/
dkato 73:fbc0212c2eaf 69 extern "C" int UART_SendData(int inDataSize, UINT8 *inData) {
dkato 73:fbc0212c2eaf 70 return serial.writeBuf((char *)inData, inDataSize);
dkato 73:fbc0212c2eaf 71 }
dkato 73:fbc0212c2eaf 72
dkato 73:fbc0212c2eaf 73 extern "C" int UART_ReceiveData(int inTimeOutTime, int inDataSize, UINT8 *outResult) {
dkato 73:fbc0212c2eaf 74 return serial.readBuf((char *)outResult, inDataSize, inTimeOutTime);
dkato 73:fbc0212c2eaf 75 }
dkato 73:fbc0212c2eaf 76
dkato 73:fbc0212c2eaf 77 void SetRegistrationrReq(void) {
dkato 73:fbc0212c2eaf 78 registrationr_req = true;
dkato 73:fbc0212c2eaf 79 }
dkato 73:fbc0212c2eaf 80
dkato 73:fbc0212c2eaf 81 void SetSettingReq(void) {
dkato 73:fbc0212c2eaf 82 setting_req = true;
dkato 73:fbc0212c2eaf 83 }
dkato 73:fbc0212c2eaf 84
dkato 73:fbc0212c2eaf 85 recognition_setting_t * GetRecognitionSettingPointer(void) {
dkato 73:fbc0212c2eaf 86 return &setting;
dkato 73:fbc0212c2eaf 87 }
dkato 73:fbc0212c2eaf 88
dkato 73:fbc0212c2eaf 89 static void EraseImage(void) {
dkato 73:fbc0212c2eaf 90 uint32_t i = 0;
dkato 73:fbc0212c2eaf 91 while (i < sizeof(user_frame_buffer0)) {
dkato 73:fbc0212c2eaf 92 user_frame_buffer0[i++] = 0x10;
dkato 73:fbc0212c2eaf 93 user_frame_buffer0[i++] = 0x80;
dkato 73:fbc0212c2eaf 94 }
dkato 73:fbc0212c2eaf 95 }
dkato 73:fbc0212c2eaf 96
dkato 73:fbc0212c2eaf 97 static void DrawImage(int x, int y, int nWidth, int nHeight, UINT8 *unImageBuffer, int magnification) {
dkato 73:fbc0212c2eaf 98 int idx_base;
dkato 73:fbc0212c2eaf 99 int idx_w = 0;
dkato 73:fbc0212c2eaf 100 int wk_tmp = 0;
dkato 73:fbc0212c2eaf 101 int i;
dkato 73:fbc0212c2eaf 102 int j;
dkato 73:fbc0212c2eaf 103 int k;
dkato 73:fbc0212c2eaf 104 int idx_r = 0;
dkato 73:fbc0212c2eaf 105
dkato 73:fbc0212c2eaf 106 if (magnification <= 0) {
dkato 73:fbc0212c2eaf 107 return;
dkato 73:fbc0212c2eaf 108 }
dkato 73:fbc0212c2eaf 109
dkato 73:fbc0212c2eaf 110 idx_base = (x + (DISP_PIXEL_WIDTH * y)) * RESULT_BUFFER_BYTE_PER_PIXEL;
dkato 73:fbc0212c2eaf 111
dkato 73:fbc0212c2eaf 112 for (i = 0; i < nHeight; i++) {
dkato 73:fbc0212c2eaf 113 idx_w = idx_base + (DISP_PIXEL_WIDTH * RESULT_BUFFER_BYTE_PER_PIXEL * i) * magnification;
dkato 73:fbc0212c2eaf 114 wk_tmp = idx_w;
dkato 73:fbc0212c2eaf 115 for (j = 0; j < nWidth; j++) {
dkato 73:fbc0212c2eaf 116 for (k = 0; k < magnification; k++) {
dkato 73:fbc0212c2eaf 117 user_frame_buffer0[idx_w] = unImageBuffer[idx_r];
dkato 73:fbc0212c2eaf 118 idx_w += 2;
dkato 73:fbc0212c2eaf 119 }
dkato 73:fbc0212c2eaf 120 idx_r++;
dkato 73:fbc0212c2eaf 121 }
dkato 73:fbc0212c2eaf 122 for (k = 1; k < magnification; k++) {
dkato 73:fbc0212c2eaf 123 memcpy(&user_frame_buffer0[wk_tmp + (DISP_PIXEL_WIDTH * RESULT_BUFFER_BYTE_PER_PIXEL * k)], &user_frame_buffer0[wk_tmp], idx_w - wk_tmp);
dkato 73:fbc0212c2eaf 124 }
dkato 73:fbc0212c2eaf 125 }
dkato 73:fbc0212c2eaf 126 }
dkato 73:fbc0212c2eaf 127
dkato 73:fbc0212c2eaf 128 static void DrawSquare(int x, int y, int size, uint32_t const colour) {
dkato 73:fbc0212c2eaf 129 int wk_x;
dkato 73:fbc0212c2eaf 130 int wk_y;
dkato 73:fbc0212c2eaf 131 int wk_w = 0;
dkato 73:fbc0212c2eaf 132 int wk_h = 0;
dkato 73:fbc0212c2eaf 133 int idx_base;
dkato 73:fbc0212c2eaf 134 int wk_idx;
dkato 73:fbc0212c2eaf 135 int i;
dkato 73:fbc0212c2eaf 136 int j;
dkato 73:fbc0212c2eaf 137 uint8_t coller_pix[RESULT_BUFFER_BYTE_PER_PIXEL]; /* ARGB4444 */
dkato 73:fbc0212c2eaf 138 bool l_draw = true;
dkato 73:fbc0212c2eaf 139 bool r_draw = true;
dkato 73:fbc0212c2eaf 140 bool t_draw = true;
dkato 73:fbc0212c2eaf 141 bool b_draw = true;
dkato 73:fbc0212c2eaf 142
dkato 73:fbc0212c2eaf 143 if ((x - (size / 2)) < 0) {
dkato 73:fbc0212c2eaf 144 l_draw = false;
dkato 73:fbc0212c2eaf 145 wk_w += x;
dkato 73:fbc0212c2eaf 146 wk_x = 0;
dkato 73:fbc0212c2eaf 147 } else {
dkato 73:fbc0212c2eaf 148 wk_w += (size / 2);
dkato 73:fbc0212c2eaf 149 wk_x = x - (size / 2);
dkato 73:fbc0212c2eaf 150 }
dkato 73:fbc0212c2eaf 151
dkato 73:fbc0212c2eaf 152 if ((x + (size / 2)) >= 1600) {
dkato 73:fbc0212c2eaf 153 r_draw = false;
dkato 73:fbc0212c2eaf 154 wk_w += (1600 - x);
dkato 73:fbc0212c2eaf 155 } else {
dkato 73:fbc0212c2eaf 156 wk_w += (size / 2);
dkato 73:fbc0212c2eaf 157 }
dkato 73:fbc0212c2eaf 158
dkato 73:fbc0212c2eaf 159 if ((y - (size / 2)) < 0) {
dkato 73:fbc0212c2eaf 160 t_draw = false;
dkato 73:fbc0212c2eaf 161 wk_h += y;
dkato 73:fbc0212c2eaf 162 wk_y = 0;
dkato 73:fbc0212c2eaf 163 } else {
dkato 73:fbc0212c2eaf 164 wk_h += (size / 2);
dkato 73:fbc0212c2eaf 165 wk_y = y - (size / 2);
dkato 73:fbc0212c2eaf 166 }
dkato 73:fbc0212c2eaf 167
dkato 73:fbc0212c2eaf 168 if ((y + (size / 2)) >= 1200) {
dkato 73:fbc0212c2eaf 169 b_draw = false;
dkato 73:fbc0212c2eaf 170 wk_h += (1200 - y);
dkato 73:fbc0212c2eaf 171 } else {
dkato 73:fbc0212c2eaf 172 wk_h += (size / 2);
dkato 73:fbc0212c2eaf 173 }
dkato 73:fbc0212c2eaf 174
dkato 73:fbc0212c2eaf 175 wk_x = wk_x / 5;
dkato 73:fbc0212c2eaf 176 wk_y = wk_y / 5;
dkato 73:fbc0212c2eaf 177 wk_w = wk_w / 5;
dkato 73:fbc0212c2eaf 178 wk_h = wk_h / 5;
dkato 73:fbc0212c2eaf 179
dkato 73:fbc0212c2eaf 180 if ((colour == 0x0000f0f0) || (colour == 0x0000fff4)) {
dkato 73:fbc0212c2eaf 181 str_draw_x = wk_x;
dkato 73:fbc0212c2eaf 182 str_draw_y = wk_y + wk_h + 1;
dkato 73:fbc0212c2eaf 183 }
dkato 73:fbc0212c2eaf 184
dkato 73:fbc0212c2eaf 185 idx_base = (wk_x + (DISP_PIXEL_WIDTH * wk_y)) * RESULT_BUFFER_BYTE_PER_PIXEL;
dkato 73:fbc0212c2eaf 186
dkato 73:fbc0212c2eaf 187 /* Select color */
dkato 73:fbc0212c2eaf 188 coller_pix[0] = (colour >> 8) & 0xff; /* 4:Green 4:Blue */
dkato 73:fbc0212c2eaf 189 coller_pix[1] = colour & 0xff; /* 4:Alpha 4:Red */
dkato 73:fbc0212c2eaf 190
dkato 73:fbc0212c2eaf 191 /* top */
dkato 73:fbc0212c2eaf 192 if (t_draw) {
dkato 73:fbc0212c2eaf 193 wk_idx = idx_base;
dkato 73:fbc0212c2eaf 194 for (j = 0; j < wk_w; j++) {
dkato 73:fbc0212c2eaf 195 user_frame_buffer_result[wk_idx++] = coller_pix[0];
dkato 73:fbc0212c2eaf 196 user_frame_buffer_result[wk_idx++] = coller_pix[1];
dkato 73:fbc0212c2eaf 197 }
dkato 73:fbc0212c2eaf 198 }
dkato 73:fbc0212c2eaf 199
dkato 73:fbc0212c2eaf 200 /* middle */
dkato 73:fbc0212c2eaf 201 for (i = 1; i < (wk_h - 1); i++) {
dkato 73:fbc0212c2eaf 202 wk_idx = idx_base + (DISP_PIXEL_WIDTH * RESULT_BUFFER_BYTE_PER_PIXEL * i);
dkato 73:fbc0212c2eaf 203 if (l_draw) {
dkato 73:fbc0212c2eaf 204 user_frame_buffer_result[wk_idx + 0] = coller_pix[0];
dkato 73:fbc0212c2eaf 205 user_frame_buffer_result[wk_idx + 1] = coller_pix[1];
dkato 73:fbc0212c2eaf 206 }
dkato 73:fbc0212c2eaf 207 wk_idx += (wk_w - 1) * 2;
dkato 73:fbc0212c2eaf 208 if (r_draw) {
dkato 73:fbc0212c2eaf 209 user_frame_buffer_result[wk_idx + 0] = coller_pix[0];
dkato 73:fbc0212c2eaf 210 user_frame_buffer_result[wk_idx + 1] = coller_pix[1];
dkato 73:fbc0212c2eaf 211 }
dkato 73:fbc0212c2eaf 212 }
dkato 73:fbc0212c2eaf 213
dkato 73:fbc0212c2eaf 214 /* bottom */
dkato 73:fbc0212c2eaf 215 if (b_draw) {
dkato 73:fbc0212c2eaf 216 wk_idx = idx_base + (DISP_PIXEL_WIDTH * RESULT_BUFFER_BYTE_PER_PIXEL * (wk_h - 1));
dkato 73:fbc0212c2eaf 217 for (j = 0; j < wk_w; j++) {
dkato 73:fbc0212c2eaf 218 user_frame_buffer_result[wk_idx++] = coller_pix[0];
dkato 73:fbc0212c2eaf 219 user_frame_buffer_result[wk_idx++] = coller_pix[1];
dkato 73:fbc0212c2eaf 220 }
dkato 73:fbc0212c2eaf 221 }
dkato 73:fbc0212c2eaf 222 }
dkato 73:fbc0212c2eaf 223
dkato 73:fbc0212c2eaf 224 static void DrawString(const char * str, uint32_t const colour) {
dkato 73:fbc0212c2eaf 225 ascii_font.Erase(0x00000090, str_draw_x, str_draw_y,
dkato 73:fbc0212c2eaf 226 (AsciiFont::CHAR_PIX_WIDTH * strlen(str) + 2),
dkato 73:fbc0212c2eaf 227 (AsciiFont::CHAR_PIX_HEIGHT + 2));
dkato 73:fbc0212c2eaf 228 ascii_font.DrawStr(str, str_draw_x + 1, str_draw_y + 1, colour, 1);
dkato 73:fbc0212c2eaf 229 str_draw_y += AsciiFont::CHAR_PIX_HEIGHT + 1;
dkato 73:fbc0212c2eaf 230 #if(1) //mbed client
dkato 73:fbc0212c2eaf 231 strcat(send_cloud_buf, str);
dkato 73:fbc0212c2eaf 232 strcat(send_cloud_buf, ",");
dkato 73:fbc0212c2eaf 233 #endif
dkato 73:fbc0212c2eaf 234 }
dkato 73:fbc0212c2eaf 235
dkato 73:fbc0212c2eaf 236 static void button_fall(void) {
dkato 73:fbc0212c2eaf 237 if (imageNo_setting == HVC_EXECUTE_IMAGE_NONE) {
dkato 73:fbc0212c2eaf 238 imageNo_setting = HVC_EXECUTE_IMAGE_QVGA_HALF;
dkato 73:fbc0212c2eaf 239 } else if (imageNo_setting == HVC_EXECUTE_IMAGE_QVGA_HALF) {
dkato 73:fbc0212c2eaf 240 imageNo_setting = HVC_EXECUTE_IMAGE_QVGA;
dkato 73:fbc0212c2eaf 241 } else {
dkato 73:fbc0212c2eaf 242 imageNo_setting = HVC_EXECUTE_IMAGE_NONE;
dkato 73:fbc0212c2eaf 243 }
dkato 73:fbc0212c2eaf 244 }
dkato 73:fbc0212c2eaf 245
dkato 73:fbc0212c2eaf 246 void init_recognition_layers(DisplayBase * p_display) {
dkato 73:fbc0212c2eaf 247 DisplayBase::rect_t rect;
dkato 73:fbc0212c2eaf 248
dkato 73:fbc0212c2eaf 249 /* The layer by which the image is drawn */
dkato 73:fbc0212c2eaf 250 rect.vs = 0;
dkato 73:fbc0212c2eaf 251 rect.vw = DISP_PIXEL_HEIGHT;
dkato 73:fbc0212c2eaf 252 rect.hs = 0;
dkato 73:fbc0212c2eaf 253 rect.hw = DISP_PIXEL_WIDTH;
dkato 73:fbc0212c2eaf 254 p_display->Graphics_Read_Setting(
dkato 73:fbc0212c2eaf 255 DisplayBase::GRAPHICS_LAYER_0,
dkato 73:fbc0212c2eaf 256 (void *)user_frame_buffer0,
dkato 73:fbc0212c2eaf 257 FRAME_BUFFER_STRIDE,
dkato 73:fbc0212c2eaf 258 DisplayBase::GRAPHICS_FORMAT_YCBCR422,
dkato 73:fbc0212c2eaf 259 DisplayBase::WR_RD_WRSWA_32_16BIT,
dkato 73:fbc0212c2eaf 260 &rect
dkato 73:fbc0212c2eaf 261 );
dkato 73:fbc0212c2eaf 262 p_display->Graphics_Start(DisplayBase::GRAPHICS_LAYER_0);
dkato 73:fbc0212c2eaf 263
dkato 73:fbc0212c2eaf 264 /* The layer by which the image recognition is drawn */
dkato 73:fbc0212c2eaf 265 rect.vs = 0;
dkato 73:fbc0212c2eaf 266 rect.vw = LCD_PIXEL_HEIGHT;
dkato 73:fbc0212c2eaf 267 rect.hs = 0;
dkato 73:fbc0212c2eaf 268 rect.hw = DISP_PIXEL_WIDTH;
dkato 73:fbc0212c2eaf 269 p_display->Graphics_Read_Setting(
dkato 73:fbc0212c2eaf 270 DisplayBase::GRAPHICS_LAYER_1,
dkato 73:fbc0212c2eaf 271 (void *)user_frame_buffer_result,
dkato 73:fbc0212c2eaf 272 RESULT_BUFFER_STRIDE,
dkato 73:fbc0212c2eaf 273 DisplayBase::GRAPHICS_FORMAT_ARGB4444,
dkato 73:fbc0212c2eaf 274 DisplayBase::WR_RD_WRSWA_32_16BIT,
dkato 73:fbc0212c2eaf 275 &rect
dkato 73:fbc0212c2eaf 276 );
dkato 73:fbc0212c2eaf 277 p_display->Graphics_Start(DisplayBase::GRAPHICS_LAYER_1);
dkato 73:fbc0212c2eaf 278 }
dkato 73:fbc0212c2eaf 279
dkato 73:fbc0212c2eaf 280 void recognition_task(DisplayBase * p_display) {
dkato 73:fbc0212c2eaf 281 INT32 ret = 0;
dkato 73:fbc0212c2eaf 282 UINT8 status;
dkato 73:fbc0212c2eaf 283 HVC_VERSION version;
dkato 73:fbc0212c2eaf 284 HVC_RESULT *pHVCResult = NULL;
dkato 73:fbc0212c2eaf 285 HVC_IMAGE *pImage = NULL;
dkato 73:fbc0212c2eaf 286 INT32 execFlag;
dkato 73:fbc0212c2eaf 287 INT32 imageNo;
dkato 73:fbc0212c2eaf 288 INT32 userID;
dkato 73:fbc0212c2eaf 289 INT32 next_userID;
dkato 73:fbc0212c2eaf 290 INT32 dataID;
dkato 73:fbc0212c2eaf 291 const char *pExStr[] = {"?", "Neutral", "Happiness", "Surprise", "Anger", "Sadness"};
dkato 73:fbc0212c2eaf 292 uint32_t i;
dkato 73:fbc0212c2eaf 293 char Str_disp[32];
dkato 73:fbc0212c2eaf 294 Timer resp_time;
dkato 73:fbc0212c2eaf 295
dkato 73:fbc0212c2eaf 296 /* Register the button */
dkato 73:fbc0212c2eaf 297 button.fall(&button_fall);
dkato 73:fbc0212c2eaf 298
dkato 73:fbc0212c2eaf 299 /* Initializing Recognition layers */
dkato 73:fbc0212c2eaf 300 EraseImage();
dkato 73:fbc0212c2eaf 301 memset(user_frame_buffer_result, 0, sizeof(user_frame_buffer_result));
dkato 73:fbc0212c2eaf 302 init_recognition_layers(p_display);
dkato 73:fbc0212c2eaf 303
dkato 73:fbc0212c2eaf 304 /* Result Structure Allocation */
dkato 73:fbc0212c2eaf 305 pHVCResult = (HVC_RESULT *)malloc(sizeof(HVC_RESULT));
dkato 73:fbc0212c2eaf 306 if (pHVCResult == NULL) {
dkato 73:fbc0212c2eaf 307 printf("Memory Allocation Error : %08x\n", sizeof(HVC_RESULT));
dkato 73:fbc0212c2eaf 308 mbed_die();
dkato 73:fbc0212c2eaf 309 }
dkato 73:fbc0212c2eaf 310
dkato 73:fbc0212c2eaf 311 /* Image Structure allocation */
dkato 73:fbc0212c2eaf 312 pImage = (HVC_IMAGE *)malloc(sizeof(HVC_IMAGE));
dkato 73:fbc0212c2eaf 313 if (pImage == NULL) {
dkato 73:fbc0212c2eaf 314 printf("Memory Allocation Error : %08x\n", sizeof(HVC_RESULT));
dkato 73:fbc0212c2eaf 315 mbed_die();
dkato 73:fbc0212c2eaf 316 }
dkato 73:fbc0212c2eaf 317
dkato 73:fbc0212c2eaf 318 while (1) {
dkato 73:fbc0212c2eaf 319 /* try to connect a serial device */
dkato 73:fbc0212c2eaf 320 while (!serial.connect()) {
dkato 73:fbc0212c2eaf 321 Thread::wait(500);
dkato 73:fbc0212c2eaf 322 }
dkato 73:fbc0212c2eaf 323 serial.baud(921600);
dkato 73:fbc0212c2eaf 324 setting_req = true;
dkato 73:fbc0212c2eaf 325
dkato 73:fbc0212c2eaf 326 do {
dkato 73:fbc0212c2eaf 327 /* Initializing variables */
dkato 73:fbc0212c2eaf 328 next_userID = 0;
dkato 73:fbc0212c2eaf 329 dataID = 0;
dkato 73:fbc0212c2eaf 330
dkato 73:fbc0212c2eaf 331 /* Get Model and Version */
dkato 73:fbc0212c2eaf 332 ret = HVC_GetVersion(UART_SETTING_TIMEOUT, &version, &status);
dkato 73:fbc0212c2eaf 333 if ((ret != 0) || (status != 0)) {
dkato 73:fbc0212c2eaf 334 break;
dkato 73:fbc0212c2eaf 335 }
dkato 73:fbc0212c2eaf 336
dkato 73:fbc0212c2eaf 337 while (1) {
dkato 73:fbc0212c2eaf 338 if (!serial.connected()) {
dkato 73:fbc0212c2eaf 339 break;
dkato 73:fbc0212c2eaf 340 }
dkato 73:fbc0212c2eaf 341 #if(1) //mbed client
dkato 73:fbc0212c2eaf 342 memset(send_cloud_buf, 0, sizeof(send_cloud_buf));
dkato 73:fbc0212c2eaf 343 #endif
dkato 73:fbc0212c2eaf 344
dkato 73:fbc0212c2eaf 345 /* Execute Setting */
dkato 73:fbc0212c2eaf 346 if (setting_req) {
dkato 73:fbc0212c2eaf 347 setting_req = false;
dkato 73:fbc0212c2eaf 348 /* Set Camera Angle */
dkato 73:fbc0212c2eaf 349 ret = HVC_SetCameraAngle(UART_SETTING_TIMEOUT, SENSOR_ROLL_ANGLE_DEFAULT, &status);
dkato 73:fbc0212c2eaf 350 if ((ret != 0) || (status != 0)) {
dkato 73:fbc0212c2eaf 351 break;
dkato 73:fbc0212c2eaf 352 }
dkato 73:fbc0212c2eaf 353 /* Set Threshold Values */
dkato 73:fbc0212c2eaf 354 ret = HVC_SetThreshold(UART_SETTING_TIMEOUT, &setting.threshold, &status);
dkato 73:fbc0212c2eaf 355 if ((ret != 0) || (status != 0)) {
dkato 73:fbc0212c2eaf 356 break;
dkato 73:fbc0212c2eaf 357 }
dkato 73:fbc0212c2eaf 358 ret = HVC_GetThreshold(UART_SETTING_TIMEOUT, &setting.threshold, &status);
dkato 73:fbc0212c2eaf 359 if ((ret != 0) || (status != 0)) {
dkato 73:fbc0212c2eaf 360 break;
dkato 73:fbc0212c2eaf 361 }
dkato 73:fbc0212c2eaf 362 /* Set Detection Size */
dkato 73:fbc0212c2eaf 363 ret = HVC_SetSizeRange(UART_SETTING_TIMEOUT, &setting.sizeRange, &status);
dkato 73:fbc0212c2eaf 364 if ((ret != 0) || (status != 0)) {
dkato 73:fbc0212c2eaf 365 break;
dkato 73:fbc0212c2eaf 366 }
dkato 73:fbc0212c2eaf 367 ret = HVC_GetSizeRange(UART_SETTING_TIMEOUT, &setting.sizeRange, &status);
dkato 73:fbc0212c2eaf 368 if ((ret != 0) || (status != 0)) {
dkato 73:fbc0212c2eaf 369 break;
dkato 73:fbc0212c2eaf 370 }
dkato 73:fbc0212c2eaf 371 /* Set Face Angle */
dkato 73:fbc0212c2eaf 372 ret = HVC_SetFaceDetectionAngle(UART_SETTING_TIMEOUT, setting.pose, setting.angle, &status);
dkato 73:fbc0212c2eaf 373 if ((ret != 0) || (status != 0)) {
dkato 73:fbc0212c2eaf 374 break;
dkato 73:fbc0212c2eaf 375 }
dkato 73:fbc0212c2eaf 376 ret = HVC_GetFaceDetectionAngle(UART_SETTING_TIMEOUT, &setting.pose, &setting.angle, &status);
dkato 73:fbc0212c2eaf 377 if ((ret != 0) || (status != 0)) {
dkato 73:fbc0212c2eaf 378 break;
dkato 73:fbc0212c2eaf 379 }
dkato 73:fbc0212c2eaf 380 }
dkato 73:fbc0212c2eaf 381
dkato 73:fbc0212c2eaf 382 /* Execute Registration */
dkato 73:fbc0212c2eaf 383 if (registrationr_req) {
dkato 73:fbc0212c2eaf 384 int wk_width;
dkato 73:fbc0212c2eaf 385
dkato 73:fbc0212c2eaf 386 if ((pHVCResult->fdResult.num == 1) && (pHVCResult->fdResult.fcResult[0].recognitionResult.uid >= 0)) {
dkato 73:fbc0212c2eaf 387 userID = pHVCResult->fdResult.fcResult[0].recognitionResult.uid;
dkato 73:fbc0212c2eaf 388 } else {
dkato 73:fbc0212c2eaf 389 userID = next_userID;
dkato 73:fbc0212c2eaf 390 }
dkato 73:fbc0212c2eaf 391 ret = HVC_Registration(UART_REGIST_EXECUTE_TIMEOUT, userID, dataID, pImage, &status);
dkato 73:fbc0212c2eaf 392 if ((ret == 0) && (status == 0)) {
dkato 73:fbc0212c2eaf 393 if (userID == next_userID) {
dkato 73:fbc0212c2eaf 394 next_userID++;
dkato 73:fbc0212c2eaf 395 if (next_userID >= USER_ID_NUM_MAX) {
dkato 73:fbc0212c2eaf 396 next_userID = 0;
dkato 73:fbc0212c2eaf 397 }
dkato 73:fbc0212c2eaf 398 }
dkato 73:fbc0212c2eaf 399 memset(user_frame_buffer_result, 0, sizeof(user_frame_buffer_result));
dkato 73:fbc0212c2eaf 400 DrawImage(128, 88, pImage->width, pImage->height, pImage->image, 1);
dkato 73:fbc0212c2eaf 401 memset(Str_disp, 0, sizeof(Str_disp));
dkato 73:fbc0212c2eaf 402 sprintf(Str_disp, "USER%03d", userID + 1);
dkato 73:fbc0212c2eaf 403 wk_width = (AsciiFont::CHAR_PIX_WIDTH * strlen(Str_disp)) + 2;
dkato 73:fbc0212c2eaf 404 ascii_font.Erase(0x00000090, (DISP_PIXEL_WIDTH - wk_width) / 2, 153, wk_width, (AsciiFont::CHAR_PIX_HEIGHT + 2));
dkato 73:fbc0212c2eaf 405 ascii_font.DrawStr(Str_disp, (DISP_PIXEL_WIDTH - wk_width) / 2 + 1, 154, 0x0000ffff, 1);
dkato 73:fbc0212c2eaf 406 Thread::wait(1200);
dkato 73:fbc0212c2eaf 407 } else {
dkato 73:fbc0212c2eaf 408 if (status == 0x02) {
dkato 73:fbc0212c2eaf 409 wk_width = (AsciiFont::CHAR_PIX_WIDTH * (sizeof(ERROR_02) - 1)) + 4;
dkato 73:fbc0212c2eaf 410 ascii_font.Erase(0x00000090, (DISP_PIXEL_WIDTH - wk_width) / 2, 120, wk_width, (AsciiFont::CHAR_PIX_HEIGHT + 3));
dkato 73:fbc0212c2eaf 411 ascii_font.DrawStr(ERROR_02, (DISP_PIXEL_WIDTH - wk_width) / 2 + 2, 121, 0x0000ffff, 1);
dkato 73:fbc0212c2eaf 412 Thread::wait(1500);
dkato 73:fbc0212c2eaf 413 }
dkato 73:fbc0212c2eaf 414 }
dkato 73:fbc0212c2eaf 415 registrationr_req = false;
dkato 73:fbc0212c2eaf 416 }
dkato 73:fbc0212c2eaf 417
dkato 73:fbc0212c2eaf 418 /* Execute Detection */
dkato 73:fbc0212c2eaf 419 execFlag = setting.execFlag;
dkato 73:fbc0212c2eaf 420 if ((execFlag & HVC_ACTIV_FACE_DETECTION) == 0) {
dkato 73:fbc0212c2eaf 421 execFlag &= ~(HVC_ACTIV_AGE_ESTIMATION | HVC_ACTIV_GENDER_ESTIMATION | HVC_ACTIV_EXPRESSION_ESTIMATION);
dkato 73:fbc0212c2eaf 422 }
dkato 73:fbc0212c2eaf 423 imageNo = imageNo_setting;
dkato 73:fbc0212c2eaf 424 resp_time.reset();
dkato 73:fbc0212c2eaf 425 resp_time.start();
dkato 73:fbc0212c2eaf 426 ret = HVC_ExecuteEx(UART_EXECUTE_TIMEOUT, execFlag, imageNo, pHVCResult, &status);
dkato 73:fbc0212c2eaf 427 resp_time.stop();
dkato 73:fbc0212c2eaf 428 if ((ret == 0) && (status == 0)) {
dkato 73:fbc0212c2eaf 429 if (imageNo == HVC_EXECUTE_IMAGE_QVGA_HALF) {
dkato 73:fbc0212c2eaf 430 DrawImage(0, 0, pHVCResult->image.width, pHVCResult->image.height, pHVCResult->image.image, 2);
dkato 73:fbc0212c2eaf 431 } else if (imageNo == HVC_EXECUTE_IMAGE_QVGA) {
dkato 73:fbc0212c2eaf 432 DrawImage(0, 0, pHVCResult->image.width, pHVCResult->image.height, pHVCResult->image.image, 1);
dkato 73:fbc0212c2eaf 433 } else {
dkato 73:fbc0212c2eaf 434 EraseImage();
dkato 73:fbc0212c2eaf 435 }
dkato 73:fbc0212c2eaf 436 memset(user_frame_buffer_result, 0, sizeof(user_frame_buffer_result));
dkato 73:fbc0212c2eaf 437 if (pHVCResult->executedFunc & HVC_ACTIV_BODY_DETECTION) {
dkato 73:fbc0212c2eaf 438 /* Body Detection result */
dkato 73:fbc0212c2eaf 439 for (i = 0; i < pHVCResult->bdResult.num; i++) {
dkato 73:fbc0212c2eaf 440 DrawSquare(pHVCResult->bdResult.bdResult[i].posX,
dkato 73:fbc0212c2eaf 441 pHVCResult->bdResult.bdResult[i].posY,
dkato 73:fbc0212c2eaf 442 pHVCResult->bdResult.bdResult[i].size,
dkato 73:fbc0212c2eaf 443 0x000000ff);
dkato 73:fbc0212c2eaf 444 }
dkato 73:fbc0212c2eaf 445 }
dkato 73:fbc0212c2eaf 446
dkato 73:fbc0212c2eaf 447 /* Face Detection result */
dkato 73:fbc0212c2eaf 448 if (pHVCResult->executedFunc &
dkato 73:fbc0212c2eaf 449 (HVC_ACTIV_FACE_DETECTION | HVC_ACTIV_FACE_DIRECTION |
dkato 73:fbc0212c2eaf 450 HVC_ACTIV_AGE_ESTIMATION | HVC_ACTIV_GENDER_ESTIMATION |
dkato 73:fbc0212c2eaf 451 HVC_ACTIV_GAZE_ESTIMATION | HVC_ACTIV_BLINK_ESTIMATION |
dkato 73:fbc0212c2eaf 452 HVC_ACTIV_EXPRESSION_ESTIMATION | HVC_ACTIV_FACE_RECOGNITION)){
dkato 73:fbc0212c2eaf 453 for (i = 0; i < pHVCResult->fdResult.num; i++) {
dkato 73:fbc0212c2eaf 454 #if(1) //mbed client
dkato 73:fbc0212c2eaf 455 strcat(send_cloud_buf, "{");
dkato 73:fbc0212c2eaf 456 #endif
dkato 73:fbc0212c2eaf 457 if (pHVCResult->executedFunc & HVC_ACTIV_FACE_DETECTION) {
dkato 73:fbc0212c2eaf 458 uint32_t detection_colour = 0x0000f0f0; /* green */
dkato 73:fbc0212c2eaf 459
dkato 73:fbc0212c2eaf 460 if (pHVCResult->executedFunc & HVC_ACTIV_FACE_RECOGNITION) {
dkato 73:fbc0212c2eaf 461 if (pHVCResult->fdResult.fcResult[i].recognitionResult.uid >= 0) {
dkato 73:fbc0212c2eaf 462 detection_colour = 0x0000fff4; /* blue */
dkato 73:fbc0212c2eaf 463 }
dkato 73:fbc0212c2eaf 464 }
dkato 73:fbc0212c2eaf 465 /* Detection */
dkato 73:fbc0212c2eaf 466 DrawSquare(pHVCResult->fdResult.fcResult[i].dtResult.posX,
dkato 73:fbc0212c2eaf 467 pHVCResult->fdResult.fcResult[i].dtResult.posY,
dkato 73:fbc0212c2eaf 468 pHVCResult->fdResult.fcResult[i].dtResult.size,
dkato 73:fbc0212c2eaf 469 detection_colour);
dkato 73:fbc0212c2eaf 470 }
dkato 73:fbc0212c2eaf 471 if (pHVCResult->executedFunc & HVC_ACTIV_FACE_RECOGNITION) {
dkato 73:fbc0212c2eaf 472 /* Recognition */
dkato 73:fbc0212c2eaf 473 if (-128 == pHVCResult->fdResult.fcResult[i].recognitionResult.uid) {
dkato 73:fbc0212c2eaf 474 DrawString("Not possible", 0x0000f0ff);
dkato 73:fbc0212c2eaf 475 } else if (pHVCResult->fdResult.fcResult[i].recognitionResult.uid < 0) {
dkato 73:fbc0212c2eaf 476 DrawString("Not registered", 0x0000f0ff);
dkato 73:fbc0212c2eaf 477 } else {
dkato 73:fbc0212c2eaf 478 memset(Str_disp, 0, sizeof(Str_disp));
dkato 73:fbc0212c2eaf 479 sprintf(Str_disp, "USER%03d", pHVCResult->fdResult.fcResult[i].recognitionResult.uid + 1);
dkato 73:fbc0212c2eaf 480 DrawString(Str_disp, 0x0000f0ff);
dkato 73:fbc0212c2eaf 481 }
dkato 73:fbc0212c2eaf 482 }
dkato 73:fbc0212c2eaf 483 if (pHVCResult->executedFunc & HVC_ACTIV_AGE_ESTIMATION) {
dkato 73:fbc0212c2eaf 484 /* Age */
dkato 73:fbc0212c2eaf 485 if (-128 != pHVCResult->fdResult.fcResult[i].ageResult.age) {
dkato 73:fbc0212c2eaf 486 memset(Str_disp, 0, sizeof(Str_disp));
dkato 73:fbc0212c2eaf 487 sprintf(Str_disp, "Age:%d", pHVCResult->fdResult.fcResult[i].ageResult.age);
dkato 73:fbc0212c2eaf 488 DrawString(Str_disp, 0x0000f0ff);
dkato 73:fbc0212c2eaf 489 }
dkato 73:fbc0212c2eaf 490 }
dkato 73:fbc0212c2eaf 491 if (pHVCResult->executedFunc & HVC_ACTIV_GENDER_ESTIMATION) {
dkato 73:fbc0212c2eaf 492 /* Gender */
dkato 73:fbc0212c2eaf 493 if (-128 != pHVCResult->fdResult.fcResult[i].genderResult.gender) {
dkato 73:fbc0212c2eaf 494 if (1 == pHVCResult->fdResult.fcResult[i].genderResult.gender) {
dkato 73:fbc0212c2eaf 495 DrawString("Male", 0x0000fff4);
dkato 73:fbc0212c2eaf 496 } else {
dkato 73:fbc0212c2eaf 497 DrawString("Female", 0x00006dff);
dkato 73:fbc0212c2eaf 498 }
dkato 73:fbc0212c2eaf 499 }
dkato 73:fbc0212c2eaf 500 }
dkato 73:fbc0212c2eaf 501 if (pHVCResult->executedFunc & HVC_ACTIV_EXPRESSION_ESTIMATION) {
dkato 73:fbc0212c2eaf 502 /* Expression */
dkato 73:fbc0212c2eaf 503 if (-128 != pHVCResult->fdResult.fcResult[i].expressionResult.score[0]) {
dkato 73:fbc0212c2eaf 504 uint32_t colour;
dkato 73:fbc0212c2eaf 505
dkato 73:fbc0212c2eaf 506 if (pHVCResult->fdResult.fcResult[i].expressionResult.topExpression > EX_SADNESS) {
dkato 73:fbc0212c2eaf 507 pHVCResult->fdResult.fcResult[i].expressionResult.topExpression = 0;
dkato 73:fbc0212c2eaf 508 }
dkato 73:fbc0212c2eaf 509 switch (pHVCResult->fdResult.fcResult[i].expressionResult.topExpression) {
dkato 73:fbc0212c2eaf 510 case 1: colour = 0x0000ffff; break; /* white */
dkato 73:fbc0212c2eaf 511 case 2: colour = 0x0000f0ff; break; /* yellow */
dkato 73:fbc0212c2eaf 512 case 3: colour = 0x000060ff; break; /* orange */
dkato 73:fbc0212c2eaf 513 case 4: colour = 0x00000fff; break; /* purple */
dkato 73:fbc0212c2eaf 514 case 5: colour = 0x0000fff4; break; /* blue */
dkato 73:fbc0212c2eaf 515 default: colour = 0x0000ffff; break; /* white */
dkato 73:fbc0212c2eaf 516 }
dkato 73:fbc0212c2eaf 517 DrawString(pExStr[pHVCResult->fdResult.fcResult[i].expressionResult.topExpression], colour);
dkato 73:fbc0212c2eaf 518 }
dkato 73:fbc0212c2eaf 519 }
dkato 73:fbc0212c2eaf 520 #if(1) //mbed client
dkato 73:fbc0212c2eaf 521 send_cloud_buf[strlen(send_cloud_buf) - 1] = '\0';
dkato 73:fbc0212c2eaf 522 strcat(send_cloud_buf, "}");
dkato 73:fbc0212c2eaf 523 #endif
dkato 73:fbc0212c2eaf 524 }
dkato 73:fbc0212c2eaf 525 }
dkato 73:fbc0212c2eaf 526 }
dkato 73:fbc0212c2eaf 527 /* Response time */
dkato 73:fbc0212c2eaf 528 memset(Str_disp, 0, sizeof(Str_disp));
dkato 73:fbc0212c2eaf 529 sprintf(Str_disp, "Response time:%dms", resp_time.read_ms());
dkato 73:fbc0212c2eaf 530 ascii_font.Erase(0, 0, 0, 0, 0);
dkato 73:fbc0212c2eaf 531 ascii_font.DrawStr(Str_disp, 0, LCD_PIXEL_HEIGHT - AsciiFont::CHAR_PIX_HEIGHT, 0x0000ffff, 1);
dkato 73:fbc0212c2eaf 532 #if(1) //mbed client
dkato 73:fbc0212c2eaf 533 if (strlen(send_cloud_buf) > 0) {
dkato 73:fbc0212c2eaf 534 HVCSendData(send_cloud_buf, strlen(send_cloud_buf));
dkato 73:fbc0212c2eaf 535 }
dkato 73:fbc0212c2eaf 536 Thread::wait(10);
dkato 73:fbc0212c2eaf 537 #endif
dkato 73:fbc0212c2eaf 538 }
dkato 73:fbc0212c2eaf 539 } while(0);
dkato 73:fbc0212c2eaf 540
dkato 73:fbc0212c2eaf 541 EraseImage();
dkato 73:fbc0212c2eaf 542 memset(user_frame_buffer_result, 0, sizeof(user_frame_buffer_result));
dkato 73:fbc0212c2eaf 543 }
dkato 73:fbc0212c2eaf 544 }