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

📄 Ȧ-

📁 基于Luminary的JPEG图片浏览器
💻
📖 第 1 页 / 共 3 页
字号:
#ifdef LANDSCAPE_FLIP
    WriteData(pRect->uiYMax);
#endif

    //
    // Write the Y extents of the rectangle.
    //
    WriteCommand(0x52);//发送命令
#ifdef PORTRAIT
    WriteData(pRect->uiYMin);//Y 起始坐标
#endif
#ifdef LANDSCAPE
    WriteData(pRect->uiXMin);
#endif
#ifdef PORTRAIT_FLIP
    WriteData(319 - pRect->uiYMax);
#endif
#ifdef LANDSCAPE_FLIP
    WriteData(319 - pRect->uiXMax);
#endif
    WriteCommand(0x53);//发送命令
#ifdef PORTRAIT
    WriteData(pRect->uiYMax);//Y 结束坐标
#endif
#ifdef LANDSCAPE
    WriteData(pRect->uiXMax);
#endif
#ifdef PORTRAIT_FLIP
    WriteData(319 - pRect->uiYMin);
#endif
#ifdef LANDSCAPE_FLIP
    WriteData(319 - pRect->uiXMin);
#endif

    //
    // Set the display cursor to the upper left of the rectangle.
    //
    WriteCommand(0x20);//AC起始x坐标地址
#ifdef PORTRAIT
    WriteData(pRect->uiXMin);
#endif
#ifdef LANDSCAPE
    WriteData(239 - pRect->uiYMin);
#endif
#ifdef PORTRAIT_FLIP
    WriteData(239 - pRect->uiXMin);
#endif
#ifdef LANDSCAPE_FLIP
    WriteData(pRect->uiYMin);
#endif
    WriteCommand(0x21);//AC起始y坐标地址
#ifdef PORTRAIT
    WriteData(pRect->uiYMin);
#endif
#ifdef LANDSCAPE
    WriteData(pRect->uiXMin);
#endif
#ifdef PORTRAIT_FLIP
    WriteData(319 - pRect->uiYMax);
#endif
#ifdef LANDSCAPE_FLIP
    WriteData(319 - pRect->uiXMax);
#endif

    //
    // Write the data RAM write command.
    //
    WriteCommand(0x22);

    //
    // Loop through the pixels of this filled rectangle.
    //
    for(lCount = ((pRect->uiXMax - pRect->uiXMin + 1) *
          (pRect->uiYMax - pRect->uiYMin + 1)); lCount >= 0; lCount--)
    {
    //
    // Write the pixel value.
    //
    WriteData(ulValue);
    }

    //
    // Reset the X extents to the entire screen.
    //
    WriteCommand(0x50);
    WriteData(0x0000);//x起始指针 0
    WriteCommand(0x51);
    WriteData(0x00ef);//x结束指针 239

    //
    // Reset the Y extents to the entire screen.
    //
    WriteCommand(0x52);
    WriteData(0x0000);//y起始指针 0
    WriteCommand(0x53);
    WriteData(0x013f);//y结束指针 319
}


void setWindow (tRectangle *pRect)
{
    /*
    Write the X extents of the rectangle.
    */
    WriteCommand(0x50);//发送命令
    WriteData(pRect->uiXMin);//X 起始坐标
    WriteCommand(0x51);//发送命令
    WriteData(pRect->uiXMax);//X 结束坐标

    /*
    Write the Y extents of the rectangle.
    */
    WriteCommand(0x52);//发送命令
    WriteData(pRect->uiYMin);//Y 起始坐标
    WriteCommand(0x53);//发送命令
    WriteData(pRect->uiYMax);//Y 结束坐标
    
    //
    // Set the cursor increment to left to right, followed by top to bottom.
    //
    WriteCommand(0x03);
    WriteData(0x0030);
  
    //
    // Set the current X address of the display cursor.
    //
    WriteCommand(0x20);
    WriteData(pRect->uiXMin + pRect->uiXinZoon);//x坐标

    //
    // Set the current Y address of the display cursor.
    //
    WriteCommand(0x21);
    WriteData(pRect->uiYMin + pRect->uiYinZoon);    
    
    //
    // Write the data RAM write command.
    //
    WriteCommand(0x22);

}
//*****************************************************************************
//
//! Fills a rectangle by a picture data which in the format of 16 bitRGB.
//!
//! \param pvDisplayData is a pointer to the driver-specific data for this
//! display driver.
//! \param pRect is a pointer to the structure describing the rectangle.
//! \param puiValue is a pointer to the color data of the rectangle.
//!
//! This function fills a rectangle on the display.  The coordinates of the
//! rectangle are assumed to be within the extents of the display, and the
//! rectangle specification is fully inclusive (in other words, both sXMin and
//! sXMax are drawn, along with sYMin and sYMax).
//!
//! \return None.
//
//*****************************************************************************
//extern tRectangle GsZoon;//定义一矩形区域
//extern void  delay(unsigned long  ulVal);
//extern volatile unsigned long  GulSysClock;
void Formike240x320x16_ILI9320PictureFill(tRectangle *psZone, unsigned short *puiValue, unsigned long ulCounter)
{
    unsigned long i = 0;
    unsigned short *puiValueptr = puiValue;
    tRectangle *pRect;
    
    pRect = psZone;
    
    setWindow (psZone);
    for(i = 0; i < ulCounter; i++)
    {
       WriteData(*puiValueptr++);// Write the pixel value.
      //WriteData(GREEN);// Write the pixel value.
      //delay(GulSysClock/8000);  
    }
    
    
    pRect->uiXinZoon = pRect->uiXinZoon + ulCounter;
    if (pRect->uiXinZoon > (pRect->uiXMax - pRect->uiXMin + 1)) {
    pRect->uiYinZoon += pRect->uiXinZoon  / (pRect->uiXMax - pRect->uiXMin + 1);
    pRect->uiXinZoon  = pRect->uiXinZoon  % (pRect->uiXMax - pRect->uiXMin + 1);
    if (pRect->uiYinZoon > (pRect->uiYMax - pRect->uiYMin + 1)) {
        pRect->uiYinZoon = 0;
    }
    }
    
  
  

    //
    // Reset the X extents to the entire screen.
    //
    WriteCommand(0x50);
    WriteData(0x0000);//x起始指针 0
    WriteCommand(0x51);
    WriteData(0x00ef);//x结束指针 239

    //
    // Reset the Y extents to the entire screen.
    //
    WriteCommand(0x52);
    WriteData(0x0000);//y起始指针 0
    WriteCommand(0x53);
    WriteData(0x013f);//y结束指针 319

}

/*********************************************************************************************************
** 函数名称: WriteOneChar
** 功能描述: 显示一个字符
** 输   入: sec    区码
**       pot    位码
**       x0     垂直线起点所在列的位置
**       y0     垂直线起点所在行的位置
**       color    显示颜色  
** 输   出: 字符模的宽度
**       
** 全局变量: 无
** 调用模块: 无
** 作   者: 张展威
** 日   期: 2008年7月22日
**-------------------------------------------------------------------------------------------------------
** 修 改 人:
** 日   期:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void setCoordinate(unsigned short x, unsigned short y)
{
  //
    // Set the current X address of the display cursor.
    //
    WriteCommand(0x20);
    WriteData(x);//x坐标

    //
    // Set the current Y address of the display cursor.
    //
    WriteCommand(0x21);
    WriteData(y);    
    
    //
    // Write the data RAM write command.
    //
    WriteCommand(0x22);
}

unsigned long  writeOneHzChar(unsigned char *pucMsk, unsigned short x0, unsigned short y0, unsigned short color)
{  
    unsigned long i,j;
    unsigned short mod[16];                       // 当前字模
    unsigned short *puiMsk;                     // 当前字库地址
    unsigned short y;
    
    puiMsk = (unsigned short *)pucMsk;
    for(i=0; i<16; i++)                       // 保存当前汉字点阵式字模
    {                     
        mod[i] = *puiMsk++;                 // 取得当前字模,半字对齐访问
        mod[i] = ((mod[i] & 0xff00) >> 8) 
            |((mod[i] & 0x00ff) << 8);          // 字模交换高低字节(为了显示需要)
    }
    y = y0;       
    for(i=0; i<16; i++) { //16行
        #ifdef __DISPLAY_BUFFER //使用显存显示
        for(j=0; j<16; j++) { //16列
        if((mod[i] << j)& 0x8000) {             // 显示字模
            DispBuf[240*(y0+i) + x0+j] = color;
        }    
        }
        #else //直接显示
        
        setCoordinate(x0, y);// 设置写数据地址指针
        for(j=0; j<16; j++) { //16列
        if((mod[i] << j) & 0x8000) {             // 显示字模
            WriteData(color);
        } else {
            WriteData(GUIBACKCOLOR);
        }    
        }
        y++;        
        #endif
    }
    return (16);//返回16位列宽
}

unsigned long  writeOneASCII(unsigned char *pucMsk, unsigned short x0, unsigned short y0, unsigned short color)
{  
    unsigned long i,j;
    unsigned short y;
    unsigned char ucChar;

    y = y0;       
    for(i=0; i<16; i++) { //16行
      ucChar = *pucMsk++;
        #ifdef __DISPLAY_BUFFER //使用显存显示
        for(j=0; j<8; j++) { //8列
          if((ucChar << j)& 0x80) {             // 显示字模
              DispBuf[240*(y0+i) + x0+j] = color;
          }    
        }
        #else //直接显示
        
        setCoordinate(x0, y);// 设置写数据地址指针
        for(j=0; j<8; j++) { //8列
        if((ucChar << j) & 0x80) {             // 显示字模
            WriteData(color);
        } else {
            WriteData(GUIBACKCOLOR);
        }    
        }
        y++;        
        #endif
    }
    return (8);//返回16位列宽
}
/*********************************************************************************************************
** 函数名称: WriteString
** 功能描述: 在指定的坐标处开始显示字符串
** 输   入: StrAdr     字符串地址
**           x0     垂直线起点所在列的位置
**           y0     垂直线起点所在行的位置
**           color    显示颜色  
** 输   出: 无   
** 全局变量: 无
** 调用模块: WriteOneChar 向显示缓存区写一个字符
** 作   者: 张展威
** 日   期: 2008年7月22日
**-------------------------------------------------------------------------------------------------------
** 修 改 人:
** 日   期:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void writeString(unsigned char *pcStr, unsigned short x0, unsigned short y0, unsigned short color)
{
    unsigned short uiIndex;
    unsigned short uiWidth;
    
    while(1)
    {
      if(*pcStr == 0) {
          break;//字符串结束
      }
      if(*pcStr > 0x80) {             // 判断为汉字
        uiIndex = findHzIndex(pcStr);
        uiWidth = writeOneHzChar((unsigned char *)&GB_16[uiIndex].Msk[0], x0, y0, color); // 显示字符
        pcStr += 2;
      } else {                     // 判断为非汉字
        uiWidth = writeOneASCII((unsigned char *)&ASCII[(*pcStr - 0x20)][0], x0, y0, color); // ASCII码表21H的值对应区位码3区
        pcStr += 1;
      }  
      
      
      x0 = x0 + (uiWidth);             // 调节字符串显示松紧度                
      if(x0 >= GUI_LCM_XMAX)               // 改变显示坐标
      {
          x0 = 0;
          y0 = y0 + 16;
          if(y0 >= GUI_LCM_XMAX) {//纵坐标超出
          y0 = 0;
          }
      }  
    }
}

//*****************************************************************************
//
//! Translates a 24-bit RGB color to a display driver-specific color.
//!
//! \param pvDisplayData is a pointer to the driver-specific data for this
//! display driver.
//! \param ulValue is the 24-bit RGB color.  The least-significant byte is the
//! blue channel, the next byte is the green channel, and the third byte is the
//! red channel.
//!
//! This function translates a 24-bit RGB color into a value that can be
//! written into the display's frame buffer in order to reproduce that color,
//! or the closest possible approximation of that color.
//!
//! \return Returns the display-driver specific color.
//
//*****************************************************************************
unsigned long Formike240x320x16_ILI9320ColorTranslate(unsigned long ulValue)
{
    //
    // Translate from a 24-bit RGB color to a 5-6-5 RGB color.
    //
    return(DPYCOLORTRANSLATE(ulValue));
}

//*****************************************************************************
//
//! Flushes any cached drawing operations.
//!
//! \param pvDisplayData is a pointer to the driver-specific data for this
//! display driver.
//!
//! This functions flushes any cached drawing operations to the display.  This
//! is useful when a local frame buffer is used for drawing operations, and the
//! flush would copy the local frame buffer to the display.  For the ILI9320
//! driver, the flush is a no operation.
//!
//! \return None.
//
//*****************************************************************************
void Formike240x320x16_ILI9320Flush(void *pvDisplayData)
{
    //
    // There is nothing to be done.
    //
}

//*****************************************************************************
//
//! The display structure that describes the driver for the Formike Electronic
//! KWH028Q02-F03 TFT panel with an ILI9320 controller.
//
//*****************************************************************************
/*const tDisplay g_sFormike240x320x16_ILI9320 =
{
    sizeof(tDisplay),
    0,
#if defined(PORTRAIT) || defined(PORTRAIT_FLIP)
    240,
    320,
#else
    320,
    240,
#endif
    Formike240x320x16_ILI9320PixelDraw,//Draws a pixel on the screen.
    Formike240x320x16_ILI9320PixelDrawMultiple,//Draws a horizontal sequence of pixels on the screen.
    Formike240x320x16_ILI9320LineDrawH,//Draws a horizontal line.
    Formike240x320x16_ILI9320LineDrawV,//Draws a vertical line.
    Formike240x320x16_ILI9320RectFill,//Fills a rectangle.矩形填充
    Formike240x320x16_ILI9320ColorTranslate,//Translates a 24-bit RGB color to a display driver-specific color.
    Formike240x320x16_ILI9320Flush//Flushes any cached drawing operations.
};
*/
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************

⌨️ 快捷键说明

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