FreeCalypso > hg > freecalypso-tools
view target-utils/lunadrv/lcdout.c @ 709:9b0ad72184e3
doc/Host-tools-overview: tiffs-mkfs documented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 23 May 2020 03:16:21 +0000 |
parents | db9a8e88e63f |
children |
line wrap: on
line source
/* * Generic LCD output operations are implemented here. All of the basic * LCD controller registers needed for these operations are the same * between ILI9225, ILI9225G and ST7775R controllers. */ #include <sys/types.h> #include "types.h" #include "luna.h" set_lcd_addr_region(xstart, xend, ystart, yend) { /* set window area */ LCD_REG_WR(0x36, xend); LCD_REG_WR(0x37, xstart); LCD_REG_WR(0x38, yend); LCD_REG_WR(0x39, ystart); /* set current write address */ LCD_REG_WR(0x20, xstart); LCD_REG_WR(0x21, ystart); /* set up for GRAM write */ LCD_IR = 0x22; } void cmd_fill(argbulk) char *argbulk; { char *argv[2]; u_long pixval; unsigned n; if (parse_args(argbulk, 1, 1, argv, 0) < 0) return; if (parse_hexarg(argv[0], 4, &pixval) < 0) { printf("ERROR: arg must be a valid 16-bit hex value\n"); return; } set_lcd_addr_region(0, 175, 0, 219); for (n = 0; n < 176 * 220; n++) LCD_DR = pixval; } void cmd_rect(argbulk) char *argbulk; { char *argv[6]; u_long pixval; int xstart, xend, ystart, yend; int npix; if (parse_args(argbulk, 5, 5, argv, 0) < 0) return; xstart = atoi(argv[0]); if (xstart < 0 || xstart > 175) { range_err: printf("ERROR: coordinate arg out of range\n"); return; } xend = atoi(argv[1]); if (xend < 0 || xend > 175) goto range_err; ystart = atoi(argv[2]); if (ystart < 0 || ystart > 219) goto range_err; yend = atoi(argv[3]); if (yend < 0 || yend > 219) goto range_err; if (xend < xstart || yend < ystart) { printf("ERROR: negative range\n"); return; } if (parse_hexarg(argv[4], 4, &pixval) < 0) { printf("ERROR: pixel arg must be a valid 16-bit hex value\n"); return; } set_lcd_addr_region(xstart, xend, ystart, yend); npix = (xend + 1 - xstart) * (yend + 1 - ystart); while (npix--) LCD_DR = pixval; } void cmd_mem2lcd(argbulk) char *argbulk; { char *argv[2]; u_long addr; const u16 *rdmem; unsigned n; if (parse_args(argbulk, 1, 1, argv, 0) < 0) return; if (parse_hexarg(argv[0], 8, &addr) < 0) { printf("ERROR: argument must be a valid 32-bit hex address\n"); return; } if (addr & 1) { printf("ERROR: unaligned address\n"); return; } rdmem = (const u16 *) addr; set_lcd_addr_region(0, 175, 0, 219); for (n = 0; n < 176 * 220; n++) LCD_DR = *rdmem++; }