예제 #1
0
/*********************************************************************
* Function: WORD GetPixel(SHORT x, SHORT y)
*
* PreCondition: none
*
* Input: pixel position
*
* Output: pixel color
*
* Side Effects: none
*
* Overview: returns pixel at given position
*
* Note: none
*
********************************************************************/
GFX_COLOR GetPixel(SHORT x, SHORT y)
{
    BYTE    columnPixel[3];         // 3 Pixels in each column
    DisplayEnable();

    // Set Row and Column Address
	DisplaySetCommand();
    DeviceWrite(LASET);
	DisplaySetData();
    DeviceWrite(y + 16);
    DeviceWrite(0x8f);
	DisplaySetCommand();
    DeviceWrite(CASET);
	DisplaySetData();
    DeviceWrite(x / 3);
    DeviceWrite(0x54);

    // Read Column
	DisplaySetCommand();
    DeviceWrite(RMWIN);
	DisplaySetData();
    columnPixel[0] = DeviceRead();    // Dummy
    columnPixel[0] = DeviceRead();    // Start reading cycle for pixel 0
    columnPixel[1] = DeviceRead();    // Start reading cycle for pixel 1
    columnPixel[2] = DeviceRead();    // Start reading cycle for pixel 2
	DisplaySetCommand();
    DeviceWrite(RMWOUT);
    DisplayDisable();
	DisplaySetData();

    return (columnPixel[x % 3]);
}
예제 #2
0
/*********************************************************************
* Function: void ClearDevice(void)
*
* PreCondition: none
*
* Input: none
*
* Output: none
*
* Side Effects: none
*
* Overview: clears screen with current color 
*
* Note: none
*
********************************************************************/
void ClearDevice(void)
{
    WORD    counter;

    DisplayEnable();

    // Whole screen
	DisplaySetCommand();
    DeviceWrite(LASET);    //Line Address Set(lines from 16 to 144 are used)
	DisplaySetData();
    DeviceWrite(0x10);    //Start Line=16
    DeviceWrite(0x8f);    //End Line =144-1
	DisplaySetCommand();
    DeviceWrite(CASET);    //Column Address Set
	DisplaySetData();
    DeviceWrite(0x00);    //Start Column=0
    DeviceWrite(0x54);    //End Column =84 ((84+1)*3 == 255)
	DisplaySetCommand();
    DeviceWrite(RAMWR);
	DisplaySetData();
    for(counter = 0; counter < (WORD) (GetMaxX() + 1) * (GetMaxY() + 1); counter++)
    {
        DeviceWrite(_color);
    }

    DisplayDisable();
}
예제 #3
0
/*********************************************************************
* Function: void PutPixel(SHORT x, SHORT y)
*
* PreCondition: none
*
* Input: x,y - pixel coordinates
*
* Output: none
*
* Side Effects: none
*
* Overview: puts pixel
*
* Note: none
*
********************************************************************/
void PutPixel(SHORT x, SHORT y)
{
    DWORD   address;
    if(_clipRgn)
    {
        if(x < _clipLeft)
            return;
        if(x > _clipRight)
            return;
        if(y < _clipTop)
            return;
        if(y > _clipBottom)
            return;
    }

    #if (DISP_ORIENTATION == 0)
    address = (long)LINE_MEM_PITCH * y + x;

    #else
    y = GetMaxY() - y;
    address = (long)LINE_MEM_PITCH * x + y;
    #endif
    DisplayEnable();
    SetAddress(address);
    WritePixel(_color);
    DisplayDisable();
}
예제 #4
0
/*********************************************************************
* Function:  void ResetDevice()
*
* PreCondition: none
*
* Input: none
*
* Output: none
*
* Side Effects: none
*
* Overview: resets LCD, initializes PMP
*
* Note: none
*
********************************************************************/
void ResetDevice(void)
{
    WORD counter;
    
    // Initialize the device
    DriverInterfaceInit();
    
    // Enable LCD
    DisplayEnable();

    DelayMs(10);

    // Clear text layer
    SetAddress(0);
    for(counter = 0; counter < 0x4b0; counter++)
    {
        DeviceWrite(0x07);
		DeviceWrite(0x07);
    }

    // Disable LCD
    DisplayDisable();

    DelayMs(20);
}
예제 #5
0
void WriteCommand(int cmd)
{
  DisplayEnable();
  DisplaySetCommand();
  PMDIN = cmd;
  PMPWaitBusy();
  DisplayDisable();
}
예제 #6
0
void WriteData(unsigned int _data)
{
  DisplayEnable();
  DisplaySetData();
  PMDIN = _data;
  PMPWaitBusy();
  DisplayDisable();
}
예제 #7
0
/*********************************************************************
* Function: void ContrastUp(void)
*
* PreCondition: none
*
* Input: none
*
* Output: none
*
* Side Effects: none
*
* Overview: increases contrast
*
* Note: none
*
********************************************************************/
void ContrastUp(void)
{
    DisplayEnable();
	DisplaySetCommand();
    DeviceWrite(VOLUP);
    DisplayDisable();
	DisplaySetData();
}
예제 #8
0
/*********************************************************************
* Function: void DisplayOn(void)
*
* PreCondition: none
*
* Input: none
*
* Output: none
*
* Side Effects: none
*
* Overview: turns off display
*
* Note: none
*
********************************************************************/
void DisplayOff(void)
{
    DisplayEnable();
	DisplaySetCommand();
    DeviceWrite(DISOFF);
    DisplayDisable();
	DisplaySetData();
}
예제 #9
0
/*********************************************************************
* Function: void ContrastDown(void)
*
* PreCondition: none
*
* Input: none
*
* Output: none
*
* Side Effects: none
*
* Overview: decreases contrast
*
* Note: none
*
********************************************************************/
void ContrastDown(void)
{
    DisplayEnable();
	DisplaySetCommand();
    DeviceWrite(VOLDOWN);  //Electronic Control
    DisplayDisable();
	DisplaySetData();
}
예제 #10
0
/*********************************************************************
* Function: void WakeUp(void)
*
* PreCondition: none
*
* Input: none
*
* Output: none
*
* Side Effects: none
*
* Overview: wakes up from sleep
*
* Note: none
*
********************************************************************/
void WakeUp(void)
{
    DisplayEnable();
	DisplaySetCommand();
    DeviceWrite(SLPOUT);
    DisplayDisable();
	DisplaySetData();
}
예제 #11
0
/*********************************************************************
* Function: void SleepIn(void)
*
* PreCondition: none
*
* Input: none
*
* Output: none
*
* Side Effects: none
*
* Overview: enters sleep mode
*
* Note: none
*
********************************************************************/
void SleepIn(void)
{
    DisplayEnable();
	DisplaySetCommand();
    DeviceWrite(SLPIN);
    DisplayDisable();
	DisplaySetData();
}
예제 #12
0
/*********************************************************************
* Function:  void  SetReg(BYTE index, BYTE value)
*
* PreCondition: none
*
* Input: index - register number
*        value - value to be set
*
* Output: none
*
* Side Effects: none
*
* Overview: sets graphics controller register
*
* Note: none
*
********************************************************************/
void SetReg(BYTE index, BYTE value)
{
	DisplayEnable();
	DisplaySetCommand();
	DeviceWrite(index);
	DisplaySetData();
	DeviceWrite(value);
	DisplayDisable();
}
예제 #13
0
/*********************************************************************
* Function: void ContrastSet(WORD contrast)
*
* PreCondition: none
*
* Input: contrast value (LSB 10-0 are valid, MSB 15-11 are not used)
*
* Output: none
*
* Side Effects: none
*
* Overview: sets contrast
*
* Note: none
*
********************************************************************/
void ContrastSet(WORD contrast)
{
    DisplayEnable();
	DisplaySetCommand();
    DeviceWrite(VOLCTRL); 
	DisplaySetData();               
    DeviceWrite((((WORD_VAL) contrast).v[0]));
    DeviceWrite((((WORD_VAL) contrast).v[1]));
    DisplayDisable();
}
예제 #14
0
WORD GetPixel(SHORT x, SHORT y)
{
    DWORD   address;
    WORD    result;
        #if (DISP_ORIENTATION == 0)
    address = (long)LINE_MEM_PITCH * y + x;
        #else
    y = GetMaxY() - y;
    address = (long)LINE_MEM_PITCH * x + y;
        #endif
    DisplayEnable();

    SetAddress(address);

    // Temporary change wait cycles for reading (250ns = 4 cycles)
        #if defined(__C30__)
    PMMODEbits.WAITM = 4;
        #elif defined(__PIC32MX__)
    PMMODEbits.WAITM = 8;
        #else
            #error Need wait states for the device
        #endif
    DisplaySetData();

    // First RD cycle to move data from GRAM to Read Data Latch
    result = PMDIN1;

    while(PMMODEbits.BUSY);

    // Second RD cycle to get data from Read Data Latch
    result = PMDIN1;

    while(PMMODEbits.BUSY);

    // Disable LCD
    DisplayDisable();

    // Disable PMP
    PMCONbits.PMPEN = 1;

    // Read result
    result = PMDIN1;

    // Restore wait cycles for writing (60ns)
        #if defined(__dsPIC33F__) || defined(__PIC24H__)
    PMMODEbits.WAITM = 2;
        #else
    PMMODEbits.WAITM = 1;
        #endif

    // Enable PMP
    PMCONbits.PMPEN = 1;

    return (result);
}
예제 #15
0
/*********************************************************************
* Function:  void  SetReg(WORD index, WORD value)
*
* PreCondition: none
*
* Input: index - register number
*        value - value to be set
*
* Output: none
*
* Side Effects: none
*
* Overview: sets graphics controller register
*
* Note: none
*
********************************************************************/
void SetReg(WORD index, WORD value)
{
#ifdef USE_16BIT_PMP
    DisplayEnable();
	DisplaySetCommand();
    DeviceWrite(index);
	DisplaySetData();
    DeviceWrite(value);
    DisplayDisable();
#else
    DisplayEnable();
	DisplaySetCommand();
    DeviceWrite(((WORD_VAL)index).v[1]);
	DeviceWrite(((WORD_VAL)index).v[0]);
	DisplaySetData();
	DeviceWrite(((WORD_VAL)value).v[1]);
	DeviceWrite(((WORD_VAL)value).v[0]);
    DisplayDisable();
#endif
}
예제 #16
0
/*********************************************************************
* Function: void PutImage16BPP(SHORT left, SHORT top, FLASH_BYTE* image, BYTE stretch)
*
* PreCondition: none
*
* Input: left,top - left top image corner, image - image pointer,
*        stretch - image stretch factor
*
* Output: none
*
* Side Effects: none
*
* Overview: outputs hicolor image starting from left,top coordinates
*
* Note: image must be located in flash
*
********************************************************************/
void PutImage16BPP(SHORT left, SHORT top, FLASH_BYTE *image, BYTE stretch)
{
    register DWORD      address;
    register FLASH_WORD *flashAddress;
    register FLASH_WORD *tempFlashAddress;
    WORD                sizeX, sizeY;
    register WORD       x, y;
    WORD                temp;
    register BYTE       stretchX, stretchY;

    // Move pointer to size information
    flashAddress = (FLASH_WORD *)image + 1;

    // Set start address
    address = BUF_MEM_OFFSET + (long)LINE_MEM_PITCH * top + left;

    // Read image size
    sizeY = *flashAddress;
    flashAddress++;
    sizeX = *flashAddress;
    flashAddress++;

    DisplayEnable();
    for(y = 0; y < sizeY; y++)
    {
        tempFlashAddress = flashAddress;
        for(stretchY = 0; stretchY < stretch; stretchY++)
        {
            flashAddress = tempFlashAddress;
            SetAddress(address);
            for(x = 0; x < sizeX; x++)
            {

                // Read pixels from flash
                temp = *flashAddress;
                flashAddress++;

                // Set color
                SetColor(temp);

                // Write pixel to screen
                for(stretchX = 0; stretchX < stretch; stretchX++)
                {
                    DeviceWrite(SETCOLOR_HIBYTE(_color));
                    DeviceWrite(SETCOLOR_LOWBYTE(_color));
                }
            }

            address += LINE_MEM_PITCH;
        }
    }

    DisplayDisable();
}
예제 #17
0
/*********************************************************************
* Function: void ClearDevice(void)
*
* PreCondition: none
*
* Input: none
*
* Output: none
*
* Side Effects: none
*
* Overview: clears screen with current color 
*
* Note: none
*
********************************************************************/
void ClearDevice(void)
{
    DWORD   counter;

    DisplayEnable();
    SetAddress(0);
    for(counter = 0; counter < (DWORD) (GetMaxX() + 1) * (GetMaxY() + 1); counter++)
    {
        WritePixel(_color);
    }

    DisplayDisable();
}
예제 #18
0
/*********************************************************************
* Function: void PutPixel(SHORT x, SHORT y)
*
* PreCondition: none
*
* Input: pixel position
*
* Output: none
*
* Side Effects: none
*
* Overview: puts pixel with current color at given position
*
* Note: none
*
********************************************************************/
void PutPixel(SHORT x, SHORT y)
{
    BYTE    columnPixel[3];         // 3 Pixels in each column
    if(_clipRgn)
    {
        if(x < _clipLeft)
            return;
        if(x > _clipRight)
            return;
        if(y < _clipTop)
            return;
        if(y > _clipBottom)
            return;
    }

    DisplayEnable();

    // Set Row and Column Address
	DisplaySetCommand();
    DeviceWrite(LASET);
	DisplaySetData();
    DeviceWrite(y + 16);
    DeviceWrite(0x8f);
	DisplaySetCommand();
    DeviceWrite(CASET);
	DisplaySetData();
    DeviceWrite(x / 3);
    DeviceWrite(0x54);

    // Read Column
	DisplaySetCommand();
    DeviceWrite(RMWIN);
	DisplaySetData();
    columnPixel[0] = DeviceRead();    // Dummy reading
    columnPixel[0] = DeviceRead();    // Start reading cycle for pixel 0
    columnPixel[1] = DeviceRead();    // Start reading cycle for pixel 1
    columnPixel[2] = DeviceRead();    // Start reading cycle for pixel 2

    // Modify pixel
    columnPixel[x % 3] = _color;

    // Write Column
    DeviceWrite(columnPixel[0]);
    DeviceWrite(columnPixel[1]);
    DeviceWrite(columnPixel[2]);

	DisplaySetCommand();
    DeviceWrite(RMWOUT);
    DisplayDisable();
	DisplaySetData();
}
예제 #19
0
/*********************************************************************
* Function: WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom)
* PreCondition: none
* Input: left,top - top left corner coordinates,
*        right,bottom - bottom right corner coordinates
* Output: none
* Side Effects: none
* Overview: draws rectangle filled with current color
* Note: none
********************************************************************/
WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom)
{
    register SHORT  x, y;

    #ifndef USE_NONBLOCKING_CONFIG
    while(IsDeviceBusy() != 0);

    /* Ready */
    #else
    if(IsDeviceBusy() != 0)
        return (0);
    #endif
    if(_clipRgn)
    {
        if(left < _clipLeft)
            left = _clipLeft;
        if(right > _clipRight)
            right = _clipRight;
        if(top < _clipTop)
            top = _clipTop;
        if(bottom > _clipBottom)
            bottom = _clipBottom;
    }

    DisplayEnable();
    
    SetRegion(left, right, top, bottom);
    DisplaySetCommand();
    DeviceWrite(MemoryWrite);
    DisplaySetData();
    for(y = top; y < bottom + 1; y++)
    {
      for(x = left; x < right + 1; x++)
      {
        DeviceWrite(_color);
      }
    }

//    SetRegion(0, GetMaxX(), 0, GetMaxY());
/*    for(y = top; y < bottom + 1; y++)
    {
        SetAddress(left, y);
        for(x = left; x < right + 1; x++)
        {
            WritePixel(_color);
        }
    }*/
//    SetRegion(0, GetMaxX(), 0, GetMaxY());
    DisplayDisable();
    return (1);
}
예제 #20
0
/*********************************************************************
* Function: void ClearDevice(void)
*
* PreCondition: none
*
* Input: none
*
* Output: none
*
* Side Effects: none
*
* Overview: clears screen with current color 
*
* Note: none
*
********************************************************************/
void ClearDevice(void)
{
    DWORD   counter;

    DisplayEnable();
    SetAddress(0x018000);
    for(counter = 0; counter < (DWORD) (GetMaxX() + 1) * (GetMaxY() + 1); counter++)
    {
        DeviceWrite(SETCOLOR_HIBYTE(_color));
        DeviceWrite(SETCOLOR_LOWBYTE(_color));
    }

    DisplayDisable();
    MoveTo(0, 0);
}
예제 #21
0
/*********************************************************************
* Function: void ClearDevice(void)
*
* PreCondition: none
*
* Input: none
*
* Output: none
*
* Side Effects: none
*
* Overview: clears screen with current color 
*
* Note: none
*
********************************************************************/
void ClearDevice(void)
{   int x, y;
    DisplayEnable();
    SetRegion(0, GetMaxX(), 0, GetMaxY());
    DisplaySetCommand();
    DeviceWrite(MemoryWrite);
    DisplaySetData();
    for (x = 0; x < GetMaxY() + 1; x++)
    {
      for (y = 0; y < GetMaxX() + 1; y++)
      {
        DeviceWrite(_color);
      }
    }
    DisplayDisable();
}
예제 #22
0
/*********************************************************************
* Function: WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom)
*
* PreCondition: none
*
* Input: left,top - top left corner coordinates,
*        right,bottom - bottom right corner coordinates
*
* Output: For NON-Blocking configuration:
*         - Returns 0 when device is busy and the shape is not yet completely drawn.
*         - Returns 1 when the shape is completely drawn.
*         For Blocking configuration:
*         - Always return 1.
*
* Side Effects: none
*
* Overview: draws rectangle filled with current color
*
* Note: none
*
********************************************************************/
WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom)
{
    DWORD       address;
    register SHORT  x, y;

    #ifndef USE_NONBLOCKING_CONFIG
    while(IsDeviceBusy() != 0);

    /* Ready */
    #else
    if(IsDeviceBusy() != 0)
        return (0);
    #endif
    if(_clipRgn)
    {
        if(left < _clipLeft)
            left = _clipLeft;
        if(right > _clipRight)
            right = _clipRight;
        if(top < _clipTop)
            top = _clipTop;
        if(bottom > _clipBottom)
            bottom = _clipBottom;
    }

    address = BUF_MEM_OFFSET + (DWORD) LINE_MEM_PITCH * top + left;

    DisplayEnable();

    for(y = top; y < bottom + 1; y++)
    {
        SetAddress(address);
        for(x = left; x < right + 1; x++)
        {
            DeviceWrite(SETCOLOR_HIBYTE(_color));
            DeviceWrite(SETCOLOR_LOWBYTE(_color));
        }

        address += LINE_MEM_PITCH;
    }

    DisplayDisable();
    return (1);
}
예제 #23
0
/*********************************************************************
* Function: void PutPixel(SHORT x, SHORT y)
*
* PreCondition: none
*
* Input: x,y - pixel coordinates
*
* Output: none
*
* Side Effects: none
*
* Overview: puts pixel
*
* Note: none
*
********************************************************************/
void PutPixel(SHORT x, SHORT y)
{
    if(_clipRgn)
    {
        if(x < _clipLeft)
            return;
        if(x > _clipRight)
            return;
        if(y < _clipTop)
            return;
        if(y > _clipBottom)
            return;
    }

    DisplayEnable();
    SetAddress(x, y);
    WritePixel(_color);
    DisplayDisable();
}
예제 #24
0
/*********************************************************************
* Function: GFX_COLOR GetPixel(SHORT x, SHORT y)
*
* PreCondition: none
*
* Input: x,y - pixel coordinates 
*
* Output: pixel color
*
* Side Effects: none
*
* Overview: return pixel color at x,y position
*
* Note: This implementation assumes an 8bit Data interface. 
*       For other data interface, this function should be modified.
*
********************************************************************/
GFX_COLOR GetPixel(SHORT x, SHORT y)
{ GFX_COLOR result;
    BYTE red = 0, green = 0, blue = 0;
    
    DisplayEnable();
    SetAddress(x, y);
    DisplaySetCommand();
    DeviceWrite(READMEMCONTINUE_REG);
    DisplaySetData(); 
    SingleDeviceRead();
    // read RED
	result = SingleDeviceRead();
/*    // read GREEN
	green = SingleDeviceRead();
    // read BLUE
	blue = SingleDeviceRead();*/

    DisplayDisable();
    return result;
//    return ((WORD) (((((GFX_COLOR)(red) & 0xF8) >> 3) << 11) | ((((GFX_COLOR)(green) & 0xFC) >> 2) << 5) | (((GFX_COLOR)(blue) & 0xF8) >> 3)));
}
예제 #25
0
/*********************************************************************
* Function: void PutPixel(SHORT x, SHORT y)
*
* PreCondition: none
*
* Input: x,y - pixel coordinates
*
* Output: none
*
* Side Effects: none
*
* Overview: puts pixel
*
* Note: none
*
********************************************************************/
void PutPixel(SHORT x, SHORT y)
{
    DWORD   address;
    if(_clipRgn)
    {
        if(x < _clipLeft)
            return;
        if(x > _clipRight)
            return;
        if(y < _clipTop)
            return;
        if(y > _clipBottom)
            return;
    }

    DisplayEnable();
    address = BUF_MEM_OFFSET + (long)LINE_MEM_PITCH * y + x;
    SetAddress(address);
    DeviceWrite(SETCOLOR_LOWBYTE(_color));
    DeviceWrite(SETCOLOR_HIBYTE(_color));
    DisplayDisable();
}
예제 #26
0
/*********************************************************************
* Function: void PutPixel(SHORT x, SHORT y)
* PreCondition: none
* Input: x,y - pixel coordinates
* Output: none
* Side Effects: none
* Overview: puts pixel
* Note: none
********************************************************************/
void PutPixel(SHORT x, SHORT y)
{
    if(_clipRgn)
    {
        if(x < _clipLeft)
            return;
        if(x > _clipRight)
            return;
        if(y < _clipTop)
            return;
        if(y > _clipBottom)
            return;
    }

    DisplayEnable();
    SetAddress(x, y);
    DisplaySetCommand();
    DeviceWrite(MemoryWrite);
    DisplaySetData();
    DeviceWrite(_color);
    DisplayDisable();
}
예제 #27
0
/*********************************************************************
* Function: WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom)
*
* PreCondition: none
*
* Input: left,top - top left corner coordinates,
*        right,bottom - bottom right corner coordinates
*
* Output: none
*
* Side Effects: none
*
* Overview: draws rectangle filled with current color
*
* Note: none
*
********************************************************************/
WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom)
{
    register SHORT  x, y;

    #ifndef USE_NONBLOCKING_CONFIG
    while(IsDeviceBusy() != 0);

    /* Ready */
    #else
    if(IsDeviceBusy() != 0)
        return (0);
    #endif
    if(_clipRgn)
    {
        if(left < _clipLeft)
            left = _clipLeft;
        if(right > _clipRight)
            right = _clipRight;
        if(top < _clipTop)
            top = _clipTop;
        if(bottom > _clipBottom)
            bottom = _clipBottom;
    }

    DisplayEnable();
    for(y = top; y < bottom + 1; y++)
    {
        SetAddress(left, y);
        for(x = left; x < right + 1; x++)
        {
            WritePixel(_color);
        }
    }

    DisplayDisable();
    return (1);
}
예제 #28
0
/*********************************************************************
* Function: WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom)
*
* PreCondition: none
*
* Input: left,top - top left corner coordinates,
*        right,bottom - bottom right corner coordinates
*
* Output: For NON-Blocking configuration:
*         - Returns 0 when device is busy and the shape is not yet completely drawn.
*         - Returns 1 when the shape is completely drawn.
*         For Blocking configuration:
*         - Always return 1.
*
* Side Effects: none
*
* Overview: draws rectangle filled with current color
*
* Note: none
*
********************************************************************/
WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom)
{
    DWORD           address;
    register SHORT  x, y;

    #ifndef USE_NONBLOCKING_CONFIG
    while(IsDeviceBusy() != 0);

    /* Ready */
    #else
    if(IsDeviceBusy() != 0)
        return (0);
    #endif
    if(_clipRgn)
    {
        if(left < _clipLeft)
            left = _clipLeft;
        if(right > _clipRight)
            right = _clipRight;
        if(top < _clipTop)
            top = _clipTop;
        if(bottom > _clipBottom)
            bottom = _clipBottom;
    }

    #if (DISP_ORIENTATION == 0)
    address = (DWORD) LINE_MEM_PITCH * top + left;

    DisplayEnable();
    for(y = top; y < bottom + 1; y++)
    {
        SetAddress(address);
        for(x = left; x < right + 1; x++)
        {
            WritePixel(_color);
        }

        address += LINE_MEM_PITCH;
    }

    DisplayDisable();

    #else
    top = GetMaxY() - top;
    bottom = GetMaxY() - bottom;
    address = (DWORD) LINE_MEM_PITCH * left + top;

    DisplayEnable();
    for(y = bottom; y < top + 1; y++)
    {
        SetAddress(address);
        for(x = left; x < right + 1; x++)
        {
            WritePixel(_color);
        }

        address -= 1;
    }

    DisplayDisable();
    #endif
    return (1);
}
예제 #29
0
/*********************************************************************
* Function:  void ResetDevice()
*
* PreCondition: none
*
* Input: none
*
* Output: none
*
* Side Effects: none
*
* Overview: resets LCD, initializes PMP
*
* Note: none
*
********************************************************************/
void ResetDevice(void)
{
    // Set FLASH CS pin as output
    DisplayFlashConfig();

    // Initialize the device
	DriverInterfaceInit();

    DelayMs(5);

    // Power on LCD
    DisplayPowerOn();
    DisplayPowerConfig();

    DelayMs(2);

    #if defined (GFX_USE_DISPLAY_CONTROLLER_LGDP4531)

    /////////////////////////////////////////////////////////
    // Synchronization after reset
    DisplayEnable();
    DeviceWrite(0);
    DeviceWrite(0);
    DisplayDisable();

    // Setup display
    SetReg(0x0010, 0x0628);
    SetReg(0x0012, 0x0006);
    SetReg(0x0013, 0x0A32);
    SetReg(0x0011, 0x0040);
    SetReg(0x0015, 0x0050);
    SetReg(0x0012, 0x0016);
    DelayMs(15);
    SetReg(0x0010, 0x5660);
    DelayMs(15);
    SetReg(0x0013, 0x2A4E);
    SetReg(0x0001, 0x0100);
    SetReg(0x0002, 0x0300);

        #if (DISP_ORIENTATION == 0)
    SetReg(0x0003, 0x1030);
        #else
    SetReg(0x0003, 0x1038);
        #endif
    SetReg(0x0008, 0x0202);
    SetReg(0x000A, 0x0000);
    SetReg(0x0030, 0x0000);
    SetReg(0x0031, 0x0402);
    SetReg(0x0032, 0x0106);
    SetReg(0x0033, 0x0700);
    SetReg(0x0034, 0x0104);
    SetReg(0x0035, 0x0301);
    SetReg(0x0036, 0x0707);
    SetReg(0x0037, 0x0305);
    SetReg(0x0038, 0x0208);
    SetReg(0x0039, 0x0F0B);
    DelayMs(15);
    SetReg(0x0041, 0x0002);
    SetReg(0x0060, 0x2700);
    SetReg(0x0061, 0x0001);
    SetReg(0x0090, 0x0119);
    SetReg(0x0092, 0x010A);
    SetReg(0x0093, 0x0004);
    SetReg(0x00A0, 0x0100);
    SetReg(0x0007, 0x0001);
    DelayMs(15);
    SetReg(0x0007, 0x0021);
    DelayMs(15);
    SetReg(0x0007, 0x0023);
    DelayMs(15);
    SetReg(0x0007, 0x0033);
    DelayMs(15);
    SetReg(0x0007, 0x0133);
    DelayMs(15);
    SetReg(0x00A0, 0x0000);
    DelayMs(20);

    /////////////////////////////////////////////////////////
    #elif defined (GFX_USE_DISPLAY_CONTROLLER_R61505)

    // Setup display
    SetReg(0x0000, 0x0000);
    SetReg(0x0007, 0x0001);
    DelayMs(5);
    SetReg(0x0017, 0x0001);
    DelayMs(5);
    SetReg(0x0010, 0x17b0);
    SetReg(0x0011, 0x0007);
    SetReg(0x0012, 0x011a);
    SetReg(0x0013, 0x0f00);
    SetReg(0x0015, 0x0000);
    SetReg(0x0029, 0x0009);
    SetReg(0x00fd, 0x0000);
    DelayMs(5);
    SetReg(0x0012, 0x013a);
    DelayMs(50);
    SetReg(0x0001, 0x0100);
    SetReg(0x0002, 0x0700);

        #if (DISP_ORIENTATION == 0)
    SetReg(0x0003, 0x1030);
        #else
    SetReg(0x0003, 0x1038);
        #endif
    SetReg(0x0008, 0x0808);
    SetReg(0x0009, 0x0000);
    SetReg(0x000a, 0x0000);
    SetReg(0x000c, 0x0000);
    SetReg(0x000d, 0x0000);
    SetReg(0x0030, 0x0000);
    SetReg(0x0031, 0x0000);
    SetReg(0x0032, 0x0000);
    SetReg(0x0033, 0x0000);
    SetReg(0x0034, 0x0000);
    SetReg(0x0035, 0x0000);
    SetReg(0x0036, 0x0000);
    SetReg(0x0037, 0x0707);
    SetReg(0x0038, 0x0707);
    SetReg(0x0039, 0x0707);
    SetReg(0x003a, 0x0303);
    SetReg(0x003b, 0x0303);
    SetReg(0x003c, 0x0707);
    SetReg(0x003d, 0x0808);
    SetReg(0x0050, 0x0000);
    SetReg(0x0051, 0x00ef);
    SetReg(0x0052, 0x0000);
    SetReg(0x0053, 0x013f);
    SetReg(0x0060, 0x2700);
    SetReg(0x0061, 0x0001);
    SetReg(0x006a, 0x0000);
    SetReg(0x0090, 0x0010);
    SetReg(0x0092, 0x0000);
    SetReg(0x0093, 0x0000);
    SetReg(0x0007, 0x0021);
    DelayMs(1);
    SetReg(0x0007, 0x0061);
    DelayMs(50);
    SetReg(0x0007, 0x0173);
    SetReg(0x0020, 0x0000);
    SetReg(0x0021, 0x0000);
    SetReg(0x0022, 0x0000);
    SetReg(0x0030, 0x0707);
    SetReg(0x0031, 0x0407);
    SetReg(0x0032, 0x0203);
    SetReg(0x0033, 0x0303);
    SetReg(0x0034, 0x0303);
    SetReg(0x0035, 0x0202);
    SetReg(0x0036, 0x001f);
    SetReg(0x0037, 0x0707);
    SetReg(0x0038, 0x0407);
    SetReg(0x0039, 0x0203);
    SetReg(0x003a, 0x0303);
    SetReg(0x003b, 0x0303);
    SetReg(0x003c, 0x0202);
    SetReg(0x003d, 0x001f);
    SetReg(0x0020, 0x0000);
    SetReg(0x0021, 0x0000);

    /////////////////////////////////////////////////////////
    #elif defined (GFX_USE_DISPLAY_CONTROLLER_S6D0129) || defined (GFX_USE_DISPLAY_CONTROLLER_S6D0139)

    // Setup display
    SetReg(0x0000, 0x0001);
    SetReg(0x0011, 0x1a00);
    SetReg(0x0014, 0x2020);
    SetReg(0x0010, 0x0900);
    SetReg(0x0013, 0x0040);
    SetReg(0x0013, 0x0060);
    SetReg(0x0013, 0x0070);
    SetReg(0x0011, 0x1a04);
    SetReg(0x0010, 0x2f00);
    SetReg(0x0001, 0x0127);
    SetReg(0x0002, 0x0700);

        #if (DISP_ORIENTATION == 0)
    SetReg(0x0003, 0x1030);
        #else
    SetReg(0x0003, 0x1038);
        #endif
    SetReg(0x0007, 0x0000);
    SetReg(0x0008, 0x0808);
    SetReg(0x0009, 0x0000);
    SetReg(0x000b, 0x0000);
    SetReg(0x000c, 0x0000);
    SetReg(0x0040, 0x0000);
    SetReg(0x0041, 0x0000);
    SetReg(0x0042, 0x013f);
    SetReg(0x0043, 0x0000);
    SetReg(0x0044, 0x00ef);
    SetReg(0x0045, 0x0000);
    SetReg(0x0046, 0xef00);
    SetReg(0x0047, 0x013f);
    SetReg(0x0048, 0x0000);
    SetReg(0x0007, 0x0014);
    SetReg(0x0007, 0x0016);
    SetReg(0x0007, 0x0017);
    SetReg(0x0020, 0x0000);
    SetReg(0x0021, 0x0000);
    SetReg(0x0022, 0x0000);

    /////////////////////////////////////////////////////////
    #elif defined (GFX_USE_DISPLAY_CONTROLLER_SPFD5408)

    // Setup display
    SetReg(0x0000, 0x0000);
    SetReg(0x0001, 0x0000);
    SetReg(0x0002, 0x0700);

        #if (DISP_ORIENTATION == 0)
    SetReg(0x0003, 0x1010);
        #else
    SetReg(0x0003, 0x1028);
        #endif
    SetReg(0x0004, 0x0000);
    SetReg(0x0008, 0x0207);
    SetReg(0x0009, 0x0000);
    SetReg(0x000a, 0x0000);
    SetReg(0x000c, 0x0000);
    SetReg(0x000d, 0x0000);
    SetReg(0x000f, 0x0000);
    SetReg(0x0007, 0x0101);
    SetReg(0x0010, 0x12b0);
    SetReg(0x0011, 0x0007);
    SetReg(0x0017, 0x0001);
    SetReg(0x0012, 0x01bb);
    SetReg(0x0013, 0x1300);
    SetReg(0x0029, 0x0010);

    SetReg(0x0030, 0x0100);
    SetReg(0x0031, 0x0c19);
    SetReg(0x0032, 0x111e);
    SetReg(0x0033, 0x3819);
    SetReg(0x0034, 0x350b);
    SetReg(0x0035, 0x0e08);
    SetReg(0x0036, 0x0d07);
    SetReg(0x0037, 0x0318);
    SetReg(0x0038, 0x0705);
    SetReg(0x0039, 0x0303);
    SetReg(0x003a, 0x0905);
    SetReg(0x003b, 0x0801);
    SetReg(0x003c, 0x030e);
    SetReg(0x003d, 0x050d);
    SetReg(0x003e, 0x0106);
    SetReg(0x003f, 0x0408);

    SetReg(0x0050, 0x0000);
    SetReg(0x0051, 0x00ef);
    SetReg(0x0052, 0x0000);
    SetReg(0x0053, 0x013f);
    SetReg(0x0060, 0xa700);
    SetReg(0x0061, 0x0001);
    SetReg(0x006a, 0x0000);
    SetReg(0x0080, 0x0000);
    SetReg(0x0081, 0x0000);
    SetReg(0x0082, 0x0000);
    SetReg(0x0083, 0x0000);
    SetReg(0x0084, 0x0000);
    SetReg(0x0085, 0x0000);
    SetReg(0x0090, 0x0010);
    SetReg(0x0092, 0x0000);
    SetReg(0x0093, 0x0103);
    SetReg(0x0095, 0x0110);
    SetReg(0x0097, 0x0000);
    SetReg(0x0098, 0x0000);
    SetReg(0x00f0, 0x5408);
    SetReg(0x00f3, 0x0010);
    SetReg(0x00f4, 0x001f);
    SetReg(0x00f0, 0x0000);
    SetReg(0x0007, 0x0133);

    /////////////////////////////////////////////////////////
    #elif defined (GFX_USE_DISPLAY_CONTROLLER_ILI9320)
    SetReg(0x0000, 0x0001); //start Int. osc
    DelayMs(15);
    SetReg(0x0001, 0x0100); //Set SS bit (shift direction of outputs is from S720 to S1)
    SetReg(0x0002, 0x0700); //select  the line inversion
        #if (DISP_ORIENTATION == 0)
    SetReg(0x0003, 0x1030); //Entry mode(Horizontal : increment,Vertical : increment, AM=0)
        #else
    SetReg(0x0003, 0x1038); //Entry mode(Horizontal : increment,Vertical : increment, AM=1)
        #endif
    SetReg(0x0004, 0x0000); //Resize control(No resizing)
    SetReg(0x0008, 0x0202); //front and back porch 2 lines
    SetReg(0x0009, 0x0000); //select normal scan
    SetReg(0x000A, 0x0000); //display control 4
    SetReg(0x000C, 0x0000); //system interface(2 transfer /pixel), internal sys clock,  	
    SetReg(0x000D, 0x0000); //Frame marker position
    SetReg(0x000F, 0x0000); //selects clk, enable and sync signal polarity,
    SetReg(0x0010, 0x0000); //	
    SetReg(0x0011, 0x0000); //power control 2 reference voltages = 1:1,
    SetReg(0x0012, 0x0000); //power control 3 VRH
    SetReg(0x0013, 0x0000); //power control 4 VCOM amplitude
    DelayMs(20);
    SetReg(0x0010, 0x17B0); //power control 1 BT,AP
    SetReg(0x0011, 0x0137); //power control 2 DC,VC
    DelayMs(50);
    SetReg(0x0012, 0x0139); //power control 3 VRH
    DelayMs(50);
    SetReg(0x0013, 0x1d00); //power control 4 vcom amplitude
    SetReg(0x0029, 0x0011); //power control 7 VCOMH
    DelayMs(50);
    SetReg(0x0030, 0x0007);
    SetReg(0x0031, 0x0403);
    SetReg(0x0032, 0x0404);
    SetReg(0x0035, 0x0002);
    SetReg(0x0036, 0x0707);
    SetReg(0x0037, 0x0606);
    SetReg(0x0038, 0x0106);
    SetReg(0x0039, 0x0007);
    SetReg(0x003c, 0x0700);
    SetReg(0x003d, 0x0707);
    SetReg(0x0020, 0x0000); //starting Horizontal GRAM Address
    SetReg(0x0021, 0x0000); //starting Vertical GRAM Address
    SetReg(0x0050, 0x0000); //Horizontal GRAM Start Position
    SetReg(0x0051, 0x00EF); //Horizontal GRAM end Position
    SetReg(0x0052, 0x0000); //Vertical GRAM Start Position
    SetReg(0x0053, 0x013F); //Vertical GRAM end Position
    SetReg(0x0060, 0x2700); //starts scanning from G1, and 320 drive lines
    SetReg(0x0061, 0x0001); //fixed base display
    SetReg(0x006a, 0x0000); //no scroll
    SetReg(0x0090, 0x0010); //set Clocks/Line =16, Internal Operation Clock Frequency=fosc/1,
    SetReg(0x0092, 0x0000); //set gate output non-overlap period=0
    SetReg(0x0093, 0x0003); //set Source Output Position=3
    SetReg(0x0095, 0x0110); //RGB interface(Clocks per line period=16 clocks)
    SetReg(0x0097, 0x0110); //set Gate Non-overlap Period 0 locksc
    SetReg(0x0098, 0x0110); //
    SetReg(0x0007, 0x0173); //display On
    /////////////////////////////////////////////////////////
    #elif defined (GFX_USE_DISPLAY_CONTROLLER_R61580)

    // Synchronization after reset
    DelayMs(2);
    SetReg(0x0000, 0x0000);
    SetReg(0x0000, 0x0000);
    SetReg(0x0000, 0x0000);
    SetReg(0x0000, 0x0000);

    // Setup display
    SetReg(0x00A4, 0x0001); // CALB=1
    DelayMs(2);
    SetReg(0x0060, 0xA700); // Driver Output Control
    SetReg(0x0008, 0x0808); // Display Control BP=8, FP=8
    SetReg(0x0030, 0x0111); // y control
    SetReg(0x0031, 0x2410); // y control
    SetReg(0x0032, 0x0501); // y control
    SetReg(0x0033, 0x050C); // y control
    SetReg(0x0034, 0x2211); // y control
    SetReg(0x0035, 0x0C05); // y control
    SetReg(0x0036, 0x2105); // y control
    SetReg(0x0037, 0x1004); // y control
    SetReg(0x0038, 0x1101); // y control
    SetReg(0x0039, 0x1122); // y control
    SetReg(0x0090, 0x0019); // 80Hz
    SetReg(0x0010, 0x0530); // Power Control
    SetReg(0x0011, 0x0237);
    SetReg(0x0012, 0x01BF);
    SetReg(0x0013, 0x1300);
    DelayMs(100);

    SetReg(0x0001, 0x0100);
    SetReg(0x0002, 0x0200);
        #if (DISP_ORIENTATION == 0)
    SetReg(0x0003, 0x1030);
        #else
    SetReg(0x0003, 0x1038);
        #endif
    SetReg(0x0009, 0x0001);
    SetReg(0x000A, 0x0008);
    SetReg(0x000C, 0x0001);
    SetReg(0x000D, 0xD000);
    SetReg(0x000E, 0x0030);
    SetReg(0x000F, 0x0000);
    SetReg(0x0020, 0x0000);
    SetReg(0x0021, 0x0000);
    SetReg(0x0029, 0x0077);
    SetReg(0x0050, 0x0000);
    SetReg(0x0051, 0xD0EF);
    SetReg(0x0052, 0x0000);
    SetReg(0x0053, 0x013F);
    SetReg(0x0061, 0x0001);
    SetReg(0x006A, 0x0000);
    SetReg(0x0080, 0x0000);
    SetReg(0x0081, 0x0000);
    SetReg(0x0082, 0x005F);
    SetReg(0x0093, 0x0701);
    SetReg(0x0007, 0x0100);
    SetReg(0x0022, 0x0000);
    #else
        #error Graphics controller is not supported.
    #endif
    DelayMs(20);
}
예제 #30
0
/*********************************************************************
* Function: void PutImage4BPP(SHORT left, SHORT top, FLASH_BYTE* image, BYTE stretch)
*
* PreCondition: none
*
* Input: left,top - left top image corner, image - image pointer,
*        stretch - image stretch factor
*
* Output: none
*
* Side Effects: none
*
* Overview: outputs 16 color image starting from left,top coordinates
*
* Note: image must be located in flash
*
********************************************************************/
void PutImage4BPP(SHORT left, SHORT top, FLASH_BYTE *image, BYTE stretch)
{
    register DWORD      address;
    register FLASH_BYTE *flashAddress;
    register FLASH_BYTE *tempFlashAddress;
    WORD                sizeX, sizeY;
    register WORD       x, y;
    BYTE                temp = 0;
    register BYTE       stretchX, stretchY;
    WORD                pallete[16];
    WORD                counter;

    #if (DISP_ORIENTATION == 90)
        top = GetMaxY() - top;
    #endif

    // Move pointer to size information
    flashAddress = image + 2;

    // Set start address
    #if (DISP_ORIENTATION == 0)
        address = (long)LINE_MEM_PITCH * top + left;
    #else
        address = (long)LINE_MEM_PITCH * left + top;
    #endif

    // Read image size
    sizeY = *((FLASH_WORD *)flashAddress);
    flashAddress += 2;
    sizeX = *((FLASH_WORD *)flashAddress);
    flashAddress += 2;

    // Read pallete
    for(counter = 0; counter < 16; counter++)
    {
        pallete[counter] = *((FLASH_WORD *)flashAddress);
        flashAddress += 2;
    }

    DisplayEnable();
    for(y = 0; y < sizeY; y++)
    {
        tempFlashAddress = flashAddress;
        for(stretchY = 0; stretchY < stretch; stretchY++)
        {
            flashAddress = tempFlashAddress;
            SetAddress(address);
            for(x = 0; x < sizeX; x++)
            {

                // Read 2 pixels from flash
                if(x & 0x0001)
                {

                    // second pixel in byte
                    SetColor(pallete[temp >> 4]);
                }
                else
                {
                    temp = *flashAddress;
                    flashAddress++;

                    // first pixel in byte
                    SetColor(pallete[temp & 0x0f]);
                }

                // Write pixel to screen
                for(stretchX = 0; stretchX < stretch; stretchX++)
                {
                    WritePixel(_color);
                }

                // Shift to the next pixel
                //temp >>= 4;
            }

            #if (DISP_ORIENTATION == 0)
                address += LINE_MEM_PITCH;
            #else
                address -= 1;
            #endif
        }