Skip to content
This repository was archived by the owner on Jan 8, 2025. It is now read-only.

Commit

Permalink
fbcon: add support for drawing diffrent color line
Browse files Browse the repository at this point in the history
Add support for drawing diffrent color line

Change-Id: I86ca0aa425ae19cbeade5609cb27cc2b62b89a3e
  • Loading branch information
lijuang authored and vijay kumar committed Nov 5, 2015
1 parent cc271e9 commit 645b0c0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
15 changes: 9 additions & 6 deletions dev/fbcon/fbcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ static struct fbcon_config *config = NULL;
#define RGB565_YELLOW 0xffe0
#define RGB565_ORANGE 0xfd20
#define RGB565_RED 0xf800
#define RGB565_GREEN 0x3666

#define RGB888_BLACK 0x000000
#define RGB888_WHITE 0xffffff
Expand All @@ -68,6 +69,7 @@ static struct fbcon_config *config = NULL;
#define RGB888_YELLOW 0xffff00
#define RGB888_ORANGE 0xffa500
#define RGB888_RED 0xff0000
#define RGB888_GREEN 0x00ff00

#define FONT_WIDTH 5
#define FONT_HEIGHT 12
Expand All @@ -89,7 +91,7 @@ static struct fb_color fb_color_formats_555[] = {
[FBCON_YELLOW_MSG] = {RGB565_YELLOW, RGB565_BLACK},
[FBCON_ORANGE_MSG] = {RGB565_ORANGE, RGB565_BLACK},
[FBCON_RED_MSG] = {RGB565_RED, RGB565_BLACK},
[FBCON_LINE_COLOR] = {RGB565_WHITE, RGB565_WHITE},
[FBCON_GREEN_MSG] = {RGB565_GREEN, RGB565_BLACK},
[FBCON_SELECT_MSG_BG_COLOR] = {RGB565_WHITE, RGB565_BLUE}};

static struct fb_color fb_color_formats_888[] = {
Expand All @@ -100,7 +102,7 @@ static struct fb_color fb_color_formats_888[] = {
[FBCON_YELLOW_MSG] = {RGB888_YELLOW, RGB888_BLACK},
[FBCON_ORANGE_MSG] = {RGB888_ORANGE, RGB888_BLACK},
[FBCON_RED_MSG] = {RGB888_RED, RGB888_BLACK},
[FBCON_LINE_COLOR] = {RGB888_WHITE, RGB888_WHITE},
[FBCON_GREEN_MSG] = {RGB888_GREEN, RGB888_BLACK},
[FBCON_SELECT_MSG_BG_COLOR] = {RGB888_WHITE, RGB888_BLUE}};


Expand Down Expand Up @@ -243,20 +245,21 @@ static void fbcon_scroll_up(void)
fbcon_flush();
}

void fbcon_draw_line()
void fbcon_draw_line(uint32_t type)
{
char *pixels;
uint32_t bg_color, tmp_color;
uint32_t line_color, tmp_color;
int i, j;

bg_color = fb_color_formats[FBCON_LINE_COLOR].bg;
/* set line's color via diffrent type */
line_color = fb_color_formats[type].fg;

pixels = config->base;
pixels += cur_pos.y * ((config->bpp / 8) * FONT_HEIGHT * config->width);
pixels += cur_pos.x * ((config->bpp / 8) * (FONT_WIDTH + 1));

for (i = 0; i < (int)config->width; i++) {
tmp_color = bg_color;
tmp_color = line_color;
for (j = 0; j < (int)(config->bpp / 8); j++) {
*pixels = (unsigned char) tmp_color;
tmp_color = tmp_color >> 8;
Expand Down
6 changes: 2 additions & 4 deletions include/dev/fbcon.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ enum fbcon_msg_type {
FBCON_YELLOW_MSG,
FBCON_ORANGE_MSG,
FBCON_RED_MSG,

/* type for line color */
FBCON_LINE_COLOR,
FBCON_GREEN_MSG,

/* and the select message's background */
FBCON_SELECT_MSG_BG_COLOR,
Expand Down Expand Up @@ -96,7 +94,7 @@ void fbcon_extract_to_screen(logo_img_header *header, void* address);
void fbcon_putc_factor(char c, int type, unsigned scale_factor);
void fbcon_draw_msg_background(unsigned y_start, unsigned y_end,
uint32_t paint, int update);
void fbcon_draw_line(void);
void fbcon_draw_line(uint32_t type);
uint32_t fbcon_get_current_line(void);
uint32_t fbcon_get_current_bg(void);
uint32_t fbcon_get_max_x(void);
Expand Down

0 comments on commit 645b0c0

Please sign in to comment.