예제 #1
0
void schedule_application() {
    unsigned long now = rtc_get_time();

    if (now < 1445990399) {
        // day 1

    } else if (now > 1445990399 && now < 1446076799) {
        // day 2

    } else if (now > 1446076799 && now < 1446163199) {
        // day 3

    } else {
        // day 4

    }

    uint16_t max_event[] = {5, 26, 25, 18, 26, 13};
    
    
    //write_data();
	//gfx_draw_filled_rect(0, 0, gfx_get_width(), gfx_get_height(), GFX_COLOR_BLACK);
    draw_background();
    //gfx_draw_filled_rect(0, 0, 320, 182, GFX_COLOR(20, 20, 20));

    draw_time();
    // gfx_draw_string_aligned("Schedule - Keynotes",    11, 2, &sysfont, GFX_COLOR_BLACK, GFX_COLOR_WHITE, TEXT_POS_LEFT, TEXT_ALIGN_LEFT);
    // gfx_draw_string_aligned("Schedule - Track 1",    11, 2, &sysfont, GFX_COLOR_BLACK, GFX_COLOR_WHITE, TEXT_POS_LEFT, TEXT_ALIGN_LEFT);
    // gfx_draw_string_aligned("Schedule - Track 2",    11, 2, &sysfont, GFX_COLOR_BLACK, GFX_COLOR_WHITE, TEXT_POS_LEFT, TEXT_ALIGN_LEFT);
    // gfx_draw_string_aligned("Schedule - Track 3",    11, 2, &sysfont, GFX_COLOR_BLACK, GFX_COLOR_WHITE, TEXT_POS_LEFT, TEXT_ALIGN_LEFT);
    // gfx_draw_string_aligned("Schedule - Track 4",    11, 2, &sysfont, GFX_COLOR_BLACK, GFX_COLOR_WHITE, TEXT_POS_LEFT, TEXT_ALIGN_LEFT);






   
    event_index = 0;
    event_track = 0;
    

    draw_event();



    // Presentors
    // Location and time
    // Description

	struct keyboard_event input;
    while(mma8451_orientation() != 6) {
        esp8266_check_buffer();

        keyboard_get_key_state(&input);
        if (input.type == KEYBOARD_RELEASE) {
            if (input.keycode == KEYBOARD_B) {
                break;
            } else if (input.keycode == KEYBOARD_A) {
               
            } else if (input.keycode == KEYBOARD_UP) {
               event_index--;
               if (event_index < 0) {
                    event_index = 0;
               }
               draw_event();
            } else if (input.keycode == KEYBOARD_DOWN) {
               event_index++;
               if (event_index > max_event[event_track]) {
                    event_index = max_event[event_track];
               }
               draw_event();
            } else if (input.keycode == KEYBOARD_RIGHT) {
               event_index = 0;
               event_track++;
               if (event_track > 5) {
                    event_track = 0;
               }
               draw_event();
            } else if (input.keycode == KEYBOARD_LEFT) {
               event_index = 0;
               event_track--;
                if (event_track < 0) {
                    event_track = 5;
               }
               draw_event();
            }
        }
        if(mma8451_clear_interrupt() && is_low_power()) {
            exit_low_power();
        }
    }
}
예제 #2
0
static void event_loop(void)
{
	for (;;) {
		GP_BackendWait(backend);

		while (GP_BackendEventsQueued(backend)) {
			GP_Event ev;

			GP_BackendGetEvent(backend, &ev);
			GP_EventDump(&ev);

			switch (ev.type) {
			case GP_EV_KEY:
				draw_event(&ev);

				switch (ev.val.key.key) {
				case GP_KEY_ESC:
					GP_BackendExit(backend);
					exit(0);
				break;
				case GP_BTN_LEFT:
					GP_HLineXXY(win, ev.cursor_x - 3,
					            ev.cursor_x + 3,
						    ev.cursor_y, red);
					GP_VLineXYY(win, ev.cursor_x,
					            ev.cursor_y - 3,
						    ev.cursor_y + 3, red);
					GP_BackendFlip(backend);
				break;
				default:
				break;
				}
			break;
			case GP_EV_REL:
				switch (ev.code) {
				static int size = 0;
				case GP_EV_REL_POS:
					if (GP_EventGetKey(&ev, GP_BTN_LEFT)) {
						GP_PutPixel(win, ev.cursor_x,
						            ev.cursor_y, green);
					}
					int align = GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM;

					GP_TextClear(win, NULL, 20, 40, align,
					             black, size);
					size = GP_Print(win, NULL, 20, 40, align,
					                white, black, "X=%3u Y=%3u dX=%3i dY=%3i",
						        ev.cursor_x, ev.cursor_y,
							ev.val.rel.rx, ev.val.rel.ry);
					GP_BackendFlip(backend);
				break;
				}
			break;
			case GP_EV_SYS:
				switch (ev.code) {
				case GP_EV_SYS_RESIZE:
					GP_BackendResizeAck(backend);
				break;
				case GP_EV_SYS_QUIT:
					GP_BackendExit(backend);
					exit(0);
				break;
				}
			break;
			}
		}
	}
}