00001 #ifndef DN_TPCOMM_H_
00002 #define DN_TPCOMM_H_
00003
00035 #ifndef _DN_EXP_TPCOMM
00036 #define _DN_EXP_TPCOMM
00037 #endif
00038
00039 #include "../dn_common.h"
00040
00046 #define TP_CONN_MAX (1)
00047
00052 #define TP_RETRY_NAK (2)
00053
00058 #define TP_RETRY_TIMEOUT (2)
00059
00064 #define TP_ID_CLIENT (0x11)
00065
00070 #define TP_ID_SERVER (0x90)
00071
00076 #define TP_CMD_REQ_ID (0x0EF0)
00077
00082 #define TP_CMD_KEYINFO (0x0C20)
00083
00088 #define TP_CMD_TOUTCHINFO (0x0C21)
00089
00094 #define TP_CMD_BEEP (0x0C28)
00095
00100 #define TP_CMD_LED_ON (0x0C29)
00101
00106 #define TP_CMD_LED_OFF (0x0C2A)
00107
00112 #define TP_CMD_LED_FLASH (0x0C2B)
00113
00118 #define TP_CMD_GET_KEYSTATE (0x0C2D)
00119
00124 #define TP_CMD_BKL_ON (0x0C33)
00125
00130 #define TP_CMD_LCD (0x0C49)
00131
00136 #define TP_CMD_MTP_DRAW (0x0C81)
00137
00142 #define TP_CMD_PING (0x0C2F)
00143
00148 enum TP_STATE
00149 {
00150 TP_DISCONNECT = 0,
00151 TP_CONNECT,
00152 TP_TPLESS,
00153 TP_TPERROR,
00154 };
00155
00160 enum TP_KEY_ENUM
00161 {
00162 DIAL_MODE_AUTO = 1,
00163 DIAL_MODE_MANUAL = 2,
00164 DIAL_MODE_TEACH = 4,
00165 BTN_DIR_UP = 1,
00166 BTN_DIR_DOWN = 2,
00167 BTN_DIR_LEFT = 4,
00168 BTN_DIR_RIGHT = 8,
00169 BTN_FUNC_F1 = 1,
00170 BTN_FUNC_F2 = 2,
00171 BTN_FUNC_F3 = 4,
00172 BTN_FUNC_F4 = 8,
00173 BTN_FUNC_F5 = 16,
00174 BTN_FUNC_F6 = 32,
00175 DIAL_DIR_MINUS = 1,
00176 DIAL_DIR_PLUS = 2,
00177 JOG_MINUS_J1 = 1,
00178 JOG_MINUS_J2 = 2,
00179 JOG_MINUS_J3 = 4,
00180 JOG_MINUS_J4 = 8,
00181 JOG_MINUS_J5 = 16,
00182 JOG_MINUS_J6 = 32,
00183 JOG_PLUS_J1 = 1,
00184 JOG_PLUS_J2 = 2,
00185 JOG_PLUS_J3 = 4,
00186 JOG_PLUS_J4 = 8,
00187 JOG_PLUS_J5 = 16,
00188 JOG_PLUS_J6 = 32,
00189 };
00190
00195 enum TP_TOUCH_ENUM
00196 {
00197 MODE_TOUCH = 0x54,
00198 MODE_RELEASE = 0x52,
00199 };
00200
00205 enum LED_STATE
00206 {
00207 LED_OFF = 0,
00208 LED_ON,
00209 LED_FLASH,
00210 };
00211
00216 enum MINITP_COMMAND
00217 {
00218 COLOR_FG = 0x10,
00219 COLOR_BG = 0x11,
00220 COLOR_FILL = 0x12,
00221 DRAW_STRING = 0x20,
00222 DRAW_LINE = 0x30,
00223 DRAW_RECT = 0x31,
00224 };
00225
00230 enum MINITP_PARAM
00231 {
00232 COLOR_BLACK = 0,
00233 COLOR_WHITE = 0xF,
00234 COLOR_TRANS = 0xFF,
00235 SIZE_SMALL = 0,
00236 SIZE_MIDDLE = 1,
00237 SIZE_LARGE = 2,
00238 SIZE_LARGE_H = 3,
00239 ATTR_NORMAL = 0,
00240 ATTR_REVERSE = 1,
00241 ATTR_FLASH = 2,
00242 ATTR_EMPHASIS = 4,
00243 ATTR_UNDERLINE = 8,
00244 };
00245
00250 struct TP_KEY_INFO
00251 {
00252 uint64_t rsv1 :2;
00253 uint64_t btn_stop :1;
00254 uint64_t dial_mode :3;
00255 uint64_t btn_motor :1;
00256 uint64_t rsv2 :3;
00257 uint64_t btn_dir :4;
00258 uint64_t btn_ok :1;
00259 uint64_t btn_cancel :1;
00260 uint64_t btn_lock :1;
00261 uint64_t btn_r_sel :1;
00262 uint64_t btn_m_mod :1;
00263 uint64_t btn_speed :1;
00264 uint64_t btn_shift :1;
00265 uint64_t btn_func :6;
00266 uint64_t rsv3 :4;
00267 uint64_t dial_dir :2;
00268 uint64_t rsv4 :8;
00269 uint64_t jog_minus :6;
00270 uint64_t rsv5 :4;
00271 uint64_t jog_plus :6;
00272 uint64_t rsv6 :7;
00273 };
00274
00279 struct TP_TOUCH_INFO
00280 {
00281 uint8_t mode;
00282 uint16_t pos_x;
00283 uint16_t pos_y;
00284 };
00285
00291 struct CALL_FUNC_TP
00292 {
00293 HRESULT
00294 (*Call_TPState)(int state);
00295 HRESULT
00296 (*Call_TPKeyInfo)(struct TP_KEY_INFO key_info);
00297 HRESULT
00298 (*Call_TPTouchInfo)(struct TP_TOUCH_INFO touch_info);
00299 #if defined(_DEBUG)
00300 HRESULT (*Call_TPDefault)(uint16_t command, const uint8_t *data, uint8_t len_data);
00301 #endif
00302 };
00303
00304 #ifdef __cplusplus
00305 extern "C"
00306 {
00307 #endif
00308
00314 _DN_EXP_TPCOMM HRESULT
00315 TPComm_SetCallFunc(const struct CALL_FUNC_TP *func);
00316
00325 _DN_EXP_TPCOMM HRESULT
00326 TPComm_Open(const char *connect, uint32_t timeout, int client, int *pfd);
00327
00333 _DN_EXP_TPCOMM HRESULT
00334 TPComm_Close(int *pfd);
00335
00342 _DN_EXP_TPCOMM HRESULT
00343 TPComm_SetTimeout(int fd, uint32_t timeout);
00344
00351 _DN_EXP_TPCOMM HRESULT
00352 TPComm_GetTimeout(int fd, uint32_t *timeout);
00353
00360 _DN_EXP_TPCOMM HRESULT
00361 TPComm_GetTPState(int fd, int *state);
00362
00369 _DN_EXP_TPCOMM HRESULT
00370 TPComm_BEEP(int fd, int16_t time);
00371
00379 _DN_EXP_TPCOMM HRESULT
00380 TPComm_LED(int fd, int16_t number, int16_t state);
00381
00389 _DN_EXP_TPCOMM HRESULT
00390 TPComm_LCD(int fd, int16_t contrast);
00391
00399 _DN_EXP_TPCOMM HRESULT
00400 TPComm_LCD(int fd, int16_t contrast);
00401
00408 _DN_EXP_TPCOMM HRESULT
00409 TPComm_DrawMiniTP(int fd, VARIANT commands);
00410
00423 _DN_EXP_TPCOMM HRESULT
00424 TPComm_DrawString(int fd, BSTR bstr, uint8_t pos_x, uint8_t pos_y,
00425 uint8_t size, uint8_t attr, uint8_t color_fg, uint8_t color_bg);
00426
00437 _DN_EXP_TPCOMM HRESULT
00438 TPComm_DrawLine(int fd, uint8_t start_x, uint8_t start_y, uint8_t end_x,
00439 uint8_t end_y, uint8_t color_fg);
00440
00452 _DN_EXP_TPCOMM HRESULT
00453 TPComm_DrawRectangle(int fd, uint8_t start_x, uint8_t start_y, uint8_t end_x,
00454 uint8_t end_y, uint8_t color_fg, uint8_t color_bg);
00455
00456 #ifdef __cplusplus
00457 }
00458 #endif
00459
00460 #endif