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

📄 f45_dip.c

📁 HSAV OTG13S USB-HOST MP3模块应用源代码
💻 C
字号:
#include "F45_main.h"           

void MDIPInitialize(){
    pRESETB = 0;
    MDELAY(5);
    pRESETB = 1;                                   
    MDELAY(5);
                
    MDIPClearALL();
    MDELAY(5);
    MLCD_Write(0, cLCM_PowerControl);
    MLCD_Write(0, cLCM_Display_On); 
    MLCD_Write(0, cLCM_EntireDisplayOn);
    MLCD_Write(0, cLCM_InitialDisplayLine);
    MLCD_Write(0, cLCM_SelectLCD_Bias);

    MLCD_Write(0, 0x81); 
//    MLCD_Write(0, 0x0f); // 调节LCD光暗度
    MLCD_Write(0, 0x01); // 调节LCD光暗度

    return;                                   
}
void MDIPClearALL(){
    BYTE gLocal_1;
    BYTE gLocal_2;                                               
    gLocal_1 = 0;
    do {
        gLocal_2 = 0;
        MLCD_Write(0, cLCM_SetPageAddress | gLocal_1);
        MLCD_Write(0, cLCM_SetColumnAddressMSB | (gLocal_2 >> 4));
        MLCD_Write(0, cLCM_SetColumnAddressLSB | (gLocal_2 & 0x0f));
        do {
            MLCD_Write(1, 0x00);
        } while (++gLocal_2 < 132); 
    } while (++gLocal_1 < 4); 
         
    return;
}

void MDIP_LineClear(BYTE gLocal_Y, BYTE gLocal_Start, BYTE gLocal_End){
    BYTE gLocal_1;
    BYTE gLocal_2;

    gLocal_Y = 4 - (gLocal_Y * 2);
    gLocal_1 = gLocal_Y;
    do {
        gLocal_2 = gLocal_Start;
        MLCD_Write(0, cLCM_SetPageAddress | gLocal_1);
        MLCD_Write(0, cLCM_SetColumnAddressMSB | (gLocal_2 >> 4));
        MLCD_Write(0, cLCM_SetColumnAddressLSB | (gLocal_2 & 0x0f));
        do {
            MLCD_Write(1, 0x00);
        } while (++gLocal_2 < gLocal_End);
    } while (++gLocal_1 < (gLocal_Y+2));                                                       

    return;
}

// pRS=0;为发送指令, pRS=1;为发送数据;
void MLCD_Write(BYTE gLocal_RS, BYTE gLocal_Data){
    BYTE gLocal_0;
    pRS = gLocal_RS;
    pCSIB = 0;
    gLocal_0 = 8;
    do {
        pSCLK = 0;
        if (gLocal_Data & 0x80) pSID = 1;
        else pSID = 0;
        pSCLK = 1;
        gLocal_Data <<= 1;
    }while(--gLocal_0 != 0);
    pSCLK = 0;
    pCSIB = 1;
    return;
}

CONST_CHAR TabDisplayASCII [] = {  // from UCDOS ASC12
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,        /*   */
    0x00,0x00,0x00,0x00,0xe4,0x30,0x00,0x00,0x00,        /* ! */
    0x00,0x80,0x30,0x00,0x00,0x02,0x80,0x00,0x23,        /* " */
    0x00,0x56,0x00,0xf8,0x56,0x30,0xf8,0x50,0x30,        /* # */
    0x00,0xd8,0x00,0x28,0x2e,0x31,0x30,0x00,0x01,        /* $ */
    0x00,0x20,0x10,0xa0,0x28,0x12,0x54,0x48,0x00,        /* % */
    0x00,0x18,0x00,0x64,0x94,0x00,0x88,0x14,0x00,        /* & */
    0x00,0x00,0x00,0x00,0xc0,0x30,0x00,0x00,0x00,        /* ' */
    0x00,0x00,0x00,0x00,0xfc,0x00,0x03,0x00,0x03,        /* ( */
    0x00,0x00,0x00,0x03,0xfc,0x03,0x00,0x00,0x00,        /* ) */
    0x00,0x00,0x10,0x60,0x80,0x31,0x60,0x00,0x11,        /* * */
    0x20,0x20,0x00,0x20,0xfc,0x10,0x20,0x20,0x00,        /* + */
    0x00,0x00,0x00,0x03,0x0e,0x00,0x08,0x00,0x00,        /* , */
    0x00,0x20,0x00,0x20,0x20,0x00,0x20,0x20,0x00,        /* - */
    0x00,0x00,0x00,0x0c,0x0c,0x00,0x00,0x00,0x00,        /* . */
    0x00,0x02,0x00,0x0c,0x30,0x00,0xc0,0x00,0x30,        /* / */
    0x00,0xf8,0x10,0x04,0x04,0x22,0x04,0xf8,0x12,        /* 0 */
    0x00,0x04,0x00,0x04,0xfc,0x32,0x04,0x04,0x00,        /* 1 */
    0x00,0x0c,0x10,0x14,0x24,0x22,0x44,0x8c,0x12,        /* 2 */
    0x00,0x08,0x10,0x04,0x44,0x22,0x44,0xb8,0x12,        /* 3 */
    0x00,0x30,0x00,0x50,0x90,0x10,0x14,0xfc,0x32,        /* 4 */
    0x00,0x08,0x00,0xc4,0x44,0x23,0x44,0x38,0x22,        /* 5 */
    0x00,0xf8,0x00,0x44,0x44,0x21,0x44,0x38,0x22,        /* 6 */
    0x00,0x00,0x30,0x00,0x0c,0x22,0x70,0x80,0x32,        /* 7 */
    0x00,0xb8,0x10,0x44,0x44,0x22,0x44,0xb8,0x12,        /* 8 */
    0x00,0xc4,0x10,0x24,0x24,0x22,0x28,0xf0,0x12,        /* 9 */
    0x00,0x00,0x00,0xcc,0xcc,0x00,0x00,0x00,0x00,        /* : */
    0x00,0x00,0x00,0x06,0xcc,0x00,0xc8,0x00,0x00,        /* ; */
    0x20,0x50,0x00,0x50,0x88,0x00,0x04,0x04,0x11,        /* < */
    0x00,0x50,0x00,0x50,0x50,0x00,0x50,0x50,0x00,        /* = */
    0x04,0x04,0x11,0x88,0x50,0x00,0x50,0x20,0x00,        /* > */
    0x00,0x00,0x00,0x84,0x14,0x10,0x20,0xc0,0x01,        /* ? */
    0x00,0xfc,0x30,0x02,0x62,0x44,0x92,0xf4,0x34,        /* @ */
    0x04,0x1c,0x00,0xf4,0x10,0x32,0xf4,0x1c,0x00,        /* A */
    0x04,0xfc,0x32,0x44,0x44,0x22,0x44,0xb8,0x12,        /* B */
    0x00,0xf8,0x10,0x04,0x04,0x22,0x04,0x08,0x32,        /* C */
    0x04,0xfc,0x32,0x04,0x04,0x22,0x08,0xf0,0x01,        /* D */
    0x04,0xfc,0x32,0x44,0xe4,0x22,0x04,0x0c,0x32,        /* E */
    0x00,0x04,0x20,0xfc,0x44,0x23,0xe0,0x00,0x22,        /* F */
    0x00,0xf8,0x10,0x04,0x04,0x22,0x24,0x38,0x32,        /* G */
    0x04,0xfc,0x32,0x44,0x40,0x02,0x44,0xfc,0x32,        /* H */
    0x00,0x04,0x20,0x04,0xfc,0x32,0x04,0x04,0x22,        /* I */
    0x00,0x38,0x00,0x04,0x04,0x22,0xf8,0x00,0x23,        /* J */
    0x04,0xfc,0x32,0x24,0x60,0x02,0x90,0x0c,0x32,        /* K */
    0x00,0x04,0x20,0xfc,0x04,0x23,0x04,0x1c,0x00,        /* L */
    0x04,0xfc,0x32,0x84,0x60,0x03,0x84,0xfc,0x33,        /* M */
    0x04,0xfc,0x32,0x84,0x70,0x03,0x0c,0xfc,0x32,        /* N */
    0x00,0xf8,0x10,0x04,0x04,0x22,0x04,0xf8,0x12,        /* O */
    0x00,0x04,0x20,0xfc,0x24,0x23,0x20,0xc0,0x12,        /* P */
    0x00,0xf8,0x10,0x04,0x06,0x22,0x06,0xfa,0x12,        /* Q */
    0x04,0xfc,0x32,0x24,0x20,0x22,0x30,0xc8,0x12,        /* R */
    0x00,0x8c,0x10,0x48,0x44,0x22,0x44,0x38,0x31,        /* S */
    0x00,0x00,0x23,0x04,0xfc,0x32,0x04,0x00,0x22,        /* T */
    0x00,0xf8,0x32,0x04,0x04,0x02,0x04,0xf8,0x32,        /* U */
    0x00,0x80,0x32,0x70,0x0c,0x02,0x70,0x80,0x32,        /* V */
    0x00,0xf8,0x32,0x04,0x78,0x02,0x04,0xf8,0x32,        /* W */
    0x04,0x0c,0x32,0x90,0x60,0x00,0x90,0x0c,0x30,        /* X */
    0x00,0x00,0x32,0xc4,0x3c,0x02,0xc4,0x00,0x32,        /* Y */
    0x00,0x0c,0x30,0x14,0x64,0x22,0x84,0x0c,0x32,        /* Z */
    0x00,0x00,0x00,0xff,0x01,0x23,0x01,0x00,0x02,        /* [ */
    0x00,0x00,0x20,0xc0,0x30,0x01,0x0e,0x00,0x00,        /* \ */
    0x00,0x00,0x00,0x01,0x01,0x22,0xff,0x00,0x03,        /* ] */
    0x00,0x40,0x00,0x80,0x00,0x30,0x80,0x40,0x00,        /* ^ */
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,        /* _ */
    0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x01,        /* ` */
    0x00,0x58,0x00,0xa4,0xa4,0x00,0xa4,0x7c,0x00,        /* a */
    0x04,0xfc,0x32,0x44,0x84,0x00,0x84,0x78,0x00,        /* b */
    0x00,0x78,0x00,0x84,0x84,0x00,0x84,0xc8,0x00,        /* c */
    0x00,0x78,0x00,0x84,0x84,0x00,0x44,0xfc,0x32,        /* d */
    0x00,0x78,0x00,0xa4,0xa4,0x00,0xa4,0x64,0x00,        /* e */
    0x00,0x84,0x00,0xfc,0x84,0x21,0x84,0x84,0x22,        /* f */
    0x00,0x78,0x00,0x85,0x85,0x00,0x45,0xfe,0x00,        /* g */
    0x04,0xfc,0x32,0x44,0x80,0x00,0x84,0x7c,0x00,        /* h */
    0x00,0x84,0x00,0x84,0xfc,0x20,0x04,0x04,0x00,        /* i */
    0x00,0x81,0x00,0x81,0x81,0x20,0xfe,0x00,0x00,        /* j */
    0x04,0xfc,0x32,0x20,0xb4,0x00,0xcc,0x84,0x00,        /* k */
    0x00,0x04,0x00,0x04,0xfc,0x32,0x04,0x04,0x00,        /* l */
    0x84,0xfc,0x00,0x84,0x7c,0x00,0x84,0x7c,0x00,        /* m */
    0x84,0xfc,0x00,0x44,0x80,0x00,0x84,0x7c,0x00,        /* n */
    0x00,0x78,0x00,0x84,0x84,0x00,0x84,0x78,0x00,        /* o */
    0x81,0xff,0x00,0x45,0x84,0x00,0x84,0x78,0x00,        /* p */
    0x00,0x78,0x00,0x84,0x84,0x00,0x45,0xff,0x00,        /* q */
    0x00,0x84,0x00,0xfc,0x44,0x00,0x84,0x84,0x00,        /* r */
    0x00,0x4c,0x00,0xa4,0xa4,0x00,0xa4,0xd8,0x00,        /* s */
    0x00,0x80,0x00,0xf8,0x84,0x01,0x84,0x84,0x00,        /* t */
    0x80,0xf8,0x00,0x04,0x04,0x00,0x88,0xfc,0x00,        /* u */
    0x80,0xe0,0x00,0x98,0x04,0x00,0x98,0xe0,0x00,        /* v */
    0x80,0xf8,0x00,0x84,0x38,0x00,0x84,0xf8,0x00,        /* w */
    0x84,0xcc,0x00,0x30,0x30,0x00,0xcc,0x84,0x00,        /* x */
    0x80,0xc1,0x00,0xb1,0x0f,0x00,0x99,0xe0,0x00,        /* y */
    0x00,0xcc,0x00,0x94,0xa4,0x00,0xc4,0x8c,0x00,        /* z */
    0x00,0x00,0x00,0x10,0xee,0x10,0x01,0x00,0x02,        /* { */
    0x00,0x00,0x00,0x00,0xfe,0x30,0x00,0x00,0x00,        /* | */
    0x00,0x00,0x00,0x01,0xee,0x12,0x10,0x00,0x00,        /* } */
    0x20,0x40,0x00,0x40,0x20,0x00,0x20,0x40,0x00,        /* ~ */

};

//////////////////////////////////////////////////////////////////////////
//函数功能:  字符显示


//          gCharacterDistance 为字符间距, 常为1, 即字符之间空一个点
//          如有需要可以在调用前赋值 0, 1, 2, 3等
//////////////////////////////////////////////////////////////////////////

                         //列数变量(0~128) //行数变量        //显示变量       //模式
BYTE MLIBWriteCharacter(char gLocal_XS, short gLocal_YS, WORD g2Local_Char){

    BYTE gLocal_1;
    BYTE gLocal_2;
    BYTE gLocal_3;
    WORD g2Local_1;                                
    
    gLocal_YS = 4 - (gLocal_YS * 2);
    if (g2Local_Char < 0x0080){
        g2Local_1 = (g2Local_Char - ' ') * 9;  

        MLCD_Write(0, cLCM_SetColumnAddressMSB | (gLocal_XS >> 4));
        MLCD_Write(0, cLCM_SetColumnAddressLSB | (gLocal_XS & 0x0f));
        MLCD_Write(0, cLCM_SetPageAddress | gLocal_YS);
        gLocal_2 = 0;
        do {
            MLCD_Write(1, TabDisplayASCII[g2Local_1 + gLocal_2]);
            MLCD_Write(1, TabDisplayASCII[g2Local_1 + gLocal_2 + 1]);  
            gLocal_2 += 3;
        } while (gLocal_2 < 9);                                    

        MLCD_Write(0, cLCM_SetColumnAddressMSB | (gLocal_XS >> 4));
        MLCD_Write(0, cLCM_SetColumnAddressLSB | (gLocal_XS & 0x0f));
        MLCD_Write(0, cLCM_SetPageAddress | (gLocal_YS + 1));
        gLocal_2 = 0;
        do {
            MLCD_Write(1, TabDisplayASCII[g2Local_1 + gLocal_2 + 2] & 0x0f);
            MLCD_Write(1, (TabDisplayASCII[g2Local_1 + gLocal_2 + 2] >> 4) & 0x0f);
            gLocal_2 += 3;
        } while (gLocal_2 < 9);                                    
        gLocal_XS +=  4;
        MLIBWriteSpace(gLocal_XS + 6, gLocal_YS);
        return gLocal_XS + 4;
    }
    else {
        return gLocal_XS + 4; 
/*
        g2Local_1 = 0;
        while (1) {  //会死机
P35 = ~P35; 
P34 = ~P34;
            if (gLocal_2 != 0x00){      // 如果结束尚未能找到对应的中文字,
                if ((gLocal_2 == (g2Local_Char >> 8)) && (gLocal_3 == (g2Local_Char & 0xff))){
                    break;
                }
            }
            else {
                gLocal_1 = 0;
                do {
                    MLIBWriteSpace(gLocal_XS + gLocal_1, gLocal_YS);
                } while (++gLocal_1 < 18);
                return gLocal_XS + 10;
            }
            g2Local_1 += 2;
        };
        
        g2Local_1 = g2Local_1 / 2;
        g2Local_1 *= 18;

        MLCD_Write(0, cLCM_SetColumnAddressMSB | (gLocal_XS >> 4));
        MLCD_Write(0, cLCM_SetColumnAddressLSB | (gLocal_XS & 0x0f));
        MLCD_Write(0, cLCM_SetPageAddress | gLocal_YS);
        gLocal_2 = 0;
        do {
            gLocal_2 += 3;
        } while (gLocal_2 < 18);                                    

        MLCD_Write(0, cLCM_SetColumnAddressMSB | (gLocal_XS >> 4));
        MLCD_Write(0, cLCM_SetColumnAddressLSB | (gLocal_XS & 0x0f));
        MLCD_Write(0, cLCM_SetPageAddress | (gLocal_YS + 1));
        gLocal_2 = 0;
        do {
            gLocal_2 += 3;
        } while (gLocal_2 < 18);                                    
        gLocal_XS += 4;
        MLIBWriteSpace(gLocal_XS + 12, gLocal_YS);
        return gLocal_XS + 10;
*/  
    }
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////
//函数功能:字符串显示(英文、中文、或其它混合字符串)
//注意: 此函数显示 一般文件中定义的字符串常量


BYTE MLIBWriteString(char gLocal_XS, short gLocal_YS,  WORD *pString) {

    BYTE gLocal_1;
    BYTE gLocal_2;
    BYTE gLocal_3;
    WORD g2Local_1;
    WORD g2Local_2;

    if (*pString == 0) return gLocal_XS;
    gLocal_1 = 0;
    do {                                            
        g2Local_2 = *pString++;
MDEBUG(g2Local_2 >> 8);
MDEBUG(g2Local_2 & 0XFF);
        if (g2Local_2 == 0x0000) break;
        if (g2Local_2 < 0x8000){
            gLocal_XS = MLIBWriteCharacter(gLocal_XS, gLocal_YS,g2Local_2 >> 8);
        }
     } while (++gLocal_1 < 18);   
    return gLocal_XS;
}

void MLIBWriteSpace(BYTE gLocal_X, BYTE gLocal_Y){
    BYTE gLocal_1;

    MLCD_Write(0, cLCM_SetColumnAddressMSB | (gLocal_X >> 4));
    MLCD_Write(0, cLCM_SetColumnAddressLSB | (gLocal_X & 0x0f));
    MLCD_Write(0, cLCM_SetPageAddress | gLocal_Y);
    gLocal_1 = 0;
    do {
        MLCD_Write(1, 0x00);
        gLocal_1 += 3;
    } while (gLocal_1 < 6);                                    

    MLCD_Write(0, cLCM_SetColumnAddressMSB | (gLocal_X >> 4));
    MLCD_Write(0, cLCM_SetColumnAddressLSB | (gLocal_X & 0x0f));
    MLCD_Write(0, cLCM_SetPageAddress | (gLocal_Y + 1));
    gLocal_1 = 0;
    do {
        MLCD_Write(1, 0x00);
        gLocal_1 += 3;
    } while (gLocal_1 < 6);                                    

    return;  
}

//====================================================================================================================
//-- 面板按键扫描 -----------------------------------------------------------------------------------------------------
//====================================================================================================================





⌨️ 快捷键说明

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