Esempio n. 1
0
/*****************************************************************************
 *
 * Description:
 *    Draw rectangular area with different boardser colors. Currently used
 *    by example game.
 *
 ****************************************************************************/
void lcdRectBrd (uint8 x, uint8 y, uint8 xLen, uint8 yLen, uint8 color1, uint8 color2, uint8 color3)
{
	uint32 i, j;

	//select controller
	selectLCD (TRUE);

	lcdWindow1 (x, y, x + xLen - 1, y + yLen - 1);

	lcdWrcmd (LCD_CMD_RAMWR); //write memory

	for (i = 0; i < xLen; i++)
		lcdWrdata (color2);
	for (j = 1; j < (yLen - 2); j++)
	{
		lcdWrdata (color2);
		for (i = 0; i < (xLen - 2); i++)
			lcdWrdata (color1);
		lcdWrdata (color3);
	}
	for (i = 0; i < xLen; i++)
		lcdWrdata (color3);

	//deselect controller
	selectLCD (FALSE);
}
Esempio n. 2
0
/*****************************************************************************
 *
 * Description:
 *    Initialize LCD controller for a window (to write in).
 *    Set start xy-position and xy-length
 *    No select/deselect of LCD controller.
 *
 ****************************************************************************/
static void lcdWindow1 (uint8 xp, uint8 yp, uint8 xe, uint8 ye)
{
	lcdWrcmd (LCD_CMD_CASET); //set X
	lcdWrdata (xp + 2);
	lcdWrdata (xe + 2);

	lcdWrcmd (LCD_CMD_PASET); //set Y
	lcdWrdata (yp + 2);
	lcdWrdata (ye + 2);
}
Esempio n. 3
0
/*****************************************************************************
 *
 * Description:
 *    Initialize LCD controller for a window (to write in).
 *    Set start xy-position and xy-length
 *    No select/deselect of LCD controller.
 *
 ****************************************************************************/
static void
lcdWindow1(tU8 xp, tU8 yp, tU8 xe, tU8 ye)
{
  lcdWrcmd(LCD_CMD_CASET);    //set X (column address set)
  lcdWrdata(xp+2);
	lcdWrdata(xe+2);

	lcdWrcmd(LCD_CMD_PASET);    //set Y (row address set)
	lcdWrdata(yp+2);
	lcdWrdata(ye+2);
}
Esempio n. 4
0
/*****************************************************************************
 *
 * Description:
 *    Initialize LCD controller for a window (to write in).
 *    Set start xy-position and xy-length
 *    No select/deselect of LCD controller.
 *
 ****************************************************************************/
static void
lcdWindow1(tU8 xp, tU8 yp, tU8 xe, tU8 ye)
{
//Why xp/xe/yp/ye+2? Suppose has to be +1, not +2

  lcdWrcmd(LCD_CMD_CASET);    //set X
  lcdWrdata(xp+1);
	lcdWrdata(xe+1);

	lcdWrcmd(LCD_CMD_PASET);    //set Y
	lcdWrdata(yp+1);
	lcdWrdata(ye+1);
}
Esempio n. 5
0
/*****************************************************************************
 *
 * Description:
 *    Draw rectangular area from bitmap. Specify xy-position and xy-length.
 *    Compressed format is supported.
 *
 *    In uncompressed color mode, pData points to an area of xLen * yLen
 *    bytes with the icon.
 *    In compressed mode the escapeChar is used to denote that the next
 *    two bytes contain a length and a color (run length encoding)
 *    Note that is is still possible to specify the color value that
 *    equals the escape value in a compressed string.
 *
 ****************************************************************************/
void
lcdIcon(tU8 x, tU8 y, tU8 xLen, tU8 yLen, tU8 compressionOn, tU8 escapeChar, const tU8* pData)
{
  tU32 i,j;
  tS32 len;

  //select controller
  selectLCD(TRUE);   

  lcdWindow1(x,y,x+xLen-1,y+yLen-1);
  
  lcdWrcmd(LCD_CMD_RAMWR);    //write memory
  
  len = xLen*yLen;
  if (compressionOn == FALSE)
  {
    for(i=0; i<len; i++)
      lcdWrdata(*pData++);
  }
  else
    while(len > 0)
    {
      if(*pData == escapeChar)
      {
        pData++;
        j = *pData++;
        for(i=0;i<j;i++)
          lcdWrdata(*pData);
        pData++;
        len -= j;
      }
      else
      {
        lcdWrdata(*pData++);
        len--;
      }
    }

  //deselect controller
  selectLCD(FALSE);
}
Esempio n. 6
0
/*****************************************************************************
 *
 * Description:
 *    Set display contrast
 *
 ****************************************************************************/
void lcdContrast (uint8 cont) //vary between 0 - 127
{
	//select controller
	selectLCD (TRUE);

	//set contrast cmd.
	lcdWrcmd (LCD_CMD_SETCON);
	lcdWrdata (cont);

	//deselect controller
	selectLCD (FALSE);
}
Esempio n. 7
0
/*****************************************************************************
 *
 * Description:
 *    Draw a rectangular area with specified color.
 *
 ****************************************************************************/
void lcdRect (uint8 x, uint8 y, uint8 xLen, uint8 yLen, uint8 color)
{
	uint32 i;
	uint32 len;

	//select controller
	selectLCD (TRUE);

	lcdWindow1 (x, y, x + xLen - 1, y + yLen - 1);

	lcdWrcmd (LCD_CMD_RAMWR); //write memory

	len = xLen * yLen;
	for (i = 0; i < len; i++)
		lcdWrdata (color);

	//deselect controller
	selectLCD (FALSE);
}
Esempio n. 8
0
/*****************************************************************************
 *
 * Description:
 *    Clear screen (with current background color)
 *
 ****************************************************************************/
void lcdClrscr (void)
{
	uint32 i;

	lcd_x = 0;
	lcd_y = 0;

	//select controller
	selectLCD (TRUE);

	lcdWindow1 (255, 255, 128, 128);

	lcdWrcmd (LCD_CMD_RAMWR); //write memory

	for (i = 0; i < 16900; i++)
		lcdWrdata (bkgColor);

	//deselect controller
	selectLCD (FALSE);
}
Esempio n. 9
0
/*****************************************************************************
 *
 * Description:
 *    Draw one character withc current foreground and background color
 *    at current xy position on display. Update x-position (+8).
 *
 ****************************************************************************/
void
lcdData(tU8 data)
{
  //select controller
  selectLCD(TRUE);
  
  if (data <= 127)
  {
    tU32 mapOffset;
    tU8 i,j,byteToShift;

    data -= 30;
    mapOffset = 14*data;

    lcdWrcmd(LCD_CMD_CASET);
    lcdWrdata(lcd_x+2);
    lcdWrdata(lcd_x+9);
    lcdWrcmd(LCD_CMD_PASET);
    lcdWrdata(lcd_y+2);
    lcdWrdata(lcd_y+15);
    lcdWrcmd(LCD_CMD_RAMWR);
    
    for(i=0; i<14; i++)
    {
      byteToShift = charMap[mapOffset++];
      for(j=0; j<8; j++)
      {
        if (byteToShift & 0x80)
          lcdWrdata(textColor);
        else
          lcdWrdata(bkgColor);
        byteToShift <<= 1;
      }
    }
  }

  //deselect controller
  selectLCD(FALSE);

  lcd_x += 8;
}
Esempio n. 10
0
/*****************************************************************************
 *
 * Description:
 *    Initialize the LCD controller and SPI interface
 *    (0,0) is top left and (129,129) is bottom right
 *    8 bits Color mode uses RRRGGGBB layout
 *
 ****************************************************************************/
void lcdInit (void)
{
	bkgColor = 0;
	textColor = 0;

	//init SPI interface
	initSpiForLcd ();

	//select controller
	selectLCD (TRUE);

	lcdWrcmd (LCD_CMD_SWRESET);

	osSleep (1);
	lcdWrcmd (LCD_CMD_SLEEPOUT);
	lcdWrcmd (LCD_CMD_DISPON);
	lcdWrcmd (LCD_CMD_BSTRON);
	osSleep (1);

	lcdWrcmd (LCD_CMD_MADCTL); //Memory data acces control
	lcdWrdata (MADCTL_HORIZ); //X Mirror and BGR format
	lcdWrcmd (LCD_CMD_COLMOD); //Colour mode
	lcdWrdata (0x02); //256 colour mode select
	lcdWrcmd (LCD_CMD_INVON); //Non Invert mode

	lcdWrcmd (LCD_CMD_RGBSET); //LUT write
	lcdWrdata (0); //Red
	lcdWrdata (2);
	lcdWrdata (4);
	lcdWrdata (6);
	lcdWrdata (9);
	lcdWrdata (11);
	lcdWrdata (13);
	lcdWrdata (15);
	lcdWrdata (0); //Green
	lcdWrdata (2);
	lcdWrdata (4);
	lcdWrdata (6);
	lcdWrdata (9);
	lcdWrdata (11);
	lcdWrdata (13);
	lcdWrdata (15);
	lcdWrdata (0); //Blue
	lcdWrdata (6);
	lcdWrdata (10);
	lcdWrdata (15);

	//deselect controller
	selectLCD (FALSE);

	lcdContrast (56);

	lcdClrscr ();
}
Esempio n. 11
0
/*****************************************************************************
 *
 * Description:
 *    Initialize the LCD controller and SPI interface
 *    (0,0) is top left and (129,129) is bottom right
 *    8 bits Color mode uses RRRGGGBB layout
 *
 ****************************************************************************/
void
lcdInit(void)
{
  bkgColor  = 0;
  textColor = 0;
  
  //init SPI interface
  initSpiForLcd();
  
  //select controller
  selectLCD(TRUE);

	lcdWrcmd(LCD_CMD_SWRESET);   //Software reset - Reset default values and all segment & common outputs are set to VC (display off: blank display)

	osSleep(1);
	lcdWrcmd(LCD_CMD_SLEEPOUT);  //switch off SLEEPIN mode
	lcdWrcmd(LCD_CMD_DISPON);    //Turn on the display screen according to the current display data RAM content and the display timing and setting
	lcdWrcmd(LCD_CMD_BSTRON);    //Booster ON- This command turns on booster related circuit
	osSleep(1);
		
	lcdWrcmd(LCD_CMD_MADCTL);   //Memory data acces control
	lcdWrdata(MADCTL_HORIZ);    //X Mirror and BGR format
	lcdWrcmd(LCD_CMD_COLMOD);   //Colour mode
	lcdWrdata(0x02);            //256 colour mode select
	lcdWrcmd(LCD_CMD_INVON);    //Non Invert mode

	lcdWrcmd(LCD_CMD_RGBSET);   //LUT write, Colour Set for 256-Color Display
  lcdWrdata(0);               //Red
  lcdWrdata(2);
  lcdWrdata(4);
  lcdWrdata(6);
  lcdWrdata(9);
  lcdWrdata(11);
  lcdWrdata(13);
  lcdWrdata(15);
  lcdWrdata(0);               //Green
  lcdWrdata(2);
  lcdWrdata(4);
  lcdWrdata(6);
  lcdWrdata(9);
  lcdWrdata(11);
  lcdWrdata(13);
  lcdWrdata(15);
  lcdWrdata(0);               //Blue
  lcdWrdata(6);
	lcdWrdata(10);
	lcdWrdata(15);

  //deselect controller
  selectLCD(FALSE);

	lcdContrast(56);

	lcdClrscr();
}