/*----------------------------------------------------------------------------*/ static void draw_cursor() { #if 0 lcd_put_char(0, 0, view_data.cursor_active ? UP_ARROW_CHR : ' '); lcd_put_char(0, 1, view_data.cursor_active ? DOWN_ARROW_CHR : ' '); #else int index, y = 0, height; height = lcd_height(); index = view_data.index; if((index >= view_data.string_count - height + 1) && (index >= height - 1)) { index -= height - 1; y += view_data.index - index; } lcd_put_char(0, y, view_data.cursor_active ? BLOCK_CHR : ' '); #endif }
/*----------------------------------------------------------------------------*/ static void display() { int width, height, y, index; width = lcd_width(); height = lcd_height(); lcd_clear(); index = view_data.index; if((index >= view_data.string_count - height + 1) && (index >= height - 1)) index -= height - 1; for(y = 0; y < height; y++) { char *str = 0; int size = 0, x = 1; SCR_ALIGN align = SCR_ALIGN_LEFT; if(index < view_data.string_count) view_data.get(view_data.data, index, &str, &align); if(str != 0) { size = strlen(str); if(align == SCR_ALIGN_CENTER) x = 1 + (width - size) / 2; else if(align == SCR_ALIGN_CENTER) x = 1 + width - size; if(size >= width && index == view_data.index) { lcd_add_scroll_text(y, 1, width - 1, str); } else { if(x < 1) x = 1; for(; x < width && *str; x++) { lcd_put_char(x, y, *str); str ++; } } } index ++; } draw_cursor(); }
int cmd_lcd(int argc, char **argv) { int i; int ret; if (is_command(argc, argv, "init")) { printf("Initializing LCD... "); ret = lcd_init(); if (ret) printf("failed: %d\n", ret); else printf("Ok\n"); } #ifdef LCD_DEBUG else if (is_command(argc, argv, "dump")) { lcd_dump(); } #endif else if (is_command(argc, argv, "run")) { printf("Running LCD... "); ret = lcd_run(); if (ret) printf("failed: %d\n", ret); else printf("Ok\n"); } else if (is_command(argc, argv, "stop")) { printf("Stopping LCD... "); ret = lcd_stop(); if (ret) printf("failed: %d\n", ret); else printf("Ok\n"); } else if (is_command(argc, argv, "tpp1")) { int w = lcd_width(); int h = lcd_height(); int total = w * h; for (i = 0; i < total; i++) lcd_addpixel(i); } else if (is_command(argc, argv, "tpp2")) { int x, y; i = 0; for (y = 0; y < lcd_height(); y++) for (x = 0; x < lcd_width(); x++) lcd_addpixel(rgb(i++, 0, 0)); } else if (is_command(argc, argv, "tpd")) { static int step = 0; pixel_t *fb; int x, y; int w, h; fb = lcd_fb(); h = lcd_height(); w = lcd_width(); /* Stupid clear-screen */ memset(fb, 0, w * h * lcd_bpp()); printf("Width: %d Height: %d\n", w, h); i = step++; fb = lcd_fb(); for (y = 0; y < h; y++) { for (x = 0; x < w; x++) { /* Swap axes, to verify X and Y work */ if (step & 1) *fb++ = color_wheel(y + step); else *fb++ = color_wheel(x + step); } } lcd_run(); } else { printf("lcd sub-commands (usage: lcd [subcmd]):\n"); printf("\tinit Initialize LCD registers\n"); printf("\trun Transfer one frame of the LCD\n"); printf("\tstop Stop and reset LCD auto-update\n"); #ifdef LCD_DEBUG printf("\tdump Dump current register list\n"); #endif printf("\ttpp1 Display bitbanged, PIO 'test pattern 1'\n"); printf("\ttpp2 Display bitbanged, PIO 'test pattern 2'\n"); printf("\ttpd DMA test pattern (flips on each iteration)\n"); } return 0; }