Exemplo 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);
}
Exemplo n.º 2
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
        lcdWrdata(0x98);
	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();
}
Exemplo n.º 3
0
/*****************************************************************************
 *
 * Description:
 *    Initialize LCD controller for a window (to write in).
 *    Set start xy-position and xy-length.
 *    Selects/deselects LCD controller.
 *
 ****************************************************************************/
void lcdWindow (uint8 xp, uint8 yp, uint8 xe, uint8 ye)
{
	//select controller
	selectLCD (TRUE);

	lcdWindow1 (xp, yp, xe, ye);

	//deselect controller
	selectLCD (FALSE);
}
Exemplo n.º 4
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();
}
Exemplo n.º 5
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);
}
Exemplo n.º 6
0
/*****************************************************************************
 *
 * Description:
 *    Shut down the LCD controller
 *
 ****************************************************************************/
void lcdOff (void)
{
	lcdClrscr ();

	//select controller
	selectLCD (TRUE);

	lcdWrcmd (LCD_CMD_SLEEPIN);

	//deselect controller
	selectLCD (FALSE);
}
Exemplo n.º 7
0
void modulo2(int nGpio){
    int num;

    switch(nGpio){
    	case GPIO_0 ... GPIO_5:
    	selectGPMC(nGpio);
    	break;

    	case GPIO_6 ... GPIO_17:
    	num = nGpio - 6;
        GPIOPinMuxSetup(CONTROL_CONF_LCD_DATA(num), CONTROL_CONF_MUXMODE(7));
    	break;

    	case GPIO_18 ... GPIO_21:
    	num = nGpio - 18;
        selectMII1RXD(nGpio);
    	break; 

    	case GPIO_22 ... GPIO_25:
    	selectLCD(nGpio);
    	break;

    	case GPIO_26 ... GPIO_31:
    	selectMMC0(nGpio);
    	break;
    }
}
Exemplo n.º 8
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);
}
Exemplo n.º 9
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);
}
Exemplo n.º 10
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;
}
Exemplo n.º 11
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);
}
Exemplo n.º 12
0
void initSpiForLcd(void) {
	//make SPI slave chip select an output and set signal high
	IODIR |= (LCD_CS | LCD_CLK | LCD_MOSI);

	//deselect controller
	selectLCD(FALSE);

	//connect SPI bus to IO-pins
	PINSEL0 |= 0x00001500;

	//initialize SPI interface
	SPI_SPCCR = 0x08;
	SPI_SPCR = 0x20;
}
Exemplo n.º 13
0
Arquivo: hw.c Projeto: budzek/embedded
/*****************************************************************************
 *
 * Description:
 *    Initialize the SPI interface for the LCD controller
 *
 ****************************************************************************/
void
initSpiForLcd(void)
{
  //make SPI slave chip select an output and set signal high

  IODIR |= (LCD_CS_V1_0 | LCD_CLK | LCD_MOSI);

  //deselect controller
  selectLCD(FALSE);

  //connect SPI bus to IO-pins
  PINSEL0 |= 0x00005500;
  
  //initialize SPI interface
  SPI_SPCCR = 0x08;    //bus into master state
  SPI_SPCR  = 0x20;    //size of sending data unit
}