/** * @} */ void RTC_IRQHandler(void) { static int delay_cnt; struct rtgui_event_command ecmd; /* enter interrupt */ rt_interrupt_enter(); ++rtc_1s_int_cnt; #if 1 == LCD_TEST_MALOOEI rt_kprintf("rtc:%d\n", rtc_1s_int_cnt); #endif if (delay_cnt < 1) { ++delay_cnt; goto ret_entry; } if (NULL == wb_thread) goto ret_entry; if (RTC_GetITStatus(RTC_IT_SEC) != RESET) { RTGUI_EVENT_COMMAND_INIT(&ecmd); ecmd.command_id = UPDATE_SYS_TIME; if (RT_EOK != rtgui_thread_send(wb_thread, &ecmd.parent, sizeof(struct rtgui_event_command))) rt_kprintf("[RTC_IRQHandler]send enent cmd fail\n"); } #if 0 if(RTC_GetFlagStatus(RTC_FLAG_ALR) != RESET) { } else { } #endif ret_entry: RTC_ClearITPendingBit(RTC_IT_ALR | RTC_IT_SEC); /* leave interrupt */ rt_interrupt_leave(); return; }
void update_radio_thread(void* parameter) { rt_err_t result; struct player_request request; /* get request from message queue */ result = rt_mq_recv(update_radio_mq, (void*)&request, sizeof(struct player_request), RT_WAITING_FOREVER); if (result == RT_EOK) { switch (request.type) { case PLAYER_REQUEST_UPDATE_RADIO_LIST: if ((strstr(request.fn, "http://") == request.fn || (strstr(request.fn, "HTTP://") == request.fn ))) { struct rtgui_event_command ecmd; if(update_radio_list(request.fn)==0) { update_radio_list_state = UPDATE_RADIO_LIST_SUCCEED; } else { update_radio_list_state = UPDATE_RADIO_LIST_CONNECT_FAILED; } RTGUI_EVENT_COMMAND_INIT(&ecmd); ecmd.type = RTGUI_EVENT_PAINT; ecmd.command_id = PLAYER_REQUEST_UPDATE_RADIO_LIST; rtgui_thread_send(rt_thread_find("ply_ui"), &ecmd.parent, sizeof(ecmd)); } break; } } rt_mq_delete(update_radio_mq); update_radio_mq = RT_NULL; }
static void calibration_data_post(rt_uint16_t x, rt_uint16_t y) { if (calibration_ptr != RT_NULL) { switch (calibration_ptr->step) { case CALIBRATION_STEP_LEFTTOP: calibration_ptr->data.min_x = x; calibration_ptr->data.min_y = y; break; case CALIBRATION_STEP_RIGHTTOP: calibration_ptr->data.max_x = x; calibration_ptr->data.min_y = (calibration_ptr->data.min_y + y)/2; break; case CALIBRATION_STEP_LEFTBOTTOM: calibration_ptr->data.min_x = (calibration_ptr->data.min_x + x)/2; calibration_ptr->data.max_y = y; break; case CALIBRATION_STEP_RIGHTBOTTOM: calibration_ptr->data.max_x = (calibration_ptr->data.max_x + x)/2; calibration_ptr->data.max_y = (calibration_ptr->data.max_y + y)/2; break; case CALIBRATION_STEP_CENTER: /* calibration done */ { rt_uint16_t w, h; struct rtgui_event_command ecmd; RTGUI_EVENT_COMMAND_INIT(&ecmd); ecmd.command_id = TOUCH_WIN_CLOSE; /* calculate calibrated data */ if (calibration_ptr->data.max_x > calibration_ptr->data.min_x) w = calibration_ptr->data.max_x - calibration_ptr->data.min_x; else w = calibration_ptr->data.min_x - calibration_ptr->data.max_x; w = (w/(calibration_ptr->width - 2 * CALIBRATION_WIDTH)) * CALIBRATION_WIDTH; if (calibration_ptr->data.max_y > calibration_ptr->data.min_y) h = calibration_ptr->data.max_y - calibration_ptr->data.min_y; else h = calibration_ptr->data.min_y - calibration_ptr->data.max_y; h = (h/(calibration_ptr->height - 2 * CALIBRATION_HEIGHT)) * CALIBRATION_HEIGHT; rt_kprintf("w: %d, h: %d\n", w, h); if (calibration_ptr->data.max_x > calibration_ptr->data.min_x) { calibration_ptr->data.min_x -= w; calibration_ptr->data.max_x += w; } else { calibration_ptr->data.min_x += w; calibration_ptr->data.max_x -= w; } if (calibration_ptr->data.max_y > calibration_ptr->data.min_y) { calibration_ptr->data.min_y -= h; calibration_ptr->data.max_y += h; } else { calibration_ptr->data.min_y += h; calibration_ptr->data.max_y -= h; } rt_kprintf("calibration data: (%d, %d), (%d, %d)\n", calibration_ptr->data.min_x, calibration_ptr->data.max_x, calibration_ptr->data.min_y, calibration_ptr->data.max_y); rtgui_thread_send(calibration_ptr->tid, &ecmd.parent, sizeof(struct rtgui_event_command)); } return; } calibration_ptr->step ++; /* post command event */ { struct rtgui_event_command ecmd; RTGUI_EVENT_COMMAND_INIT(&ecmd); ecmd.command_id = TOUCH_WIN_UPDATE; rtgui_thread_send(calibration_ptr->tid, &ecmd.parent, sizeof(struct rtgui_event_command)); } } }
static void calibration_data_post(rt_uint16_t x, rt_uint16_t y) { if (calibration_ptr == RT_NULL) return; switch (calibration_ptr->step) { case CALIBRATION_STEP_LEFTTOP: cal_data->xfb[0] = CALIBRATION_WIDTH; cal_data->yfb[0] = CALIBRATION_HEIGHT; cal_data->x[0] = x; cal_data->y[0] = y; break; case CALIBRATION_STEP_RIGHTTOP: cal_data->xfb[1] = calibration_ptr->width - CALIBRATION_WIDTH; cal_data->yfb[1] = CALIBRATION_HEIGHT; cal_data->x[1] = x; cal_data->y[1] = y; break; case CALIBRATION_STEP_LEFTBOTTOM: cal_data->xfb[3] = CALIBRATION_WIDTH; cal_data->yfb[3] = calibration_ptr->height - CALIBRATION_HEIGHT; cal_data->x[3] = x; cal_data->y[3] = y; break; case CALIBRATION_STEP_RIGHTBOTTOM: cal_data->xfb[2] = calibration_ptr->width - CALIBRATION_WIDTH; cal_data->yfb[2] = calibration_ptr->height - CALIBRATION_HEIGHT; cal_data->x[2] = x; cal_data->y[2] = y; break; case CALIBRATION_STEP_CENTER: /* calibration done */ { rt_uint8_t i; struct rtgui_event_command ecmd; RTGUI_EVENT_COMMAND_INIT(&ecmd); ecmd.wid = calibration_ptr->win; ecmd.command_id = TOUCH_WIN_CLOSE; cal_data->xfb[4] = (calibration_ptr->width >> 1); cal_data->yfb[4] = (calibration_ptr->height >> 1); cal_data->x[4] = x; cal_data->y[4] = y; for (i = 0; i < 5; i++) { rt_kprintf("xfb[%d]:%d,yfb[%d]:%d,x[%d]:%d,y[%d]:%d\r\n", i, cal_data->xfb[i], i, cal_data->yfb[i], i, cal_data->x[i], i, cal_data->y[i]); } perform_calibration(cal_data); rtgui_send(calibration_ptr->app, &ecmd.parent, sizeof(struct rtgui_event_command)); } calibration_ptr->step = 0; return; } calibration_ptr->step++; /* post command event */ { struct rtgui_event_command ecmd; RTGUI_EVENT_COMMAND_INIT(&ecmd); ecmd.wid = calibration_ptr->win; ecmd.command_id = TOUCH_WIN_UPDATE; rtgui_send(calibration_ptr->app, &ecmd.parent, sizeof(struct rtgui_event_command)); } }