Exemple #1
0
void fbcon_setup(struct fbcon_config *_config)
{
	uint32_t bg;
	uint32_t fg;

	ASSERT(_config);

	config = _config;

	switch (config->format) {
	case FB_FORMAT_RGB565:
		fg = RGB565_WHITE;
		bg = RGB565_BLACK;
		break;
        case FB_FORMAT_RGB888:
                fg = RGB888_WHITE;
                bg = RGB888_BLACK;
                break;
	default:
		dprintf(CRITICAL, "unknown framebuffer pixel format\n");
		ASSERT(0);
		break;
	}

#if DISPLAY_TYPE_TOUCHPAD
	fbcon_set_colors(0, 0, 0, 0, 0, 255);
#else
	fbcon_set_colors(bg, fg);
#endif

	cur_pos.x = 0;
	cur_pos.y = 0;
#if DISPLAY_TYPE_TOUCHPAD
	max_pos.x = config->width - FONT_WIDTH;
	max_pos.y = config->height - FONT_HEIGHT;
#else
	max_pos.x = config->width / (FONT_WIDTH+1);
	max_pos.y = (config->height - 1) / FONT_HEIGHT;
#endif
#if !DISPLAY_SPLASH_SCREEN
	fbcon_clear();
#endif
}
Exemple #2
0
void init_ui(void)
{
	ui_clear_all();

	/* config fb console, it has been set up in display_init() */
	fbcon_set_colors(FBCON_BACKGROUND, FBCON_FOREGROUND);
	fbcon_set_top_margin(MENU_MAX_HEIGHT);
	fbcon_set_bottom_margin(0);
	fbcon_reset();

	/* init the menu */
	ui_menu_init();

	/* start keypad listener */
	ui_key_listener_start();

	dprintf(INFO, "init_ui()\n");
}
Exemple #3
0
int moboot_menu(unsigned x, unsigned y, char **entries, unsigned init, unsigned total, unsigned timeout)
{
	unsigned curpos, i, max, keys, is_pressed, has_timeout, countdown;
	time_t tick;

	max = total - 1;
	curpos = init;

	if (timeout) {
		has_timeout = 1;
		countdown = timeout;
		tick = current_time() + 1000;
	} else {
		has_timeout = 0;
	}

	while (1) {
		for (i = 0; i < total; i++) {
			if (i == curpos) {
				fbcon_set_colors(0, 0, 255, 0, 0, 0);
			} else {
				fbcon_set_colors(0, 0, 0, 0, 0, 255);
			}
			fbcon_setpos(x, y + i);
			printf("%s", entries[i]);
		}
		fbcon_set_colors(0, 0, 0, 0, 0, 255);
		is_pressed = gpiokeys_poll(KEY_ALL);
		while (1) {
			if (has_timeout) {
				if (current_time() > tick) {
					tick += 1000;
					countdown--;
					if (!countdown) {
						return curpos;
					}
				}
				fbcon_setpos(x, y + total + 1);
				printf("timeout in %d     ", countdown);
			}
			thread_sleep(20);
			keys = gpiokeys_poll(KEY_ALL);
			if (has_timeout && keys) {
				fbcon_setpos(x, y + total + 1);
				printf("                         ");
				has_timeout = 0;
			}
			if (is_pressed && !keys) {
				if (is_pressed & KEY_SELECT) {
					return curpos;
				}
				if (is_pressed & KEY_UP) {
					if (curpos == 0) {
						curpos = max;
					} else {
						curpos--;
					}
				}
				if (is_pressed & KEY_DOWN) {
					if (curpos == max) {
						curpos = 0;
					} else {
						curpos++;
					}
				}
				break;
			} else if (keys) {
				is_pressed = keys;
			}
		}
	}
}