summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/lcd-bitmap-common.c39
-rw-r--r--firmware/export/lcd.h2
2 files changed, 38 insertions, 3 deletions
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c
index 5961bba7a5..2b309ba75a 100644
--- a/firmware/drivers/lcd-bitmap-common.c
+++ b/firmware/drivers/lcd-bitmap-common.c
@@ -41,8 +41,21 @@
41#endif 41#endif
42 42
43#if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR) 43#if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR)
44void lcd_gradient_fillrect(int x, int y, int width, int height, 44/* Fill a rectangle with a gradient. This function draws only the partial
45 unsigned start_rgb, unsigned end_rgb) 45 * gradient. It assumes the original gradient is src_height high and skips
46 * the first few rows. This is useful for drawing only the bottom half of
47 * a full gradient.
48 *
49 * height == src_height and row_skip == 0 will draw the full gradient
50 *
51 * x, y, width, height - dimensions describing the rectangle
52 * start_rgb - beginning color of the gradient
53 * end_rgb - end color of the gradient
54 * src_height - assumed original height (only height rows will be drawn)
55 * row_skip - how many rows of the original gradient to skip
56 */
57void lcd_gradient_fillrect_part(int x, int y, int width, int height,
58 unsigned start_rgb, unsigned end_rgb, int src_height, int row_skip)
46{ 59{
47 int old_pattern = current_vp->fg_pattern; 60 int old_pattern = current_vp->fg_pattern;
48 int step_mul, i; 61 int step_mul, i;
@@ -52,7 +65,7 @@ void lcd_gradient_fillrect(int x, int y, int width, int height,
52 65
53 if (height == 0) return; 66 if (height == 0) return;
54 67
55 step_mul = (1 << 16) / height; 68 step_mul = (1 << 16) / src_height;
56 int h_r = RGB_UNPACK_RED(start_rgb); 69 int h_r = RGB_UNPACK_RED(start_rgb);
57 int h_g = RGB_UNPACK_GREEN(start_rgb); 70 int h_g = RGB_UNPACK_GREEN(start_rgb);
58 int h_b = RGB_UNPACK_BLUE(start_rgb); 71 int h_b = RGB_UNPACK_BLUE(start_rgb);
@@ -63,6 +76,13 @@ void lcd_gradient_fillrect(int x, int y, int width, int height,
63 h_g = (h_g << 16) + (1 << 15); 76 h_g = (h_g << 16) + (1 << 15);
64 h_b = (h_b << 16) + (1 << 15); 77 h_b = (h_b << 16) + (1 << 15);
65 78
79 if (row_skip > 0)
80 {
81 h_r -= rstep * row_skip;
82 h_g -= gstep * row_skip;
83 h_b -= bstep * row_skip;
84 }
85
66 for(i = y; i < y + height; i++) { 86 for(i = y; i < y + height; i++) {
67 current_vp->fg_pattern = LCD_RGBPACK(h_r >> 16, h_g >> 16, h_b >> 16); 87 current_vp->fg_pattern = LCD_RGBPACK(h_r >> 16, h_g >> 16, h_b >> 16);
68 lcd_hline(x1, x2, i); 88 lcd_hline(x1, x2, i);
@@ -74,6 +94,19 @@ void lcd_gradient_fillrect(int x, int y, int width, int height,
74 current_vp->fg_pattern = old_pattern; 94 current_vp->fg_pattern = old_pattern;
75} 95}
76 96
97/* Fill a rectangle with a gradient. The gradient's color will fade from
98 * start_rgb to end_rgb over the height of the rectangle
99 *
100 * x, y, width, height - dimensions describing the rectangle
101 * start_rgb - beginning color of the gradient
102 * end_rgb - end color of the gradient
103 */
104void lcd_gradient_fillrect(int x, int y, int width, int height,
105 unsigned start_rgb, unsigned end_rgb)
106{
107 lcd_gradient_fillrect_part(x, y, width, height, start_rgb, end_rgb, height, 0);
108}
109
77/* Fill a text line with a gradient: 110/* Fill a text line with a gradient:
78 * x1, x2 - x pixel coordinates to start/stop 111 * x1, x2 - x pixel coordinates to start/stop
79 * y - y pixel to start from 112 * y - y pixel to start from
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h
index 745c445dda..af32b796be 100644
--- a/firmware/export/lcd.h
+++ b/firmware/export/lcd.h
@@ -530,6 +530,8 @@ extern void lcd_drawrect(int x, int y, int width, int height);
530extern void lcd_fillrect(int x, int y, int width, int height); 530extern void lcd_fillrect(int x, int y, int width, int height);
531extern void lcd_gradient_fillrect(int x, int y, int width, int height, 531extern void lcd_gradient_fillrect(int x, int y, int width, int height,
532 unsigned start_rgb, unsigned end_rgb); 532 unsigned start_rgb, unsigned end_rgb);
533extern void lcd_gradient_fillrect_part(int x, int y, int width, int height,
534 unsigned start_rgb, unsigned end_rgb, int src_height, int row_skip);
533extern void lcd_draw_border_viewport(void); 535extern void lcd_draw_border_viewport(void);
534extern void lcd_fill_viewport(void); 536extern void lcd_fill_viewport(void);
535extern void lcd_bitmap_part(const fb_data *src, int src_x, int src_y, 537extern void lcd_bitmap_part(const fb_data *src, int src_x, int src_y,