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

📄 display.c

📁 用ADE7169F16单片机实现了单向多费4率电能表
💻 C
📖 第 1 页 / 共 2 页
字号:
}
#endif

void UpdDisplay(void)
{
	// ClearLCDBuf
	// DispWatt
	// ContDispWatt
	// Disprms
	// VRMSConf
	// IRMSConf
	// ContDisprms
	// DoneUpdate
}
/*************************************************
 * 显示日期、时间
 *************************************************/
void DisplayDate(void)
{
    //lcd_buf[0] = DigitTable[(Hex2BcdChar(tmp[3])>>4)&0x0F];
    lcd_buf[1] = DigitTable[(Hex2BcdChar(Systime.Date.Year)>>4)&0x0F];
    lcd_buf[2] = DigitTable[(Hex2BcdChar(Systime.Date.Year))&0x0F];
    lcd_buf[3] = DigitTable[(Hex2BcdChar(Systime.Date.Month)>>4)&0x0F];
    lcd_buf[4] = DigitTable[(Hex2BcdChar(Systime.Date.Month))&0x0F];
    lcd_buf[5] = DigitTable[(Hex2BcdChar(Systime.Date.Day)>>4)&0x0F];
    lcd_buf[6] = DigitTable[(Hex2BcdChar(Systime.Date.Day))&0x0F];
    lcd_buf[9] = 0x5F;          // ID '6'
    // Display P1,P3,P2,P5
    Disp_Point(Disp_P5_Addr,Disp_P5);
    Disp_Point(Disp_P3_Addr,Disp_P3);
    Disp_Point(Disp_P2_Addr,Disp_P2);
    Disp_Point(Disp_P1_Addr,Disp_P1);
    _Lcd_WScreen(lcd_buf);
}

void _DispProcB00(void)     // kwh
{
    Disp_KWHIcon();

    // exchage to xx xx xx.xxV
    sys_tmp=Hex2BcdLong(curdata.watthour[curdata.tariff]);  // K?
    //tmp <<= 4;// 去除最高字节的高半字节,显示位数不够
    __Disp_Digits((unsigned char idata *)&sys_tmp);
    lcd_buf[9] = 0x60;//DigitTable[1];   //ID '1'
    Disp_Point(Disp_P5_Addr,Disp_P5);
    _Lcd_WScreen(lcd_buf);
    #if 0
    unsigned long tmp;

    Disp_KWHIcon();
    Disp_Point(PointsTable[PointsTabIndx_P6],PointsTable[PointsTabIndx_P6+1]);
    tmp=Hex2BcdLong(curdata.watthour[curdata.tariff]);
    Disp_Digit(Digit7Addr,((unsigned char)(tmp)&0x0f));
    Disp_Digit(Digit6Addr,(((unsigned char)(tmp)&0x0f)>>4));
    Disp_Digit(Digit5Addr,((unsigned char)(tmp>>8)&0x0f));
    Disp_Digit(Digit4Addr,(((unsigned char)(tmp>>8)&0x0f)>>4));
    Disp_Digit(Digit3Addr,((unsigned char)(tmp>>16)&0x0f));
    Disp_Digit(Digit2Addr,(((unsigned char)(tmp>>16)&0x0f)>>4));
    Disp_Digit(Digit3Addr,((unsigned char)(tmp>>24)&0x0f));
    Disp_Digit(Digit2Addr,(((unsigned char)(tmp>>24)&0x0f)>>4));
    #endif
}

void _DispProcB01(void)     // kvarh
{
    Disp_KVARHIcon();
    // exchage to xx xx xx.xxV
    sys_tmp=Hex2BcdLong(curdata.varthour[curdata.tariff]);   // K?
    //tmp <<= 4;// 去除最高字节的高半字节,显示位数不够
    __Disp_Digits((unsigned char idata*)&sys_tmp);
    lcd_buf[9] = 0x3e;//DigitTable[2];   //ID '2'
    Disp_Point(Disp_P5_Addr,Disp_P5);
    _Lcd_WScreen(lcd_buf);
    #if 0
    unsigned long tmp;

    Disp_KVARHIcon();
    Disp_Point(PointsTable[PointsTabIndx_P6],PointsTable[PointsTabIndx_P6+1]);
    tmp=Hex2BcdLong(curdata.varthour[curdata.tariff]);
    // Disp_Digit(Digit7Addr,((unsigned char)(tmp)&0x0f));
    Disp_Digit(Digit7Addr,(((unsigned char)(tmp)&0x0f)>>4));
    Disp_Digit(Digit6Addr,((unsigned char)(tmp>>8)&0x0f));
    Disp_Digit(Digit5Addr,(((unsigned char)(tmp>>8)&0x0f)>>4));
    Disp_Digit(Digit4Addr,((unsigned char)(tmp>>16)&0x0f));
    Disp_Digit(Digit3Addr,(((unsigned char)(tmp>>16)&0x0f)>>4));
    Disp_Digit(Digit2Addr,((unsigned char)(tmp>>24)&0x0f));
    Disp_Digit(Digit1Addr,(((unsigned char)(tmp>>24)&0x0f)>>4));
    #endif
}

/************************************************/
void _DispProcB02(void)     // Vrms
{

    Disp_VrmsIcon();
    GetVrms();

    // exchage to xx xx xx.xxV
    sys_tmp=Hex2BcdLong(instdata.Vrms);
    //tmp <<= 4;// 去除最高字节的高半字节,显示位数不够
    __Disp_Digits((unsigned char idata*)&sys_tmp);
    /*
    Disp_Digit(Digit7Addr,((unsigned char)(tmp)&0x0f));
    Disp_Digit(Digit6Addr,(((unsigned char)(tmp)&0x0f)>>4));
    Disp_Digit(Digit5Addr,((unsigned char)(tmp>>8)&0x0f));
    Disp_Digit(Digit4Addr,(((unsigned char)(tmp>>8)&0x0f)>>4));
    Disp_Digit(Digit3Addr,((unsigned char)(tmp>>16)&0x0f));
    Disp_Digit(Digit2Addr,(((unsigned char)(tmp>>16)&0x0f)>>4));
    */
    lcd_buf[9] = 0x7A;//DigitTable[3];   //ID '3'
    Disp_Point(Disp_P5_Addr,Disp_P5);
    _Lcd_WScreen(lcd_buf);
}

void _DispProcB03(void)     // Irms
{
    Disp_IrmsIcon();
    GetIrms();
    // exchage to xx xx xx.xxV
    sys_tmp=Hex2BcdLong(instdata.Vrms);
    //tmp <<= 4;// 去除最高字节的高半字节,显示位数不够
    __Disp_Digits((unsigned char idata*)&sys_tmp);
    lcd_buf[9] = 0x63;//DigitTable[4];   //ID '4'
    Disp_Point(Disp_P5_Addr,Disp_P5);
    _Lcd_WScreen(lcd_buf);
    #if 0
    unsigned long tmp;

    Disp_IrmsIcon();
    Disp_Point(PointsTable[PointsTabIndx_P5],PointsTable[PointsTabIndx_P5+1]);
    GetIrms();
    tmp=Hex2BcdLong(instdata.Irms);
    Disp_Digit(Digit7Addr,((unsigned char)(tmp)&0x0f));
    Disp_Digit(Digit6Addr,(((unsigned char)(tmp)&0x0f)>>4));
    Disp_Digit(Digit5Addr,((unsigned char)(tmp>>8)&0x0f));
    Disp_Digit(Digit4Addr,(((unsigned char)(tmp>>8)&0x0f)>>4));
    Disp_Digit(Digit3Addr,((unsigned char)(tmp>>16)&0x0f));
    Disp_Digit(Digit2Addr,(((unsigned char)(tmp>>16)&0x0f)>>4));
    #endif
}

void _DispProcB04(void)     // kw
{
    Disp_KWIcon();
}

void _DispProcB05(void)     // Hz
{
    #if 0
    unsigned long tmp;

    Disp_HzIcon();
    tmp=Hex2BcdShort(instdata.PER_FREQ);
    Disp_Digit(Digit5Addr,((unsigned char)(tmp>>8)&0x0f));
    Disp_Digit(Digit4Addr,(((unsigned char)(tmp>>8)&0x0f)>>4));
    Disp_Digit(Digit3Addr,((unsigned char)(tmp>>16)&0x0f));
    Disp_Digit(Digit2Addr,(((unsigned char)(tmp>>16)&0x0f)>>4));
    #endif
}
/*
void _DispProcB06(void)
{
}

void _DispProcB07(void)
{
}
*/

code const PROC_FUNC DisplayProc[]={
    _Lcd_All_On,
    _DispProcB00,
    _DispProcB01,
    _DispProcB02,
    _DispProcB03,
    //_DispProcB04,
    //_DispProcB05,
    _DisplayTime,
    DisplayDate,
    //_DispProcB06,
    //_DispProcB07,
    //_Lcd_All_On,
};

/******************************************************************************/
void DisplayContentCode(void)
{
}

void DisplayPointerNext(void)
{
}

void PageUpNext(void)
{
    if(LcdDispFlag&LCD_DISP_NEXT)
    {
        DisplayBitLocation++;
    }
}


void PageDownNext(void)
{
    DisplayBitLocation=0;
    if(DisplayPointer==0)
    {
        DisplayPointer=1;
    }
}

void _display_next(void)
{
    // Auto display
    DisplayPointer++;
    if(DisplayPointer >= (sizeof(DisplayProc)/sizeof(PROC_FUNC)))// -1 RT 2006-07-05
    {
        DisplayPointer=0;
    }
}

/*************************************************
 * 显示处理
 *************************************************/
void DisplayProcess(void)
{
    // if(DisplayPointer > (sizeof(DisplayProc)/sizeof(PROC_FUNC))){DisplayPointer = (sizeof(DisplayProc)/sizeof(PROC_FUNC));}
    //__disable_interrupt();
    _mem_set(lcd_buf,0,12);
    DisplayProc[DisplayPointer]();
    //__enable_interrupt();
    if(bManDisp)
    {
        bManDisp=0;
        // Page up: DisplayPointer--
        if(LcdDispFlag & LCD_DISP_FLG_PAGEUP)
        {
            LcdDispFlag &= ~(LCD_DISP_FLG_PAGEUP);
            if(DisplayPointer == 0){DisplayPointer = (sizeof(DisplayProc)/sizeof(PROC_FUNC));}
            DisplayPointer--;
        }
        // Page Down: DisplayPointer++
        else if(LcdDispFlag & LCD_DISP_FLG_PAGEDOWN)
        {
            LcdDispFlag &= ~(LCD_DISP_FLG_PAGEDOWN);
            DisplayPointer++;
            if(DisplayPointer == (sizeof(DisplayProc)/sizeof(PROC_FUNC))){DisplayPointer = 0;}
        }
    }
    /*
    else
    {
        // Auto display
        DisplayPointer++;
        if(DisplayPointer >= (sizeof(DisplayProc)/sizeof(PROC_FUNC)))
        {
            DisplayPointer=0;
        }
    }
    */
    #if 0
    unsigned char *_disp_info=(unsigned char *)&_SysPotInfo.dispcontent[0];
    LcdDispFlag&=~(LCD_DISP_ALL);

    while(1)
    {
        if(_disp_info[DisplayPointer])
        {
            // 判断显示选择位
            if(_disp_info[DisplayPointer]&(BIT0<<DisplayBitLocation))
            {
                ClearLcd();
                LcdDispFlag&=~(LCD_DISP_FLG_REFIND);
                // 如果有选择项,则执行相应的函数
                (DisplayProc[DisplayPointer])();
                if(!(LcdDispFlag&LCD_DISP_FLG_REFIND))
                {
                    DisplayContentCode();
                    break;
                }
            }
        }
        else
        {
            if(LcdDispFlag&LCD_DISP_FLG_PAGEDOWN)
            {
                if(LcdDispFlag&LCD_DISP_FLG_PAGEUP)
                {
                    //PageDownNext();
                    PageUpNext();
                }
            }
        }
        if(LcdDispFlag&LCD_DISP_FLG_PAGEDOWN)
        {
            if(LcdDispFlag&LCD_DISP_FLG_PAGEUP)
            {
                PageUpNext();
            }
            else
            {
                PageDownNext();
            }
        }
        else
        {
            DisplayPointerNext();
        }
    }
    #endif
}

/*************************************************
 * 显示刷新 Auto display
 *************************************************/
void DisplayRefresh(void)
{
    if(LcdInterval==0)
    {
        LcdInterval = 7;//_SysPotInfo.disptime;
        _display_next();
    }
    LcdInterval--;
    DisplayProcess();

#if 0
    //unsigned char mrs,lvisw;
    //unsigned char temp1,temp2;

    // 时间/日期显示
    if(LcdDispFlag&LCD_DISP_TIME)
    {
        if((LcdInterval==0)&&(!(LcdDispFlag&LCD_DISP_FLG_PAGEDOWN)))
        {
            if(!(LcdDispFlag&LCD_DISP_NEXT))
            {
                DisplayBitLocation++;
                LcdInterval=6;// 6s for debug; _SysPotInfo.disptime;
                LcdDispFlag|=LCD_DISP_NEXT;
            }
            else
            {
                LcdDispFlag&=~(LCD_DISP_TIME);
                goto DISP_PROC;
            }
        }
        Disp_Clear();//ClearLcd();
        /*
        LCDMEM[LCD_SY_INFO_ADDR_P2]|=LCD_SY_INFO_P2;
        LCDMEM[LCD_CODE_ADDR_01]|=_LcdCodeHex[0];
        LCDMEM[LCD_CODE_ADDR_02]|=_LcdCodeHex[0];
        LCDMEM[LCD_CODE_ADDR_03]|=_LcdCodeHex[0];
        if(LcdDispFlag&LCD_DISP_NEXT)
        {
            LCDMEM[LCD_CODE_ADDR_04]|=_LcdCodeHex[4];
        }
        else
        {
            LCDMEM[LCD_CODE_ADDR_04]|=_LcdCodeHex[3];
        }
        */
        DisplayDateTime();
        LcdInterval--;
        goto DISP_OTHERS;
    }

    // 如果没有进入翻页显示状态
    // 如果已经设置了轮显编码,则进入轮显处理
    if((LcdDispFlag&0x0F)==LCD_DISP_FLG_ACTIVE)
    {
            if(LcdInterval==0)
            {
DISP_PROC:
                DisplayProcess();

                // 重新设置轮显时间
                LcdInterval=6;// 6s; _SysPotInfo.disptime;

                if(LcdDispFlag&LCD_DISP_NEXT)
                {
                    DisplayPointerNext();
                }
            }
            LcdInterval--;
    }
    if(LcdDispFlag&LCD_DISP_ALL)
    {
        return;
    }
DISP_OTHERS:
    return;
#endif

}

/******************************************
* 上翻页键
******************************************/
void OnDisplayPageUp(void)
{
    if(LcdDispFlag&LCD_DISP_FLG_PAGEDOWN)
    {
        PageUpNext();
        DisplayProcess();
    }
    LcdDispFlag&=~(LCD_DISP_FLG_PAGEUP);
}




⌨️ 快捷键说明

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