Advanced New Stage--LCD

Source: Internet
Author: User
Tags clear screen

LCD can finally be loaded with a full screen, filled with joy, the result began on a large area of black screen, the original is part of the new board burned to write the old superboot, re-burn write new after the problem solved.

LCD display principle is from point to line, the line to the surface of the continuous scanning principle, the specific design to the left and right margin of the timing of the relevant data, here will not repeat. Here is the idea of the relevant configuration,

The first thing is to make the register work, of course, the LCD and the chip hardware interface, configuration-related pins,

Second, LCD through the interface with the chip, of course, to configure the LCD controller register, Timing Control Register, window control register, it is important to distinguish the difference between the three, as long as a step-by-step configuration will be found to make the LCD simple work is not like that complex

Finally, configure the window to the left and right margin and the size of the picture, as well as to indicate the image cache to address, this is specified, finally enable channel 0 to transmit data

The relevant code below, the relevant register is not posted out, the chip manual is easy to find, here only focus

void Lcd_init (void)
{
Configuration PIN for LCD function
Gpf0con = 0x22222222; 4//4--7
Gpf1con = 0x22222222; 0--7
Gpf2con = 0x22222222; 0--7
Gpf3con = 0x22222222; 0--3

Turn on the backlight
Gpd0con &= ~ (0xf<<4);
Gpd0con |= (1<<4); Output mode??? (1<<5)

Gpd0dat |= (1<<1); //???? Output high, turn on backlight

10:RGB=FIMD I80=FIMD ITU=FIMD Setting the data output path
Display_control = 2<<0;

BIT[26~28]: Using RGB interface 000
Bit[18]:rgb Parallel 0
BIT[2]: Select clock Source is Hclk_dsys=166mhz 0
VIDCON0 &= ~ ((3<<26) | ( 1<<18) | (1<<2));

BIT[1]: Enable LCD controller
BIT[0]: Enable LCD controller after current frame end
VIDCON0 |= ((1<<0) | ( 1<<1));

BIT[4]: Select Need crossover
BIT[6~13]: The crossover factor is???, i.e. VCLK = 166m/(14+1) = 11M
VIDCON0 |= 5<<6 | 1<<4;


H43-hsd043i9w1.pdf (p13) Timing diagram: VSync and hsync are low pulses
s5pv210 chip Manual (p1207) Timing diagram: Both VSync and HSync are high-pulse efficient, so you need to invert
VIDCON1 |= 1<<5 | 1<<6;

Set Timing p1207 P13
VIDTCON0 = vbpd<<16 | vfpd<<8 | vspw<<0;
VIDTCON1 = hbpd<<16 | hfpd<<8 | hspw<<0;
Set the length width
VIDTCON2 = (lineval << 11) | (hozval << 0);

Setting up Windows 0
BIT[0]: Enable 1
BIT[2~5]:24BPP 1011
WINCON0 |= 1<<0;
WINCON0 &= ~ (0xf << 2); Qing 2--5
WINCON0 |= (0xb<<2) | (1<<15); 24 Guests

#define LEFTTOPX 0
#define LEFTTOPY 0
#define RIGHTBOTX 799
#define RIGHTBOTY 479

Set the windows1 up or down
vidosd0a = (lefttopx<<11) | (lefttopy << 0);
vidosd0b = (rightbotx<<11) | (rightboty << 0);
The Window Size
VIDOSD0C = (lineval + 1) * (Hozval + 1);


Set the address of the FB
vidw00add0b0 = fb_addr;
Vidw00add1b0 = (((hozval + 1) + 0) * (lineval + 1)) & (0XFFFFFF);//Length

Enable channel 0 to transmit data
Shadowcon = 0x1;
}

The LCD configuration is complete and you can start working, then you can draw gracefully. haha

Drawing
void Lcd_draw_bmp (const unsigned char gimage_bmp[])
{
int I, J;
unsigned char *p = (unsigned char *) gimage_bmp;
int blue, green, red;
int color;
Picture size 480x270 pixels |
for (i = 0; i < 480; i++)
for (j = 0; J <; J + +)
{
blue = *p++;
green = *p++;
red = *p++;

color = Red << 16 | Green << 8 | Blue << 0;
Lcd_draw_pixel (i, J, color);
}
}

Clear screen will produce a black screen (0x0), so the back to do when the mouse to turn off the clear screen
void lcd_clear_screen (int color)
{
int I, J;

for (i = 0; i < ROW; i++)
for (j = 0; J < COL; J + +)
Lcd_draw_pixel (i, J, color);

}

Drawing of related shapes below

A stroke.
void Lcd_draw_pixel (int row, int col, int color)
{
unsigned long * pixel = (unsigned long *) fb_addr;

* (pixel + row * col + col) = color;

}

Draw horizontal Line
void Lcd_draw_hline (int row, int col1, int col2, int color)
{
Int J;

Description row row, column J
for (j = col1; J <= Col2, J + +)
Lcd_draw_pixel (Row, J, color);

}

Draw Vertical Line
void Lcd_draw_vline (int col, int row1, int row2, int color)
{
int i;
Stroke line I, col column
for (i = row1; I <= row2; i++)
Lcd_draw_pixel (i, col, color);

}

Crossed Cross
void Lcd_draw_cross (int row, int col, int halflen, int color)
{
Lcd_draw_hline (Row, Col-halflen, Col+halflen, color);
Lcd_draw_vline (col, Row-halflen, Row+halflen, color);
}

stooped characters
void Lcd_draw_char (unsigned char c)
{
Must be a static variable
static int x = 0;//the first few columns
static int y = 0;//the first few lines

int i,j;
unsigned char line_dots;

Obtain the font
unsigned char *char_dots = (unsigned char *) (fontdata_8x16 + c * 16);


Do you want to enter a line break
if (c = = ' \ n ')
{
Y + = 16;
if (Y > ROW)
y = 0;
return;
}
else if (c = = ' \ r ')
{
x = 0;
Return
}

for (i = 0; i <; i++)
{
Line_dots = Char_dots[i];
for (j = 0; J < 8; J + +)
{
is 1, the blue dot is traced
if (Line_dots & (0x80 >> j))
{
Lcd_draw_pixel (Y+i, X+j, 0xff);
}
}
}

The cursor moves to the next 8*16 position
x + = 8;
if (x > COL)
{
x = 0;
Y + = 16;
if (Y > ROW)
y = 0;
}
}

Advanced New Stage--LCD

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.