#include "user_config.h"
#include "esp_log.h"
#include "qr_encode.h"
#include "qr_consts.h"
#include "list.h"
#include "esp_timer.h"
static const char *LOG_TAG = "yc_paint";
#include "esp_sleep.h"
#include "user_sleep.h"
#include "esp_mac.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"

extern TERMINAL_INFO_T terminal_info;

int last_batt_precent;

#if 0
#define DISPLAY_BUFFER_SIZE   (480*648/8)
uint32_t display_size = DISPLAY_BUFFER_SIZE;
unsigned char tmp_paint_buf[480*81] = {0};
unsigned char last_paint_buf_left[480*81] = {0};
unsigned char last_paint_buf_right[480*81] = {0};
#else


#define DISPLAY_BUFFER_SIZE   (480*648/8)
uint32_t display_size = DISPLAY_BUFFER_SIZE;
unsigned char  tmp_paint_buf[480*81]={0};
unsigned char *last_paint_buf_left = NULL;
unsigned char *last_paint_buf_right= NULL;


static RTC_FAST_ATTR unsigned  int compressedSize   = 0;
static RTC_FAST_ATTR unsigned int decompressedSize =  0;




static RTC_FAST_ATTR unsigned int right_compressedSize   = 0;
static RTC_FAST_ATTR unsigned int right_decompressedSize = 0;



// #if 0  //压缩
//     int compressedSize = compressRLE(Paint_info.Image, 480*81, old_buffer);

//     printf(" src size = %d, zip size:%d\r\n",480*81,compressedSize);

//     memset((uint8_t*)tmp_paint_buf,0,sizeof(tmp_paint_buf));
  
//     int decompressedSize = decompressRLE(old_buffer, compressedSize, tmp_paint_buf);
//     printf("src size = %d unzip %d\r\n",480*81,decompressedSize);

// #endif


#endif
RTC_FAST_ATTR uint32_t arr_heights[6] = {0};


char str_operation[6] =     {0xd4,0xcb,0xd0,0xd0,0x00,0x00};//运行
char str_upKeep[6] =        {0xb1,0xa3,0xd1,0xf8,0x00,0x00};//保养
char str_shutDown[6] =      {0xcd,0xa3,0xbb,0xfa,0x00,0x00};//停机
char str_safeKeep[6] =      {0xb7,0xe2,0xb4,0xe6,0x00,0x00};//封存
char str_waitMaterials[6] = {0xb4,0xfd,0xc1,0xcf,0x00,0x00};//待料
char str_breakDown[6] =     {0xb9,0xca,0xd5,0xcf,0x00,0x00};//故障
char str_inspection[6] =    {0xd1,0xb2,0xbc,0xec,0x00,0x00};
char str_production[6] =    {0xc9,0xfa,0xb2,0xfa,0x00,0x00};
char str_repair[6]      =   {0xce,0xac,0xd0,0xde,0x00,0x00};


// char str_0[14] = {0xb9,0xdc,0x20,0x20,0xc0,0xed,0x20,0x20,0xd4,0xb1,0xa3,0xba,0x00,0x00};
// char str_1[14] = {0xc9,0xfa,0xb2,0xfa,0xd4,0xf0,0xc8,0xce,0xc8,0xcb,0xa3,0xba,0x00,0x00};
// char str_2[14] = {0xce,0xac,0xd0,0xde,0xd4,0xf0,0xc8,0xce,0xc8,0xcb,0xa3,0xba,0x00,0x00};
// char str_3[14] = {0xb1,0xa3,0xd1,0xf8,0xd4,0xf0,0xc8,0xce,0xc8,0xcb,0xa3,0xba,0x00,0x00};
// char str_4[14] = {0xd1,0xb2,0xbc,0xec,0xd4,0xf0,0xc8,0xce,0xc8,0xcb,0xa3,0xba,0x00,0x00};


bool isASCII(char c);
bool isGBKChinese(char c1, char c2);
void countCharacters(const char* str, int* chineseCount, int* asciiCount);
int calculateStringWidth(const char* str,int en_px,int cn_px);


static void QRGenerator(char* input);

void displayQRCode(int side, uint8_t* bitdata,int x,int y)
{
    int i = 0;int j = 0;int a = 0;
    for (i = 0; i < side; i++) 
    {
        for (j = 0; j < side; j++) 
        {
            a = j * side + i;
            if ((bitdata[a / 8] & (1 << (7 - a % 8)))) //画点
            {
                Paint_SetPixel(x+j, y+i, WHITE);//画一个点
                
            }
            else 
            {

            }  
        }
    }
}
static void QRGenerator(char* input)
{
    //printf("%s \n",(char*)input);
    int side;uint8_t bitdata[QR_MAX_BITDATA];
    // remove newline
    if (input[strlen(input) - 1] == '\n')
    {
        input[strlen(input) - 1] = 0;
    }

    side = qr_encode(QR_LEVEL_L, 0, input, 0, bitdata); //生成二维码
    //printf("总 %dx%d\n\nlen =%d\n", side, side,strlen((char*)bitdata)); //二维码大小

    memset(tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((UBYTE *)tmp_paint_buf, 40, 40, ROTATE_0, WHITE );
    displayQRCode(side,bitdata,0,0);
    epd_partial_cache(440,0,480,80,SCREEN_LEFT,Paint_info.Image);
}

void displayQRCode_expand(int side, uint8_t* bitdata,int x,int y,int expand)//expand 扩大边长的倍数
{
    int i = 0;int j = 0;int a = 0;
    for (i = 0; i < side; i++) 
    {
        for (j = 0; j < side; j++) 
        {
            a = j * side + i;
            if ((bitdata[a / 8] & (1 << (7 - a % 8)))) //画点
            {//Paint_SetPixel(x+j, y+i, WHITE);//画一个点

                Paint_DrawPoint(x+j*expand,y+i*expand,WHITE,DOT_PIXEL_2X2,DOT_FILL_RIGHTUP);
            }
            else 
            {
            } 
        }
    }
}







#include <stdio.h>
#include <stdbool.h>
#include <string.h>

// 函数用于判断字符是否是ASCII字符
bool isASCII(char c) {
    return (c >= 32 && c <= 126);
}

// 函数用于判断字符是否是GBK编码的汉字
bool isGBKChinese(char c1, char c2) {
    return (c1 >= 0x81 && c1 <= 0xFE && c2 >= 0x40 && c2 <= 0xFE);
}

// 统计字符串中GBK编码的汉字和ASCII字符的个数
void countCharacters(const char* str, int* chineseCount, int* asciiCount) {
    *chineseCount = 0;
    *asciiCount = 0;

    int len = strlen(str);

    for (int i = 0; i < len; i++) {
        char c1 = str[i];

        if (isASCII(c1)) {
            (*asciiCount)++;
        } else if (i + 1 < len) {
            char c2 = str[i + 1];

            if (isGBKChinese(c1, c2)) {
                (*chineseCount)++;
                i++; // 跳过下一个字节
            }
        }
    }
}



// 函数用于计算字符串的宽度
int calculateStringWidth(const char* str,int en_px,int cn_px) {
    int len=0;
    // if(str[0]==0)
    // {
    //     len = strlen(str+1);
    //     len++;
    // }
    // else
    // {
        len = strlen(str);
    // }

    int width = 0;

    for (int i = 0; i < len; i++) {
        // 判断字符是中文还是英文，并累加宽度
        if (str[i] >= 0 && str[i] <= 127) {
            // 英文字符
            width += en_px; // 假设英文字符宽度为12像素
        } else {
            // 中文字符
            width += cn_px; // 假设中文字符宽度为24像素
            i+=1;
        }
    }

    return width;
}


/*******下面是全屏缓冲区，快刷代码******/
// Function to calculate and return an array of bar chart heights
// Function to calculate and return an array of bar chart heights in pixels
// Function to calculate and return an array of bar chart heights in pixels
unsigned int* calculateBarChartHeights(unsigned int data[], int size, unsigned int chartHeight) {
    unsigned int max = data[0];
    for (int i = 1; i < size; i++) {
        if (data[i] > max) {
            max = data[i];
        }
    }

    // Allocate memory for the array of heights
    unsigned int* heights = (unsigned int*)malloc(size * sizeof(unsigned int));

    for (int i = 0; i < size; i++) {
        if(data[i] == 0)
        {
            heights[i] = 0; 
        }else if (data[i] == max) {
            // If data[i] is the maximum value, set height to chartHeight
            heights[i] = chartHeight;
        }else {
            // Calculate height in pixels based on proportion
            heights[i] = (unsigned int)(((double)data[i] / max) * chartHeight);
        }
    }

    return heights; // 返回高度数组
}



//获得百分比曲线高度，最大值10000，为100%.XXxx为XX. 。整数位XX.小数位xx。
unsigned int* getBarChartHeights(unsigned int data[], int size ,unsigned int chartHeight) {
    unsigned int* heights = (unsigned int*)malloc(size * sizeof(unsigned int));
    for (int i = 0; i < size; i++) {
        if(data[i] == 0)
        {
            heights[i] = 0;
        }
        else if(data[i]>0&&data[i]<10000)
        {
            heights[i] = (unsigned int)(((double)data[i] / 10000) * chartHeight);
        }
        else if(data[i] == 10000)
        {
            heights[i] = chartHeight;
        }
        else
        {
            ESP_LOGE(LOG_TAG,"ERR:>10000[%d]",i);
            heights[i] = 0;
        }
    }

    return heights; // 返回高度数组
}
//字符居中对齐
//参数：展示字符串，屏幕宽度，单个英文字符像素，单个中文字符像素
//返回值：字符展示开始位置
int center_align(char* str,int screenWidth,int en_px,int cn_px)
{
    //int chineseCount, asciiCount;
    //countCharacters(str, &chineseCount, &asciiCount);
    int textWidth = calculateStringWidth(str,en_px,cn_px);
    int x = (screenWidth - textWidth) / 2;
    return x;
}

static void QRGenerator_quick(char* input)
{
    //printf("%s \n",(char*)input);
    int side;uint8_t bitdata[QR_MAX_BITDATA];
    // remove newline
    if (input[strlen(input) - 1] == '\n')
    {
        input[strlen(input) - 1] = 0;
    }

    side = qr_encode(QR_LEVEL_L, 0, input, 0, bitdata); //生成二维码
    //printf("总 %dx%d\n\nlen =%d\n", side, side,strlen((char*)bitdata)); //二维码大小

    //memset(tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    //displayQRCode(side,bitdata,450,435);
    //displayQRCode(side,bitdata,500,435);
    displayQRCode_expand(side,bitdata,478,394,2);
}
static uint8_t* partial_bar_chart_07_02_quick(Machine_info_t* info);
static uint8_t* partial_bar_chart_07_03_quick(Machine_info_t* info);
static uint8_t* partial_bar_chart_07_04_quick(Machine_info_t* info);


//关机状态下显示充电图标和说明书逻辑
void dis_right_instructions()
{
    //右屏
    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((uint8_t*)tmp_paint_buf, 648, 480, ROTATE_270, WHITE);
    Paint_DrawBitMap_Paste(gImage_right_instruction, 0,0  ,480,648 ,1);

    if(!decection_state_0()) //判断充电中逻辑
    {

    #define BAT_X_OFFSET    2
    #define BAT_Y_OFFSET    2

    Paint_DrawBitMap_Paste((uint8_t*)gImage_battery      ,480-50-BAT_X_OFFSET,24,37,18,1 );

        switch (Machine_info.batt_precent)
        {
        case 0:
            break;
        case 1 ... 24:
        Paint_DrawRectangle(433 -BAT_X_OFFSET,27,439 -BAT_X_OFFSET,41,WHITE,1,1 );
            break;
        case 25 ... 49:
        Paint_DrawRectangle(433 -BAT_X_OFFSET,27,439-BAT_X_OFFSET,41,WHITE,1,1 );
        Paint_DrawRectangle(441-BAT_X_OFFSET,27,447-BAT_X_OFFSET,41,WHITE,1,1 );
            break;
        case 50 ... 74:
        Paint_DrawRectangle(433-BAT_X_OFFSET,27,439-BAT_X_OFFSET,41,WHITE,1,1 );
        Paint_DrawRectangle(441-BAT_X_OFFSET,27,447-BAT_X_OFFSET,41,WHITE,1,1 );
        Paint_DrawRectangle(449-BAT_X_OFFSET,27,455-BAT_X_OFFSET,41,WHITE,1,1 );
            break;
        case 75 ... 100:
        Paint_DrawRectangle(433-BAT_X_OFFSET,27,439-BAT_X_OFFSET,41,WHITE,1,1 );
        Paint_DrawRectangle(441-BAT_X_OFFSET,27,447-BAT_X_OFFSET,41,WHITE,1,1 );
        Paint_DrawRectangle(449-BAT_X_OFFSET,27,455-BAT_X_OFFSET,41,WHITE,1,1 );
        Paint_DrawRectangle(457-BAT_X_OFFSET,27,462-BAT_X_OFFSET,41,WHITE,1,1 );
            break;
        default:
            ESP_LOGE(LOG_TAG,"err:batt_precent = %d",Machine_info.batt_precent);
            break;
        }


        Machine_info.batt_precent =  read_battery_voltage();
        if(Machine_info.batt_precent >=95)
        {
            Paint_DrawBitMap_Paste((uint8_t*)gImage_charging      ,480-47+37,27 - BAT_Y_OFFSET,8,18,1 );
        }
        else
        {
            Paint_DrawBitMap_Paste((uint8_t*)gImage_charging     ,480-47+35,27 - BAT_Y_OFFSET,8,18,1 );
        }
    }


#if 1
    epd_init_cmd(SCREEN_RIGHT);
    epd_display(SCREEN_RIGHT,Paint_info.Image);  
#else
    epd_cache_quick(SCREEN_RIGHT,(uint8_t*)last_paint_buf_right,Paint_info.Image);
    epd_powerOn_refresh_sleep(SCREEN_RIGHT);
#endif

    memcpy(last_paint_buf_right,Paint_info.Image,sizeof(uint8_t)*648*480/8);
    // int ret = memcmp(last_paint_buf_right,Paint_info.Image,38880);
    // ESP_LOGW(LOG_TAG,"memcmp :ret = %d",ret);
    if(memcmp(last_paint_buf_right,Paint_info.Image,38880))
    {
        ESP_LOGE(LOG_TAG,"err:last_paint_buf_right");
    }
    Machine_info.last_batt_precent = Machine_info.batt_precent;//右屏刷完后记录电池电量

}
void dis_instructions()
{
    ESP_LOGW(LOG_TAG,"dis_instructions");
    //左屏

    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((uint8_t*)tmp_paint_buf, 648, 480, ROTATE_180, WHITE);

    Paint_DrawBitMap_Paste(gImage_left_instructions, 0,0  ,648,480 ,1);

    //qrcode
    char qrcode_string[1024]= {0};
    qrcode_protocol_create(qrcode_string,Machine_info);
    QRGenerator_quick(qrcode_string);

    Paint_DrawBitMap_Paste((uint8_t*)gImage_nfc     ,573,215,44,44,1 );

    epd_init_cmd(SCREEN_LEFT);
    epd_display(SCREEN_LEFT,Paint_info.Image);  
    memcpy(last_paint_buf_left,Paint_info.Image,sizeof(uint8_t)*648*480/8);
    // int ret = memcmp(last_paint_buf_left,Paint_info.Image,38880);
    // ESP_LOGW(LOG_TAG,"memcmp :ret = %d",ret);
    if(memcmp(last_paint_buf_left,Paint_info.Image,38880))
    {
        ESP_LOGE(LOG_TAG,"err:last_paint_buf_left");
    }


//右屏
    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((uint8_t*)tmp_paint_buf, 648, 480, ROTATE_270, WHITE);
    Paint_DrawBitMap_Paste(gImage_right_instruction, 0,0  ,480,648 ,1);

    if(!decection_state_0()) //判断充电中逻辑
    {

        #define BAT_X_OFFSET    2
        #define BAT_Y_OFFSET    2

        Paint_DrawBitMap_Paste((uint8_t*)gImage_battery      ,480-50-BAT_X_OFFSET,24,37,18,1 );
        ESP_LOGW(LOG_TAG,"判断充电中逻辑batt_precent = %d",Machine_info.batt_precent);


        switch (Machine_info.batt_precent)
        {
        case 0:
            break;
        case 1 ... 24:
        Paint_DrawRectangle(433 -BAT_X_OFFSET,27,439 -BAT_X_OFFSET,41,WHITE,1,1 );
            break;
        case 25 ... 49:
        Paint_DrawRectangle(433 -BAT_X_OFFSET,27,439-BAT_X_OFFSET,41,WHITE,1,1 );
        Paint_DrawRectangle(441-BAT_X_OFFSET,27,447-BAT_X_OFFSET,41,WHITE,1,1 );
            break;
        case 50 ... 74:
        Paint_DrawRectangle(433-BAT_X_OFFSET,27,439-BAT_X_OFFSET,41,WHITE,1,1 );
        Paint_DrawRectangle(441-BAT_X_OFFSET,27,447-BAT_X_OFFSET,41,WHITE,1,1 );
        Paint_DrawRectangle(449-BAT_X_OFFSET,27,455-BAT_X_OFFSET,41,WHITE,1,1 );
            break;
        case 75 ... 99:
        Paint_DrawRectangle(433-BAT_X_OFFSET,27,439-BAT_X_OFFSET,41,WHITE,1,1 );
        Paint_DrawRectangle(441-BAT_X_OFFSET,27,447-BAT_X_OFFSET,41,WHITE,1,1 );
        Paint_DrawRectangle(449-BAT_X_OFFSET,27,455-BAT_X_OFFSET,41,WHITE,1,1 );
        Paint_DrawRectangle(457-BAT_X_OFFSET,27,462-BAT_X_OFFSET,41,WHITE,1,1 );
            break;
        case 100:
        Paint_DrawRectangle(433-BAT_X_OFFSET,27,439-BAT_X_OFFSET,41,WHITE,1,1 );
        Paint_DrawRectangle(441-BAT_X_OFFSET,27,447-BAT_X_OFFSET,41,WHITE,1,1 );
        Paint_DrawRectangle(449-BAT_X_OFFSET,27,455-BAT_X_OFFSET,41,WHITE,1,1 );
        Paint_DrawRectangle(457-BAT_X_OFFSET,27,462-BAT_X_OFFSET,41,WHITE,1,1 );
            break;
        default:
            break;
        }


        Machine_info.batt_precent =  read_battery_voltage();
        if(Machine_info.batt_precent >=95)
        {
            Paint_DrawBitMap_Paste((uint8_t*)gImage_filled      ,480-47+37,27 - BAT_Y_OFFSET,8,18,1 );
        }
        else
        {
            Paint_DrawBitMap_Paste((uint8_t*)gImage_charging     ,480-47+35,27 - BAT_Y_OFFSET,8,18,1 );
        }
    }else
    {

        if(read_battery_voltage()<10)
        {
            Paint_DrawBitMap_Paste(gImage_low_batt, 30,428 ,420,154,1); //低电量请充电
        }

    }

        epd_init_cmd(SCREEN_RIGHT);
        epd_display(SCREEN_RIGHT,Paint_info.Image);  

        memcpy(last_paint_buf_right,Paint_info.Image,sizeof(uint8_t)*648*480/8);
        if(memcmp(last_paint_buf_right,Paint_info.Image,38880))
        {
            ESP_LOGE(LOG_TAG,"err:last_paint_buf_right");
        }
}
void Paint_leftScreen_main_powerOn(void)
{
    printf("Paint_leftScreen_main_powerOn\r\n");

     //当前未配对进入出厂模式


   //当前系统的状态 关机 未配网
    if( /*(!Machine_info.paired) &&*/(!Machine_info.power_status))
    {
        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 648, 480, ROTATE_180, WHITE);

        Paint_DrawBitMap_Paste(gImage_left_instructions, 0,0  ,648,480 ,1);

        //qrcode
        char qrcode_string[1024]= {0};
        qrcode_protocol_create(qrcode_string,Machine_info);
        QRGenerator_quick(qrcode_string);

        Paint_DrawBitMap_Paste((uint8_t*)gImage_nfc     ,573,215,44,44,1 );
        #if DEVOP_TEST
            // char btn_test[] = {0x00,0x6f,0x00,0x6b,0x00,0x00};
            // //int x = center_align(&btn_test,128,64,64);
            // Paint_DrawRectangle(400,0,528,64,WHITE,1,1);
            // Paint_DrawString_CN64(400,0,(char*)btn_test );


            char  mac_addr[20]={0};

            esp_read_mac((uint8_t *)Machine_info.mac_addr, ESP_MAC_WIFI_STA);

            sprintf(mac_addr,"%02X:%02X:%02X:%02X:%02X:%02X",
            Machine_info.mac_addr[0],
            Machine_info.mac_addr[1],
            Machine_info.mac_addr[2],
            Machine_info.mac_addr[3],
            Machine_info.mac_addr[4],
            Machine_info.mac_addr[5]
            );
            
            //Paint_DrawRectangle(30+10+350,250-timeHeights[5],30+10+50+350,250,WHITE,1,1 );
            //Paint_DrawString_CN(30+10+8+350, 250+8,(char*)str_waitMaterials, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
            Paint_DrawString_EN(0,0,(char *)mac_addr, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );

            char  version[20]={0};

            sprintf(version,"version = %d.%d",
            MAJOR_VERSION,SECOND_VERSION
            );


            Paint_DrawString_EN(0,24,(char *)version, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );
        #endif



        epd_init_cmd(SCREEN_LEFT);
        epd_display(SCREEN_LEFT,Paint_info.Image);  
        memcpy(last_paint_buf_left,Paint_info.Image,sizeof(uint8_t)*648*480/8);
        // int ret = memcmp(last_paint_buf_left,Paint_info.Image,38880);
        // ESP_LOGW(LOG_TAG,"memcmp :ret = %d",ret);
        if(memcmp(last_paint_buf_left,Paint_info.Image,38880))
        {
            ESP_LOGE(LOG_TAG,"err:last_paint_buf_left");
        }






        
#if 0//USER_DEEP_SLEEP_ENABLE


        int  reson = is_wake_up_reson();  //返回唤醒的原因
        if ((reson != ESP_SLEEP_WAKEUP_ULP) && (reson != ESP_SLEEP_WAKEUP_TIMER)) 
        {

                uint8_t *old_buffer= heap_caps_malloc(480*81, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);  //申请内存

                memset(old_buffer,0x00,480*81);
                //memset((uint8_t*)last_paint_buf_left,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
              //压缩
                compressedSize = compressRLE(last_paint_buf_left, 480*81, old_buffer);
                // printf(" src size = %d, zip size:%d\r\n",480*81,compressedSize);
                //memset((uint8_t*)tmp_paint_buf,0,sizeof(tmp_paint_buf));
            


                //button_deinit();
                //写入数据
                left_spiffs_write(old_buffer,compressedSize);
                //button_init(adc1_handle);

                

                free(old_buffer);

        } 
#endif






    }
    else  //不是出厂模式
    {

    //得到图像buf
    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 32, ROTATE_0, WHITE);
    Paint_DrawString_CN(0,0,(char*)str_operation,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND );
    uint8_t* operation_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
    memcpy(operation_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);

    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((uint8_t*)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
    Paint_DrawBitMap_Paste(operation_64x32_buf,16,8,64,32,1);
    uint8_t* operation_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
    memcpy(operation_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);

    //str_shutDown
    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_90, WHITE);
    Paint_DrawString_CN(0,0,(char*)str_shutDown,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
    uint8_t* shutDown_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
    memcpy(shutDown_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);

    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
    Paint_DrawBitMap_Paste(shutDown_64x32_buf,8,16,32,64,1);
    uint8_t* shutDown_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
    memcpy(shutDown_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);

    //str_breakDown
    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_90, WHITE);
    Paint_DrawString_CN(0,0,(char*)str_breakDown,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
    uint8_t* breakDown_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
    memcpy(breakDown_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);

    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
    Paint_DrawBitMap_Paste(breakDown_64x32_buf,8,16,32,64,1);
    uint8_t* breakDown_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
    memcpy(breakDown_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);

    //str_safeKeep
    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 32, ROTATE_0, WHITE);
    Paint_DrawString_CN(0,0,(char*)str_safeKeep,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
    uint8_t* safeKeep_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
    memcpy(safeKeep_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);

    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((uint8_t*)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
    Paint_DrawBitMap_Paste(safeKeep_64x32_buf,16,8,64,32,1);
    uint8_t* safeKeep_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
    memcpy(safeKeep_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);

    //str_upKeep
    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_270, WHITE);
    Paint_DrawString_CN(0,0,(char*)str_upKeep,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
    uint8_t* upKeep_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
    memcpy(upKeep_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);

    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
    Paint_DrawBitMap_Paste(upKeep_64x32_buf,8,16,32,64,1);
    uint8_t* upKeep_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
    memcpy(upKeep_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);

    //str_waitMaterials
    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_270, WHITE);
    Paint_DrawString_CN(0,0,(char*)str_waitMaterials,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
    uint8_t* waitMaterials_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
    memcpy(waitMaterials_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);

    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
    Paint_DrawBitMap_Paste(waitMaterials_64x32_buf,8,16,32,64,1);
    uint8_t* waitMaterials_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
    memcpy(waitMaterials_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);

    uint8_t* image_320x384_buf = (uint8_t*)calloc(320*384/8,sizeof(uint8_t));

    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((uint8_t*)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
    Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);   
    Paint_DrawString_CN(16,8,(char*)str_operation,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND); 
    memcpy(operation_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);

    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_0, WHITE);
    Paint_DrawBitMap_Paste((uint8_t*)gImage_mid_,0,0,320,384,1);
    Paint_DrawString_CN64(96,160,(char*)str_operation );
    memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);


    //---
    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((uint8_t*)tmp_paint_buf, 648, 480, ROTATE_180, WHITE);


    //  
    Paint_DrawBitMap_Paste(operation_background_96x48_buf,      272,0  ,96 ,48 ,1);
    Paint_DrawBitMap_Paste(shutDown_background_96x48_buf,       600,48 ,48 ,96 ,1);
    Paint_DrawBitMap_Paste(breakDown_background_96x48_buf,      600,336,48 ,96 ,1);
    Paint_DrawBitMap_Paste(safeKeep_background_96x48_buf,       272,432,96 ,48 ,1);
    Paint_DrawBitMap_Paste(upKeep_background_96x48_buf,         0  ,336,48 ,96 ,1);
    Paint_DrawBitMap_Paste(waitMaterials_background_96x48_buf,  0  ,48 ,48 ,96 ,1);
    Paint_DrawBitMap_Paste(image_320x384_buf,   164,48 ,320,384,1);
    Paint_DrawBitMap_Paste((uint8_t*)gImage_nfc     ,573,215,44,44,1 );

    //qrcode
    char qrcode_string[1024]= {0};
    qrcode_protocol_create(qrcode_string,Machine_info);
    QRGenerator_quick(qrcode_string);


#if DEVOP_TEST
    char  mac_addr[20]={0};
  



	esp_read_mac((uint8_t *)Machine_info.mac_addr, ESP_MAC_WIFI_STA);

      sprintf(mac_addr,"%02X:%02X:%02X:%02X:%02X:%02X",
    Machine_info.mac_addr[0],
    Machine_info.mac_addr[1],
    Machine_info.mac_addr[2],
    Machine_info.mac_addr[3],
    Machine_info.mac_addr[4],
    Machine_info.mac_addr[5]
    );
    
    //Paint_DrawRectangle(30+10+350,250-timeHeights[5],30+10+50+350,250,WHITE,1,1 );
    //Paint_DrawString_CN(30+10+8+350, 250+8,(char*)str_waitMaterials, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(0,0,(char *)mac_addr, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );


    char  version[20]={0};

    sprintf(version,"version = %d.%d",
    MAJOR_VERSION,SECOND_VERSION
    );


    Paint_DrawString_EN(0,24,(char *)version, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );
#endif









    epd_init_cmd(SCREEN_LEFT);
    epd_display(SCREEN_LEFT,Paint_info.Image);
    memcpy(last_paint_buf_left,Paint_info.Image,sizeof(uint8_t)*648*480/8);
    // int ret = memcmp(last_paint_buf_left,Paint_info.Image,38880);
    // ESP_LOGW(LOG_TAG,"memcmp :ret = %d",ret);
    if(memcmp(last_paint_buf_left,Paint_info.Image,38880))
    {
        ESP_LOGE(LOG_TAG,"err:last_paint_buf_left");
    }


    free(operation_64x32_buf);
    free(shutDown_64x32_buf);
    free(breakDown_64x32_buf);
    free(upKeep_64x32_buf);
    free(safeKeep_64x32_buf);
    free(waitMaterials_64x32_buf);

    free(image_320x384_buf);

    free(operation_background_96x48_buf);
    free(shutDown_background_96x48_buf);
    free(breakDown_background_96x48_buf);
    free(upKeep_background_96x48_buf);
    free(safeKeep_background_96x48_buf);
    free(waitMaterials_background_96x48_buf);





#if 0//USER_DEEP_SLEEP_ENABLE


        int  reson = is_wake_up_reson();  //返回唤醒的原因
        if ((reson != ESP_SLEEP_WAKEUP_ULP) && (reson != ESP_SLEEP_WAKEUP_TIMER)) 
        {

                uint8_t *old_buffer= heap_caps_malloc(480*81, MALLOC_CAP_8BIT|MALLOC_CAP_SPIRAM);  //申请内存

                memset(old_buffer,0x00,480*81);
                //memset((uint8_t*)last_paint_buf_left,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                #if 1  //压缩
                compressedSize = compressRLE(last_paint_buf_left, 480*81, old_buffer);
                // printf(" src size = %d, zip size:%d\r\n",480*81,compressedSize);
                //memset((uint8_t*)tmp_paint_buf,0,sizeof(tmp_paint_buf));
            


                //button_deinit();
                //写入数据
                left_spiffs_write(old_buffer,compressedSize);
                //button_init(adc1_handle);

                

                free(old_buffer);

        } 
#endif




#endif



    }

 
}




void Paint_leftScreen_main_slow(Machine_info_t* info)
{

       printf("Paint_leftScreen_main_slow\r\n");
    // set_button_anotherName();
    int x = 0;//居中偏移
    //先利用NewImage,得到各个部分的图像buf
    //再画图
    
    uint8_t* image_320x384_buf = (uint8_t*)calloc(320*384/8,sizeof(uint8_t));
#if 1
    uint8_t* tmp = NULL;
    switch (Machine_info.left_display_mode)
    {
    case 0x00:
        //ESP_LOGW(LOG_TAG,"left_display_mode 0x01:");
        break;

    case 0x01:
        /* code */
        tmp = partial_bar_chart_07_02_quick(info);
        break;

    case 0x02:
        /* code */
        tmp = partial_bar_chart_07_03_quick(info);
        break;

    case 0x03:
        /* code */
        tmp = partial_bar_chart_07_04_quick(info);
        break;

    default:
        break;
    }
#else
    tmp = partial_bar_chart_07_04_quick(info);
#endif

        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 32, ROTATE_0, WHITE);
        x = center_align(&Machine_info.btn_operation,64,16,32);
        Paint_DrawString_CN(0+x,0,(char*)Machine_info.btn_operation,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND );
        uint8_t* operation_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
        memcpy(operation_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);

        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
        Paint_DrawBitMap_Paste(operation_64x32_buf,16,8,64,32,1);
        uint8_t* operation_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
        memcpy(operation_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
        free(operation_64x32_buf);


        //str_shutDown
        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_90, WHITE);
        x = center_align(&Machine_info.btn_shutDown_info,64,16,32);
        Paint_DrawString_CN(0,0,(char*)Machine_info.btn_shutDown_info,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
        uint8_t* shutDown_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
        memcpy(shutDown_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);

        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
        Paint_DrawBitMap_Paste(shutDown_64x32_buf,8,16,32,64,1);
        uint8_t* shutDown_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
        memcpy(shutDown_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
        free(shutDown_64x32_buf);

        //str_breakDown
        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_90, WHITE);
        x = center_align(&Machine_info.btn_breakDown_info,64,16,32);
        Paint_DrawString_CN(0,0,(char*)Machine_info.btn_breakDown_info,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
        uint8_t* breakDown_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
        memcpy(breakDown_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);

        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
        Paint_DrawBitMap_Paste(breakDown_64x32_buf,8,16,32,64,1);
        uint8_t* breakDown_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
        memcpy(breakDown_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
        free(breakDown_64x32_buf);

        //str_safeKeep
        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 32, ROTATE_0, WHITE);
        x = center_align(&Machine_info.btn_safeKeep_info,64,16,32);
        Paint_DrawString_CN(0,0,(char*)Machine_info.btn_safeKeep_info,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
        uint8_t* safeKeep_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
        memcpy(safeKeep_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);

        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
        Paint_DrawBitMap_Paste(safeKeep_64x32_buf,16,8,64,32,1);
        uint8_t* safeKeep_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
        memcpy(safeKeep_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
        free(safeKeep_64x32_buf);

        //str_upKeep
        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_270, WHITE);
        x = center_align(&Machine_info.btn_upKeep_info,64,16,32);
        Paint_DrawString_CN(0,0,(char*)Machine_info.btn_upKeep_info,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
        uint8_t* upKeep_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
        memcpy(upKeep_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);

        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
        Paint_DrawBitMap_Paste(upKeep_64x32_buf,8,16,32,64,1);
        uint8_t* upKeep_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
        memcpy(upKeep_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
        free(upKeep_64x32_buf);

        //str_waitMaterials
        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_270, WHITE);
        x = center_align(&Machine_info.btn_waitMaterials_info,64,16,32);
        Paint_DrawString_CN(0,0,(char*)Machine_info.btn_waitMaterials_info,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
        uint8_t* waitMaterials_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
        memcpy(waitMaterials_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);

        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
        Paint_DrawBitMap_Paste(waitMaterials_64x32_buf,8,16,32,64,1);
        uint8_t* waitMaterials_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
        memcpy(waitMaterials_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
        free(waitMaterials_64x32_buf);


        uint8_t* background_128x64_buf = (uint8_t*)calloc(128*64/8,sizeof(uint8_t));
    //得到图像buf
        ESP_LOGW(LOG_TAG,"----------------Machine_info.left_state = %d-------left_display_mode =%d -------\r\n",Machine_info.left_state,Machine_info.left_display_mode);


    switch (Machine_info.left_state)
    {
    case STATE_NONE:
    case STATE_OPERATION:
        {
            if(Machine_info.left_display_mode==0)
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);   
                x = center_align(&Machine_info.btn_operation,64,16,32);
                Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_operation,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND); 
                memcpy(operation_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);

                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_0, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_mid_,0,0,320,384,1);
                x = center_align(&Machine_info.btn_operation,128,64,64);
                Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_operation );
                memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
            }
            else
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 128, 64, ROTATE_0, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);   
                x = center_align(&Machine_info.btn_operation,96,24,48);
                // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_operation,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND); 
                Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_operation,false);
                memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);

            }

            
        }
        break;
    case STATE_SHUT_DOWN:
        {
            if(Machine_info.left_display_mode==0)
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_90, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);
                x = center_align(&Machine_info.btn_shutDown_info,64,16,32);
                Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_shutDown_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
                memcpy(shutDown_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);

                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_0, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_right_,0,0,320,384,1);
                x = center_align(&Machine_info.btn_shutDown_info,128,64,64);
                Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_shutDown_info );
                memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
            }
            else
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 128, ROTATE_90, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);
                x = center_align(&Machine_info.btn_shutDown_info,96,24,48);
                // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_shutDown_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
                Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_shutDown_info,false);
                memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);

            }
        }
        break;
    case STATE_BREAKDOWN:
        {
            if(Machine_info.left_display_mode==0)
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_90, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);
                x = center_align(&Machine_info.btn_breakDown_info,64,16,32);
                Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_breakDown_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
                memcpy(breakDown_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
                        
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_180, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_left_,0,0,320,384,1);
                memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);

                Paint_NewImage(image_320x384_buf, 320, 384, ROTATE_0, WHITE);
                x = center_align(&Machine_info.btn_breakDown_info,128,64,64);
                Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_breakDown_info );
                memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
            }
            else
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 64,128, ROTATE_90, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);
                x = center_align(&Machine_info.btn_breakDown_info,96,24,48);
                // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_breakDown_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
                Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_breakDown_info,false);
                memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);
            }

        }
        break;
    case STATE_SAFEKEEP:
        {
            if(Machine_info.left_display_mode==0)
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);   
                x = center_align(&Machine_info.btn_safeKeep_info,64,16,32);
                Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_safeKeep_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND); 
                memcpy(safeKeep_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);

                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_180, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_mid_,0,0,320,384,1);
                memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);

                Paint_NewImage(image_320x384_buf, 320, 384, ROTATE_0, WHITE);
                x = center_align(&Machine_info.btn_safeKeep_info,128,64,64);
                Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_safeKeep_info );
                memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
            }
            else
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 128, 64, ROTATE_0, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);   
                x = center_align(&Machine_info.btn_safeKeep_info,96,24,48);
                // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_safeKeep_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND); 
                Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_safeKeep_info,false);
                memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);
            }

        }
        break;
    case STATE_UPKEEP:
        {
            if(Machine_info.left_display_mode==0)
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_270, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);
                x = center_align(&Machine_info.btn_upKeep_info,64,16,32);
                Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_upKeep_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
                memcpy(upKeep_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);

                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_180, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_right_,0,0,320,384,1);
                memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);

                Paint_NewImage(image_320x384_buf, 320, 384, ROTATE_0, WHITE);
                x = center_align(&Machine_info.btn_upKeep_info,128,64,64);
                Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_upKeep_info );
                memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
            }
            else
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 128, ROTATE_270, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);
                x = center_align(&Machine_info.btn_upKeep_info,96,24,48);
                // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_upKeep_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
                Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_upKeep_info,false);
                memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);
            }

        }
        break;
    case STATE_WAIT_MATERIALS:
        {
            if(Machine_info.left_display_mode==0)
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_270, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);
                x = center_align(&Machine_info.btn_waitMaterials_info,64,16,32);
                Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_waitMaterials_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
                memcpy(waitMaterials_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);//黑底白字

                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_0, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_left_,0,0,320,384,1);
                x = center_align(&Machine_info.btn_waitMaterials_info,128,64,64);
                Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_waitMaterials_info );
                memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
            }
            else
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 128, ROTATE_270, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);
                x = center_align(&Machine_info.btn_waitMaterials_info,96,24,48);
                // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_waitMaterials_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
                Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_waitMaterials_info,false);
                memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);//黑底白字
            }

        }
        break;    
    default:
        ESP_LOGE(LOG_TAG," err: (info->left_state)");
        break;
    }
        //画图
        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 648, 480, ROTATE_180, WHITE);

        Paint_DrawBitMap_Paste(operation_background_96x48_buf,      272,0  ,96 ,48 ,1);
        Paint_DrawBitMap_Paste(shutDown_background_96x48_buf,       600,48 ,48 ,96 ,1);
        Paint_DrawBitMap_Paste(breakDown_background_96x48_buf,      600,336,48 ,96 ,1);
        Paint_DrawBitMap_Paste(safeKeep_background_96x48_buf,       272,432,96 ,48 ,1);
        Paint_DrawBitMap_Paste(upKeep_background_96x48_buf,         0  ,336,48 ,96 ,1);
        Paint_DrawBitMap_Paste(waitMaterials_background_96x48_buf,  0  ,48 ,48 ,96 ,1);

        free(operation_background_96x48_buf);
        free(shutDown_background_96x48_buf);
        free(breakDown_background_96x48_buf);
        free(upKeep_background_96x48_buf);
        free(safeKeep_background_96x48_buf);
        free(waitMaterials_background_96x48_buf);

        if(Machine_info.left_display_mode!=0)
        {
            switch (Machine_info.left_state)
            {
            case STATE_NONE:
            case STATE_OPERATION:
                Paint_DrawBitMap_Paste(background_128x64_buf,      272-16,0      ,128 ,64 ,1);
                break;
            case STATE_SHUT_DOWN:
                Paint_DrawBitMap_Paste(background_128x64_buf,       600-16,48-8     ,64 ,128 ,1);
                break;
            case STATE_BREAKDOWN:
                Paint_DrawBitMap_Paste(background_128x64_buf,      600-16,336-8    ,64 ,128 ,1);
                break;
            case STATE_SAFEKEEP:
                Paint_DrawBitMap_Paste(background_128x64_buf,       272-16,432-16    ,128 ,64 ,1);
                break;
            case STATE_UPKEEP:
                Paint_DrawBitMap_Paste(background_128x64_buf,         0  ,336-16    ,64 ,128 ,1);
                break;
            case STATE_WAIT_MATERIALS:
                Paint_DrawBitMap_Paste(background_128x64_buf,  0  ,48-16     ,64 ,128 ,1);
                break;
            default:
                break;
            }
        }

        free(background_128x64_buf);


    Paint_DrawBitMap_Paste((uint8_t*)gImage_nfc     ,573,215,44,44,1 );

#if 0
    if((info->left_display_mode == 0x01) || (info->left_display_mode == 0x00) )
#else
    if((info->left_display_mode == 0x00) )
#endif
    {
        Paint_DrawBitMap_Paste(image_320x384_buf,   164,48 ,320,384,1);
    }
    else
    {
        Paint_DrawBitMap_Paste(tmp,  84  ,90 ,480 ,300 ,1);//648-480 168
        free(tmp);
    }
    



    //qrcode
    char qrcode_string[1024]= {0};
    qrcode_protocol_create(qrcode_string,Machine_info);
    QRGenerator_quick(qrcode_string);
    //  

// printf("btn_operation = %s\r\n",Machine_info.btn_operation);
// printf("btn_breakDown_info = %s\r\n",Machine_info.btn_breakDown_info);
// printf("btn_upKeep_info = %s\r\n",Machine_info.btn_upKeep_info);
// printf("btn_shutDown_info = %s\r\n",Machine_info.btn_shutDown_info);
// printf("btn_safeKeep_info = %s\r\n",Machine_info.btn_safeKeep_info);
// printf("btn_waitMaterials_info = %s\r\n",Machine_info.btn_operation);




#if USER_DEEP_SLEEP_ENABLE


    uint8_t *old_buffer= heap_caps_malloc(compressedSize, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL|MALLOC_CAP_DMA);  //申请内存
    if(old_buffer == NULL)
    {
        printf("buffer malloc fail\r\n");
    }
    memset(old_buffer,0x00,compressedSize);




    if ((reson == ESP_SLEEP_WAKEUP_ULP) || (reson == ESP_SLEEP_WAKEUP_TIMER)) 
    {
        //读取数据到内存
        left_spiffs_read(old_buffer,compressedSize);

        //解压数据
        decompressedSize = decompressRLE(old_buffer, compressedSize, last_paint_buf_left);
        printf("src size = %d unzip %d\r\n",compressedSize,decompressedSize);

    }

#endif



   epd_init_cmd(SCREEN_LEFT);
   epd_display(SCREEN_LEFT,Paint_info.Image);  


#if USER_DEEP_SLEEP_ENABLE
    if ((reson == !ESP_SLEEP_WAKEUP_ULP) || (reson != ESP_SLEEP_WAKEUP_TIMER)) 
#endif    
    {

            //last buf
            memcpy(last_paint_buf_left,Paint_info.Image,sizeof(uint8_t)*648*480/8);
            if(memcmp(last_paint_buf_left,Paint_info.Image,38880))
            {
                ESP_LOGE(LOG_TAG,"err:last_paint_buf_left");
            }
    }





        

#if 0//USER_DEEP_SLEEP_ENABLE
    int  reson = is_wake_up_reson();  //返回唤醒的原因
    if ((reson == ESP_SLEEP_WAKEUP_ULP) || (reson == ESP_SLEEP_WAKEUP_TIMER) ||(reson == ESP_SLEEP_WAKEUP_EXT0)) 

        {
            compressedSize = compressRLE(Paint_info.Image, 480*81, last_paint_buf_left);
            // printf(" src size = %d, zip size:%d\r\n",480*81,compressedSize);
            //memset((uint8_t*)tmp_paint_buf,0,sizeof(tmp_paint_buf));
            //button_deinit();
            //写入数据
            left_spiffs_write(last_paint_buf_left,compressedSize);
            //button_init(adc1_handle);
        }


    //free(old_buffer);


#endif



//int  reson = is_wake_up_reson();  //返回唤醒的原



#if USER_DEEP_SLEEP_ENABLE
 if ((reson == ESP_SLEEP_WAKEUP_ULP) || (reson == ESP_SLEEP_WAKEUP_TIMER)) 
 {
   deepsleep_epd_powerOn_refresh_sleep(SCREEN_LEFT);
 }
#endif  

    free(image_320x384_buf);


}


void Paint_leftScreen_main_quick(Machine_info_t* info)
{
     printf("Paint_leftScreen_main_quick\r\n");
    // set_button_anotherName();
    int x = 0;//居中偏移
    //先利用NewImage,得到各个部分的图像buf
    //再画图
    uint8_t* image_320x384_buf = (uint8_t*)calloc(320*384/8,sizeof(uint8_t));
#if 1
    uint8_t* tmp = NULL;
    switch (Machine_info.left_display_mode)
    {
    case 0x00:
        //ESP_LOGW(LOG_TAG,"left_display_mode 0x01:");
        break;

    case 0x01:
        /* code */
        tmp = partial_bar_chart_07_02_quick(info);
        break;

    case 0x02:
        /* code */
        tmp = partial_bar_chart_07_03_quick(info);
        break;

    case 0x03:
        /* code */
        tmp = partial_bar_chart_07_04_quick(info);
        break;

    default:
        break;
    }
#else
    tmp = partial_bar_chart_07_04_quick(info);
#endif

        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 32, ROTATE_0, WHITE);
        x = center_align(&Machine_info.btn_operation,64,16,32);
        Paint_DrawString_CN(0+x,0,(char*)Machine_info.btn_operation,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND );
        uint8_t* operation_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
        memcpy(operation_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);

        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
        Paint_DrawBitMap_Paste(operation_64x32_buf,16,8,64,32,1);
        uint8_t* operation_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
        memcpy(operation_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
        free(operation_64x32_buf);


        //str_shutDown
        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_90, WHITE);
        x = center_align(&Machine_info.btn_shutDown_info,64,16,32);
        Paint_DrawString_CN(0,0,(char*)Machine_info.btn_shutDown_info,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
        uint8_t* shutDown_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
        memcpy(shutDown_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);

        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
        Paint_DrawBitMap_Paste(shutDown_64x32_buf,8,16,32,64,1);
        uint8_t* shutDown_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
        memcpy(shutDown_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
        free(shutDown_64x32_buf);

        //str_breakDown
        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_90, WHITE);
        x = center_align(&Machine_info.btn_breakDown_info,64,16,32);
        Paint_DrawString_CN(0,0,(char*)Machine_info.btn_breakDown_info,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
        uint8_t* breakDown_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
        memcpy(breakDown_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);

        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
        Paint_DrawBitMap_Paste(breakDown_64x32_buf,8,16,32,64,1);
        uint8_t* breakDown_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
        memcpy(breakDown_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
        free(breakDown_64x32_buf);

        //str_safeKeep
        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 32, ROTATE_0, WHITE);
        x = center_align(&Machine_info.btn_safeKeep_info,64,16,32);
        Paint_DrawString_CN(0,0,(char*)Machine_info.btn_safeKeep_info,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
        uint8_t* safeKeep_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
        memcpy(safeKeep_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);

        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
        Paint_DrawBitMap_Paste(safeKeep_64x32_buf,16,8,64,32,1);
        uint8_t* safeKeep_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
        memcpy(safeKeep_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
        free(safeKeep_64x32_buf);

        //str_upKeep
        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_270, WHITE);
        x = center_align(&Machine_info.btn_upKeep_info,64,16,32);
        Paint_DrawString_CN(0,0,(char*)Machine_info.btn_upKeep_info,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
        uint8_t* upKeep_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
        memcpy(upKeep_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);

        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
        Paint_DrawBitMap_Paste(upKeep_64x32_buf,8,16,32,64,1);
        uint8_t* upKeep_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
        memcpy(upKeep_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
        free(upKeep_64x32_buf);

        //str_waitMaterials
        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_270, WHITE);
        x = center_align(&Machine_info.btn_waitMaterials_info,64,16,32);
        Paint_DrawString_CN(0,0,(char*)Machine_info.btn_waitMaterials_info,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
        uint8_t* waitMaterials_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
        memcpy(waitMaterials_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);

        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
        Paint_DrawBitMap_Paste(waitMaterials_64x32_buf,8,16,32,64,1);
        uint8_t* waitMaterials_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
        memcpy(waitMaterials_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
        free(waitMaterials_64x32_buf);


        uint8_t* background_128x64_buf = (uint8_t*)calloc(128*64/8,sizeof(uint8_t));
    //得到图像buf
        ESP_LOGW(LOG_TAG,"----------------Machine_info.left_state = %d-------left_display_mode =%d -------\r\n",Machine_info.left_state,Machine_info.left_display_mode);

    switch (Machine_info.left_state)
    {
    case STATE_NONE:
    case STATE_OPERATION:
        {
            if(Machine_info.left_display_mode==0)
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);   
                x = center_align(&Machine_info.btn_operation,64,16,32);
                Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_operation,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND); 
                memcpy(operation_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);

                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_0, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_mid_,0,0,320,384,1);
                x = center_align(&Machine_info.btn_operation,128,64,64);
                Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_operation );
                memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
            }
            else
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 128, 64, ROTATE_0, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);   
                x = center_align(&Machine_info.btn_operation,96,24,48);
                // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_operation,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND); 
                Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_operation,false);
                memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);
            }
        }
        break;
    case STATE_SHUT_DOWN:
        {
            if(Machine_info.left_display_mode==0)
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_90, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);
                x = center_align(&Machine_info.btn_shutDown_info,64,16,32);
                Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_shutDown_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
                memcpy(shutDown_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);

                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_0, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_right_,0,0,320,384,1);
                x = center_align(&Machine_info.btn_shutDown_info,128,64,64);
                Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_shutDown_info );
                memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
            }
            else
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 128, ROTATE_90, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);
                x = center_align(&Machine_info.btn_shutDown_info,96,24,48);
                // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_shutDown_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
                Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_shutDown_info,false);
                memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);

            }
        }
        break;
    case STATE_BREAKDOWN:
        {
            if(Machine_info.left_display_mode==0)
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_90, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);
                x = center_align(&Machine_info.btn_breakDown_info,64,16,32);
                Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_breakDown_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
                memcpy(breakDown_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
                        
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_180, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_left_,0,0,320,384,1);
                memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);

                Paint_NewImage(image_320x384_buf, 320, 384, ROTATE_0, WHITE);
                x = center_align(&Machine_info.btn_breakDown_info,128,64,64);
                Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_breakDown_info );
                memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
            }
            else
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 64,128, ROTATE_90, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);
                x = center_align(&Machine_info.btn_breakDown_info,96,24,48);
                // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_breakDown_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
                Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_breakDown_info,false);
                memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);
            }

        }
        break;
    case STATE_SAFEKEEP:
        {
            if(Machine_info.left_display_mode==0)
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);   
                x = center_align(&Machine_info.btn_safeKeep_info,64,16,32);
                Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_safeKeep_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND); 
                memcpy(safeKeep_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);

                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_180, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_mid_,0,0,320,384,1);
                memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);

                Paint_NewImage(image_320x384_buf, 320, 384, ROTATE_0, WHITE);
                x = center_align(&Machine_info.btn_safeKeep_info,128,64,64);
                Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_safeKeep_info );
                memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
            }
            else
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 128, 64, ROTATE_0, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);   
                x = center_align(&Machine_info.btn_safeKeep_info,96,24,48);
                // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_safeKeep_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND); 
                Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_safeKeep_info,false);
                memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);
            }

        }
        break;
    case STATE_UPKEEP:
        {
            if(Machine_info.left_display_mode==0)
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_270, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);
                x = center_align(&Machine_info.btn_upKeep_info,64,16,32);
                Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_upKeep_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
                memcpy(upKeep_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);

                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_180, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_right_,0,0,320,384,1);
                memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);

                Paint_NewImage(image_320x384_buf, 320, 384, ROTATE_0, WHITE);
                x = center_align(&Machine_info.btn_upKeep_info,128,64,64);
                Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_upKeep_info );
                memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
            }
            else
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 128, ROTATE_270, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);
                x = center_align(&Machine_info.btn_upKeep_info,96,24,48);
                // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_upKeep_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
                Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_upKeep_info,false);
                memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);
            }
        }
        break;
    case STATE_WAIT_MATERIALS:
        {
            if(Machine_info.left_display_mode==0)
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_270, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);
                x = center_align(&Machine_info.btn_waitMaterials_info,64,16,32);
                Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_waitMaterials_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
                memcpy(waitMaterials_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);//黑底白字

                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_0, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_left_,0,0,320,384,1);
                x = center_align(&Machine_info.btn_waitMaterials_info,128,64,64);
                Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_waitMaterials_info );
                memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
            }
            else
            {
                memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 128, ROTATE_270, WHITE);
                Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);
                x = center_align(&Machine_info.btn_waitMaterials_info,96,24,48);
                // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_waitMaterials_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
                Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_waitMaterials_info,false);
                memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);//黑底白字
            }

        }
        break;    
    default:
        ESP_LOGE(LOG_TAG," err: (info->left_state)");
        break;
    }
        //画图
        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 648, 480, ROTATE_180, WHITE);

        Paint_DrawBitMap_Paste(operation_background_96x48_buf,      272,0  ,96 ,48 ,1);
        Paint_DrawBitMap_Paste(shutDown_background_96x48_buf,       600,48 ,48 ,96 ,1);
        Paint_DrawBitMap_Paste(breakDown_background_96x48_buf,      600,336,48 ,96 ,1);
        Paint_DrawBitMap_Paste(safeKeep_background_96x48_buf,       272,432,96 ,48 ,1);
        Paint_DrawBitMap_Paste(upKeep_background_96x48_buf,         0  ,336,48 ,96 ,1);
        Paint_DrawBitMap_Paste(waitMaterials_background_96x48_buf,  0  ,48 ,48 ,96 ,1);

        free(operation_background_96x48_buf);
        free(shutDown_background_96x48_buf);
        free(breakDown_background_96x48_buf);
        free(upKeep_background_96x48_buf);
        free(safeKeep_background_96x48_buf);
        free(waitMaterials_background_96x48_buf);

        if(Machine_info.left_display_mode!=0)
        {
            switch (Machine_info.left_state)
            {
            case STATE_NONE:
            case STATE_OPERATION:
                Paint_DrawBitMap_Paste(background_128x64_buf,      272-16,0      ,128 ,64 ,1);
                break;
            case STATE_SHUT_DOWN:
                Paint_DrawBitMap_Paste(background_128x64_buf,       600-16,48-8     ,64 ,128 ,1);
                break;
            case STATE_BREAKDOWN:
                Paint_DrawBitMap_Paste(background_128x64_buf,      600-16,336-8    ,64 ,128 ,1);
                break;
            case STATE_SAFEKEEP:
                Paint_DrawBitMap_Paste(background_128x64_buf,       272-16,432-16    ,128 ,64 ,1);
                break;
            case STATE_UPKEEP:
                Paint_DrawBitMap_Paste(background_128x64_buf,         0  ,336-16    ,64 ,128 ,1);
                break;
            case STATE_WAIT_MATERIALS:
                Paint_DrawBitMap_Paste(background_128x64_buf,  0  ,48-16     ,64 ,128 ,1);
                break;
            default:
                break;
            }
        }

        free(background_128x64_buf);


    Paint_DrawBitMap_Paste((uint8_t*)gImage_nfc     ,573,215,44,44,1 );

#if 0
    if((info->left_display_mode == 0x01) || (info->left_display_mode == 0x00) )
#else
    if((info->left_display_mode == 0x00) )
#endif
    {
        Paint_DrawBitMap_Paste(image_320x384_buf,   164,48 ,320,384,1);
    }
    else
    {
        Paint_DrawBitMap_Paste(tmp,  84  ,90 ,480 ,300 ,1);//648-480 168
        free(tmp);
    }
    



    //qrcode
    char qrcode_string[1024]= {0};
    qrcode_protocol_create(qrcode_string,Machine_info);
    QRGenerator_quick(qrcode_string);
    //  

// printf("btn_operation = %s\r\n",Machine_info.btn_operation);
// printf("btn_breakDown_info = %s\r\n",Machine_info.btn_breakDown_info);
// printf("btn_upKeep_info = %s\r\n",Machine_info.btn_upKeep_info);
// printf("btn_shutDown_info = %s\r\n",Machine_info.btn_shutDown_info);
// printf("btn_safeKeep_info = %s\r\n",Machine_info.btn_safeKeep_info);
// printf("btn_waitMaterials_info = %s\r\n",Machine_info.btn_operation);




#if 0//USER_DEEP_SLEEP_ENABLE
    printf("free_heap_size:%ld \r\n free_internal_heap_size:%ld \r\n minimum_free_heap_size:%ld\r\n",\
    esp_get_free_heap_size(),esp_get_free_internal_heap_size(),esp_get_minimum_free_heap_size());
    printf("compressedSize size =%d\r\n",compressedSize);
    uint8_t *old_buffer= heap_caps_malloc(compressedSize, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);  //申请内存
    if(old_buffer == NULL)
    {
        printf("buffer malloc fail\r\n");
    }
    memset(old_buffer,0x00,compressedSize);



int  reson = is_wake_up_reson();  //返回唤醒的原

    if ((reson == ESP_SLEEP_WAKEUP_ULP) || (reson == ESP_SLEEP_WAKEUP_TIMER)) 
    {
        //读取数据到内存
        left_spiffs_read(old_buffer,compressedSize);

        //解压数据
        decompressedSize = decompressRLE(old_buffer, compressedSize, last_paint_buf_left);
        // printf("src size = %d unzip %d\r\n",compressedSize,decompressedSize);

    }

#endif



bool ret = epd_cache_quick(SCREEN_LEFT,(uint8_t*)last_paint_buf_left,Paint_info.Image);
epd_powerOn_refresh_sleep(SCREEN_LEFT);


#if 0//USER_DEEP_SLEEP_ENABLE
    if ((reson == !ESP_SLEEP_WAKEUP_ULP) || (reson != ESP_SLEEP_WAKEUP_TIMER)) 
#endif    
    if(ret)
    {
        //last buf

        memcpy(last_paint_buf_left,Paint_info.Image,sizeof(uint8_t)*648*480/8);
        // int ret = memcmp(last_paint_buf_left,Paint_info.Image,38880);
        // ESP_LOGW(LOG_TAG,"memcmp :ret = %d",ret);
        if(memcmp(last_paint_buf_left,Paint_info.Image,38880))
        {
            ESP_LOGE(LOG_TAG,"err:last_paint_buf_left");
        }
    }
    else
    {
        ESP_LOGE(LOG_TAG,"不保存上一帧");
    }






#if 0//USER_DEEP_SLEEP_ENABLE

    if ((reson == ESP_SLEEP_WAKEUP_ULP) || (reson == ESP_SLEEP_WAKEUP_TIMER)) 
        {
            compressedSize = compressRLE(Paint_info.Image, 480*81, last_paint_buf_left);
            // printf(" src size = %d, zip size:%d\r\n",480*81,compressedSize);
            //memset((uint8_t*)tmp_paint_buf,0,sizeof(tmp_paint_buf));
            //button_deinit();
            //写入数据
            left_spiffs_write(last_paint_buf_left,compressedSize);
            //button_init(adc1_handle);
        }


    free(old_buffer);


#endif

    free(image_320x384_buf);


}

static uint8_t* partial_bar_chart_07_02_quick(Machine_info_t* info)
{
#if 0
    // extern Node *clockIn_list;
    // int production_num =    countClockNodes_byCMD(clockIn_list,0x00);
    // int repair_num =        countClockNodes_byCMD(clockIn_list,0x01);
    // int inspection_num =    countClockNodes_byCMD(clockIn_list,0x02);
    // int upKeep_num =        countClockNodes_byCMD(clockIn_list,0x03);
#else
    //签到人数只加不减
    // int production_num =    Machine_info.personnel_check_in[0];
    // int repair_num =        Machine_info.personnel_check_in[1];
    // int inspection_num =    Machine_info.personnel_check_in[2];
    // int upKeep_num =        Machine_info.personnel_check_in[3];

#endif
    char arr_string[20];
    uint32_t arr_num[4] = {Machine_info.checkIn_set[0].number,Machine_info.checkIn_set[1].number,Machine_info.checkIn_set[2].number,Machine_info.checkIn_set[3].number};
    unsigned int* numHeights = calculateBarChartHeights(arr_num,4,200);

    ESP_LOGW(LOG_TAG,"当前在岗：%ld ,%ld,%ld,%ld",arr_num[0],arr_num[1],arr_num[2],arr_num[3]);

    uint8_t* bar_chart_07_02_buf = (uint8_t*)calloc(480*300/8,sizeof(uint8_t));//free();
    

    memset(tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((uint8_t *)tmp_paint_buf, 480, 300, ROTATE_0, WHITE );

    Paint_DrawLine(40,250,440,250,WHITE,DOT_PIXEL_2X2,LINE_STYLE_SOLID );


// S:screen 
// R:rectangle 
// C:CN 
// E:EN 
// L:LINE
//ITV:(interval)
#define BAR_LINE_Y_POS  250
#define BAR_CHART_Y_MAX   250
#define BAR_CHART_Y_MIN   50
#define BAR_07_02_S_L_ITV      40
#define BAR_07_02_L_R_ITV       18
#define BAR_07_02_R_R_ITV      100
#define BAR_07_02_R_WIDTH       64
#define BAR_07_02_C_SKEW        2
#define BAR_07_02_E_SKEW        (24+4)


#define BAR_07_02_R1  (BAR_07_02_S_L_ITV+BAR_07_02_L_R_ITV)
#define BAR_07_02_C1  (BAR_07_02_R1+BAR_07_02_C_SKEW)
#define BAR_07_02_E1  (BAR_07_02_C1)

#define BAR_07_02_R2  (BAR_07_02_R1+BAR_07_02_R_R_ITV)
#define BAR_07_02_C2  (BAR_07_02_C1+BAR_07_02_R_R_ITV)
#define BAR_07_02_E2  (BAR_07_02_E1+BAR_07_02_R_R_ITV)

#define BAR_07_02_R3  (BAR_07_02_R2+BAR_07_02_R_R_ITV)
#define BAR_07_02_C3  (BAR_07_02_C2+BAR_07_02_R_R_ITV)
#define BAR_07_02_E3  (BAR_07_02_E2+BAR_07_02_R_R_ITV)

#define BAR_07_02_R4  (BAR_07_02_R3+BAR_07_02_R_R_ITV)
#define BAR_07_02_C4  (BAR_07_02_C3+BAR_07_02_R_R_ITV)
#define BAR_07_02_E4  (BAR_07_02_E3+BAR_07_02_R_R_ITV)


    char tmp_12[4][6] = {0};
    char tmp_34[4][6] = {0};

    memcpy(tmp_12[0],Machine_info.checkIn_set[0].other_name,4);
    memcpy(tmp_34[0],Machine_info.checkIn_set[0].other_name+4,4);

    memcpy(tmp_12[1],Machine_info.checkIn_set[1].other_name,4);
    memcpy(tmp_34[1],Machine_info.checkIn_set[1].other_name+4,4);

    memcpy(tmp_12[2],Machine_info.checkIn_set[2].other_name,4);
    memcpy(tmp_34[2],Machine_info.checkIn_set[2].other_name+4,4);

    memcpy(tmp_12[3],Machine_info.checkIn_set[3].other_name,4);
    memcpy(tmp_34[3],Machine_info.checkIn_set[3].other_name+4,4);

    memset(arr_string,0,20);
    itoa(arr_num[0],arr_string,10);
    Paint_DrawRectangle(BAR_07_02_R1,BAR_LINE_Y_POS-numHeights[0],BAR_07_02_R1+BAR_07_02_R_WIDTH,BAR_LINE_Y_POS,WHITE,1,1 );
    // Paint_DrawString_CN(BAR_07_02_C1, BAR_LINE_Y_POS+BAR_07_02_C_SKEW,(char*)str_production, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(BAR_07_02_C1, BAR_LINE_Y_POS+BAR_07_02_C_SKEW,tmp_12[0], &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(BAR_07_02_C1, BAR_LINE_Y_POS+BAR_07_02_C_SKEW+24,tmp_34[0], &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(BAR_07_02_E1,BAR_LINE_Y_POS-BAR_07_02_E_SKEW-numHeights[0],(char*)arr_string, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );



    memset(arr_string,0,20);
    itoa(arr_num[1],arr_string,10);
    Paint_DrawRectangle(BAR_07_02_R2,BAR_LINE_Y_POS-numHeights[1],BAR_07_02_R2+BAR_07_02_R_WIDTH,BAR_LINE_Y_POS,WHITE,1,1 );
    // Paint_DrawString_CN(BAR_07_02_C2, BAR_LINE_Y_POS+BAR_07_02_C_SKEW, (char*)str_repair, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(BAR_07_02_C2, BAR_LINE_Y_POS+BAR_07_02_C_SKEW, tmp_12[1], &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(BAR_07_02_C2, BAR_LINE_Y_POS+BAR_07_02_C_SKEW+24, tmp_34[1], &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(BAR_07_02_E2,BAR_LINE_Y_POS-BAR_07_02_E_SKEW-numHeights[1],(char*)arr_string, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );

    memset(arr_string,0,20);
    itoa(arr_num[2],arr_string,10);
    Paint_DrawRectangle(BAR_07_02_R3,BAR_LINE_Y_POS-numHeights[2],BAR_07_02_R3+BAR_07_02_R_WIDTH,BAR_LINE_Y_POS,WHITE,1,1 );
    // Paint_DrawString_CN(BAR_07_02_C3, BAR_LINE_Y_POS+BAR_07_02_C_SKEW, (char*)str_inspection, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(BAR_07_02_C3, BAR_LINE_Y_POS+BAR_07_02_C_SKEW, tmp_12[2], &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(BAR_07_02_C3, BAR_LINE_Y_POS+BAR_07_02_C_SKEW+24, tmp_34[2], &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(BAR_07_02_E3,BAR_LINE_Y_POS-BAR_07_02_E_SKEW-numHeights[2],(char*)arr_string, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );

    
    memset(arr_string,0,20);
    itoa(arr_num[3],arr_string,10);
    Paint_DrawRectangle(BAR_07_02_R4,BAR_LINE_Y_POS-numHeights[3],BAR_07_02_R4+BAR_07_02_R_WIDTH,BAR_LINE_Y_POS,WHITE,1,1 );
    // Paint_DrawString_CN(BAR_07_02_C4, BAR_LINE_Y_POS+BAR_07_02_C_SKEW, (char*)str_upKeep, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(BAR_07_02_C4, BAR_LINE_Y_POS+BAR_07_02_C_SKEW, tmp_12[3], &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(BAR_07_02_C4, BAR_LINE_Y_POS+BAR_07_02_C_SKEW+24, tmp_34[3], &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(BAR_07_02_E4,BAR_LINE_Y_POS-BAR_07_02_E_SKEW-numHeights[3],(char*)arr_string, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );
    



    memcpy(bar_chart_07_02_buf,Paint_info.Image,sizeof(uint8_t)*480*300/8);


    free(numHeights);
    return bar_chart_07_02_buf;
}

static uint8_t* partial_bar_chart_07_03_quick(Machine_info_t* info)
{
    char arr_string[20];

    uint32_t* timeHeights = calculateBarChartHeights(arr_heights,6,200);

    uint8_t* bar_chart_07_03_buf = (uint8_t*)calloc(480*300/8,sizeof(uint8_t));
    memset(tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((UBYTE *)tmp_paint_buf, 480, 300, ROTATE_0, WHITE );
    Paint_DrawLine(30,250,450,250,WHITE,DOT_PIXEL_2X2,LINE_STYLE_SOLID );

    memset(arr_string,0,20);
    itoa(arr_heights[0],arr_string,10);
    Paint_DrawRectangle(30+10,250-timeHeights[0],30+10+50,250,WHITE,1,1 );
    //Paint_DrawString_CN(30+10+8, 250+8,(char*)str_operation, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(30+10+8, 250+8,(char*)Machine_info.btn_operation, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(30+10+8,250-timeHeights[0]-4-24,arr_string, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );

    memset(arr_string,0,20);
    itoa(arr_heights[1],arr_string,10);
    Paint_DrawRectangle(30+10+70,250-timeHeights[1],30+10+50+70,250,WHITE,1,1 );
    // Paint_DrawString_CN(30+10+8+70, 250+8,(char*)str_shutDown, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(30+10+8+70, 250+8,(char*)Machine_info.btn_shutDown_info, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(30+10+8+70,250-timeHeights[1]-4-24,arr_string, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );


    memset(arr_string,0,20);
    itoa(arr_heights[2],arr_string,10);
    Paint_DrawRectangle(30+10+140,250-timeHeights[2],30+10+50+140,250,WHITE,1,1 );
    // Paint_DrawString_CN(30+10+8+140, 250+8,(char*)str_breakDown, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(30+10+8+140, 250+8,(char*)Machine_info.btn_breakDown_info, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(30+10+8+140,250-timeHeights[2]-4-24,arr_string, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );


    memset(arr_string,0,20);
    itoa(arr_heights[3],arr_string,10);
    Paint_DrawRectangle(30+10+210,250-timeHeights[3],30+10+50+210,250,WHITE,1,1 );
    // Paint_DrawString_CN(30+10+8+210, 250+8,(char*)str_safeKeep, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(30+10+8+210, 250+8,(char*)Machine_info.btn_safeKeep_info, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(30+10+8+210, 250-timeHeights[3]-4-24,arr_string, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );



    memset(arr_string,0,20);
    itoa(arr_heights[4],arr_string,10);
    Paint_DrawRectangle(30+10+280,250-timeHeights[4],30+10+50+280,250,WHITE,1,1 );
    //Paint_DrawString_CN(30+10+8+280, 250+8,(char*)str_upKeep, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(30+10+8+280, 250+8,(char*)Machine_info.btn_upKeep_info, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(30+10+8+280,250-timeHeights[4]-4-24,arr_string, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );


    memset(arr_string,0,20);
    itoa(arr_heights[5],arr_string,10);
    Paint_DrawRectangle(30+10+350,250-timeHeights[5],30+10+50+350,250,WHITE,1,1 );
    // Paint_DrawString_CN(30+10+8+350, 250+8,(char*)str_waitMaterials, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(30+10+8+350, 250+8,(char*)Machine_info.btn_waitMaterials_info, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(30+10+8+350,250-timeHeights[5]-4-24,arr_string, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );

    memcpy(bar_chart_07_03_buf,Paint_info.Image,sizeof(uint8_t)*480*300/8);


    free(timeHeights);
    return bar_chart_07_03_buf;
}


static uint8_t* partial_bar_chart_07_04_quick(Machine_info_t* info)
{
    char arr_string[20];

    uint32_t arr_num[4] = {Machine_info.checkIn_set[0].number,Machine_info.checkIn_set[1].number,Machine_info.checkIn_set[2].number,Machine_info.checkIn_set[3].number};

    uint32_t* arrHeights = calculateBarChartHeights(arr_heights,6,200);
    uint32_t* numHeights = calculateBarChartHeights(arr_num,4,200);

    uint8_t* bar_chart_07_04_buf = (uint8_t*)calloc(480*300/8,sizeof(uint8_t));
    memset(tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((UBYTE *)tmp_paint_buf, 480, 300, ROTATE_0, WHITE );

    Paint_DrawLine(10,250,274,250,WHITE,DOT_PIXEL_2X2,LINE_STYLE_SOLID );
    Paint_DrawLine(294,250,470,250,WHITE,DOT_PIXEL_2X2,LINE_STYLE_SOLID );

    memset(arr_string,0,20);
    itoa(arr_heights[0],arr_string,10);
    Paint_DrawRectangle(10+2,250-arrHeights[0],10+2+40,250,WHITE,1,1 );
    Paint_DrawString_CN(10+2+8, 250+2,(char*)Machine_info.btn_operation, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(10+2+5, 250-arrHeights[0]-2-16,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );

    memset(arr_string,0,20);
    itoa(arr_heights[1],arr_string,10);
    Paint_DrawRectangle(10+2+44,250-arrHeights[1],10+2+40+44,250,WHITE,1,1 );
    Paint_DrawString_CN(10+2+8+44, 250+2,(char*)Machine_info.btn_shutDown_info, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(10+2+5+44, 250-arrHeights[1]-2-16,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );

    memset(arr_string,0,20);
    itoa(arr_heights[2],arr_string,10);
    Paint_DrawRectangle(10+2+88,250-arrHeights[2],10+2+40+88,250,WHITE,1,1 );
    Paint_DrawString_CN(10+2+8+88, 250+2,(char*)Machine_info.btn_breakDown_info, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(10+2+5+88, 250-arrHeights[2]-2-16,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );

    memset(arr_string,0,20);
    itoa(arr_heights[3],arr_string,10);
    Paint_DrawRectangle(10+2+132,250-arrHeights[3],10+2+40+132,250,WHITE,1,1 );
    Paint_DrawString_CN(10+2+8+132, 250+2,(char*)Machine_info.btn_safeKeep_info, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(10+2+5+132, 250-arrHeights[3]-2-16,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );

    memset(arr_string,0,20);
    itoa(arr_heights[4],arr_string,10);
    Paint_DrawRectangle(10+2+176,250-arrHeights[4],10+2+40+176,250,WHITE,1,1 );
    Paint_DrawString_CN(10+2+8+176, 250+2,(char*)Machine_info.btn_upKeep_info, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(10+2+5+176, 250-arrHeights[4]-2-16,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );

    memset(arr_string,0,20);
    itoa(arr_heights[5],arr_string,10);
    Paint_DrawRectangle(10+2+220,250-arrHeights[5],10+2+40+220,250,WHITE,1,1 );
    Paint_DrawString_CN(10+2+8+220, 250+2,(char*)Machine_info.btn_waitMaterials_info, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(10+2+5+220, 250-arrHeights[5]-2-16,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );


    //  next
    char tmp_12[4][6] = {0};
    char tmp_34[4][6] = {0};

    memcpy(tmp_12[0],Machine_info.checkIn_set[0].other_name,4);
    memcpy(tmp_34[0],Machine_info.checkIn_set[0].other_name+4,4);

    memcpy(tmp_12[1],Machine_info.checkIn_set[1].other_name,4);
    memcpy(tmp_34[1],Machine_info.checkIn_set[1].other_name+4,4);

    memcpy(tmp_12[2],Machine_info.checkIn_set[2].other_name,4);
    memcpy(tmp_34[2],Machine_info.checkIn_set[2].other_name+4,4);

    memcpy(tmp_12[3],Machine_info.checkIn_set[3].other_name,4);
    memcpy(tmp_34[3],Machine_info.checkIn_set[3].other_name+4,4);



    memset(arr_string,0,20);
    itoa(arr_num[0],arr_string,10);
    Paint_DrawRectangle(294+2,250-numHeights[0],294+2+40,250,WHITE,1,1 );
    // Paint_DrawString_CN(294+2+8, 250+2,(char*)str_production, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(294+2+8, 250+2,tmp_12[0], &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(294+2+8, 250+2+16,tmp_34[0], &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(292+2+5,250-numHeights[0]-2-16,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );

    memset(arr_string,0,20);
    itoa(arr_num[1],arr_string,10);
    Paint_DrawRectangle(294+2+44,250-numHeights[1],294+2+40+44,250,WHITE,1,1 );
    // Paint_DrawString_CN(294+2+8+44, 250+2,(char*)str_repair, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(294+2+8+44, 250+2,tmp_12[1], &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(294+2+8+44, 250+2+16,tmp_34[1], &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(292+2+5+44,250-numHeights[1]-2-16,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );

    memset(arr_string,0,20);
    itoa(arr_num[2],arr_string,10);
    Paint_DrawRectangle(294+2+88,250-numHeights[2],294+2+40+88,250,WHITE,1,1 );
    // Paint_DrawString_CN(294+2+8+88, 250+2, (char*)str_inspection, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(294+2+8+88, 250+2,tmp_12[2], &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(294+2+8+88, 250+2+16,tmp_34[2], &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(292+2+5+88,250-numHeights[2]-2-16,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );

    memset(arr_string,0,20);
    itoa(arr_num[3],arr_string,10);
    Paint_DrawRectangle(294+2+132,250-numHeights[3],294+2+40+132,250,WHITE,1,1 );
    // Paint_DrawString_CN(294+2+8+132, 250+2, (char*)str_upKeep, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(294+2+8+132, 250+2,tmp_12[3], &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(294+2+8+132, 250+2+16,tmp_34[3], &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(292+2+5+132,250-numHeights[3]-2-16,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
    
    free(arrHeights);
    free(numHeights);

    memcpy(bar_chart_07_04_buf,Paint_info.Image,sizeof(uint8_t)*480*300/8);
    return bar_chart_07_04_buf;

}


#define RIGHT1_HIGHT  100
#define RIGHT2_HIGHT  172


static uint8_t* partial_right1_quick(Machine_info_t* info)
{


    //Machine_info.batt_precent = 100;
    uint8_t* partial_right1_buf = (uint8_t*)calloc(RIGHT1_HIGHT*480/8,sizeof(uint8_t));

    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((uint8_t*)tmp_paint_buf, 480, RIGHT1_HIGHT, ROTATE_0, WHITE );

    Paint_DrawLine(10,95,470,95,WHITE,DOT_PIXEL_1X1,LINE_STYLE_SOLID );

    int x = center_align(&info->station_name,480,16,32);

    Paint_DrawString_CN(x, 25,&info->station_name, &chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND );
    //显示终端号码
    //printf("  terminal name x=%d--------------%s----------------\r\n",x,(char *)&info->terminal_name);

    x = center_align(&info->station_number,480,8,16);
    Paint_DrawString_CN(x, 70,&info->station_number, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    //printf("  terminal_number  x=%d--------------%s----------------\r\n",x,(char *)&info->terminal_number);
    
#define BAT_X_OFFSET    2
#define BAT_Y_OFFSET    2

    //batt
    Paint_DrawBitMap_Paste((uint8_t*)gImage_battery      ,480-50-BAT_X_OFFSET,24,37,18,1 );
    #if 1
    switch (Machine_info.batt_precent)
    {
    case 0:
        break;
    case 1 ... 24:
     Paint_DrawRectangle(433 -BAT_X_OFFSET,27,439 -BAT_X_OFFSET,41,WHITE,1,1 );
        break;
    case 25 ... 49:
    Paint_DrawRectangle(433 -BAT_X_OFFSET,27,439-BAT_X_OFFSET,41,WHITE,1,1 );
    Paint_DrawRectangle(441-BAT_X_OFFSET,27,447-BAT_X_OFFSET,41,WHITE,1,1 );
         break;
    case 50 ... 74:
    Paint_DrawRectangle(433-BAT_X_OFFSET,27,439-BAT_X_OFFSET,41,WHITE,1,1 );
    Paint_DrawRectangle(441-BAT_X_OFFSET,27,447-BAT_X_OFFSET,41,WHITE,1,1 );
    Paint_DrawRectangle(449-BAT_X_OFFSET,27,455-BAT_X_OFFSET,41,WHITE,1,1 );
        break;
    case 75 ... 99:
    Paint_DrawRectangle(433-BAT_X_OFFSET,27,439-BAT_X_OFFSET,41,WHITE,1,1 );
    Paint_DrawRectangle(441-BAT_X_OFFSET,27,447-BAT_X_OFFSET,41,WHITE,1,1 );
    Paint_DrawRectangle(449-BAT_X_OFFSET,27,455-BAT_X_OFFSET,41,WHITE,1,1 );
    Paint_DrawRectangle(457-BAT_X_OFFSET,27,462-BAT_X_OFFSET,41,WHITE,1,1 );
        break;
    case 100:
    Paint_DrawRectangle(433-BAT_X_OFFSET,27,439-BAT_X_OFFSET,41,WHITE,1,1 );
    Paint_DrawRectangle(441-BAT_X_OFFSET,27,447-BAT_X_OFFSET,41,WHITE,1,1 );
    Paint_DrawRectangle(449-BAT_X_OFFSET,27,455-BAT_X_OFFSET,41,WHITE,1,1 );
    Paint_DrawRectangle(457-BAT_X_OFFSET,27,462-BAT_X_OFFSET,41,WHITE,1,1 );
        break;
    default:
        break;
    }

    if(!decection_state_0()) //判断充电中逻辑
    {
        Machine_info.batt_precent =  read_battery_voltage();
        if(Machine_info.batt_precent >=95)
        {
            Paint_DrawBitMap_Paste((uint8_t*)gImage_charging      ,480-47+37,27 - BAT_Y_OFFSET,8,18,1 );
        }
        else
        {
            Paint_DrawBitMap_Paste((uint8_t*)gImage_charging     ,480-47+35,27 - BAT_Y_OFFSET,8,18,1 );
        }
    }

    #else
    Paint_DrawBitMap_Paste((uint8_t*)gImage_filled      ,480-47+37,24,8,18,1 );
    Paint_DrawRectangle(433,27,439,41,WHITE,1,1 );
    Paint_DrawRectangle(441,27,447,41,WHITE,1,1 );
    Paint_DrawRectangle(449,27,455,41,WHITE,1,1 );
    Paint_DrawRectangle(457,27,462,41,WHITE,1,1 );
    #endif


    #if 0
    //rssi
    switch (Machine_info.rssi)
    {
        case 0:
        Paint_DrawRectangle(480-57-32,42-3,391+5,42,WHITE,1,0 );
        Paint_DrawRectangle(480-57-24,42-8,399+5,42,WHITE,1,0 );
        Paint_DrawRectangle(480-57-16,42-13,407+5,42,WHITE,1,0 );
        Paint_DrawRectangle(480-57-8,42-18,415+5,42,WHITE,1,0 );
            break;
        case 1 ... 24:
        Paint_DrawRectangle(480-57-32,42-3,391+5,42,WHITE,1,1 );
        Paint_DrawRectangle(480-57-24,42-8,399+5,42,WHITE,1,0 );
        Paint_DrawRectangle(480-57-16,42-13,407+5,42,WHITE,1,0 );
        Paint_DrawRectangle(480-57-8,42-18,415+5,42,WHITE,1,0 );
            break;
        case 25 ... 49:
        Paint_DrawRectangle(480-57-32,42-3,391+5,42,WHITE,1,1 );
        Paint_DrawRectangle(480-57-24,42-8,399+5,42,WHITE,1,1 );
        Paint_DrawRectangle(480-57-16,42-13,407+5,42,WHITE,1,0 );
        Paint_DrawRectangle(480-57-8,42-18,415+5,42,WHITE,1,0 );
            break;
        case 50 ... 74:
        Paint_DrawRectangle(480-57-32,42-3,391+5,42,WHITE,1,1 );
        Paint_DrawRectangle(480-57-24,42-8,399+5,42,WHITE,1,1 );
        Paint_DrawRectangle(480-57-16,42-13,407+5,42,WHITE,1,1 );
        Paint_DrawRectangle(480-57-8,42-18,415+5,42,WHITE,1,0 );
            break;
        case 75 ... 100:
        Paint_DrawRectangle(480-57-32,42-3,391+5,42,WHITE,1,1 );
        Paint_DrawRectangle(480-57-24,42-8,399+5,42,WHITE,1,1 );
        Paint_DrawRectangle(480-57-16,42-13,407+5,42,WHITE,1,1 );
        Paint_DrawRectangle(480-57-8,42-18,415+5,42,WHITE,1,1 );
            break;
        default:
        ESP_LOGW(LOG_TAG," err:rssi ");
        Paint_DrawRectangle(480-57-32,42-3,391+5,42,WHITE,1,1 );
        Paint_DrawRectangle(480-57-24,42-8,399+5,42,WHITE,1,1 );
        Paint_DrawRectangle(480-57-16,42-13,407+5,42,WHITE,1,1 );
        Paint_DrawRectangle(480-57-8,42-18,415+5,42,WHITE,1,1 );
            break;
    }

    #else

    //添加在线离线
     uint8_t online[6]=  {0xd4,0xda,0xcf,0xdf,0x00,0x00};  //在线
     uint8_t outline[6]= {0xc0,0xeb,0xcf,0xdf,0x00,0x00};  //离线

     Paint_DrawBitMap_Paste((uint8_t*)gImage_online,480-50-BAT_X_OFFSET - 50,24,37,18,1);
     if (Machine_info.paired)
     {
        Paint_DrawString_CN(480-50 - BAT_X_OFFSET - 50 +3,25,(char *)online, &chinese_type_16,FONT_BACKGROUND,FONT_FOREGROUND);
     }else
     {
        Paint_DrawString_CN(480-50 - BAT_X_OFFSET - 50 +3,25,(char *)outline, &chinese_type_16,FONT_BACKGROUND,FONT_FOREGROUND);
     }
     
     
    // Paint_DrawRectangle(480-57-32,40-3,391+5,40,WHITE,1,1 );
    // Paint_DrawRectangle(480-57-24,40-8,399+5,40,WHITE,1,1 );
    // Paint_DrawRectangle(480-57-16,40-13,407+5,40,WHITE,1,1 );
    // Paint_DrawRectangle(480-57-8,40-18,415+5,40,WHITE,1,0 );
    #endif

    memcpy(partial_right1_buf,Paint_info.Image,sizeof(uint8_t)*480*RIGHT1_HIGHT/8);
    return partial_right1_buf;
}
#define MAX_NAME_STRING_LEN 52
void dis_name(char* tmp,int len)//times为空格的次数，如果为管理员要多加4次，管理员字符串->char str_0[14] = {0xb9,0xdc,0x20,0x20,0xc0,0xed,0x20,0x20,0xd4,0xb1,0xa3,0xba,0x00,0x00};
{
    if(len < MAX_NAME_STRING_LEN )
    {
        return;
    }
    ESP_LOGW(LOG_TAG,"------dis name----");
    ESP_LOG_BUFFER_HEX(LOG_TAG,tmp,len);
    strcpy(&tmp[MAX_NAME_STRING_LEN]," ...");

    tmp[MAX_NAME_STRING_LEN+4] = 0;
    tmp[MAX_NAME_STRING_LEN+5] = 0;
}

static uint8_t* partial_right2_quick(void)
{
    uint8_t* partial_right2_buf = (uint8_t*)calloc(RIGHT2_HIGHT*480/8,sizeof(uint8_t));
    char buffer[200]={0};
    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((UBYTE *)tmp_paint_buf, 480, RIGHT2_HIGHT, ROTATE_0, WHITE );

    ESP_LOGE(LOG_TAG,"paint Charge_close %d %d %d %d %d",Machine_info.person[0].Charge_close,Machine_info.person[1].Charge_close,Machine_info.person[2].Charge_close,\
    Machine_info.person[3].Charge_close,Machine_info.person[4].Charge_close);
    ESP_LOGW(LOG_TAG,"责任人人数 [%d][%d][%d][%d][%d]",person_get_num(0),person_get_num(1),person_get_num(2),person_get_num(3),person_get_num(4)); //获取当前类型人员数量

    //管理员不会关闭
    memset((uint8_t*)buffer,0,sizeof(buffer));
    strcat(buffer,(char*)Machine_info.person[0].other_name);
    strcat(buffer, Machine_info.person[0].string_name);
    dis_name(buffer,strlen(buffer));
    Paint_DrawString_CN(10, 7,(char*)buffer, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );


    if(!Machine_info.person[1].Charge_close)
    {
        memset((uint8_t*)buffer,0,sizeof(buffer));
        strcat(buffer,(char*)Machine_info.person[1].other_name);
        strcat(buffer, Machine_info.person[1].string_name);
        dis_name(buffer,strlen(buffer));
        Paint_DrawString_CN(10, 41,(char*)buffer, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    }

    

    if(!Machine_info.person[2].Charge_close)
    {
        memset((uint8_t*)buffer,0,sizeof(buffer));
        strcat(buffer,(char*)Machine_info.person[2].other_name);
        strcat(buffer, Machine_info.person[2].string_name);
        dis_name(buffer,strlen(buffer));
        Paint_DrawString_CN(10, 75,(char*)buffer, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    }


    if(!Machine_info.person[4].Charge_close)
    {
        memset((uint8_t*)buffer,0,sizeof(buffer));
        strcat(buffer,(char*)Machine_info.person[4].other_name);
        strcat(buffer, Machine_info.person[4].string_name);
        dis_name(buffer,strlen(buffer));
        Paint_DrawString_CN(10, 109,(char*)buffer, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    }



    if(!Machine_info.person[3].Charge_close)
    {
        memset((uint8_t*)buffer,0,sizeof(buffer));
        strcat(buffer,(char*)Machine_info.person[3].other_name);
        strcat(buffer, Machine_info.person[3].string_name);
        dis_name(buffer,strlen(buffer));
        Paint_DrawString_CN(10, 143,(char*)buffer, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    }

    // ESP_LOG_BUFFER_HEX(LOG_TAG,buffer,strlen(buffer));
    Paint_DrawLine(10,170,470,170,WHITE,DOT_PIXEL_1X1,LINE_STYLE_DOTTED );

    memcpy(partial_right2_buf,Paint_info.Image,sizeof(uint8_t)*480*RIGHT2_HIGHT/8);
    return partial_right2_buf;
}

char* right3_change_time_to_dis(bool flag)//flag为true 显示前四个小时  ，flag为false，显示最近
{
    char arr_int[5];
    char arr_dec[5];
    char* arr_string = (char*)malloc(20*sizeof(char));
    uint8_t time_min,time_hour;
    if(Machine_info.min>=30)
    {
        if(Machine_info.hour>=4)
        {
            time_hour = Machine_info.hour - 4;
            time_min = 30;
        }
        else
        {
            time_hour = Machine_info.hour + 20;
            time_min = 30;
        }
    }
    else
    {
        if(Machine_info.hour>=4)
        {
            time_hour = Machine_info.hour - 4;
            time_min = 0;
        }
        else
        {
            time_hour = Machine_info.hour + 20;
            time_min = 0;
        }
    }
    if(flag)
    {//前4小时
        memset(arr_string,0,20);
        itoa(time_hour,arr_int,10);
        if(time_min == 0)
        {
            strcpy(arr_string,arr_int);
            strcat(arr_string,":");
            strcat(arr_string,"00");
        }
        else
        {
            itoa(time_min,arr_dec,10);
            strcpy(arr_string,arr_int);
            strcat(arr_string,":");
            strcat(arr_string,arr_dec);
        }
    }
    else
    {
        memset(arr_string,0,20);
        itoa(Machine_info.hour,arr_int,10);
        strcpy(arr_string,arr_int);
        strcat(arr_string,":");
        if(Machine_info.min>=30)
        {
            time_min = 30;
            itoa(time_min,arr_dec,10);
            strcat(arr_string,arr_dec);
        }
        else
        {
            strcat(arr_string,"00");
        }
    }
    return arr_string;
}
static uint8_t* partial_right3_quick(void)
{
       /* Get timestamp before entering sleep */
    // int64_t t_before_us = esp_timer_get_time();
    // //ESP_LOGW(LOG_TAG,"-=-=-=-=-=-=-=");
    // printf(" ==>[%lld]",t_before_us);

    uint8_t* partial_right3_buf = (uint8_t*)calloc(224*480/8,sizeof(uint8_t));


    #define __MAX_PIXEL  140
    uint32_t num_max = 0,i=0,sum_products=0;
    uint32_t num_totalProducts[8];
    uint32_t scale_UR[8];
    uint32_t scale_YR[8];
    uint8_t time_min,time_hour;
    char arr_string[20];
    char arr_int[5];
    char arr_dec[5];
    for(i=0;i<8;i++)
    {
        num_totalProducts[i] = Machine_info.num_goodProducts[i]+Machine_info.num_badProducts[i];
        scale_UR[i] = (Machine_info.scale_UR_int[i])*100+ Machine_info.scale_UR_dec[i];
        scale_YR[i] = (Machine_info.scale_YR_int[i])*100+ Machine_info.scale_YR_dec[i];
        //ESP_LOGW(LOG_TAG,"good:[%ld] bad[%ld]",num_goodProducts[i],num_badProducts[i]);
        //ESP_LOGW(LOG_TAG,"total:[%ld]",num_totalProducts[i]);
        //sum_products+=num_totalProducts[i];
        if(num_max <(Machine_info.num_goodProducts[i]+Machine_info.num_badProducts[i]))
        num_max = Machine_info.num_goodProducts[i]+Machine_info.num_badProducts[i];
    }

    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((UBYTE *)tmp_paint_buf, 480, 224, ROTATE_0, WHITE );

    //Paint_DrawLine(10,2,470,2,WHITE,DOT_PIXEL_1X1,LINE_STYLE_DOTTED );
    Paint_DrawLine(10,220,470,220,WHITE,DOT_PIXEL_1X1,LINE_STYLE_DOTTED );


    unsigned int* chartHeights = calculateBarChartHeights(num_totalProducts,sizeof(num_totalProducts)/sizeof(num_totalProducts[0]),__MAX_PIXEL);
    for(i=0;i<8;i++)
    {
        //chartHeights[i] = 140;
        Paint_DrawRectangle(60+i*25 ,192 - chartHeights[i]  ,80+i*25,    192,WHITE,1,1 );
        memset(arr_string,0,20);
        //itoa((int)num_totalProducts[i],arr_string,10);
        //取消柱状图上方数值
        //Paint_DrawString_EN(60+i*25 ,192 - chartHeights[i]-8,(char*)arr_string, &ascii_type_5x7,FONT_FOREGROUND,FONT_BACKGROUND );
        //ESP_LOGW(LOG_TAG,"heights = %d",chartHeights[i]);
    }
    free(chartHeights);

    char* time_before = right3_change_time_to_dis(true);
    Paint_DrawString_EN(60,192+2,time_before, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
    free(time_before);

    time_before = right3_change_time_to_dis(false);
    Paint_DrawString_EN(60+150,192+2,time_before, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
    free(time_before);

    memset(arr_string,0,20);
    itoa(num_totalProducts[7],arr_string,10);

    int x = center_align(&arr_string,160,16,0);
    Paint_DrawString_EN(300+x,70,(char*)arr_string, &ascii_type_16x32,FONT_FOREGROUND,FONT_BACKGROUND );


    uint32_t tmp =0;
    for(i=0;i<5;i++)
    {
        memset(arr_string,0,20);//140 5
        tmp = (num_max/5)*(5-i);
        //strcpy(arr_string,tmp);
        //itoa(tmp,arr_string,10);//这里导致数值错误
        sprintf(arr_string, "%lu", tmp);
        // ESP_LOGW(LOG_TAG,"%s",arr_string);
        Paint_DrawString_EN(10,48+i*30,(char*)arr_string, &ascii_type_5x7,FONT_FOREGROUND,FONT_BACKGROUND );
        //Paint_DrawString_EN(20,40+i*28,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
    }

    for(i=0;i<5;i++)//ur yr y坐标
    {
        memset(arr_string,0,20);
        tmp = (100/5)*(5-i);
        //strcpy(arr_string,tmp);
        itoa(tmp,arr_string,10);
        strcat(arr_string,".00%");
        Paint_DrawString_EN(60+200,48+i*30,(char*)arr_string, &ascii_type_5x7,FONT_FOREGROUND,FONT_BACKGROUND );
    }

    char str_ur[8] = {0xbc,0xda,0xb6,0xaf,0xc2,0xca,0x00,0x00};
    Paint_DrawString_CN(320, 170,(char*)str_ur, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );//ur
    Paint_DrawLine(320,170+16+3,368,170+16+3,WHITE,DOT_PIXEL_2X2,LINE_STYLE_SOLID );
    char str_yr[8] = {0xc1,0xbc,0xc6,0xb7,0xc2,0xca,0x00,0x00};
    Paint_DrawString_CN(390, 170,(char*)str_yr, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );//yr
    Paint_DrawLine(390,170+16+3,438,170+16+3,WHITE,DOT_PIXEL_1X1,LINE_STYLE_DOTTED_2 );


    memset(arr_int,0,5);
    memset(arr_dec,0,5);
    memset(arr_string,0,20);
    itoa(Machine_info.scale_UR_int[7],arr_int,10);
    itoa(Machine_info.scale_UR_dec[7],arr_dec,10);
    strcpy(arr_string,arr_int);
    strcat(arr_string,".");
    strcat(arr_string,arr_dec);
    strcat(arr_string,"%");
    x = center_align(&arr_string,48,8,16);
    Paint_DrawString_EN(320+x,170-16-1,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );


    memset(arr_int,0,5);
    memset(arr_dec,0,5);
    memset(arr_string,0,20);
    itoa(Machine_info.scale_YR_int[7],arr_int,10);
    itoa(Machine_info.scale_YR_dec[7],arr_dec,10);
    strcpy(arr_string,arr_int);
    strcat(arr_string,".");
    strcat(arr_string,arr_dec);
    strcat(arr_string,"%");
    x = center_align(&arr_string,48,8,16);
    Paint_DrawString_EN(390+x,170-16-1,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );

    // drawQuadraticBezierCurve(uint8_t* framebuffer, int width, int height,
    //                               int x0, int y0, int x1, int y1, int x2, int y2,
    //                               uint8_t color, int thickness)
    unsigned int* UR_Heights = getBarChartHeights(scale_UR,sizeof(scale_UR)/sizeof(scale_UR[0]),__MAX_PIXEL);
    unsigned int* YR_Heights = getBarChartHeights(scale_YR,sizeof(scale_YR)/sizeof(scale_YR[0]),__MAX_PIXEL);
    unsigned int tmp_heihgts[6];
    unsigned int tmp1_heihgts[6];
    //https://zhuanlan.zhihu.com/p/46676386
    #if 1
    for(i=0;i<6;i++)
    {
        tmp_heihgts[i] = (UR_Heights[i+1]+UR_Heights[i+2])/2;
        tmp1_heihgts[i] = (YR_Heights[i+1]+YR_Heights[i+2])/2;
    }
    #else
    for(i=0;i<6;i++)
    {
        tmp_heihgts[i] = 30+i*10;
        tmp1_heihgts[i] = 10+i*10;
    }
    #endif
    //UR
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72,192-UR_Heights[0],72+25,192-UR_Heights[1],72+25+12,192-tmp_heihgts[0],0xff,2);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25+12,192-tmp_heihgts[0],72+25*2,192-UR_Heights[2],72+25*2+12,192-tmp_heihgts[1],0xff,2);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*2+12,192-tmp_heihgts[1],72+25*3,192-UR_Heights[3],72+25*3+12,192-tmp_heihgts[2],0xff,2);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*3+12,192-tmp_heihgts[2],72+25*4,192-UR_Heights[4],72+25*4+12,192-tmp_heihgts[3],0xff,2);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*4+12,192-tmp_heihgts[3],72+25*5,192-UR_Heights[5],72+25*5+12,192-tmp_heihgts[4],0xff,2);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*5+12,192-tmp_heihgts[4],72+25*6,192-UR_Heights[6],72+25*7,192-UR_Heights[7],0xff,2);
    
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72,192-UR_Heights[0]+2,72+25,192-UR_Heights[1]+2,72+25+12,192-tmp_heihgts[0]+2,0,2);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25+12,192-tmp_heihgts[0]+2,72+25*2,192-UR_Heights[2]+2,72+25*2+12,192-tmp_heihgts[1]+2,0,2);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*2+12,192-tmp_heihgts[1]+2,72+25*3,192-UR_Heights[3]+2,72+25*3+12,192-tmp_heihgts[2]+2,0,2);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*3+12,192-tmp_heihgts[2]+2,72+25*4,192-UR_Heights[4]+2,72+25*4+12,192-tmp_heihgts[3]+2,0,2);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*4+12,192-tmp_heihgts[3]+2,72+25*5,192-UR_Heights[5]+2,72+25*5+12,192-tmp_heihgts[4]+2,0,2);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*5+12,192-tmp_heihgts[4]+2,72+25*6,192-UR_Heights[6]+2,72+25*7,192-UR_Heights[7]+2,0,2);
       
    //YR
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72,192-YR_Heights[0],72+25,192-YR_Heights[1],72+25+12,192-tmp1_heihgts[0],0xff,1);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25+12,192-tmp1_heihgts[0],72+25*2,192-YR_Heights[2],72+25*2+12,192-tmp1_heihgts[1],0xff,1);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*2+12,192-tmp1_heihgts[1],72+25*3,192-YR_Heights[3],72+25*3+12,192-tmp1_heihgts[2],0xff,1);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*3+12,192-tmp1_heihgts[2],72+25*4,192-YR_Heights[4],72+25*4+12,192-tmp1_heihgts[3],0xff,1);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*4+12,192-tmp1_heihgts[3],72+25*5,192-YR_Heights[5],72+25*5+12,192-tmp1_heihgts[4],0xff,1);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*5+12,192-tmp1_heihgts[4],72+25*6,192-YR_Heights[6],72+25*7,192-YR_Heights[7],0xff,1);
    
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72,192-YR_Heights[0]+1,72+25,192-YR_Heights[1]+1,72+25+12,192-tmp1_heihgts[0],0,1);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25+12,192-tmp1_heihgts[0]+1,72+25*2,192-YR_Heights[2]+1,72+25*2+12,192-tmp1_heihgts[1]+1,0,1);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*2+12,192-tmp1_heihgts[1]+1,72+25*3,192-YR_Heights[3]+1,72+25*3+12,192-tmp1_heihgts[2]+1,0,1);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*3+12,192-tmp1_heihgts[2]+1,72+25*4,192-YR_Heights[4]+1,72+25*4+12,192-tmp1_heihgts[3]+1,0,1);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*4+12,192-tmp1_heihgts[3]+1,72+25*5,192-YR_Heights[5]+1,72+25*5+12,192-tmp1_heihgts[4]+1,0,1);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*5+12,192-tmp1_heihgts[4]+1,72+25*6,192-YR_Heights[6]+1,72+25*7,192-YR_Heights[7]+1,0,1);
    free(UR_Heights);
    free(YR_Heights);

    Paint_DrawLine(60,192,80+7*25,192,WHITE,DOT_PIXEL_2X2,LINE_STYLE_SOLID );//表格线

    extern Node *clockIn_list;
    // int production_num =    countClockNodes_byCMD(clockIn_list,0x00);
    // int repair_num =        countClockNodes_byCMD(clockIn_list,0x01);
    // int upKeep_num =        countClockNodes_byCMD(clockIn_list,0x03);
    // int inspection_num =    countClockNodes_byCMD(clockIn_list,0x02);
    int type_num[4] = {countClockNodes_byCMD(clockIn_list,0x00),countClockNodes_byCMD(clockIn_list,0x01),countClockNodes_byCMD(clockIn_list,0x02),countClockNodes_byCMD(clockIn_list,0x03)};
    ESP_LOGI(LOG_TAG,"在岗人数 ：[%d] [%d] [%d] [%d]",type_num[0],type_num[1],type_num[2],type_num[3]);
    char str_arr[20];

    char str_ren[] = {0xc8,0xcb,0x00,0x00};
    char str_Currently[] = {0xb5,0xb1,0xc7,0xb0,0xd4,0xda,0xb8,0xda,0x3a,0xba,0x00,0x00};//当前在岗B5B1C7B0D4DAB8DAA3BA

    // char str_test[] = {0xB2,0xE2,0xCA,0xD4,0xB8,0xBA,0xD4,0xF0,0x00,0x00};
    // memcpy((char*)Machine_info.checkIn_set[3].other_name,str_test,strlen(str_test));//测试签到人数

    int all_len = 0;
    int other_name_len = 0;

    Paint_DrawString_CN(10, 5,(char*)str_Currently, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    memset(str_arr,0,20);
    itoa(type_num[0],str_arr,10);
    other_name_len = strlen((char*)Machine_info.checkIn_set[0].other_name)*8;
    all_len = other_name_len +strlen(str_arr)*8;
    if(!Machine_info.checkIn_set[0].checkIn_close)
    {
        Paint_DrawString_CN(10+16*5, 5,(char*)Machine_info.checkIn_set[0].other_name, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
        Paint_DrawString_EN(10+16*5+other_name_len,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
        Paint_DrawString_CN(10+16*5+all_len, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );  
    }


    memset(str_arr,0,20);
    itoa(type_num[1],str_arr,10);
    other_name_len = strlen((char*)Machine_info.checkIn_set[1].other_name)*8;
    all_len = other_name_len +strlen(str_arr)*8;
    if(!Machine_info.checkIn_set[1].checkIn_close)
    {
        Paint_DrawString_CN(186, 5,(char*)Machine_info.checkIn_set[1].other_name, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
        Paint_DrawString_EN(186+other_name_len,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
        Paint_DrawString_CN(186+all_len, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );  
    }


    memset(str_arr,0,20);
    itoa(type_num[2],str_arr,10);
    other_name_len = strlen((char*)Machine_info.checkIn_set[2].other_name)*8;
    all_len = other_name_len +strlen(str_arr)*8;
    if(!Machine_info.checkIn_set[2].checkIn_close)
    {
        Paint_DrawString_CN(282, 5,(char*)Machine_info.checkIn_set[2].other_name, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
        Paint_DrawString_EN(282+other_name_len,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
        Paint_DrawString_CN(282+all_len, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );  
    }


    memset(str_arr,0,20);
    itoa(type_num[3],str_arr,10);
    other_name_len = strlen((char*)Machine_info.checkIn_set[3].other_name)*8;
    all_len = other_name_len +strlen(str_arr)*8;
    if(!Machine_info.checkIn_set[3].checkIn_close)
    {
        Paint_DrawString_CN(378, 5,(char*)Machine_info.checkIn_set[3].other_name, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
        Paint_DrawString_EN(378+other_name_len,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
        Paint_DrawString_CN(378+all_len, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );  
    }

    memcpy(partial_right3_buf,Paint_info.Image,sizeof(uint8_t)*480*224/8);

    return partial_right3_buf;
}

static uint8_t* partial_right3_2_quick(void)
{
    uint8_t* partial_right3_buf = (uint8_t*)calloc(224*480/8,sizeof(uint8_t));

    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((UBYTE *)tmp_paint_buf, 480, 224, ROTATE_0, WHITE );

    Paint_DrawLine(10,220,470,220,WHITE,DOT_PIXEL_1X1,LINE_STYLE_DOTTED );//分隔右屏第三部分和第四部分线表格线
    #if 0
    extern Node *clockIn_list;
    int production_num =    countClockNodes_byCMD(clockIn_list,0x00);
    int repair_num =        countClockNodes_byCMD(clockIn_list,0x01);
    int upKeep_num =        countClockNodes_byCMD(clockIn_list,0x03);
    int inspection_num =    countClockNodes_byCMD(clockIn_list,0x02);
    ESP_LOGD(LOG_TAG,"(2)生产【%d】,巡检【%d】,保养【%d】,维修【%d】",production_num,repair_num,upKeep_num,inspection_num);
    char str_arr[20];

    char str_ren[4] = {0xc8,0xcb,0x00,0x00};
    char str_now_and_production[16] = {0xb5,0xb1,0xc7,0xb0,0xd4,0xda,0xb8,0xda,0xa3,0xba,0xc9,0xfa,0xb2,0xfa,0x00,0x00};//当前在岗：生产
    // char str_inspection[6] = {0xd1,0xb2,0xbc,0xec,0x00,0x00};
    // char str_upKeep[]
    memset(str_arr,0,20);
    itoa(production_num,str_arr,10);
    Paint_DrawString_CN(10, 5,(char*)str_now_and_production, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(10+16*7,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(10+16*7+strlen(str_arr)*8, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );  

    memset(str_arr,0,20);
    itoa(inspection_num,str_arr,10);
    Paint_DrawString_CN(180, 5,(char*)str_inspection, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(180+16*2,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(180+16*2+strlen(str_arr)*8, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );  

    memset(str_arr,0,20);
    itoa(upKeep_num,str_arr,10);
    Paint_DrawString_CN(280, 5,(char*)str_upKeep, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(280+16*2,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(280+16*2+strlen(str_arr)*8, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );  

    memset(str_arr,0,20);
    itoa(repair_num,str_arr,10);
    Paint_DrawString_CN(380, 5,(char*)str_repair, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_EN(380+16*2,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
    Paint_DrawString_CN(380+16*2+strlen(str_arr)*8, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );  
#else
    extern Node *clockIn_list;
    int type_num[4] = {countClockNodes_byCMD(clockIn_list,0x00),countClockNodes_byCMD(clockIn_list,0x01),countClockNodes_byCMD(clockIn_list,0x02),countClockNodes_byCMD(clockIn_list,0x03)};
    char str_arr[20];
    ESP_LOGI(LOG_TAG,"#在岗人数 ：[%d] [%d] [%d] [%d]",type_num[0],type_num[1],type_num[2],type_num[3]);
    char str_ren[] = {0xc8,0xcb,0x00,0x00};
    char str_Currently[] = {0xb5,0xb1,0xc7,0xb0,0xd4,0xda,0xb8,0xda,0x3a,0xba,0x00,0x00};//当前在岗B5B1C7B0D4DAB8DAA3BA


    int all_len = 0;
    int other_name_len = 0;
    Paint_DrawString_CN(10, 5,(char*)str_Currently, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    memset(str_arr,0,20);
    itoa(type_num[0],str_arr,10);
    other_name_len = strlen((char*)Machine_info.checkIn_set[0].other_name)*8;
    all_len = other_name_len +strlen(str_arr)*8;
    if(!Machine_info.checkIn_set[0].checkIn_close)
    {

        Paint_DrawString_CN(10+16*5, 5,(char*)Machine_info.checkIn_set[0].other_name, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
        Paint_DrawString_EN(10+16*5+other_name_len,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
        Paint_DrawString_CN(10+16*5+all_len, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );  
    }


    memset(str_arr,0,20);
    itoa(type_num[1],str_arr,10);
    other_name_len = strlen((char*)Machine_info.checkIn_set[1].other_name)*8;
    all_len = other_name_len +strlen(str_arr)*8;
    if(!Machine_info.checkIn_set[1].checkIn_close)
    {
        Paint_DrawString_CN(186, 5,(char*)Machine_info.checkIn_set[1].other_name, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
        Paint_DrawString_EN(186+other_name_len,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
        Paint_DrawString_CN(186+all_len, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );  
    }


    memset(str_arr,0,20);
    itoa(type_num[2],str_arr,10);
    other_name_len = strlen((char*)Machine_info.checkIn_set[2].other_name)*8;
    all_len = other_name_len +strlen(str_arr)*8;
    if(!Machine_info.checkIn_set[2].checkIn_close)
    {
        Paint_DrawString_CN(282, 5,(char*)Machine_info.checkIn_set[2].other_name, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
        Paint_DrawString_EN(282+other_name_len,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
        Paint_DrawString_CN(282+all_len, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );  
    }


    memset(str_arr,0,20);
    itoa(type_num[3],str_arr,10);
    other_name_len = strlen((char*)Machine_info.checkIn_set[3].other_name)*8;
    all_len = other_name_len +strlen(str_arr)*8;
    if(!Machine_info.checkIn_set[3].checkIn_close)
    {
        Paint_DrawString_CN(378, 5,(char*)Machine_info.checkIn_set[3].other_name, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
        Paint_DrawString_EN(378+other_name_len,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
        Paint_DrawString_CN(378+all_len, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );  
    }

    memcpy(partial_right3_buf,Paint_info.Image,sizeof(uint8_t)*480*224/8);

#endif



    //画表格
    int i;
    char arr_string[20];
    uint32_t tmp =0;
    //柱状图

    uint16_t num_max_manHour = 0;

    uint32_t num_tmp[8];
    for(i=0;i<8;i++)
    {
        num_tmp[i] = (uint32_t)Machine_info.num_manHour[i];
    }
    unsigned int* manHour_Heights = calculateBarChartHeights(num_tmp,8,__MAX_PIXEL);
    
    for(i=0;i<8;i++)
    {
        if(num_max_manHour < Machine_info.num_manHour[i])
        {num_max_manHour = Machine_info.num_manHour[i];}
        // Paint_DrawRectangle(60+i*25 ,192 - manHour_Heights[i]  ,80+i*25,    192,WHITE,1,1 );
        Paint_DrawRectangle(60+i*25 ,193 - manHour_Heights[i]  ,80+i*25,    193,WHITE,1,1 );
        memset(arr_string,0,20);
        itoa((int)Machine_info.num_manHour[i],arr_string,10);
        //ESP_LOGW(LOG_TAG,"%s",arr_string);
        //取消柱状图上方数值
        Paint_DrawString_EN(60+i*25 ,192 - manHour_Heights[i]-8,(char*)arr_string, &ascii_type_5x7,FONT_FOREGROUND,FONT_BACKGROUND );
        //ESP_LOGW(LOG_TAG,"manHour_Heights = %d,num_manHour = %d,max_manHour = %d ",manHour_Heights[i],Machine_info.num_manHour[i],num_max_manHour);
    }

    for(i=0;i<5;i++)
    {
        tmp = ((int)(num_max_manHour/5))*(5-i);
        memset(arr_string,0,20);//140 5
        
        //strcpy(arr_string,tmp);
        //itoa(tmp,arr_string,10);//这里导致数值错误
        sprintf(arr_string, "%lu", tmp);
        // ESP_LOGW(LOG_TAG,"3——2  %s",arr_string);
        Paint_DrawString_EN(20,48+i*30,(char*)arr_string, &ascii_type_5x7,FONT_FOREGROUND,FONT_BACKGROUND );
    }


    //右屏3_2 贝塞尔曲线
    uint16_t num_max_people = 0;
        for(i=0;i<8;i++)
    {
        num_tmp[i] = (uint32_t)Machine_info.num_people[i];
    }
    unsigned int* people_Heights = calculateBarChartHeights(num_tmp,sizeof(Machine_info.num_people)/sizeof(Machine_info.num_people[0]),__MAX_PIXEL);
    unsigned int tmp_heihgts[6];
    for(i=0;i<8;i++)
    {
        if(num_max_people < Machine_info.num_people[i])
        {num_max_people = Machine_info.num_people[i];}
        //ESP_LOGW(LOG_TAG,"num_people[%d]=(%d),max :[%d]",i,Machine_info.num_people[i],num_max_people);
    }
    //https://zhuanlan.zhihu.com/p/46676386
    for(i=0;i<6;i++)
    {
        tmp_heihgts[i] = (people_Heights[i+1]+people_Heights[i+2])/2;
    }
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72,192-people_Heights[0],72+25,192-people_Heights[1],72+25+12,192-tmp_heihgts[0],0xff,1);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25+12,192-tmp_heihgts[0],72+25*2,192-people_Heights[2],72+25*2+12,192-tmp_heihgts[1],0xff,1);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*2+12,192-tmp_heihgts[1],72+25*3,192-people_Heights[3],72+25*3+12,192-tmp_heihgts[2],0xff,1);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*3+12,192-tmp_heihgts[2],72+25*4,192-people_Heights[4],72+25*4+12,192-tmp_heihgts[3],0xff,1);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*4+12,192-tmp_heihgts[3],72+25*5,192-people_Heights[5],72+25*5+12,192-tmp_heihgts[4],0xff,1);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*5+12,192-tmp_heihgts[4],72+25*6,192-people_Heights[6],72+25*7,192-people_Heights[7],0xff,1);
    
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72,192-people_Heights[0]-1,72+25,192-people_Heights[1]-1,72+25+12,192-tmp_heihgts[0],0,1);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25+12,192-tmp_heihgts[0]-1,72+25*2,192-people_Heights[2]-1,72+25*2+12,192-tmp_heihgts[1]-1,0,1);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*2+12,192-tmp_heihgts[1]-1,72+25*3,192-people_Heights[3]-1,72+25*3+12,192-tmp_heihgts[2]-1,0,1);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*3+12,192-tmp_heihgts[2]-1,72+25*4,192-people_Heights[4]-1,72+25*4+12,192-tmp_heihgts[3]-1,0,1);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*4+12,192-tmp_heihgts[3]-1,72+25*5,192-people_Heights[5]-1,72+25*5+12,192-tmp_heihgts[4]-1,0,1);
    drawQuadraticBezierCurve(Paint_info.Image,480,224,72+25*5+12,192-tmp_heihgts[4]-1,72+25*6,192-people_Heights[6]-1,72+25*7,192-people_Heights[7]-1,0,1);
    for(i=0;i<5;i++)
    {
        memset(arr_string,0,20);
        if((num_max_people  <= 5)&&(i == 0))
        {
            tmp = num_max_people;
        }
        else
        {
            tmp = (num_max_people/5)*(5-i);
        }
        sprintf(arr_string, "%lu", tmp);
        // ESP_LOGW(LOG_TAG,"%s",arr_string);
        //ESP_LOG_BUFFER_HEX(LOG_TAG,arr_string,30);
        Paint_DrawString_EN(60+200,48+i*30,(char*)arr_string, &ascii_type_5x7,FONT_FOREGROUND,FONT_BACKGROUND );
    }


    free(manHour_Heights);
    free(people_Heights);
    Paint_DrawLine(60,193,80+7*25,193,WHITE,DOT_PIXEL_1X1,LINE_STYLE_SOLID );
    //画表格结束


    memset(arr_string,0,20);
        
    itoa(Machine_info.num_manHour[7],arr_string,10);//最近工时显示
    i = center_align(&arr_string,160,16,32);
    Paint_DrawString_EN(300+i,70,(char*)arr_string, &ascii_type_16x32,FONT_FOREGROUND,FONT_BACKGROUND );


    memset(arr_string,0,20);
    itoa(Machine_info.num_people[7],arr_string,10);//最近人数显示
    //strcat(arr_string,"123456");
    i = center_align(&arr_string,160,8,16);
    Paint_DrawString_EN(300+i,150,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );


    char str_people[8] = {0xC8,0xCB,0xCA,0xFD,0x00,0x00};
   //i = center_align(&arr_string,160,8,16);
    Paint_DrawString_CN(300+i+strlen(arr_string)*4 - 16, 165,(char*)str_people, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );//ur
    //Paint_DrawLine(300+i,167+18,300+i+strlen(arr_string)*8,167+18,WHITE,DOT_PIXEL_1X1,LINE_STYLE_DOTTED );
    Paint_DrawLine(300+i+strlen(arr_string)*4 - 16,167+18,300+i+strlen(arr_string)*4 + 16,167+18,WHITE,DOT_PIXEL_1X1,LINE_STYLE_SOLID );

    char* time_before = right3_change_time_to_dis(true);
    Paint_DrawString_EN(60,192+2,time_before, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
    free(time_before);

    time_before = right3_change_time_to_dis(false);
    Paint_DrawString_EN(60+150,192+2,time_before, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
    free(time_before);


    memcpy(partial_right3_buf,Paint_info.Image,sizeof(uint8_t)*480*224/8);
    return partial_right3_buf;
}

static uint8_t* partial_right4_quick(void)
{
    uint8_t* partial_right4_buf = (uint8_t*)calloc(152*480/8,sizeof(uint8_t));
    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    char str_announcement[8] = {0xb9,0xab,0xb8,0xe6,0x3a,0x00,0x00,0x00};
    Paint_NewImage((UBYTE *)tmp_paint_buf, 480, 152, ROTATE_0, WHITE );
    

    uint8_t *string_infor = malloc(120);
    memset(string_infor,0x00,120);
    strcat((char *)string_infor,str_announcement);
    strcat((char *)string_infor,(char *)Machine_info.announcement);

    Paint_DrawString_CN(10, 6,(char*)string_infor, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
    free(string_infor);
// #if 0//系统消息固定
//     //系统提示:系统3.01固件版本更新了新的功能，请及时更新。
//     //CFB5CDB3CCE1CABE3ACFB5CDB3332E302E31B9CCBCFEB0E6B1BEB8FCD0C2C1CBD0C2B5C4B9A6C4DCA3ACC7EBBCB0CAB1B8FCD0C2A1A30A
//     uint8_t string_system_message[] = {0xCF,0xB5,0xCD,0xB3,0xCC,0xE1,0xCA,0xBE,0x3A,0xCF,0xB5,0xCD,0xB3,0x33,0x2E,0x30,0x2E,0x31,0xB9,0xCC,0xBC,0xFE,0xB0,0xE6,0xB1,0xBE
//                         ,0xB8,0xFC,0xD0,0xC2,0xC1,0xCB,0xD0,0xC2,0xB5,0xC4,0xB9,0xA6,0xC4,0xDC,0xA3,0xAC, 0xC7,0xEB,0xBC,0xB0,0xCA,0xB1,0xB8,0xFC,0xD0,0xC2,0xA1,0xA3,0x0A,0x00,0x00};
//     Paint_DrawString_CN(20, 122,(char*)string_system_message, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
// #else
//     uint8_t *string_sys = malloc(120);
//     char str_xitong[12] = {0xcf,0xb5,0xcd,0xb3,0xcc,0xe1,0xca,0xbe,0x3a,0x00,0x00,0x00};
//     memset(string_sys,0x00,120);
//     strcat((char *)string_sys,str_xitong);
//     strcat((char *)string_sys,(char *)Machine_info.systemMessage);
//     Paint_DrawString_CN(10, 90,(char*)string_sys, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
//     free(string_sys);
// #endif

    memcpy(partial_right4_buf,Paint_info.Image,sizeof(uint8_t)*480*152/8);
    return partial_right4_buf;
}
void Paint_rightScreen_main_powerON()
{

    printf("%s\r\n",__FUNCTION__);

  //当前未配对进入出厂模式


   
   //当前系统的状态 关机 未配网
    if( /*(!Machine_info.paired) &&*/(!Machine_info.power_status))
    {

        printf("power off\r\n");

        memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
        Paint_NewImage((uint8_t*)tmp_paint_buf, 648, 480, ROTATE_270, WHITE);
        Paint_DrawBitMap_Paste(gImage_right_instruction, 0,0  ,480,648 ,1);
        printf("当前系统的状态 关机\n");

        if(read_battery_voltage()<10)
        {
            Paint_DrawBitMap_Paste(gImage_low_batt, 30,428 ,420,154,1); //低电量请充电
        }
    




        epd_init_cmd(SCREEN_RIGHT);
        epd_display(SCREEN_RIGHT,Paint_info.Image);
        memcpy(last_paint_buf_right,Paint_info.Image,sizeof(uint8_t)*648*480/8);
    //         int ret = memcmp(last_paint_buf_right,Paint_info.Image,38880);
    // ESP_LOGW(LOG_TAG,"memcmp :ret = %d",ret);
        if(memcmp(last_paint_buf_right,Paint_info.Image,38880))
        {
            ESP_LOGE(LOG_TAG,"err:last_paint_buf_right");
        }
    }else
        {

            printf("power on\r\n");

            uint8_t* right1_buf = partial_right1_quick(&Machine_info);
            uint8_t* right2_buf = partial_right2_quick();
            uint8_t* right3_buf = partial_right3_quick();
            uint8_t* right4_buf = partial_right4_quick();


            memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
            Paint_NewImage((uint8_t*)tmp_paint_buf, 648, 480, ROTATE_270, WHITE);

            Paint_DrawBitMap_Paste(right1_buf,0,0,480,100,1);
            free(right1_buf);

            Paint_DrawBitMap_Paste(right2_buf,0,100,480,172,1);
            free(right2_buf);

            Paint_DrawBitMap_Paste(right3_buf,0,272,480,224,1);
            free(right3_buf);
            Paint_DrawBitMap_Paste(right4_buf,0,496,480,152,1);
            free(right4_buf);


            printf("当前系统的状态 开机!\n");
            epd_init_cmd(SCREEN_RIGHT);
            epd_display(SCREEN_RIGHT,Paint_info.Image);

            
            memcpy(last_paint_buf_right,Paint_info.Image,sizeof(uint8_t)*648*480/8);
            // int ret = memcmp(last_paint_buf_right,Paint_info.Image,38880);
            // ESP_LOGW(LOG_TAG,"memcmp :ret = %d",ret);
            if(memcmp(last_paint_buf_right,Paint_info.Image,38880))
            {
                ESP_LOGE(LOG_TAG,"err:last_paint_buf_right");
            }



        #if USER_DEEP_SLEEP_ENABLE

                int  reson = is_wake_up_reson();  //返回唤醒的原因

                    if ((reson != ESP_SLEEP_WAKEUP_ULP) || (reson != ESP_SLEEP_WAKEUP_TIMER)) 
                    {

                        uint8_t *old_buffer= heap_caps_malloc(480*81, MALLOC_CAP_8BIT|MALLOC_CAP_SPIRAM);  //申请内存

                        memset(old_buffer,0x00,480*81);
                        //memset((uint8_t*)last_paint_buf_left,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
                    
                        right_compressedSize = compressRLE(last_paint_buf_right, 480*81, old_buffer);
                        printf(" right src size = %d, zip size:%d\r\n",480*81,right_compressedSize);
                        //memset((uint8_t*)tmp_paint_buf,0,sizeof(tmp_paint_buf));
                    
                        //button_deinit();
                        //写入数据
                        right_spiffs_write(old_buffer,right_compressedSize);

                        //button_init(adc1_handle);



                        free(old_buffer);
                    }
        #endif   

        }    


}

void Paint_rightScreen_main_slow(Machine_info_t* info)
{
   printf("Paint_rightScreen_main_slow\r\n");

    uint8_t* right1_buf = partial_right1_quick(&Machine_info);
    uint8_t* right2_buf = partial_right2_quick();
    uint8_t* right3_buf = NULL;
    
    if(Machine_info.right_display_mode == 1)
    {
        right3_buf = partial_right3_2_quick();
    }
    else
    {
        right3_buf = partial_right3_quick();
    }

    uint8_t* right4_buf = partial_right4_quick();


    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((uint8_t*)tmp_paint_buf, 648, 480, ROTATE_270, WHITE);

    Paint_DrawBitMap_Paste(right1_buf,0,0,480,100,1);
    free(right1_buf);

    Paint_DrawBitMap_Paste(right2_buf,0,100,480,172,1);
    free(right2_buf);

    Paint_DrawBitMap_Paste(right3_buf,0,272,480,224,1);
    free(right3_buf);
    Paint_DrawBitMap_Paste(right4_buf,0,496,480,152,1);
    free(right4_buf);







// #if 1 //USER_DEEP_SLEEP_ENABLE


//      uint8_t *old_buffer= heap_caps_malloc(right_compressedSize, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL|MALLOC_CAP_DMA);  //申请内存
//      memset(old_buffer,0x00,right_compressedSize);

//      int  reson = is_wake_up_reson();  //返回唤醒的原因
        
//     if ((reson == ESP_SLEEP_WAKEUP_ULP) || (reson == ESP_SLEEP_WAKEUP_TIMER)) 
//     {

//         //读取数据到内存
//         right_spiffs_read(old_buffer,right_compressedSize);

//         //解压数据
//         right_decompressedSize = decompressRLE(old_buffer, right_compressedSize, last_paint_buf_right);
//         printf("right src size = %d unzip %d\r\n",right_compressedSize,right_decompressedSize);
//     }
    // free(old_buffer);
// #endif

    epd_init_cmd(SCREEN_RIGHT);
    epd_display(SCREEN_RIGHT,Paint_info.Image);  


#if USER_DEEP_SLEEP_ENABLE
if ((reson != ESP_SLEEP_WAKEUP_ULP) || (reson != ESP_SLEEP_WAKEUP_TIMER)) 
#endif   
    {
        memcpy(last_paint_buf_right,Paint_info.Image,sizeof(uint8_t)*648*480/8);
    //         int ret = memcmp(last_paint_buf_right,Paint_info.Image,38880);
    // ESP_LOGW(LOG_TAG,"memcmp :ret = %d",ret);
        if(memcmp(last_paint_buf_right,Paint_info.Image,38880))
        {
            ESP_LOGE(LOG_TAG,"err:last_paint_buf_right");
        }
    }

   

//epd_powerOn_refresh_sleep(SCREEN_RIGHT );


#if 0// USER_DEEP_SLEEP_ENABLE
    int  reson = is_wake_up_reson();  //返回唤醒的原因
    if ((reson == ESP_SLEEP_WAKEUP_ULP) || (reson == ESP_SLEEP_WAKEUP_TIMER)||(reson == ESP_SLEEP_WAKEUP_EXT0)) 
    {
        right_compressedSize = compressRLE(Paint_info.Image, 480*81, last_paint_buf_right);
        // printf("right src size = %d, zip size:%d\r\n",480*81,right_compressedSize);
        //button_deinit();
        //写入数据
        right_spiffs_write(last_paint_buf_right,right_compressedSize);
        //button_init(adc1_handle);
    }
#endif
}

void Paint_rightScreen_main_quick(Machine_info_t* info)
{
     printf("Paint_rightScreen_main_quick\r\n");
    uint8_t* right1_buf = partial_right1_quick(&Machine_info);
    uint8_t* right2_buf = partial_right2_quick();
    uint8_t* right3_buf = NULL;
    
    if(Machine_info.right_display_mode == 1)
    {
        right3_buf = partial_right3_2_quick();
    }
    else
    {
        right3_buf = partial_right3_quick();
    }
    uint8_t* right4_buf = partial_right4_quick();


    memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
    Paint_NewImage((uint8_t*)tmp_paint_buf, 648, 480, ROTATE_270, WHITE);

    Paint_DrawBitMap_Paste(right1_buf,0,0,480,100,1);
    free(right1_buf);

    Paint_DrawBitMap_Paste(right2_buf,0,100,480,172,1);
    free(right2_buf);

    Paint_DrawBitMap_Paste(right3_buf,0,272,480,224,1);
    free(right3_buf);
    Paint_DrawBitMap_Paste(right4_buf,0,496,480,152,1);
    free(right4_buf);







#if USER_DEEP_SLEEP_ENABLE


     uint8_t *old_buffer= heap_caps_malloc(right_compressedSize, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL|MALLOC_CAP_DMA);  //申请内存
     memset(old_buffer,0x00,right_compressedSize);

     int  reson = is_wake_up_reson();  //返回唤醒的原因
        
    if ((reson == ESP_SLEEP_WAKEUP_ULP) || (reson == ESP_SLEEP_WAKEUP_TIMER)) 
    {

        //读取数据到内存
        right_spiffs_read(old_buffer,right_compressedSize);

        //解压数据
        right_decompressedSize = decompressRLE(old_buffer, right_compressedSize, last_paint_buf_right);
        printf("right src size = %d unzip %d\r\n",right_compressedSize,right_decompressedSize);
    }
#endif



    bool ret = epd_cache_quick(SCREEN_RIGHT,(uint8_t*)last_paint_buf_right,Paint_info.Image);
    epd_powerOn_refresh_sleep(SCREEN_RIGHT );

 #if USER_DEEP_SLEEP_ENABLE
    if ((reson != ESP_SLEEP_WAKEUP_ULP) || (reson != ESP_SLEEP_WAKEUP_TIMER)) 
 #endif   
    if(ret)
    {
        memcpy(last_paint_buf_right,Paint_info.Image,sizeof(uint8_t)*648*480/8);
    //         int ret = memcmp(last_paint_buf_right,Paint_info.Image,38880);
    // ESP_LOGW(LOG_TAG,"memcmp :ret = %d",ret);
        if(memcmp(last_paint_buf_right,Paint_info.Image,38880))
        {
            ESP_LOGE(LOG_TAG,"err:last_paint_buf_right");
        }
    }
    else
    {
        ESP_LOGE(LOG_TAG,"r 不保存上一帧");
    }

   





#if USER_DEEP_SLEEP_ENABLE
     //if ((reson == ESP_SLEEP_WAKEUP_ULP) || (reson == ESP_SLEEP_WAKEUP_TIMER)) 
    {

        right_compressedSize = compressRLE(Paint_info.Image, 480*81, last_paint_buf_right);
        printf("right src size = %d, zip size:%d\r\n",480*81,right_compressedSize);
    

        //button_deinit();
        //写入数据
        right_spiffs_write(last_paint_buf_right,right_compressedSize);

        //button_init(adc1_handle);

    } 


    free(old_buffer);

#endif
    Machine_info.last_batt_precent = Machine_info.batt_precent;//右屏刷完后记录电池电量
}


