Beispiel #1
0
void draw_same(void) {
  redraw_same = 1;
  draw_continue();
  draw_next();
}
Beispiel #2
0
int main (void)
{
	unsigned pagenum = 0, backlight, contrast = 0x3f;
	unsigned left_pressed = 0, right_pressed = 0;
	unsigned up_pressed = 0, down_pressed = 0;
	extern const gpanel_font_t font_fixed6x8;

        led_init();
	joystick_init ();
	gpanel_init (&display, &font_fixed6x8);

	draw (pagenum);
        backlight = 1;
        gpanel_backlight (&display, backlight);

	/*
	 * Poll buttons.
	 */
	for (;;) {
		mdelay (20);
		draw_next (pagenum);

                int key = joystick_get();

                /* Light LED when a key is pressed. */
		if (key > JOYSTICK_IDLE)
		    led_control (1);
                else
		    led_control (0);

		if (key != JOYSTICK_LEFT)
			left_pressed = 0;
		else if (! left_pressed) {
			/* Left button: show previous page of symbols. */
			left_pressed = 1;
			pagenum = (pagenum - 1 + NPAGES) % NPAGES;
			draw (pagenum);
		}

		if (key != JOYSTICK_RIGHT)
			right_pressed = 0;
		else if (! right_pressed) {
			/* Right button: show next page of symbols. */
			right_pressed = 1;
			pagenum = (pagenum + 1) % NPAGES;
			draw (pagenum);
		}

		if (key != JOYSTICK_DOWN)
			down_pressed = 0;
		else if (! down_pressed) {
			/* Down button: switch backlight. */
			down_pressed = 1;
                        backlight = !backlight;
                        gpanel_backlight (&display, backlight);
		}

		if (key != JOYSTICK_UP)
			up_pressed = 0;
		else if (! up_pressed) {
			/* Up button: contrast control. */
			up_pressed = 1;
                        contrast++;
                        if (contrast >= 127)
                            contrast = 0;
                        gpanel_contrast (&display, contrast);
                        gpanel_move (&display, 0, 0);
                        printf (&display, "Vop = %-8u\n", contrast);
		}
	}
}