Example #1
0
static void bouncing_logo(Bitmap *bm)
{
	const long SPEED_SCALE = 1000;
	const long GRAVITY_ACCEL = 100;
	const long BOUNCE_ELASTICITY = 1;
	long h = (long)(-bertos_logo.height) * SPEED_SCALE;
	long speed = 0, i;

	for (i = 0; ; i++)
	{
		/* Move */
		h += speed;

		/* Gravity acceleration */
		speed += GRAVITY_ACCEL;

		if (h > 0 && speed > 0)
		{
			/* Bounce */
			speed = -(speed / BOUNCE_ELASTICITY);

		}
		/* Update graphics */
		gfx_bitmapClear(bm);
		gfx_blitImage(bm,
			(LCD_WIDTH - bertos_logo.width) / 2,
			(LCD_HEIGHT - bertos_logo.height) / 2 + h / SPEED_SCALE,
			&bertos_logo);
		text_xprintf(bm, 13, 0, TEXT_FILL | TEXT_CENTER, "Press any key to quit");
		lcd_ili9225_blitBitmap(bm);
		timer_delay(15);
		if (kbd_peek() & KEY_MASK)
			break;
	}
}
Example #2
0
/*extern "C"*/ void lcd_gfx_qt_init(Bitmap *lcd_bitmap)
{
	//FIXME INIT_WALL(wall_before_raster);
	//FIXME INIT_WALL(wall_after_raster);
	gfx_bitmapInit(lcd_bitmap, lcd_raster, EmulLCD::WIDTH, EmulLCD::HEIGHT);
	gfx_bitmapClear(lcd_bitmap);
}
int main(int argc, char *argv[])
{
	emul_init(&argc, argv);
	lcd_init();

	coord_t x = 0, y = LCD_WIDTH / 2;
	coord_t xdir = +1, ydir = -1;
	Bitmap *bm = &lcd_bitmap;

	for(;;)
	{
		gfx_bitmapClear(bm);
		gfx_setClipRect(bm, 0, 0, bm->width, bm->height);
		gfx_rectDraw(bm, 10, 10, bm->width-10, bm->height-10);
		gfx_setClipRect(bm, 11, 11, bm->width-11, bm->height-11);
		magic(bm, x, y);

		x += xdir;
		y += ydir;
		if (x >= bm->width)  xdir = -1;
		if (x <= -50)        xdir = +1;
		if (y >= bm->height) ydir = -1;
		if (y <= -50)        ydir = +1;

		lcd_blit_bitmap(bm);
		emul_idle();
		usleep(10000);
	}

	emul_cleanup();
	return 0;
}
Example #4
0
static void context_switch_test(Bitmap *bm)
{
	const Font *old_font = bm->font;
	gfx_setFont(&lcd_bitmap, &font_gohu);

	gfx_bitmapClear(bm);
	text_xprintf(bm, 0, 0, TEXT_FILL,
			"CPU: Cortex-M3 %luMHz", CPU_FREQ / 1000000);
	text_xprintf(bm, 1, 0, TEXT_FILL, "Board: SAM3N-EK EVB");

	res_process();

	gfx_setFont(&lcd_bitmap, old_font);
}
Example #5
0
static void uptime(Bitmap *bm)
{
	gfx_bitmapClear(bm);
	text_xprintf(bm, 0, 0, TEXT_FILL | TEXT_CENTER, "Uptime");
	while (1)
	{
		ticks_t clock = ticks_to_ms(timer_clock_unlocked());

		/* Display uptime (in ticks) */
		text_xprintf(&lcd_bitmap, 2, 0, TEXT_FILL | TEXT_CENTER,
				"seconds: %lu", clock / 1000);
		lcd_ili9225_blitBitmap(bm);
		timer_delay(5);
		if (kbd_peek() & KEY_MASK)
			break;
	}
}
Example #6
0
static void NORETURN soft_reset(Bitmap * bm)
{
	int i;

	gfx_bitmapClear(bm);
	for (i = 5; i; --i)
	{
		text_xprintf(bm, 2, 0, TEXT_FILL | TEXT_CENTER, "%d", i);
		lcd_ili9225_blitBitmap(bm);
		timer_delay(1000);
	}
	text_xprintf(bm, 2, 0, TEXT_FILL | TEXT_CENTER, "REBOOT");
	lcd_ili9225_blitBitmap(bm);
	timer_delay(1000);

	/* Perform a software reset request */
	HWREG(NVIC_APINT) = NVIC_APINT_VECTKEY | NVIC_APINT_SYSRESETREQ;
	UNREACHABLE();
}
Example #7
0
static void screen_saver(Bitmap *bm)
{
	int x1, y1, x2, y2;
	int i;

	for (i = 0; ; i++)
	{
		x1 = i % LCD_WIDTH;
		y1 = i % LCD_HEIGHT;

		x2 = LCD_WIDTH - i % LCD_WIDTH;
		y2 = LCD_HEIGHT - i % LCD_HEIGHT;

		gfx_bitmapClear(bm);
		gfx_rectDraw(bm, x1, y1, x2, y2);
		lcd_ili9225_blitBitmap(bm);
		if (kbd_peek() & KEY_MASK)
			break;
	}
}
Example #8
0
/*
 * Lcd
 */
static void setBrightness(Bitmap *bm)
{
	while (1)
	{
		gfx_bitmapClear(bm);
		text_xprintf(bm, 1, 0, TEXT_FILL | TEXT_CENTER, "Brightness: %d", lcd_brightness);
		text_xprintf(bm, 3, 0, TEXT_FILL | TEXT_CENTER, "RIGHT key: change");
		text_xprintf(bm, 4, 0, TEXT_FILL | TEXT_CENTER, "LEFT  key: back  ");
		lcd_ili9225_blitBitmap(bm);

		keymask_t mask = kbd_get();

		if (mask & K_LEFT)
			break;
		else if (mask & K_RIGHT)
		{
			if (++lcd_brightness > LCD_BACKLIGHT_MAX)
				lcd_brightness = 0;
			lcd_setBacklight(lcd_brightness);
		}
	}
}