示例#1
0
void set_orientation(orientation o)
{
	display.orient = o;
	write_cmd(MEMORY_ACCESS_CONTROL);
	if (o==North) { 
		display.width = LCDWIDTH;
		display.height = LCDHEIGHT;
		write_data(0x48);
	}
	else if (o==West) {
		display.width = LCDHEIGHT;
		display.height = LCDWIDTH;
		write_data(0xE8);
	}
	else if (o==South) {
		display.width = LCDWIDTH;
		display.height = LCDHEIGHT;
		write_data(0x88);
	}
	else if (o==East) {
		display.width = LCDHEIGHT;
		display.height = LCDWIDTH;
		write_data(0x28);
	}
	write_cmd(COLUMN_ADDRESS_SET);
	write_data16(0);
	write_data16(display.width-1);
	write_cmd(PAGE_ADDRESS_SET);
	write_data16(0);
	write_data16(display.height-1);
}
示例#2
0
static inline void set_viewport(GDisplay* g) {
	write_index(g, SSD1963_SET_PAGE_ADDRESS);
	write_data16(g, g->p.y);
	write_data16(g, g->p.y+g->p.cy-1);
	write_index(g, SSD1963_SET_COLUMN_ADDRESS);
	write_data16(g, g->p.x);
	write_data16(g, g->p.x+g->p.cx-1);
	write_index(g, SSD1963_WRITE_MEMORY_START);
}
示例#3
0
void fill_rectangle_indexed(rectangle r, uint16_t* col)
{
	uint16_t x, y;
	write_cmd(COLUMN_ADDRESS_SET);
	write_data16(r.left);
	write_data16(r.right);
	write_cmd(PAGE_ADDRESS_SET);
	write_data16(r.top);
	write_data16(r.bottom);
	write_cmd(MEMORY_WRITE);
	for(x=r.left; x<=r.right; x++)
		for(y=r.top; y<=r.bottom; y++)
			write_data16(*col++);
}
示例#4
0
文件: lcd.c 项目: arian009/GroupG
void display_char(char c)
{
	uint16_t x, y;
	PGM_P fdata; 
	uint8_t bits, mask;
	uint16_t sc=display.x, ec=display.x + 4, sp=display.y, ep=display.y + 7;
	if (c < 32 || c > 126) return;
	fdata = (c - ' ')*5 + font5x7;
	write_cmd(PAGE_ADDRESS_SET);
	write_data16(sp);
	write_data16(ep);
	for(x=sc; x<=ec; x++) {
		write_cmd(COLUMN_ADDRESS_SET);
		write_data16(x);
		write_data16(x);
		write_cmd(MEMORY_WRITE);
		bits = pgm_read_byte(fdata++);
		for(y=sp, mask=0x01; y<=ep; y++, mask<<=1)
			write_data16((bits & mask) ? display.foreground : display.background);
	}
	write_cmd(COLUMN_ADDRESS_SET);
	write_data16(x);
	write_data16(x);
	write_cmd(MEMORY_WRITE);
	for(y=sp; y<=ep; y++)
		write_data16(display.background);

	display.x += 6;
	if (display.x >= display.width) { display.x=0; display.y+=8; }
}
示例#5
0
void MEMORY::write_data32(uint32 addr, uint32 data)
{
	int bank = (addr & ADDR_MASK) >> addr_shift;
	
	if(write_table[bank].dev != NULL) {
		write_table[bank].dev->write_memory_mapped_io32(addr, data);
	}
	else {
		write_data16(addr, data & 0xffff);
		write_data16(addr + 2, (data >> 16) & 0xffff);
	}
}
示例#6
0
文件: lcd.c 项目: mjones204/KanaQuiz
void init_lcd()
{
    /* Enable extended memory interface with 10 bit addressing */
    XMCRB = _BV(XMM2) | _BV(XMM1);
    XMCRA = _BV(SRE);
    DDRC |= _BV(RESET);
    DDRB |= _BV(BLC);
    _delay_ms(1);
    PORTC &= ~_BV(RESET);
    _delay_ms(20);
    PORTC |= _BV(RESET);
    _delay_ms(120);
    write_cmd(DISPLAY_OFF);
    write_cmd(SLEEP_OUT);
    _delay_ms(60);
    write_cmd_data(INTERNAL_IC_SETTING,          0x01);
    write_cmd(POWER_CONTROL_1);
        write_data16(0x2608);
    write_cmd_data(POWER_CONTROL_2,              0x10);
    write_cmd(VCOM_CONTROL_1);
        write_data16(0x353E);
    write_cmd_data(VCOM_CONTROL_2, 0xB5);
    write_cmd_data(INTERFACE_CONTROL, 0x01);
        write_data16(0x0000);
    write_cmd_data(PIXEL_FORMAT_SET, 0x55);     /* 16bit/pixel */
    set_orientation(West);
    clear_screen();
    display.x = 0;
    display.y = 0;
    display.background = BLACK;
    display.foreground = WHITE;
    write_cmd(DISPLAY_ON);
    _delay_ms(50);
    write_cmd_data(TEARING_EFFECT_LINE_ON, 0x00);
    EICRB |= _BV(ISC61);
    PORTB |= _BV(BLC);
}
示例#7
0
文件: lcd.c 项目: mjones204/KanaQuiz
void fill_rectangle(rectangle r, uint16_t col)
{
    write_cmd(COLUMN_ADDRESS_SET);
    write_data16(r.left);
    write_data16(r.right);
    write_cmd(PAGE_ADDRESS_SET);
    write_data16(r.top);
    write_data16(r.bottom);
    write_cmd(MEMORY_WRITE);
/*  uint16_t x, y;
    for(x=r.left; x<=r.right; x++)
        for(y=r.top; y<=r.bottom; y++)
            write_data16(col);
*/
    uint16_t wpixels = r.right - r.left + 1;
    uint16_t hpixels = r.bottom - r.top + 1;
    uint8_t mod8, div8;
    uint16_t odm8, odd8;
    if (hpixels > wpixels) {
        mod8 = hpixels & 0x07;
        div8 = hpixels >> 3;
        odm8 = wpixels*mod8;
        odd8 = wpixels*div8;
    } else {
示例#8
0
文件: lcd.c 项目: arian009/GroupG
void fill_rectangle_indexed_scale(rectangle r, uint16_t* col, int s) {
	uint16_t x, y, i, j, k;
	write_cmd(COLUMN_ADDRESS_SET);
	//write_data16(r.left);
	//write_data16(r.left + ((r.right - r.left + 1) * s) - 1);
	write_data16(r.left * s);
	write_data16(r.right * s);
	write_cmd(PAGE_ADDRESS_SET);
	//write_data16(r.top);
	//write_data16(r.top + ((r.bottom - r.top + 1) * s) - 1);
	write_data16(r.top * s);
	write_data16(r.bottom * s);
	write_cmd(MEMORY_WRITE);
	for(x = 0; x < (r.right - r.left); x++) {
		for(i = 0; i < s; i++) {
			for(y = 0; y < (r.bottom - r.top); y++) {
				k = (x * (r.bottom - r.top)) + y;
				for(j = 0; j < s; j++) {
					write_data16(*(col + k));
				}
			}
		}
	}
}
示例#9
0
void display_char(char c)
{
	uint16_t x, y;
	PGM_P fdata; 
	uint8_t bits, mask;
	uint16_t sc=display.x, ec=display.x + 4, sp=display.y, ep=display.y + 7;

	/*   ::: MODIFIED :::  [KPZ-05.01.2014] */
	/* Carriage return starts a new line, or if the end of the
           display has been reached, clears the display.
	 */
	if (c == '\n') { 
	    display.x=0; display.y+=8;
	    if (display.y >= display.height) { clear_screen(); }
	    return;
	}

	if (c < 32 || c > 126) return;
	fdata = (c - ' ')*5 + font5x7;
	write_cmd(PAGE_ADDRESS_SET);
	write_data16(sp);
	write_data16(ep);
	for(x=sc; x<=ec; x++) {
		write_cmd(COLUMN_ADDRESS_SET);
		write_data16(x);
		write_data16(x);
		write_cmd(MEMORY_WRITE);
		bits = pgm_read_byte(fdata++);
		for(y=sp, mask=0x01; y<=ep; y++, mask<<=1)
			write_data16((bits & mask) ? display.foreground : display.background);
	}
	write_cmd(COLUMN_ADDRESS_SET);
	write_data16(x);
	write_data16(x);
	write_cmd(MEMORY_WRITE);
	for(y=sp; y<=ep; y++)
		write_data16(display.background);

	display.x += 6;
	if (display.x >= display.width) { display.x=0; display.y+=8; }

}
示例#10
0
文件: lcd.c 项目: arian009/GroupG
void fill_rectangle_bitmap(rectangle r, uint16_t* bitmap, uint16_t foreground, uint16_t background) {
	uint16_t x, y, i;
	write_cmd(COLUMN_ADDRESS_SET);
	write_data16(r.left);
	write_data16(r.right);
	write_cmd(PAGE_ADDRESS_SET);
	write_data16(r.top);
	write_data16(r.bottom);
	write_cmd(MEMORY_WRITE);
	i = 0;
	for(x = r.left; x <= r.right; x++) {
		for(y = r.top; y <= r.bottom; y++) {
			if((*bitmap) & (1 << i)) {
				write_data16(foreground);
			} else {
				write_data16(background);
			}
			if(++i == 16) {
				i = 0;
				bitmap++;
			}
		}
	}
}
示例#11
0
	LLDSPEC	void gdisp_lld_write_color(GDisplay *g) {
		write_data16(g, gdispColor2Native(g->p.color));
	}
示例#12
0
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
	LCD_Parameters *	lcdp;

	// The private area for this controller is the LCD timings
	lcdp = (void *)&DisplayTimings[g->controllerdisplay];
	g->priv = lcdp;

	// Initialise the board interface
	init_board(g);

	// Hardware reset
	setpin_reset(g, TRUE);
	gfxSleepMilliseconds(20);
	setpin_reset(g, FALSE);
	gfxSleepMilliseconds(20);

	// Get the bus for the following initialisation commands
	acquire_bus(g);
	
	write_index(g, SSD1963_SOFT_RESET);
	gfxSleepMilliseconds(5);

	/* Driver PLL config */
	write_index(g, SSD1963_SET_PLL_MN);
	write_data(g, 35);								// PLLclk = REFclk (10Mhz) * 36 (360Mhz)
	write_data(g, 2);								// SYSclk = PLLclk / 3  (120MHz)
	write_data(g, 4);								// Apply calculation bit, else it is ignored
	write_reg(g, SSD1963_SET_PLL, 0x01);			// Enable PLL
	gfxSleepMilliseconds(5);
	write_reg(g, SSD1963_SET_PLL, 0x03);			// Use PLL
	gfxSleepMilliseconds(5);
	write_index(g, SSD1963_SOFT_RESET);
	gfxSleepMilliseconds(5);

	/* Screen size */
	write_index(g, SSD1963_SET_GDISP_MODE);
	write_data(g, 0x18);							//Enabled dithering
	write_data(g, 0x00);
	write_data16(g, lcdp->width-1);
	write_data16(g, lcdp->height-1);
	write_data(g, 0x00);							// RGB

	write_reg(g, SSD1963_SET_PIXEL_DATA_INTERFACE, SSD1963_PDI_16BIT565);

	/* LCD Clock specs */
	write_index(g, SSD1963_SET_LSHIFT_FREQ);
	write_data(g, (lcdp->fpr >> 16) & 0xFF);
	write_data(g, (lcdp->fpr >> 8) & 0xFF);
	write_data(g, lcdp->fpr & 0xFF);

	write_index(g, SSD1963_SET_HORI_PERIOD);
	write_data16(g, lcdp->hperiod);
	write_data16(g, lcdp->hpulse + lcdp->hbporch);
	write_data(g, lcdp->hpulse);
	write_data(g, 0x00);
	write_data(g, 0x00);
	write_data(g, 0x00);

	write_index(g, SSD1963_SET_VERT_PERIOD);
	write_data16(g, lcdp->vperiod);
	write_data16(g, lcdp->vpulse + lcdp->vbporch);
	write_data(g, lcdp->vpulse);
	write_data(g, 0x00);
	write_data(g, 0x00);

	/* Tear effect indicator ON. This is used to tell the host MCU when the driver is not refreshing the panel (during front/back porch) */
	write_reg(g, SSD1963_SET_TEAR_ON, 0x00);

	/* Turn on */
	write_index(g, SSD1963_SET_DISPLAY_ON);
	
	/* Turn on the back-light */
	set_backlight(g, GDISP_INITIAL_BACKLIGHT);

	// Finish Init
	post_init_board(g);

	// Release the bus
	release_bus(g);

	/* Initialise the GDISP structure */
	g->g.Width = lcdp->width;
	g->g.Height = lcdp->height;
	g->g.Orientation = GDISP_ROTATE_0;
	g->g.Powermode = powerOn;
	g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
	g->g.Contrast = GDISP_INITIAL_CONTRAST;
	return TRUE;
}