Index: ModuleDemo/POS/prj/GCC/makefile
===================================================================
--- /YC3121_demo/ModuleDemo/POS/prj/GCC/makefile	(revision 804)
+++ /YC3121_demo/ModuleDemo/POS/prj/GCC/makefile	(working copy)
@@ -169,6 +169,8 @@
 	.data : AT (__etext)
 	{
 		__data_start__ = .;
+		*(.ARM.__at_0x00020000);
+		*(.ARM.__at_0x00020004);
 		*(vtable)
 		*(.data*)
 
Index: ModuleDemo/POS/user/meun.c
===================================================================
--- /YC3121_demo/ModuleDemo/POS/user/meun.c	(revision 804)
+++ /YC3121_demo/ModuleDemo/POS/user/meun.c	(working copy)
@@ -1,5 +1,7 @@
 #include "meun.h"
 
+/* Private define ------------------------------------------------------------*/
+
 
 void BEEP_Start()
 {
@@ -1821,6 +1823,10 @@
 /*************************************************QR_Code start*****************************************************************/
 #include "YC_QRDecode.h"
 #include "YC_QRDecode_TypeDef.h"
+
+#define QR_FLASH_BACKUP_ADDR   (0x1000000 + 4 * 200 * 1024)
+#define QR_SCAN_TIME_OUT       (0)
+
 uint8_t get_gpio_num(uint16_t groupx, uint16_t pinx)
 {
     for (int i = 0; i < GPIO_PIN_NUM; i++)
@@ -1834,81 +1840,82 @@
 
 uint8_t camera_setpara[][2] =
 {
-    0x00
-//	{0xfe, 0x00},
+    {0xfe, 0x00},
 //	{0x14, 0x7f},//[1] updown [0]mirror //MIRROR
 };
-void QRCode_test1()
+
+/**
+  * @brief  qrdecode init and enter scan
+  * @param  timeout :   qrdecode time(s)
+  * @retval  None
+  */
+void QRCode_Enter(uint8_t timeout)
 {
     uint32_t len = 0;
     uint8_t show_messsage_len = 0;
-    int8_t QR_Enter_Ret = 0, message[1024] = {0};
+    yc_qr_return_type_ENUM QR_Enter_Ret = QR_SUCCESS;
+    uint8_t message[1024] = {0};
     uint32_t i = 0;
     QRDecode_Config_CB  p_QRDecode_Config;
 
-    QSPI_CTRL  |= (0x80); //设置half clk
+    /*enable halk clk*/
+    QSPI_CTRL  |= (0x80);
 
-    /*Enable GPIO32 FUC*/
+    /*enable gpio32 function*/
     uint32_t value = lpm_bt_read(LPMBT_CONTROL1);
     value &= ~(1 << 17);
     lpm_bt_write(LPMBT_CONTROL1, value);
 
-    p_QRDecode_Config.lcd_configCB.is_tft      = TRUE;
+    p_QRDecode_Config.lcd_configCB.display_type = CAMERA_TFT;
+    p_QRDecode_Config.lcd_configCB.start_column = QR_TFT_START_COLUMN;//(320 - 236)/2;
     p_QRDecode_Config.lcd_configCB.is_init_lcd = TRUE;
-    #if (BOARD_VER == EPOS_BOARD_V1_0)
-    p_QRDecode_Config.lcd_configCB.lcd_pin_rst = get_gpio_num(ST7789_TFT_RST_PORT, ST7789_TFT_RST_PIN);
-    p_QRDecode_Config.lcd_configCB.lcd_pin_cs  = get_gpio_num(ST7789_TFT_CS_PORT, ST7789_TFT_CS_PIN);
-    p_QRDecode_Config.lcd_configCB.lcd_pin_clk = get_gpio_num(ST7789_TFT_SCL_PORT, ST7789_TFT_SCL_PIN);
-    p_QRDecode_Config.lcd_configCB.lcd_pin_mosi = get_gpio_num(ST7789_TFT_SDA_PORT, ST7789_TFT_SDA_PIN);
-    p_QRDecode_Config.lcd_configCB.lcd_pin_a0  = get_gpio_num(ST7789_TFT_A0_PORT, ST7789_TFT_A0_PIN);
-    p_QRDecode_Config.lcd_configCB.lcd_pin_bl  = get_gpio_num(ST7789_TFT_BL_PORT, ST7789_TFT_BL_PIN) | (ST7789_TFT_BL_HIGH_LIGHT << 7);
-    #endif
-    p_QRDecode_Config.keyboard_configCB.mode = 0;
-    p_QRDecode_Config.keyboard_configCB.line_num = 6;
-    p_QRDecode_Config.keyboard_configCB.col_num = 0;
-    p_QRDecode_Config.keyboard_configCB.cancel_position = (5 << 4) | 6;
-    #if (BOARD_VER == EPOS_BOARD_V1_0)
-    p_QRDecode_Config.keyboard_configCB.line1 = get_gpio_num(KEY_PORT_1, KEY_PIN_1);
-    p_QRDecode_Config.keyboard_configCB.line2 = get_gpio_num(KEY_PORT_2, KEY_PIN_2);
-    p_QRDecode_Config.keyboard_configCB.line3 = get_gpio_num(KEY_PORT_3, KEY_PIN_3);
-    p_QRDecode_Config.keyboard_configCB.line4 = get_gpio_num(KEY_PORT_4, KEY_PIN_4);
-    p_QRDecode_Config.keyboard_configCB.line5 = get_gpio_num(KEY_PORT_5, KEY_PIN_5);
-    p_QRDecode_Config.keyboard_configCB.line6 = get_gpio_num(KEY_PORT_6, KEY_PIN_6);
-    #endif
+    p_QRDecode_Config.lcd_configCB.lcd_pin_rst = QR_TFT_RST;//11;
+    p_QRDecode_Config.lcd_configCB.lcd_pin_cs  = QR_TFT_CS;//5;
+    p_QRDecode_Config.lcd_configCB.lcd_pin_clk = QR_TFT_CLK;//40;
+    p_QRDecode_Config.lcd_configCB.lcd_pin_mosi = QR_TFT_MOSI;//39;
+    p_QRDecode_Config.lcd_configCB.lcd_pin_a0  = QR_TFT_A0;//10;
+    p_QRDecode_Config.lcd_configCB.lcd_pin_bl  = QR_TFT_BL;//12 | (1 << 7);
+
+    p_QRDecode_Config.keyboard_configCB.mode = QR_KEY_T_MATRIX;
+    p_QRDecode_Config.keyboard_configCB.line_num = QR_KEY_LINE_NUM;
+    p_QRDecode_Config.keyboard_configCB.col_num = QR_KEY_COL_NUM;
+    p_QRDecode_Config.keyboard_configCB.cancel_position = QR_KEY_CANCEL_POSTION;
+    p_QRDecode_Config.keyboard_configCB.line1 = QR_KEY_LINE_1;
+    p_QRDecode_Config.keyboard_configCB.line2 = QR_KEY_LINE_2;
+    p_QRDecode_Config.keyboard_configCB.line3 = QR_KEY_LINE_3;
+    p_QRDecode_Config.keyboard_configCB.line4 = QR_KEY_LINE_4;
+    p_QRDecode_Config.keyboard_configCB.line5 = QR_KEY_LINE_5;
+    p_QRDecode_Config.keyboard_configCB.line6 = QR_KEY_LINE_6;
+
     p_QRDecode_Config.camera_configCB.camera_type = UNKNOW;
-    p_QRDecode_Config.camera_configCB.freq_mclk   = 24;
-    #if (BOARD_VER == EPOS_BOARD_V1_0)
-    p_QRDecode_Config.camera_configCB.pin_sda   = CAMERA_SDA;
-    p_QRDecode_Config.camera_configCB.pin_scl   = CAMERA_SCL;
-    p_QRDecode_Config.camera_configCB.pin_reset = CAMERA_RST;
-    p_QRDecode_Config.camera_configCB.pin_pwdn  = CAMERA_PD;
-    p_QRDecode_Config.camera_configCB.pin_mclk  = CAMERA_MCLK;
-    p_QRDecode_Config.camera_configCB.pin_pclk  = CAMERA_PCLK;
-    p_QRDecode_Config.camera_configCB.pin_data  = CAMERA_DATA;
-    p_QRDecode_Config.camera_configCB.pin_cs    = CAMERA_CS;
-    #endif
+    p_QRDecode_Config.camera_configCB.freq_mclk   = QR_CAMERA_FREQ;//24;
+    p_QRDecode_Config.camera_configCB.pin_sda   = QR_CAMERA_SDA;//28;
+    p_QRDecode_Config.camera_configCB.pin_scl   = QR_CAMERA_SCL;//29;
+    p_QRDecode_Config.camera_configCB.pin_reset = QR_CAMERA_RST;//32;
+    p_QRDecode_Config.camera_configCB.pin_pwdn  = QR_CAMERA_PD;//31;
+    p_QRDecode_Config.camera_configCB.pin_mclk  = QR_CAMERA_MCLK;//35;
+    p_QRDecode_Config.camera_configCB.pin_pclk  = QR_CAMERA_PCLK;//34;
+    p_QRDecode_Config.camera_configCB.pin_data  = QR_CAMERA_DATA;//30;
+    p_QRDecode_Config.camera_configCB.pin_cs    = QR_CAMERA_CS;//42;
     p_QRDecode_Config.camera_configCB.camera_setparaCB.camera_setpara_num = sizeof(camera_setpara) / 2;
-    MyPrintf("camera_setpara_num=%x\n", sizeof(camera_setpara) / 2);
+
     for (uint8_t i = 0; i < p_QRDecode_Config.camera_configCB.camera_setparaCB.camera_setpara_num; i++)
     {
         p_QRDecode_Config.camera_configCB.camera_setparaCB.camera_setpara[i][0] = camera_setpara[i][0];
         p_QRDecode_Config.camera_configCB.camera_setparaCB.camera_setpara[i][1] = camera_setpara[i][1];
     }
-    p_QRDecode_Config.flash_backup_addr = 0x1000000 + 4 * 200 * 1024;
-    p_QRDecode_Config.timeout = 30;
+    p_QRDecode_Config.flash_backup_addr = QR_FLASH_BACKUP_ADDR;
+    p_QRDecode_Config.timeout = timeout;
 
-    st7789_tft_clear(WHITE);
+    ST7789_TFT_Clear_White(0, 0, TFT_COL, TFT_ROW);
     QR_Enter_Ret = YC_QRDecode(&p_QRDecode_Config, &len, message);
-    MyPrintf("\nQR_Enter_Ret = %d", QR_Enter_Ret);
 
-    st7789_tft_clear(WHITE);
+    ST7789_TFT_Clear_White(0, 0, TFT_COL, TFT_ROW);
 
     if (QR_Enter_Ret ==  QR_SUCCESS)
     {
-        MyPrintf("\nEnterQRDecode End \r\n");
-        MyPrintf("len=%d\r\n", len);
-        message[len] = 0;
-        MyPrintf("message:%s\r\n", message);
+
+        UART_SendBuf(UART0, message, len);
         if (len > 250) show_messsage_len = 250;
         else show_messsage_len = len;
         ST7789_TFT_ShowString(0, 0, show_messsage_len * 12,  12, message, 24, 1, WHITE, OLIVE);
@@ -1917,35 +1924,36 @@
         BEEP_End();
         return;
     }
+
     switch (QR_Enter_Ret)
     {
-    case QR_CANCEL:
-        ST7789_TFT_ShowString(50, 100, 12 * sizeof("QR_CANCEL"), 12, "QR_CANCEL", 24, 1, WHITE, MAROON);
-        break;
-    case QR_CAMERA_PWM_INIT_FAIL:
-        ST7789_TFT_ShowString(50, 100, 12 * sizeof("QR_CAMERA_PWM_INIT_FAIL"), 12, "QR_CAMERA_PWM_INIT_FAIL", 24, 1, WHITE, MAROON);
-        break;
-    case QR_CAMERA_IIC_INIT_FAIL:
-        ST7789_TFT_ShowString(50, 100, 12 * sizeof("QR_CAMERA_IIC_INIT_FAIL"), 12, "QR_CAMERA_IIC_INIT_FAIL", 24, 1, WHITE, MAROON);
-        break;
-    case QR_CAMERA_OPEN_FAIL:
-        ST7789_TFT_ShowString(50, 100, 12 * sizeof("QR_CAMERA_OPEN_FAIL"), 12, "QR_CAMERA_OPEN_FAIL", 24, 1, WHITE, MAROON);
-        break;
-    case QR_CAMERA_READ_FAIL:
-        ST7789_TFT_ShowString(50, 100, 12 * sizeof("QR_CAMERA_READ_FAIL"), 12, "QR_CAMERA_READ_FAIL", 24, 1, WHITE, MAROON);
-        break;
-    case QR_KEY_PARA_FAIL:
-        ST7789_TFT_ShowString(50, 100, 12 * sizeof("QR_KEY_PARA_FAIL"), 12, "QR_KEY_PARA_FAIL", 24, 1, WHITE, MAROON);
-        break;
-    case QR_CANCEL_KEY:
-        ST7789_TFT_ShowString(50, 100, 12 * sizeof("QR_CANCEL_KEY"), 12, "QR_CANCEL_KEY", 24, 1, WHITE, MAROON);
-        break;
-    case QR_CANCEL_TIMEOUT:
-        ST7789_TFT_ShowString(50, 100, 12 * sizeof("QR_CANCEL_TIMEOUT"), 12, "QR_CANCEL_TIMEOUT", 24, 1, WHITE, MAROON);
-        break;
-    default:
-        ST7789_TFT_ShowString(50, 100, 12 * sizeof("UNUSUAL"), 21, "UNUSUAL", 24, 1, WHITE, MAROON);
-        break;
+        case QR_CANCEL:
+            ST7789_TFT_ShowString(50, 100, 12 * sizeof("QR_CANCEL"), 12, (uint8_t *)"QR_CANCEL", 24, 1, WHITE, MAROON);
+            break;
+        case QR_CAMERA_PWM_INIT_FAIL:
+            ST7789_TFT_ShowString(50, 100, 12 * sizeof("QR_CAMERA_PWM_INIT_FAIL"), 12, (uint8_t *)"QR_CAMERA_PWM_INIT_FAIL", 24, 1, WHITE, MAROON);
+            break;
+        case QR_CAMERA_IIC_INIT_FAIL:
+            ST7789_TFT_ShowString(50, 100, 12 * sizeof("QR_CAMERA_IIC_INIT_FAIL"), 12, (uint8_t *)"QR_CAMERA_IIC_INIT_FAIL", 24, 1, WHITE, MAROON);
+            break;
+        case QR_CAMERA_OPEN_FAIL:
+            ST7789_TFT_ShowString(50, 100, 12 * sizeof("QR_CAMERA_OPEN_FAIL"), 12, (uint8_t *)"QR_CAMERA_OPEN_FAIL", 24, 1, WHITE, MAROON);
+            break;
+        case QR_CAMERA_READ_FAIL:
+            ST7789_TFT_ShowString(50, 100, 12 * sizeof("QR_CAMERA_READ_FAIL"), 12, (uint8_t *)"QR_CAMERA_READ_FAIL", 24, 1, WHITE, MAROON);
+            break;
+        case QR_KEY_PARA_FAIL:
+            ST7789_TFT_ShowString(50, 100, 12 * sizeof("QR_KEY_PARA_FAIL"), 12, (uint8_t *)"QR_KEY_PARA_FAIL", 24, 1, WHITE, MAROON);
+            break;
+        case QR_CANCEL_KEY:
+            ST7789_TFT_ShowString(50, 100, 12 * sizeof("QR_CANCEL_KEY"), 12, (uint8_t *)"QR_CANCEL_KEY", 24, 1, WHITE, MAROON);
+            break;
+        case QR_CANCEL_TIMEOUT:
+            ST7789_TFT_ShowString(50, 100, 12 * sizeof("QR_CANCEL_TIMEOUT"), 12, (uint8_t *)"QR_CANCEL_TIMEOUT", 24, 1, WHITE, MAROON);
+            break;
+        default:
+            ST7789_TFT_ShowString(50, 100, 12 * sizeof("UNUSUAL"), 21, (uint8_t *)"UNUSUAL", 24, 1, WHITE, MAROON);
+            break;
     }
     ST7789_TFT_ShowChinese(100, 1, Yichip_ch, 24, 5, 1, WHITE, OLIVE);
     ST7789_TFT_Draw_Piece(0, 27, TFT_COL, 28, DGRAY);
@@ -1970,7 +1978,7 @@
     uint8_t keyCode;
     while (1)
     {
-        QRCode_test1();
+        QRCode_Enter(QR_SCAN_TIME_OUT);
         ST7789_TFT_ShowString(0, 200, sizeof("CANCEL             CONFIRM") * 12,  12, "CANCEL             CONFIRM", 24, 1, WHITE, OLIVE);
         while (1)
         {
@@ -1988,6 +1996,39 @@
     }
 }
 /*************************************************QR_Code end*****************************************************************/
+
+/*************************************************Touch start*****************************************************************/
+
+/* Private typedef -----------------------------------------------------------*/
+typedef enum
+{
+    PAGE0 = 0,
+    PAGE1,
+    PAGE2,
+    PAGE3
+} TP_MENU_TypeDef;
+/* Private define ------------------------------------------------------------*/
+
+#define TP_X_LEFT_BORDER     (14)
+#define TP_X_RIGHT_BORDER    (320 - TP_X_LEFT_BORDER)
+#define TP_Y_HIGT_BORDER     (35)
+#define TP_Y_LOW_BORDER      (240 - 16*3 - 5)
+
+#define TP_CLEAR_X_LEFT      (320/2 - 5*16/2)
+#define TP_CLEAR_Y_LEFT      (240 - 45)
+#define TP_CLEAR_X_RIGHT     (TP_CLEAR_X_LEFT + 16*5)
+#define TP_CLEAR_Y_RIGHT     (240)
+
+#define TP_EXIT_X_LEFT      (13)
+#define TP_EXIT_Y_LEFT      (240 - 45)
+#define TP_EXIT_X_RIGHT     (TP_EXIT_X_LEFT + 16*4)
+#define TP_EXIT_Y_RIGHT     (240)
+
+#define TP_SAVE_X_LEFT      (320 -13-16*4)
+#define TP_SAVE_Y_LEFT      (240 - 45)
+#define TP_SAVE_X_RIGHT     (TP_SAVE_X_LEFT + 16*4)
+#define TP_SAVE_Y_RIGHT     (240)
+
 /**
   * @brief  ADC initialization function.
   * @param  None
@@ -2001,218 +2042,219 @@
     ADC_Init(&ADCInitStruct);
 }
 
-#define GPIO_AD_MAXVALUE 0x7fe
-#define DIFFERENCE_X_MAX 80
-#define DIFFERENCE_Y_MAX 60
-
-extern struct TOUCH _touch;
-extern struct TOUCH_PANEl _touchpanel;
-
-static void Display_touch(void)
+static void Tp_menu(TP_MENU_TypeDef type)
 {
-    uint8_t cb_flag = 0;
-    uint8_t calibrated = 0;
-    uint8_t Difference_x = 0, Difference_y = 0;
-
-    ADC_Configuration();
-    //保存上拉检测的AD值
-    _touch.Adc_Max = GPIO_AD_MAXVALUE;
-
-    if (changeFlag == 0)
+    switch (type)
     {
+    case PAGE0 :
         ST7789_TFT_Clear_White(0, 28, TFT_COL, TFT_ROW);
         ST7789_TFT_ShowChinese(56, 36, calibrated_ch, 32, 7, 1, WHITE, RED);
         St7789_tft_DrawRectangle(115, 88, 205, 129, BLACK);
         ST7789_TFT_ShowChinese(136, 89, confirm_ch, 24, 2, 1, WHITE, MAROON);
-        ST7789_TFT_ShowString(132, 113,  56,  8, "CONFIRM", 16, 1, WHITE, MAROON);
+        ST7789_TFT_ShowString(132, 113,  56,  8, (uint8_t *)"CONFIRM", 16, 1, WHITE, MAROON);
         St7789_tft_DrawRectangle(115, 136, 205, 177, BLACK);
         ST7789_TFT_ShowChinese(136, 137, cancel_ch, 24, 2, 1, WHITE, MAROON);
-        ST7789_TFT_ShowString(136, 161,  48,  8, "CANCEL", 16, 1, WHITE, MAROON);
+        ST7789_TFT_ShowString(136, 161,  48,  8, (uint8_t *)"CANCEL", 16, 1, WHITE, MAROON);
         St7789_tft_DrawRectangle(115, 184, 205, 225, BLACK);
         ST7789_TFT_ShowChinese(136, 185, clear_ch, 24, 2, 1, WHITE, MAROON);
-        ST7789_TFT_ShowString(140, 209,  48,  8, "CLEAR", 16, 1, WHITE, MAROON);
-        cb_flag = 1;
-        KEY_Scan_check();
-    }
-    while (cb_flag)
-    {
-        switch (KEY_Scan())
+        ST7789_TFT_ShowString(140, 209,  48,  8, (uint8_t *)"CLEAR", 16, 1, WHITE, MAROON);
+        break;
+    case PAGE1 :
+        ST7789_TFT_ShowChinese(136, 89, confirm_ch, 24, 2, 0, YELLOW, MAROON);
+        ST7789_TFT_ShowString(132, 113,  56,  8, (uint8_t *)"CONFIRM", 16, 0, YELLOW, MAROON);
+        delay_ms(500);
+        ST7789_TFT_Clear_White(0, 28, TFT_COL, TFT_ROW);
+        break;
+    case PAGE2 :
+        ST7789_TFT_Clear_White(0, 28, TFT_COL, TFT_ROW);
+        for (uint8_t i = 0; i < 5 ; i++)
         {
-        case KEY_CONFIRM:
-            cb_flag = 0;
-            changeFlag = 1;
-            calibrated = 1;
-            ST7789_TFT_ShowChinese(136, 89, confirm_ch, 24, 2, 0, YELLOW, MAROON);
-            ST7789_TFT_ShowString(132, 113,  56,  8, "CONFIRM", 16, 0, YELLOW, MAROON);
-            KEY_Scan_check();
-            break;
-        case KEY_CANCEL:
-            cb_flag = 0;
-            changeFlag = 1;
-            ST7789_TFT_ShowChinese(136, 137, cancel_ch, 24, 2, 0, YELLOW, MAROON);
-            ST7789_TFT_ShowString(136, 161,  48,  8, "CANCEL", 16, 0, YELLOW, MAROON);
-            ST7789_TFT_Clear_White(0, 28, TFT_COL, TFT_ROW);
-#if 1
-            _touchpanel.xfac = 102;
-            _touchpanel.yfac = 84;
-            _touchpanel.xbase = 30;
-            _touchpanel.ybase = 30;
-            _touchpanel.xlogic = 29;
-            _touchpanel.ylogic = 83;
-#else
-            _touchpanel.xfac = 96;
-            _touchpanel.yfac = 114;
-            _touchpanel.xbase = 30;
-            _touchpanel.ybase = 30;
-            _touchpanel.xlogic = 51;
-            _touchpanel.ylogic = 26;
-#endif
-            St7789_tft_DrawRectangle(5, 60, 315, 180, RED);
-            St7789_tft_DrawRectangle(6, 61, 314, 179, RED);
-            St7789_tft_DrawRectangle(7, 62, 313, 178, RED);
-            St7789_tft_DrawRectangle(10, 240 - 5, 100, 240 - 50, BLACK);
-            St7789_tft_DrawRectangle(320 - 100, 240 - 5, 320 - 10, 240 - 50, BLACK);
-            ST7789_TFT_ShowString(10 + 3, 240 - 45, 80, 16, "Clear", 32, 1, WHITE, PURPLE);
-            ST7789_TFT_ShowString(320 - 95, 240 - 47, 64, 16, "Save", 32, 1, WHITE, PURPLE);
-            KEY_Scan_check();
-            break;
-        case KEY_CLEAR:
-            cb_flag = 0;
-            ST7789_TFT_ShowChinese(136, 185, clear_ch, 24, 2, 0, YELLOW, MAROON);
-            ST7789_TFT_ShowString(140, 209,  48,  8, "CLEAR", 16, 0, YELLOW, MAROON);
-            KEY_Scan_check();
-            break;
-        default:
-            break;
+            St7789_tft_DrawRectangle(1 + i, 29 + i, 318 - i, 240 - 16 * 3 - i, BLACK);
         }
+
+        ST7789_TFT_ShowString(320 - 13 - 16 * 4, 240 - 45, 16 * 4, 16, (uint8_t *)"Save", 32, 1, WHITE, PURPLE);
+        ST7789_TFT_ShowString(13, 240 - 45, 5 * 16, 16, (uint8_t *)"Exit", 32, 1, WHITE, PURPLE);
+        ST7789_TFT_ShowString(320 / 2 - 5 * 16 / 2, 240 - 45, 16 * 5, 16, (uint8_t *)"Clear", 32, 1, WHITE, PURPLE);
+        break;
+    case PAGE3 :
+        ST7789_TFT_ShowString(320 / 2 - 5 * 16 / 2, 240 - 45, 16 * 5, 16, (uint8_t *)"Clear", 32, 1, YELLOW, MAROON);
+        ST7789_TFT_Clear_White(5, 34, 313, 188);
+        ST7789_TFT_ShowString(320 / 2 - 5 * 16 / 2, 240 - 45, 16 * 5, 16, (uint8_t *)"Clear", 32, 1, WHITE, PURPLE);
+        break;
     }
+}
 
-    while (calibrated == 1)
+static Boolean Touch_Cali(void)
+{
+    uint8_t cal_cnt = 3;
+    uint8_t Show_buff1[] = "Calibration success";
+    uint8_t Show_buff2[] = "Calibration failure please recalibrate";
+    while (cal_cnt --)
     {
-        ST7789_TFT_Clear_White(0, 0, TFT_COL, TFT_ROW);
-        if (TP_UpdateCoordVal() == 1)
+        if (Tp_Calibrate() == TRUE)
         {
-            calibrated = 0;
-            St7789_tft_DrawRectangle(5, 60, 315, 180, RED);
-            St7789_tft_DrawRectangle(6, 61, 314, 179, RED);
-            St7789_tft_DrawRectangle(7, 62, 313, 178, RED);
-            St7789_tft_DrawRectangle(10, 240 - 5, 100, 240 - 50, BLACK);
-            St7789_tft_DrawRectangle(320 - 100, 240 - 5, 320 - 10, 240 - 50, BLACK);
-            ST7789_TFT_ShowString(10 + 3, 240 - 45, 80, 16, "Clear", 32, 1, WHITE, PURPLE);
-            ST7789_TFT_ShowString(320 - 95, 240 - 47, 64, 16, "Save", 32, 1, WHITE, PURPLE);
-
+            ST7789_TFT_Clear_White(0, 28, TFT_COL, TFT_ROW);
+            ST7789_TFT_ShowString(10, 80, 8 * sizeof(Show_buff1), 8, Show_buff1, 16, 1, WHITE, MAROON);
+            delay_ms(2000);
+            ST7789_TFT_Clear_White(0, 30, TFT_COL, TFT_ROW);
+            return TRUE;
         }
         else
         {
-            ST7789_TFT_ShowString(0, 100,  16 * 20,  16, "Calibration failure", 32, 1, YELLOW, MAROON);
+            ST7789_TFT_Clear_White(0, 28, TFT_COL, TFT_ROW);
+            ST7789_TFT_ShowString(10, 80, 8 * sizeof(Show_buff2), 8, Show_buff2, 16, 1, WHITE, MAROON);
             delay_ms(2000);
-            calibrated = 0;
-            changeFlag = 0;
+            ST7789_TFT_Clear_White(0, 28, TFT_COL, TFT_ROW);
         }
-
     }
-    if (changeFlag == 1)
+}
+
+static void Touch_Drow_Line(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey)
+{
+    St7899_tft_DrawLine(sx, sy, ex, ey, BLACK);
+    St7899_tft_DrawLine(sx - 1, sy, ex - 1, ey, BLACK);
+    St7899_tft_DrawLine(sx, sy + 1, ex, ey + 1, BLACK);
+    St7899_tft_DrawLine(sx + 1, sy, ex + 1, ey, BLACK);
+    St7899_tft_DrawLine(sx, sy - 1, ex, ey - 1, BLACK);
+}
+
+static void Touch_Display(void)
+{
+    uint8_t keyCode = 0;
+    Tp_Sign_Para_TypeDef Sign_Para = {0};
+
+    ADC_Configuration();
+
+    /*Select whether to calibrate*/
+
+    Tp_menu(PAGE0);
+    while (1)
     {
-        ST7789_TFT_ShowChinese(100, 1, Yichip_ch, 24, 5, 1, WHITE, OLIVE);
-        ST7789_TFT_Draw_Piece(0, 27, TFT_COL, 28, DGRAY);
-        TFT_Power_scan();
-        TFT_Single_scan();
+        keyCode = KEY_Scan();
+        if (keyCode == KEY_CONFIRM)
+        {
+            Tp_menu(PAGE1);
+            Touch_Cali();
+            break;
+        }
+        else if (keyCode == KEY_CANCEL)
+        {
+            /*Use the default calibration parameters*/
+            Constant.kx = TP_CONSTANT_X;
+            Constant.ky = TP_CONSTANT_Y;
+            fac.kx = TP_FAC_KX;
+            fac.ky = TP_FAC_KY;
+            break;
+        }
+        else if (keyCode == KEY_CLEAR)
+        {
+            return ;
+        }
     }
-    while (changeFlag == 1)
+
+    /*Start the signature*/
+
+    Tp_menu(PAGE2);
+
+    while (1)
     {
-        if (TP_DetectPressing() == 0)
+        if (Tp_DetectPressing() == TRUE)
         {
-            //读取物理坐标值
-            TP_ReadXY();
+            Tp_GetPoint(&Sign_Para.nx, &Sign_Para.ny);
+
+            TP_PRINT("Sign_Para.nx :%d,Sign_Para.ny :%d\n", Sign_Para.nx, Sign_Para.ny);
+            TP_PRINT("Sign_Para.lx :%d,Sign_Para.ly :%d\n", Sign_Para.lx, Sign_Para.ly);
 
-            if (TP_DetectPressing() == 1)
+            if (Tp_DetectPressing() == FALSE)
             {
-                _touch.PressAgainFalg = 0;
+                Sign_Para.pressflag = 0;
             }
-
-            //检测是否为连续按下的动作
-            if (_touch.PressAgainFalg == 2)
+            /*Continuous press*/
+            if (Sign_Para.pressflag == 2)
             {
-                //如果是连续按下的点，计算上个点与当前点的偏差
-                if (_touchpanel.x > _touchpanel.ltx) Difference_x = _touchpanel.x - _touchpanel.ltx;
-                else Difference_x = _touchpanel.ltx - _touchpanel.x;
-                if (_touchpanel.y > _touchpanel.lty) Difference_y = _touchpanel.y - _touchpanel.lty;
-                else Difference_y = _touchpanel.lty - _touchpanel.y;
-
-                //如果偏差属于范围内，用线与该点连接
-                if (Difference_x < DIFFERENCE_X_MAX && Difference_y < DIFFERENCE_Y_MAX && _touchpanel.y > 62 && _touchpanel.y < 178 && _touchpanel.x > 7 && _touchpanel.x < 313)
+                if (Sign_Para.nx > TP_X_LEFT_BORDER && Sign_Para.nx < TP_X_RIGHT_BORDER && \
+                        Sign_Para.ny > TP_Y_HIGT_BORDER && Sign_Para.ny < TP_Y_LOW_BORDER)
                 {
-                    St7899_tft_DrawLine(_touchpanel.ltx, _touchpanel.lty, _touchpanel.x, _touchpanel.y, BLACK);
-                    St7899_tft_DrawLine(_touchpanel.ltx - 1, _touchpanel.lty, _touchpanel.x - 1, _touchpanel.y, BLACK);
-                    St7899_tft_DrawLine(_touchpanel.ltx, _touchpanel.lty + 1, _touchpanel.x, _touchpanel.y + 1, BLACK);
-                    St7899_tft_DrawLine(_touchpanel.ltx + 1, _touchpanel.lty, _touchpanel.x + 1, _touchpanel.y, BLACK);
-                    St7899_tft_DrawLine(_touchpanel.ltx, _touchpanel.lty - 1, _touchpanel.x, _touchpanel.y - 1, BLACK);
-                    St7899_tft_DrawLine(_touchpanel.ltx + 2, _touchpanel.lty, _touchpanel.x + 2, _touchpanel.y, BLACK);
-                    St7899_tft_DrawLine(_touchpanel.ltx, _touchpanel.lty - 2, _touchpanel.x, _touchpanel.y - 2, BLACK);
-                    _touchpanel.ltx = _touchpanel.x;
-                    _touchpanel.lty = _touchpanel.y;
-                }
-                //如果偏差不属于范围内，但当前点在签名区域内，画出当前点
-                else if ((_touchpanel.y > 62 && _touchpanel.y < 178 && _touchpanel.x > 7 && _touchpanel.x < 313))
-                {
-                    _touchpanel.ltx = _touchpanel.x;
-                    _touchpanel.lty = _touchpanel.y;
+                    if (Tp_AbsolouteDifference(Sign_Para.nx, Sign_Para.lx) < 30 && Tp_AbsolouteDifference(Sign_Para.ny, Sign_Para.ly) < 30)
+                    {
+                        Touch_Drow_Line(Sign_Para.nx, Sign_Para.ny, Sign_Para.lx, Sign_Para.ly);
+                    }
+                    Sign_Para.lx = Sign_Para.nx;
+                    Sign_Para.ly = Sign_Para.ny;
                 }
-                // 弃点
-                else {}
+            }
+            /*first press*/
 
+            else if (Sign_Para.nx > TP_X_LEFT_BORDER && Sign_Para.nx < TP_X_RIGHT_BORDER && \
+                     Sign_Para.ny > TP_Y_HIGT_BORDER && Sign_Para.ny < TP_Y_LOW_BORDER)
+            {
+                Sign_Para.pressflag ++;
+                Sign_Para.lx = Sign_Para.nx;
+                Sign_Para.ly = Sign_Para.ny;
             }
-            //触摸到清屏
-            else if ((_touchpanel.x > 10 && _touchpanel.x < 100) && (_touchpanel.y < 235 && _touchpanel.y > 190))
+            /*press clear*/
+
+            else if (Sign_Para.nx > TP_CLEAR_X_LEFT && Sign_Para.nx < TP_CLEAR_X_RIGHT && \
+                     Sign_Para.ny > TP_CLEAR_Y_LEFT && Sign_Para.ny < TP_CLEAR_Y_RIGHT)
             {
-                St7789_tft_RectangleFill(10, 190, 100, 235, OLIVE);
-                ST7789_TFT_ShowString(13, 195, 80, 16, "Clear", 32, 1, WHITE, PURPLE);
-                ST7789_TFT_Clear_White(8, 63, 312, 177);
-                if (TP_DetectPressing() == 1)
-                {
-                    St7789_tft_RectangleFill(10, 190, 100, 235, WHITE);
-                    St7789_tft_DrawRectangle(10, 235, 100, 190, BLACK);
-                    ST7789_TFT_ShowString(13, 195, 80, 16, "Clear", 32, 1, WHITE, PURPLE);
-                }
-                St7789_tft_DrawRectangle(5, 60, 315, 180, RED);
-                St7789_tft_DrawRectangle(6, 61, 314, 179, RED);
-                St7789_tft_DrawRectangle(7, 62, 313, 178, RED);
-            }
-            else if ((_touchpanel.x > 220 && _touchpanel.x < 310) && (_touchpanel.y < 235 && _touchpanel.y > 190))
-            {
-                St7789_tft_RectangleFill(220, 190, 310, 235, OLIVE);
-                ST7789_TFT_ShowString(225, 193, 64, 16, "Save", 32, 1, WHITE, PURPLE);
-                ST7789_TFT_Clear_White(8, 63, 312, 177);
-                if (TP_DetectPressing() == 1)
-                {
-                    St7789_tft_RectangleFill(220, 190, 310, 235, WHITE);
-                    St7789_tft_DrawRectangle(220, 235, 310, 190, BLACK);
-                    ST7789_TFT_ShowString(225, 193, 128, 16, "Save", 32, 1, WHITE, PURPLE);
-                }
-                ST7789_TFT_ShowString(50, 80, 160, 16, "Saveing...", 32, 1, WHITE, OLIVE);
-                delay_ms(1000);
-                changeFlag = 0;
-                break;
+                Tp_menu(PAGE3);
             }
-            //第一次触摸
-            else if ((_touchpanel.y > 62 && _touchpanel.y < 178 && _touchpanel.x > 7 && _touchpanel.x < 313))
+            /*press exit*/
+
+            else if (Sign_Para.nx > TP_EXIT_X_LEFT && Sign_Para.nx < TP_EXIT_X_RIGHT && \
+                     Sign_Para.ny > TP_EXIT_Y_LEFT && Sign_Para.ny < TP_EXIT_Y_RIGHT)
             {
-                _touch.PressAgainFalg++;
-                _touchpanel.ltx = _touchpanel.x;
-                _touchpanel.lty = _touchpanel.y;
+                return ;
+            }
 
+            /*Save exit*/
+            else if (Sign_Para.nx > TP_SAVE_X_LEFT && Sign_Para.nx < TP_SAVE_X_RIGHT && \
+                     Sign_Para.ny > TP_SAVE_Y_LEFT && Sign_Para.ny < TP_SAVE_Y_RIGHT)
+            {
+                return ;
             }
-            else {}
         }
-        else _touch.PressAgainFalg = 0;
+        else
+        {
+            /*no press*/
+            Sign_Para.pressflag = 0;
+        }
     }
+}
 
-    ST7789_TFT_Clear_White(0, 28, TFT_COL, TFT_ROW);
-    Display_InterfaceWindow();
-    TFT_Power_scan();
-    TFT_Single_scan();
+static void Display_touch(void)
+{
+    uint8_t keyCode = 0;
+    uint8_t Show_buff2[] = "Whether or not to continue";
+    
+    while (1)
+    {
+        Touch_Display();
+        ST7789_TFT_Clear_White(0, 0, TFT_COL, TFT_ROW);
+        ST7789_TFT_ShowChinese(100, 1, Yichip_ch, 24, 5, 1, WHITE, OLIVE);
+        ST7789_TFT_Draw_Piece(0, 27, TFT_COL, 28, DGRAY);
+        TFT_Power_scan();
+        TFT_Single_scan();
+        ST7789_TFT_ShowString(10, 80, 8 * sizeof(Show_buff2), 8, Show_buff2, 16, 1, WHITE, MAROON);
+        ST7789_TFT_ShowString(0, 180, 20 * 16,  16, (uint8_t *)"CANCEL       CONFIRM", 32, 1, WHITE, OLIVE);
+        while (1)
+        {
+            keyCode = KEY_Scan();
+            if (keyCode == KEY_CANCEL)
+            {
+                Display_InterfaceWindow();
+                return;
+            }
+            else if (keyCode == KEY_CONFIRM)
+            {
+                break;
+            }
+        }
+    }
 }
 
+/*************************************************Touch end*****************************************************************/
+
 static void Display_expense(void)
 {
     uint8_t key = 0;
Index: ModuleDemo/QRDecode/QRDecode_lcd_demo/prj/GCC/makefile
===================================================================
--- /YC3121_demo/ModuleDemo/QRDecode/QRDecode_lcd_demo/prj/GCC/makefile	(revision 809)
+++ /YC3121_demo/ModuleDemo/QRDecode/QRDecode_lcd_demo/prj/GCC/makefile	(working copy)
@@ -145,9 +145,9 @@
 		
 	.data : AT (__etext)
 	{
+		__data_start__ = .;
 		*(.ARM.__at_0x00020000);
 		*(.ARM.__at_0x00020004);
-		__data_start__ = .;
 		*(vtable)
 		*(.data*)
 
Index: ModuleDemo/QRDecode/QRDecode_tft_demo/prj/GCC/makefile
===================================================================
--- /YC3121_demo/ModuleDemo/QRDecode/QRDecode_tft_demo/prj/GCC/makefile	(revision 809)
+++ /YC3121_demo/ModuleDemo/QRDecode/QRDecode_tft_demo/prj/GCC/makefile	(working copy)
@@ -144,9 +144,9 @@
 		
 	.data : AT (__etext)
 	{
+		__data_start__ = .;
 		*(.ARM.__at_0x00020000);
 		*(.ARM.__at_0x00020004);
-		__data_start__ = .;
 		*(vtable)
 		*(.data*)
 
