Ejemplo n.º 1
0
/* Prepares the first frame of animation */
static void draw_first_frame(void) {
    VMUINT8* img_data;
    VMUINT32 img_size;
    vm_graphic_color_argb_t color;

    /* draw background image */
    //img_data = vm_res_get_image(IMG_ID_BG, &img_size);
    //vm_graphic_draw_image_memory(g_frame_group[0], 0, 0, img_data, img_size, 0);

    /* draw a purple horizontal blue line from center of screen */
    color.a = 255;
    color.r = 0;
    color.g = 0;
    color.b = 255;
    vm_graphic_set_color(color);
    vm_graphic_draw_solid_rectangle(&g_temp_frame, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    color.r = 255;
    vm_graphic_set_color(color);
    vm_graphic_draw_line(&g_temp_frame, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, SCREEN_WIDTH / 2 + LINE_LENGTH - 1, SCREEN_HEIGHT / 2);

    /* create animation timer */
    g_timer_id = vm_timer_create_precise(100, timer_callback, NULL);
    theta = 0;

    /* explicitly trigger 1st frame */
    timer_callback(g_timer_id, NULL);
}
Ejemplo n.º 2
0
int timer_create(lua_State *L)
{
    timer_info_t *p;
    int ref;
    unsigned interval = luaL_checkinteger(L, 1);

    if (hisr_id == NULL) {
    	hisr_id = vm_timer_create_hisr("HISR_TIMER");
    	if(hisr_id != NULL) {
    	        vm_timer_set_hisr(hisr_id, customer_hisr_timer_proc, 0, 10, 10);
    	    }
   	    else {
   	    	vm_log_debug("create hisr timer fail");
   	    }
    }
    lua_pushvalue(L, 2);

    ref = luaL_ref(L, LUA_REGISTRYINDEX);

    p = (timer_info_t *)lua_newuserdata(L, sizeof(timer_info_t));

    luaL_getmetatable(L, LUA_TIMER);
    lua_setmetatable(L, -2);

    p->L = L;
    p->cb_ref = ref;
    p->timer_id = vm_timer_create_precise(interval, __timer_callback, p);

    return 1;
}
Ejemplo n.º 3
0
int timer_create(lua_State *L)
{
    timer_info_t *p;
    int ref;
    unsigned interval = luaL_checkinteger(L, 1);

    lua_pushvalue(L, 2);

    ref = luaL_ref(L, LUA_REGISTRYINDEX);

    p = (timer_info_t *)lua_newuserdata(L, sizeof(timer_info_t));

    luaL_getmetatable(L, LUA_TIMER);
    lua_setmetatable(L, -2);

    p->L = L;
    p->cb_ref = ref;
    p->timer_id = vm_timer_create_precise(interval, __timer_callback, p);

    return 1;
}