Example #1
0
void drawDraw()
{
	int i, j;
	WORD* p = FrameBuffer - 8;
	for (i = 0; i < LCD_MAIN_H; i++)
	{
		for (j = 0; j < 8; j++)
		{
			*p++ = 0;
		}
		p += LCD_MAIN_W;
		for (j = 0; j < 8; j++)
		{
			*p++ = 0;
		}
		p += SCREEN_WIDTH - LCD_MAIN_W - 16;
	}
	__dcache_writeback_all();
	_lcd_set_frame();
	lcd_flip();
	FrameBuffer = _lcd_get_frame() + SCREN_OFFSET;
}
Example #2
0
/*
 * This is the code for the simple DMA2D Demo
 *
 * Basically it lets you put display digits on the
 * screen manually or with the DMA2D peripheral. It
 * has various 'bling' levels, and it tracks performance
 * by measuring how long it takes to go from one frame
 * to the next.
 */
int
main(void) {
	int	i;
	uint32_t t1, t0;
	char buf[35];
	char *scr_opt;
	int f_ndx = 0;
	float avg_frame;
	int	can_switch;
	int	opt, ds;

	/* Enable the clock to the DMA2D device */
	rcc_periph_clock_enable(RCC_DMA2D);
	fprintf(stderr, "DMA2D Demo program : Digits Gone Wild\n");
	printf("Generate background\n");
	generate_background();
	printf("Generate digits\n");
	generate_digits();

	gfx_init(lcd_draw_pixel, 800, 480, GFX_FONT_LARGE);
	opt = 0; /* screen clearing mode */
	can_switch = 0; /* auto switching every 10 seconds */
	t0 = mtime();
	ds = 0;
	while (1) {
		switch (opt) {
		default:
		case 0:
			/* very slow way to clear the screen */
			scr_opt = "manual clear";
			gfx_fillScreen(0xffff);
			break;
		case 1:
			/* faster, using a tight loop */
			scr_opt = "dedicated loop";
			lcd_clear(0xff7f7f);
			break;
		case 2:
			/* fastest? Using DMA2D to fill screen */
			scr_opt = "DMA 2D Fill";
			dma2d_fill(0xff7fff7f);
			break;
		case 3:
			/* still fast, using DMA2D to pre-populate BG */
			scr_opt = "DMA 2D Background";
			dma2d_bgfill();
			break;
		case 4:
			/* Now render all of the digits with DMA2D */
			scr_opt = "DMA 2D Digits";
			ds = 0;
			dma2d_bgfill();
			break;
		case 5:
			/* still fast, using DMA2D to render drop shadows */
			scr_opt = "DMA 2D Shadowed Digits";
			ds = 1;
			dma2d_bgfill();
			break;
		}

		/* This little state machine implements an automatic switch
		 * every 10 seconds unless you've disabled it with the 'd'
		 * command.
		 */
		if (((t0 / 1000) % 10 == 0) && (can_switch > 0)) {
			opt = (opt + 1) % MAX_OPTS;
			can_switch = 0;
		} else  if (((t0 / 1000) % 10 != 0) && (can_switch == 0)) {
			can_switch = 1;
		}

		/*
		 * The first four options (0, 1, 2, 3) all render the digits
		 * in software every time, options 4 and 5 use the DMA2
		 * device to render the digits
		 */
		if (opt < 4) {
			display_clock(25, 20, mtime());
		} else {
			dma2d_clock(25, 20, mtime(), ds);
		}
		for (i = 0; i < 10; i++) {
			if (opt < 4) {
				draw_digit(25 + i * (DISP_WIDTH + 8), 350, i, GFX_COLOR_GREEN, GFX_COLOR_BLACK);
			} else {
				if (ds) {
					dma2d_digit(35 + i * (DISP_WIDTH + 8), 360, i, SHADOW, SHADOW);
				}
				dma2d_digit(25 + i * (DISP_WIDTH + 8), 350, i, 0xff40c040, 0xff000000);
			}
		}

		/* In both cases we write the notes using the graphics library */
		gfx_setTextColor(0, 0);
		gfx_setTextSize(3);
		gfx_setCursor(25, 30 + DISP_HEIGHT + gfx_getTextHeight() + 2);
		gfx_puts((unsigned char *)"Hello world for DMA2D!");
		lcd_flip(te_lock);
		t1 = mtime();

		/* this computes a running average of the last 10 frames */
		frame_times[f_ndx] = t1 - t0;
		f_ndx = (f_ndx + 1) % N_FRAMES;
		for (i = 0, avg_frame = 0; i < N_FRAMES; i++) {
			avg_frame += frame_times[i];
		}
		avg_frame = avg_frame / (float) N_FRAMES;
		snprintf(buf, 35, "FPS: %6.2f", 1000.0 / avg_frame);
		gfx_setCursor(25, 30 + DISP_HEIGHT + 2 * (gfx_getTextHeight() + 2));
		gfx_puts((unsigned char *)buf);
		gfx_puts((unsigned char *)" ");
		gfx_setCursor(25, 30 + DISP_HEIGHT + 3 * (gfx_getTextHeight() + 2));
		gfx_puts((unsigned char *)scr_opt);
		/*
		 * The demo runs continuously but it watches for characters
		 * typed at the console. There are a few options you can select.
		 */
		i = console_getc(0);
		switch (i) {
		case 's':
			opt = (opt + 1) % MAX_OPTS;
			printf("Switched to : %s\n", demo_options[opt]);
			break;
		case 'd':
			can_switch = -1;
			printf("Auto switching disabled\n");
			break;
		case 'e':
			can_switch = 0;
			printf("Auto switching enabled\n");
			break;
		case 't':
			te_lock = (te_lock == 0);
			printf("We are %s for the TE bit to be set\n", (te_lock) ? "WAITING" : "NOT WAITING");
			break;
		default:
			printf("Options:\n");
			printf("\ts - switch demo mode\n");
			printf("\td - disable auto-switching of demo mode\n");
			printf("\te - enable auto-switching of demo mode\n");
			printf("\tt - enable/disable Tearing effect lock wait\n");
		case 0:
			break;
		}
		t0 = t1;
	}
}
Example #3
0
void lcd_update24( void )
{
	lcd_flip();
}
Example #4
0
void lcd_updateui( void )
{
	lcd_flip();
}
Example #5
0
void display_flip() {
	lcd_flip();
	__dcache_writeback_all();
	_lcd_set_frame();
}