⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 s_toolssample.c

📁 dragon ball vz328 上的一个例子程序。 用于做手持仪表用。
💻 C
📖 第 1 页 / 共 4 页
字号:

    }
    if (LowpowerCheckNum>120) {
        DisplayCut();
    }
}

/********************************************************************
**电量读取相关函数
********************************************************************/
/**$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$**/
#define XCH_BIT         0x0100
#define XCH_MASK        0xFEFF
#define SPMEN_BIT       0x0200
#define SPMEN_MASK      0xFDFF
#define SPIM_IRQ_BIT    0x0080
#define SPIM_IRQ_MASK   0xFF7F


void ADCCSEnable(void)  {    // enable ADS7843
    *(P_U8)M328_PBDIR  |=  0x40; \
    *(P_U8)M328_PBPUEN &= ~0x40; \
    *(P_U8)M328_PBDATA &= ~0x40;
}


void ADCCSDisable(void)  {  // disable ADS7843
    *(P_U8)M328_PBDATA |=  0x40; \
    *(P_U8)M328_PBPUEN |=  0x40; \
    *(P_U8)M328_PBDIR  &= ~0x40;
}  

void SPIInit(void)      
{
    /* set Data Rate */
    *(P_U16)M328_SPIMCONT  = (U16)(0xC00F);  /// 
    *(P_U16)M328_SPIMCONT &= (U16)XCH_MASK;

    /* Enable SPI */
    *(P_U16)M328_SPIMCONT |= (U16)(0x0200);
}


void SPIPollDone(void)
{
    U32 temp;
    temp=0;

    /* Poll until IRQ bit is set (exchange complete). */
    while (!( *(P_U16)M328_SPIMCONT & SPIM_IRQ_BIT ) ) {
        if (temp>0xFF) {
            break;
        }
        temp++;   
    }  
    /* Reset SPI IRQ bit */
    *(P_U16)M328_SPIMCONT &= SPIM_IRQ_MASK;
}

void SPITx(U16 data)  // spi txd
{
    /* ensure data will not be transmitted while writing to SPI */
    *(P_U16)M328_SPIMCONT &= XCH_MASK;
    *(P_U16)M328_SPIMCONT |= SPMEN_BIT;

    *(P_U16)M328_SPIMDATA  = data;

    /* exchange data */
    *(P_U16)M328_SPIMCONT |= XCH_BIT;
    SPIPollDone();
    *(P_U16)M328_SPIMCONT &= XCH_MASK;
}

/***************************************************
  Read the Pen Coordinate
  Using 24-bit clock for the ADC ADS7843
***************************************************/



U16 Checkvoltage(void){  // read voltage
    U16  i,x_upper[10],x_lower[10];
    U32 temp;

    SPIInit();

    temp=0; 
    for (i=0;i<10;i++) {
        ADCCSEnable(); /* Assert ADC chip select */
        SPITx(0xE400); 
        x_upper[i] = *(P_U16)M328_SPIMDATA;
        SPITx(0x0000); 
        x_lower[i] = *(P_U16)M328_SPIMDATA;
        temp += (((x_upper[i]<<5) & 0x0FE0) | ((x_lower[i]>>11) & 0x001F))  ;
        ADCCSDisable(); /* Negate ADC chip select */
        *(P_U16)M328_SPIMCONT &= SPMEN_MASK;  /* disable SPIM */ 
    }
    temp=(temp*15*147)/(4095*47);



    return(U16)temp;
}

void PreVoltageProcess(void)
{
    U16 Voltage;
    TEXT  Txt1[]={'电','池','电','量',':','20','% ',0};
    TEXT  Txt2[]={'电','池','电','量',':','40','% ',0};
    TEXT  Txt3[]={'电','池','电','量',':','60','% ',0};
    TEXT  Txt4[]={'电','池','电','量',':','80','% ',0};
    TEXT  Txt5[]={'电','池','电','量',':','10','0%',0};
    TEXT  Txt6[]={'电','池','电','量',':','0%','  ',0}; 
    ClearRec(WHITE, 285,142,21,58,REPLACE_STYLE);
    Voltage = Checkvoltage();
    if (Voltage<328) {
        DrawRec(BLACK, 285,142,305,199,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,144,303,153,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,155,303,164,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,166,303,175,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,177,303,186,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,188,303,197,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 290,136,300,142,0,REPLACE_STYLE);
        if (PutString270((P_TEXT)Txt6, 40, 260, 16, 16) !=PPSM_OK) rv=PPSM_ERROR;
    } 
    else if ((Voltage>=328)&&(Voltage<344)) {
        DrawRec(BLACK, 285,142,305,199,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,144,303,153,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,155,303,164,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,166,303,175,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,177,303,186,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 287,188,303,197,0,REPLACE_STYLE);
        DrawRec(BLACK, 290,136,300,142,0,REPLACE_STYLE);
        if (PutString270((P_TEXT)Txt1, 40, 260, 16, 16) !=PPSM_OK) rv=PPSM_ERROR;
    } 
    else if ((Voltage>=344)&&(Voltage<360)) {
        DrawRec(BLACK, 285,142,305,199,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,144,303,153,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,155,303,164,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,166,303,175,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 287,177,303,186,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,188,303,197,0,REPLACE_STYLE);
        DrawRec(BLACK, 290,136,300,142,0,REPLACE_STYLE);
        if (PutString270((P_TEXT)Txt2, 40, 260, 16, 16) !=PPSM_OK) rv=PPSM_ERROR;
    } 
    else if ((Voltage>=360)&&(Voltage<376)) {
        DrawRec(BLACK, 285,142,305,199,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,144,303,153,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,155,303,164,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 287,166,303,175,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,177,303,186,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,188,303,197,0,REPLACE_STYLE);
        DrawRec(BLACK, 290,136,300,142,0,REPLACE_STYLE);
        if (PutString270((P_TEXT)Txt3, 40, 260, 16, 16) !=PPSM_OK) rv=PPSM_ERROR;
    } 
    else if ((Voltage>=376)&&(Voltage<392)) {
        DrawRec(BLACK, 285,142,305,199,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,144,303,153,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 287,155,303,164,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,166,303,175,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,177,303,186,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,188,303,197,0,REPLACE_STYLE);
        DrawRec(BLACK, 290,136,300,142,0,REPLACE_STYLE);
        if (PutString270((P_TEXT)Txt4, 40, 260, 16, 16) !=PPSM_OK) rv=PPSM_ERROR;
    } 
    else if (Voltage>=392) {
        DrawRec(BLACK, 285,142,305,199,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 287,144,303,153,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,155,303,164,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,166,303,175,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,177,303,186,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,188,303,197,0,REPLACE_STYLE);
        DrawRec(BLACK, 290,136,300,142,0,REPLACE_STYLE);
        if (PutString270((P_TEXT)Txt5, 40, 260, 16, 16) !=PPSM_OK) rv=PPSM_ERROR;
    }
    SetPatternFill(0, BLACK, TRUE, 1);
}

void PreVoltageProcess2(void)
{
    U16 Voltage;
    ClearRec(WHITE, 17,13,31,11,REPLACE_STYLE);
    Voltage = Checkvoltage();
    if (Voltage<328) {
        DrawRec(BLACK, 20,13,47,23,0,REPLACE_STYLE);
        DrawRec(BLACK, 22,15,25,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 27,15,30,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 32,15,35,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 37,15,40,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 42,15,45,21,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 17,16,20,20,0,REPLACE_STYLE);
    } 
    else if ((Voltage>=328)&&(Voltage<344)) {
        DrawRec(BLACK, 20,13,47,23,0,REPLACE_STYLE);
        DrawRec(BLACK, 22,15,25,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 27,15,30,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 32,15,35,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 37,15,40,21,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 42,15,45,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 17,16,20,20,0,REPLACE_STYLE);
    } 
    else if ((Voltage>=344)&&(Voltage<360)) {
        DrawRec(BLACK, 20,13,47,23,0,REPLACE_STYLE);
        DrawRec(BLACK, 22,15,25,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 27,15,30,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 32,15,35,21,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 37,15,40,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 42,15,45,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 17,16,20,20,0,REPLACE_STYLE);
    } 
    else if ((Voltage>=360)&&(Voltage<376)) {
        DrawRec(BLACK, 20,13,47,23,0,REPLACE_STYLE);
        DrawRec(BLACK, 22,15,25,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 27,15,30,21,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 32,15,35,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 37,15,40,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 42,15,45,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 17,16,20,20,0,REPLACE_STYLE);
    } 
    else if ((Voltage>=376)&&(Voltage<392)) {
        DrawRec(BLACK, 20,13,47,23,0,REPLACE_STYLE);
        DrawRec(BLACK, 22,15,25,21,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 27,15,30,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 32,15,35,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 37,15,40,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 42,15,45,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 17,16,20,20,0,REPLACE_STYLE);
    } 
    else if (Voltage>=392) {
        DrawRec(BLACK, 20,13,47,23,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 22,15,25,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 27,15,30,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 32,15,35,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 37,15,40,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 42,15,45,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 17,16,20,20,0,REPLACE_STYLE);
    }
    SetPatternFill(0, BLACK, TRUE, 1);

}




void VoltageProcess(void)
{
    U16 Voltage;
    U8 a[4],i;
    TEXT  Txt1[]={'电','池','电','量',':','20','% ',0};
    TEXT  Txt2[]={'电','池','电','量',':','40','% ',0};
    TEXT  Txt3[]={'电','池','电','量',':','60','% ',0};
    TEXT  Txt4[]={'电','池','电','量',':','80','% ',0};
    TEXT  Txt5[]={'电','池','电','量',':','10','0%',0};
    TEXT  Txt6[]={'电','池','电','量',':','0%','  ',0}; 
    Voltage = Checkvoltage();
    /*for (i=0;i<4;i++) {
        a[i]=0;
    }
    a[0]=Voltage/100+0x30;
    a[1]=(Voltage%100)/10+'0';
    a[2]=(Voltage%100)%10+'0';
    if (PutString270((P_TEXT)a, 40, 220, 16, 16) !=PPSM_OK) rv=PPSM_ERROR;*/
    if (Voltage<=328) {
        ClearRec(WHITE, 285,142,21,58,REPLACE_STYLE);
        DrawRec(BLACK, 285,142,305,199,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,144,303,153,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,155,303,164,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,166,303,175,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,177,303,186,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,188,303,197,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 290,136,300,142,0,REPLACE_STYLE);
        if (PutString270((P_TEXT)Txt6, 40, 260, 16, 16) !=PPSM_OK) rv=PPSM_ERROR;
    } 
    else if ((Voltage>=336)&&(Voltage<=344)) {
        ClearRec(WHITE, 285,142,21,58,REPLACE_STYLE);
        DrawRec(BLACK, 285,142,305,199,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,144,303,153,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,155,303,164,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,166,303,175,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,177,303,186,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 287,188,303,197,0,REPLACE_STYLE);
        DrawRec(BLACK, 290,136,300,142,0,REPLACE_STYLE);
        if (PutString270((P_TEXT)Txt1, 40, 260, 16, 16) !=PPSM_OK) rv=PPSM_ERROR;
    } 
    else if ((Voltage>=352)&&(Voltage<=360)) {
        ClearRec(WHITE, 285,142,21,58,REPLACE_STYLE);
        DrawRec(BLACK, 285,142,305,199,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,144,303,153,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,155,303,164,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,166,303,175,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 287,177,303,186,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,188,303,197,0,REPLACE_STYLE);
        DrawRec(BLACK, 290,136,300,142,0,REPLACE_STYLE);
        if (PutString270((P_TEXT)Txt2, 40, 260, 16, 16) !=PPSM_OK) rv=PPSM_ERROR;
    } 
    else if ((Voltage>=368)&&(Voltage<=376)) {
        ClearRec(WHITE, 285,142,21,58,REPLACE_STYLE);
        DrawRec(BLACK, 285,142,305,199,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,144,303,153,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,155,303,164,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 287,166,303,175,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,177,303,186,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,188,303,197,0,REPLACE_STYLE);
        DrawRec(BLACK, 290,136,300,142,0,REPLACE_STYLE);
        if (PutString270((P_TEXT)Txt3, 40, 260, 16, 16) !=PPSM_OK) rv=PPSM_ERROR;
    } 
    else if ((Voltage>=384)&&(Voltage<=392)) {
        ClearRec(WHITE, 285,142,21,58,REPLACE_STYLE);
        DrawRec(BLACK, 285,142,305,199,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,144,303,153,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 287,155,303,164,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,166,303,175,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,177,303,186,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,188,303,197,0,REPLACE_STYLE);
        DrawRec(BLACK, 290,136,300,142,0,REPLACE_STYLE);
        if (PutString270((P_TEXT)Txt4, 40, 260, 16, 16) !=PPSM_OK) rv=PPSM_ERROR;
    } 
    else if (Voltage>=400) {
        ClearRec(WHITE, 285,142,21,58,REPLACE_STYLE);
        DrawRec(BLACK, 285,142,305,199,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 287,144,303,153,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,155,303,164,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,166,303,175,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,177,303,186,0,REPLACE_STYLE);
        DrawRec(BLACK, 287,188,303,197,0,REPLACE_STYLE);
        DrawRec(BLACK, 290,136,300,142,0,REPLACE_STYLE);
        if (PutString270((P_TEXT)Txt5, 40, 260, 16, 16) !=PPSM_OK) rv=PPSM_ERROR;
    } 
    else {
        ;
    }
    SetPatternFill(0, BLACK, TRUE, 1);
}

void VoltageProcess2(void)
{
    U16 Voltage;
    Voltage = Checkvoltage();
    if (Voltage<=328) {
        ClearRec(WHITE, 17,13,31,11,REPLACE_STYLE);
        DrawRec(BLACK, 20,13,47,23,0,REPLACE_STYLE);
        DrawRec(BLACK, 22,15,25,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 27,15,30,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 32,15,35,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 37,15,40,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 42,15,45,21,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 17,16,20,20,0,REPLACE_STYLE);
    } 
    else if ((Voltage>=336)&&(Voltage<=344)) {
        ClearRec(WHITE, 17,13,31,11,REPLACE_STYLE);
        DrawRec(BLACK, 20,13,47,23,0,REPLACE_STYLE);
        DrawRec(BLACK, 22,15,25,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 27,15,30,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 32,15,35,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 37,15,40,21,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 42,15,45,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 17,16,20,20,0,REPLACE_STYLE);
    } 
    else if ((Voltage>=352)&&(Voltage<=360)) {
        ClearRec(WHITE, 17,13,31,11,REPLACE_STYLE);
        DrawRec(BLACK, 20,13,47,23,0,REPLACE_STYLE);
        DrawRec(BLACK, 22,15,25,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 27,15,30,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 32,15,35,21,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 37,15,40,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 42,15,45,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 17,16,20,20,0,REPLACE_STYLE);
    } 
    else if ((Voltage>=368)&&(Voltage<=376)) {
        ClearRec(WHITE, 17,13,31,11,REPLACE_STYLE);
        DrawRec(BLACK, 20,13,47,23,0,REPLACE_STYLE);
        DrawRec(BLACK, 22,15,25,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 27,15,30,21,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 32,15,35,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 37,15,40,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 42,15,45,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 17,16,20,20,0,REPLACE_STYLE);
    } 
    else if ((Voltage>=384)&&(Voltage<=392)) {
        ClearRec(WHITE, 17,13,31,11,REPLACE_STYLE);
        DrawRec(BLACK, 20,13,47,23,0,REPLACE_STYLE);
        DrawRec(BLACK, 22,15,25,21,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 27,15,30,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 32,15,35,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 37,15,40,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 42,15,45,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 17,16,20,20,0,REPLACE_STYLE);
    } 
    else if (Voltage>=400) {
        ClearRec(WHITE, 17,13,31,11,REPLACE_STYLE);
        DrawRec(BLACK, 20,13,47,23,0,REPLACE_STYLE);
        SetPatternFill(1, BLACK, TRUE, 1);
        DrawRec(BLACK, 22,15,25,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 27,15,30,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 32,15,35,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 37,15,40,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 42,15,45,21,0,REPLACE_STYLE);
        DrawRec(BLACK, 17,16,20,20,0,REPLACE_STYLE);
    } 
    else {
        ;
    }
    SetPatternFill(0, BLACK, TRUE, 1);
}


void VoltageProcess3(void)
{
    U16 Voltage;

    if (CheckVoltageNum<10) {
        CheckVoltageNum++;
    } else {
        Voltage = Checkvoltage();
        if (Voltage<328)
            LowPowerAlarm();
        CheckVoltageNum=0;
    }
}

void StartLowPowerCheck(void)
{
    U32  i,j;
    U16  tmpVoltage;
    TEXT ShutDownHintTxt[]={'电','量','不','足',',','请','充','电','后','使','用','!',0};
    TEXT VerErrorHintTxt[]={'此','PD','A ','与','程','序','版','本','不','对','应','!',0};

    tmpVoltage=Checkvoltage();
    if (tmpVoltage<100) {
        ClearScreen(WHITE);
        Typing(GB_NORMAL_FONT, REPLACE_STYLE, BLACK, 30, 100, (P_U8)VerErrorHintTxt);
        for (i=0;i<5;i++) {
            for(j=0;j<0x3FFFF;j++);
            BUZZER_ON();
        }
        POWER_OFF();//关闭电源
        asm("    JSR START");  
        return;
    }
    if (tmpVoltage<330) {
        ClearScreen(WHITE);
        Typing(GB_NORMAL_FONT, REPLACE_STYLE, BLACK, 30, 100, (P_U8)ShutDownHintTxt);
        for (i=0;i<5;i++) {
            for(j=0;j<0x3FFFF;j++);
            BUZZER_ON();
        }
        DisplayCut();
    }
}
/**$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$**/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -