Exemplo n.º 1
0
static void robot_logo(UNUSED_ARG(Bitmap *, bm))
{
	lcd_ili9225_blitBitmap24(0, 0, BMP_THINKING_WIDTH, BMP_THINKING_HEIGHT, bmp_thinking);

	while (!(kbd_peek() & KEY_MASK))
		timer_delay(50);
}
Exemplo n.º 2
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;
	}
}
Exemplo n.º 3
0
Arquivo: kbd.c Projeto: mtarek/BeRTOS
/**
 * Wait for a keypress and return the mask of depressed keys.
 *
 * \note This function is \b not interrupt safe!
 */
keymask_t kbd_get(void)
{
    keymask_t key;

    while (!(key = kbd_peek())) {}

    return key;
}
Exemplo n.º 4
0
static void pushbutton(void)
{
	if (kbd_peek() & K_START)
	{
		PIOA_SODR = LEDR | LEDG | CUTOFF_PIN | LAND_PIN;
		timer_delay(5000);
	}

	PIOA_CODR = LEDR | LEDG | BUZZER_BIT | CUTOFF_PIN | LAND_PIN;
}
Exemplo n.º 5
0
Arquivo: kbd.c Projeto: mtarek/BeRTOS
/**
 * Wait up to \c timeout ms for a keypress
 * and return the mask of depressed keys, or K_TIMEOUT
 * if the timeout was reacked.
 */
keymask_t kbd_get_timeout(mtime_t timeout)
{
    keymask_t key;

    ticks_t start = timer_clock();
    ticks_t stop  = ms_to_ticks(timeout);
    do
    {
        if ((key = kbd_peek()))
            return key;
    }
    while (timer_clock() - start < stop);

    return K_TIMEOUT;
}
Exemplo n.º 6
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;
	}
}
Exemplo n.º 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;
	}
}
Exemplo n.º 8
0
static void res_process(void)
{
	const char spinner[] = {'/', '-', '\\', '|'};
	int i;
	char c;

	for (i = 0; ; i++)
	{
		/* Show context switch (in clock cycles) */
		c = spinner[i % countof(spinner)];
		text_xprintf(&lcd_bitmap, 3, 0, TEXT_CENTER | TEXT_FILL, "%c Context switch %c", c, c);
		text_xprintf(&lcd_bitmap, 5, 0, TEXT_FILL, " %lu clock cycles", end - start);
		/* Show context switch (in usec) */
		text_xprintf(&lcd_bitmap, 6, 0, TEXT_FILL,
			" %lu.%lu usec",
				((end - start) * 1000000) / CPU_FREQ,
				((end - start) * (100000000 / CPU_FREQ)) % 100);
		lcd_ili9225_blitBitmap(&lcd_bitmap);
		timer_delay(5);
		if (kbd_peek() & KEY_MASK)
			break;
	}
}