/* Fill a text line with a gradient: * x1, x2 - x pixel coordinates to start/stop * y - y pixel to start from * h - line height * num_lines - number of lines to span the gradient over * cur_line - current line being draw */ static void lcd_do_gradient_line(int x1, int x2, int y, unsigned h, int num_lines, int cur_line) { int step_mul; if (h == 0) return; num_lines *= h; cur_line *= h; step_mul = (1 << 16) / (num_lines); int h_r = RGB_UNPACK_RED(current_vp->lss_pattern); int h_g = RGB_UNPACK_GREEN(current_vp->lss_pattern); int h_b = RGB_UNPACK_BLUE(current_vp->lss_pattern); int rstep = (h_r - RGB_UNPACK_RED(current_vp->lse_pattern)) * step_mul; int gstep = (h_g - RGB_UNPACK_GREEN(current_vp->lse_pattern)) * step_mul; int bstep = (h_b - RGB_UNPACK_BLUE(current_vp->lse_pattern)) * step_mul; unsigned start_rgb, end_rgb; h_r = (h_r << 16) + (1 << 15); h_g = (h_g << 16) + (1 << 15); h_b = (h_b << 16) + (1 << 15); if (cur_line) { h_r -= cur_line * rstep; h_g -= cur_line * gstep; h_b -= cur_line * bstep; } start_rgb = LCD_RGBPACK(h_r >> 16, h_g >> 16, h_b >> 16); h_r -= h * rstep; h_g -= h * gstep; h_b -= h * bstep; end_rgb = LCD_RGBPACK(h_r >> 16, h_g >> 16, h_b >> 16); lcd_gradient_fillrect(x1, y, x2 - x1, h, start_rgb, end_rgb); }
void lcd_gradient_fillrect(int x, int y, int width, int height, unsigned start_rgb, unsigned end_rgb) { int old_pattern = current_vp->fg_pattern; int step_mul, i; int x1, x2; x1 = x; x2 = x + width; if (height == 0) return; step_mul = (1 << 16) / height; int h_r = RGB_UNPACK_RED(start_rgb); int h_g = RGB_UNPACK_GREEN(start_rgb); int h_b = RGB_UNPACK_BLUE(start_rgb); int rstep = (h_r - RGB_UNPACK_RED(end_rgb)) * step_mul; int gstep = (h_g - RGB_UNPACK_GREEN(end_rgb)) * step_mul; int bstep = (h_b - RGB_UNPACK_BLUE(end_rgb)) * step_mul; h_r = (h_r << 16) + (1 << 15); h_g = (h_g << 16) + (1 << 15); h_b = (h_b << 16) + (1 << 15); for(i = y; i < y + height; i++) { current_vp->fg_pattern = LCD_RGBPACK(h_r >> 16, h_g >> 16, h_b >> 16); lcd_hline(x1, x2, i); h_r -= rstep; h_g -= gstep; h_b -= bstep; } current_vp->fg_pattern = old_pattern; }
bool cfg_to_string(int i/*setting_id*/, char* buf, int buf_len) { switch (settings[i].flags&F_T_MASK) { case F_T_CUSTOM: settings[i].custom_setting->write_to_cfg(settings[i].setting, buf, buf_len); break; case F_T_INT: case F_T_UINT: #ifdef HAVE_LCD_COLOR if (settings[i].flags&F_RGB) { int colour = *(int*)settings[i].setting; snprintf(buf,buf_len,"%02x%02x%02x", (int)RGB_UNPACK_RED(colour), (int)RGB_UNPACK_GREEN(colour), (int)RGB_UNPACK_BLUE(colour)); } else #endif if (settings[i].cfg_vals == NULL) { snprintf(buf,buf_len,"%d",*(int*)settings[i].setting); } else { if (cfg_int_to_string(i, *(int*)settings[i].setting, buf, buf_len) == false) { snprintf(buf,buf_len,"%d",*(int*)settings[i].setting); } else return false; } break; case F_T_BOOL: cfg_int_to_string(i, *(bool*)settings[i].setting==false?0:1, buf, buf_len); break; case F_T_CHARPTR: case F_T_UCHARPTR: if (((char*)settings[i].setting)[0] && settings[i].filename_setting->prefix) { snprintf(buf,buf_len,"%s%s%s", settings[i].filename_setting->prefix, (char*)settings[i].setting, settings[i].filename_setting->suffix); } else strlcpy(buf,(char*)settings[i].setting, settings[i].filename_setting->max_len); break; } /* switch () */ return true; }
/* Fill a rectangle with a gradient */ static void lcd_gradient_rect(int x1, int x2, int y, unsigned h, int num_lines, int cur_line) { int old_pattern = current_vp->fg_pattern; int step_mul; if (h == 0) return; num_lines *= h; cur_line *= h; step_mul = (1 << 16) / (num_lines); int h_r = RGB_UNPACK_RED(current_vp->lss_pattern); int h_g = RGB_UNPACK_GREEN(current_vp->lss_pattern); int h_b = RGB_UNPACK_BLUE(current_vp->lss_pattern); int rstep = (h_r - RGB_UNPACK_RED(current_vp->lse_pattern)) * step_mul; int gstep = (h_g - RGB_UNPACK_GREEN(current_vp->lse_pattern)) * step_mul; int bstep = (h_b - RGB_UNPACK_BLUE(current_vp->lse_pattern)) * step_mul; h_r = (h_r << 16) + (1 << 15); h_g = (h_g << 16) + (1 << 15); h_b = (h_b << 16) + (1 << 15); if (cur_line) { h_r -= cur_line * rstep; h_g -= cur_line * gstep; h_b -= cur_line * bstep; } unsigned count; for(count = 0; count < h; count++) { current_vp->fg_pattern = LCD_RGBPACK(h_r >> 16, h_g >> 16, h_b >> 16); lcd_hline(x1, x2, y + count); h_r -= rstep; h_g -= gstep; h_b -= bstep; } current_vp->fg_pattern = old_pattern; }
void lcd_update_rect(int x, int y, int w, int h) { #ifdef HAVE_LCD_ENABLE if(!lcd_on) return; #endif for(int yy = y; yy < y + h; yy++) { uint16_t *pix = FBADDR(x, yy); uint8_t *p = 3 * (yy * LCD_WIDTH + x) + (uint8_t *)FRAME; for(int xx = 0; xx < w; xx++, pix++) { *p++ = RGB_UNPACK_RED(*pix); *p++ = RGB_UNPACK_GREEN(*pix); *p++ = RGB_UNPACK_BLUE(*pix); } } }