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

📄 ddi_display_controller_lds514.c

📁 LCD驱动源代码 应用于手机的话,需要改写,找了好久,网上下的,将就一下了,参考参考,自己动手改一下吧.有在MTK平台上改成功的,放上来给大家参考一下啊
💻 C
📖 第 1 页 / 共 3 页
字号:
    ddi_display_controller_WriteDirect(CMD_MODE, 0x3c);    // Blue peak pulse width set
    ddi_display_controller_WriteDirect(PARAM_MODE, 0x0a);
    
    ddi_display_controller_WriteDirect(CMD_MODE, 0x18);    // Pre-charge width set
    ddi_display_controller_WriteDirect(PARAM_MODE, 0x03);

    ddi_display_controller_WriteDirect(CMD_MODE, 0x48);    // Row overlap timing
    ddi_display_controller_WriteDirect(PARAM_MODE, 0x03);
#endif
    
    //Screen Saver
    ddi_display_controller_WriteDirect(CMD_MODE, 0xc3);    // SS Step timer set
    ddi_display_controller_WriteDirect(PARAM_MODE, 0x2c);   // ---
    ddi_display_controller_WriteDirect(CMD_MODE, 0xc4);    // SS Step timer unit set
    ddi_display_controller_WriteDirect(PARAM_MODE, 0x01);

    ddi_display_controller_WriteDirect(CMD_MODE, 0xca);    // SS Changing X step
    ddi_display_controller_WriteDirect(PARAM_MODE, 0x01);
    ddi_display_controller_WriteDirect(CMD_MODE, 0xcb);    // SS Changing Y step
    ddi_display_controller_WriteDirect(PARAM_MODE, 0x01);
    
    ddi_display_controller_WriteDirect(CMD_MODE, 0xcc);    // SS Condition set
    ddi_display_controller_WriteDirect(PARAM_MODE, 0x12);

#ifdef DDI_LCDIF_WORDLENGTH_16BITS
    ddi_display_controller_WriteDirect(CMD_MODE, 0x0d);     // Data bus size
    ddi_display_controller_WriteDirect(PARAM_MODE, 0x01);   // 16-bit bus
#else
    ddi_display_controller_WriteDirect(CMD_MODE, 0x0d);     // Data bus size
    ddi_display_controller_WriteDirect(PARAM_MODE, 0x00);   // 8-bit bus
#endif

    // Set up the bitmap type and screen dimensions
    ret = SendControllerResolution(u32Width, u32Height, DDI_DISPLAY_ROTATION_NONE);
    if( !ret )
        ret = SendControllerBitmapType(eBitmapType);

    return ret;
}

////////////////////////////////////////////////////////////////////////////////
//! \fn static void SendControllerOutputEnable(bool bOn)
//! 
//! \brief Turns the display on or off
//!
//! \fntype Function
//!
//! \param[in] bOn true to turn on the display, false to turn it off
//!
//! This function sends commands to the controller to enable the output of the
//! display.
//!
////////////////////////////////////////////////////////////////////////////////
static void SendControllerOutputEnable(bool bOn)
{
    if( bOn )
    {
        ddi_display_controller_WriteDirect(CMD_MODE, 0x02);    // Dot matrix display on/off
        ddi_display_controller_WriteDirect(PARAM_MODE, 0x01);   // --- on
    }
    else
    {
        ddi_display_controller_WriteDirect(CMD_MODE, 0x02);    // Dot matrix on/off
        ddi_display_controller_WriteDirect(PARAM_MODE, 0x00);   // --- off
    }
}

////////////////////////////////////////////////////////////////////////////////
//! \fn static void SendControllerContrast(uint32_t u32Percentage)
//! 
//! \brief Sets the specified contrast on the display
//!
//! \fntype Function
//!
//! \param[in] u32Percentage Percent total contrast from 0 -> 100
//!
//! This function sends commands to the controller to set the desired contrast
//! percentage.
//!
////////////////////////////////////////////////////////////////////////////////
static void SendControllerContrast(uint32_t u32Percentage)
{
    DDI_DISPLAY_WORD_TYPE ContrastRed = MIN_CONTRAST_RED + (((u32Percentage * (MAX_CONTRAST_RED - MIN_CONTRAST_RED))) / 100);
    DDI_DISPLAY_WORD_TYPE ContrastGreen = MIN_CONTRAST_GREEN + (((u32Percentage * (MAX_CONTRAST_GREEN - MIN_CONTRAST_GREEN))) / 100);
    DDI_DISPLAY_WORD_TYPE ContrastBlue = MIN_CONTRAST_BLUE + (((u32Percentage * (MAX_CONTRAST_BLUE - MIN_CONTRAST_BLUE))) / 100);

    ddi_display_controller_WriteDirect(CMD_MODE, 0x40);    // Contrast for color A
    ddi_display_controller_WriteDirect(PARAM_MODE, ContrastRed);  
    ddi_display_controller_WriteDirect(CMD_MODE, 0x41);    // Contrast for color B
    ddi_display_controller_WriteDirect(PARAM_MODE, ContrastGreen);
    ddi_display_controller_WriteDirect(CMD_MODE, 0x42);    // Contrast for color C
    ddi_display_controller_WriteDirect(PARAM_MODE, ContrastBlue);
}

////////////////////////////////////////////////////////////////////////////////
//! \fn static void SendControllerBrightness(uint32_t u32Percentage)
//!
//! \brief Sets the specified brightness percentage on the display
//!
//! \fntype Function
//!
//! \param[in] u32Percentage Percent total contrast from 0 -> 100
//!
//! Sets the master current setting for the controller.  The higher the
//! master current, the steeper the contrast response slope.
//!
////////////////////////////////////////////////////////////////////////////////
static void SendControllerBrightness(uint32_t u32Percentage)
{
//    DDI_DISPLAY_WORD_TYPE Brightness = MIN_BRIGHTNESS + (((u32Percentage * (MAX_BRIGHTNESS - MIN_BRIGHTNESS))) / 100);

    // FIXME !!!
}

////////////////////////////////////////////////////////////////////////////////
//! \fn static RtStatus_t SendControllerRegion(uint32_t u32XDst, uint32_t u32YDst, uint32_t *pu32Width, uint32_t *pu32Height, ddi_display_Rotation_t eRotation)
//!
//! \brief Sets up the region on the controller where pixels are to be placed
//!
//! \fntype Function
//!
//! \param[in] u32XDst X coordinate of upper left corner of the destination region
//! \param[in] u32YDst Y coordinate of upper left corner of the destination region
//! \param[in] pu32Width Width of the destination region
//! \param[in] pu32Height Height of the destination region
//! \param[in] eRotation Desired orientation of the display
//!
//! This function sends commands to the controller to set up the destination
//! region (or "box") where pixels are to be placed.  The rotation is specified
//! here as well as with the SendControllerRotation function because some
//! controllers handle rotation on a per region basis.
//!
//! \retval SUCCESS No error
//!
//! \retval ERROR_DDI_DISPLAY_CONTROLLER_ROTATION - The specified rotation is
//!         not supported by the controller
//!
//! \retval ERROR_DDI_DISPLAY_PLACEMENT - There was an error placing the given
//!         region on the display that clipping could not compensate for.
//!
////////////////////////////////////////////////////////////////////////////////
static RtStatus_t SendControllerRegion(uint32_t u32XDst, uint32_t u32YDst, 
                                       uint32_t *pu32Width, uint32_t *pu32Height,
                                       ddi_display_Rotation_t eRotation)
{
    uint32_t u32TotalWidth = g_ddi_display_u16ScreenWidth;
    uint32_t u32TotalHeight = g_ddi_display_u16ScreenHeight;

    RtStatus_t ret = SUCCESS;

    DDI_DISPLAY_WORD_TYPE HorzCommandStart;  // Command byte for horizontal setup
    DDI_DISPLAY_WORD_TYPE HorzCommandStop;  // Command byte for horizontal setup
    DDI_DISPLAY_WORD_TYPE XStart;       // X region start
    DDI_DISPLAY_WORD_TYPE XStop;        // X region stop
    DDI_DISPLAY_WORD_TYPE VertCommandStart;  // Command byte for vertical setup
    DDI_DISPLAY_WORD_TYPE VertCommandStop;  // Command byte for vertical setup
    DDI_DISPLAY_WORD_TYPE YStart;       // Y region start
    DDI_DISPLAY_WORD_TYPE YStop;        // Y region stop

    switch(eRotation)
    {
        case DDI_DISPLAY_ROTATION_NONE:
#ifdef DDI_DISPLAY_CONTROLLER_SUPPORT_ROTATION_180_270
        case DDI_DISPLAY_ROTATION_180:
#endif
            VertCommandStart = DDI_DISPLAY_VERT_START_REGION_CMD;
            VertCommandStop= DDI_DISPLAY_VERT_STOP_REGION_CMD;
            HorzCommandStart = DDI_DISPLAY_HORZ_START_REGION_CMD;
            HorzCommandStop = DDI_DISPLAY_HORZ_STOP_REGION_CMD;
            break;

        case DDI_DISPLAY_ROTATION_90:
#ifdef DDI_DISPLAY_CONTROLLER_SUPPORT_ROTATION_180_270
        case DDI_DISPLAY_ROTATION_270:
#endif
            // Swap the vertical and horizontal commands
            VertCommandStart = DDI_DISPLAY_HORZ_START_REGION_CMD;
            VertCommandStop = DDI_DISPLAY_HORZ_STOP_REGION_CMD;
            HorzCommandStart = DDI_DISPLAY_VERT_START_REGION_CMD;
            HorzCommandStop = DDI_DISPLAY_VERT_STOP_REGION_CMD;
            break;

        default:
            ret = ERROR_DDI_DISPLAY_CONTROLLER_ROTATION;
            break;
    }

    if( !ret )
    {
        // Check for zero sized region
        if( !*pu32Width || !*pu32Height 
            || u32XDst >= u32TotalWidth
            || u32YDst >= u32TotalHeight )
        {
            return ERROR_DDI_DISPLAY_PLACEMENT;
        }

        // Check for clipping
        if( u32XDst + *pu32Width > u32TotalWidth)
        {
            // FIXME - Must do a DrawRegion type xfer for this
            // since the clipped pixels will not be contiguous
            return ERROR_DDI_DISPLAY_PLACEMENT;
        }

        // Check for clipping
        if( u32YDst + *pu32Height > u32TotalHeight )
        {
            *pu32Height = u32TotalHeight - u32YDst;
        }

        XStart = u32XDst;
        XStop = u32XDst + *pu32Width - 1;

        YStart = u32YDst;
        YStop = u32YDst + *pu32Height - 1;

        ddi_display_controller_WriteDirect(CMD_MODE, HorzCommandStart);
        ddi_display_controller_WriteDirect(PARAM_MODE, XStart);
        ddi_display_controller_WriteDirect(CMD_MODE, HorzCommandStop);
        ddi_display_controller_WriteDirect(PARAM_MODE, XStop);
        ddi_display_controller_WriteDirect(CMD_MODE, VertCommandStart);
        ddi_display_controller_WriteDirect(PARAM_MODE, YStart);
        ddi_display_controller_WriteDirect(CMD_MODE, VertCommandStop);
        ddi_display_controller_WriteDirect(PARAM_MODE, YStop);

        // Setup the pixel write
        ddi_display_controller_WriteDirect(CMD_MODE, 0x08);
    }

    return ret;
}

////////////////////////////////////////////////////////////////////////////////
//! \fn RtStatus_t SendControllerBitmapType(gfx_BitmapTypeEnum_t eBitmapType)
//!
//! \brief Sets up the controller for the specified bitmap format
//!
//! \fntype Function
//!
//! \param[in] eBitmapType - The new bitmap format
//!
//! This function sends the appropriate commands to the display controller 
//! to set it up for the new bitmap type format.
//!
//! \retval SUCCESS No error
//!
//! \retval ERROR_DDI_DISPLAY_CONTROLLER_BITMAP_TYPE_UNSUPPORTED - The specified bitmap
//!         type is not supported by the controller
//!
////////////////////////////////////////////////////////////////////////////////
static RtStatus_t SendControllerBitmapType(gfx_BitmapTypeEnum_t eBitmapType)

⌨️ 快捷键说明

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