Exemple #1
0
/*---------------------------------------------------------------------------*/
static void *alsps_update_iv_thread(void *priv)
{
    struct lps_data *dat = (struct lps_data *)priv; 
    struct lps_priv *lps = &dat->lps;
    struct itemview *iv = dat->iv;    
    int err = 0, len = 0;
    char *status;

    LOGD(TAG "%s: Start\n", __FUNCTION__);
    if ((err = alsps_open(lps))) {
    	memset(dat->info, 0x00, sizeof(dat->info));
        sprintf(dat->info, uistr_info_sensor_init_fail);
        iv->redraw(iv);
        FLPLOGE("alsps() err = %d(%s)\n", err, dat->info);
        pthread_exit(NULL);
        return NULL;
    }
        
    while (1) {
        
        if (dat->exit_thd)
            break;
            
        if ((err = alsps_update_info(lps)))
            continue;     

        len = 0;
        len += snprintf(dat->info+len, sizeof(dat->info)-len, "ALS: %4Xh (0:dark; +:bright) \n", lps->als_raw);      
        len += snprintf(dat->info+len, sizeof(dat->info)-len, "PS : %4Xh (0:far ; +:close) \n", lps->ps_raw);
	if(lps->ps_threshold_high == 0){
	len += snprintf(dat->info+len, sizeof(dat->info)-len, "%s: %s\n", uistr_info_sensor_alsps_thres_high, uistr_info_sensor_alsps_check_command);//yucong add for factory mode test support
	}else{
	len += snprintf(dat->info+len, sizeof(dat->info)-len, "%s: %4Xh\n", uistr_info_sensor_alsps_thres_high, lps->ps_threshold_high);	
	}
	if(lps->ps_threshold_low == 0){
	len += snprintf(dat->info+len, sizeof(dat->info)-len, "%s: %s\n", uistr_info_sensor_alsps_thres_low, uistr_info_sensor_alsps_check_command);//yucong add for factory mode test support
	}else{
	len += snprintf(dat->info+len, sizeof(dat->info)-len, "%s: %4Xh\n", uistr_info_sensor_alsps_thres_low, lps->ps_threshold_low);	
	}
	if(lps->ps_threshold_value == 2){
	len += snprintf(dat->info+len, sizeof(dat->info)-len, "%s: %s\n", uistr_info_sensor_alsps_result, uistr_info_sensor_alsps_check_command);//yucong add for factory mode test support
	}else{
	len += snprintf(dat->info+len, sizeof(dat->info)-len, "%s: %s\n", uistr_info_sensor_alsps_result, (lps->ps_threshold_value == 1)?uistr_info_sensor_pass:uistr_info_sensor_fail	);//yucong add for factory mode test support
	}
        iv->set_text(iv, &dat->text);
        iv->redraw(iv);
        pthread_mutex_lock (&alsps_mutex);
        if(support_ata)
        { 
            thread_exit = true;  
            pthread_mutex_unlock (&alsps_mutex);
            break;
        }
        pthread_mutex_unlock (&alsps_mutex);
    }
    alsps_close(lps);
    LOGD(TAG "%s: Exit\n", __FUNCTION__);    
    pthread_exit(NULL);    
    return NULL;
}
/*---------------------------------------------------------------------------*/
static void *alsps_update_iv_thread(void *priv)
{
    struct lps_data *dat = (struct lps_data *)priv; 
    struct lps_priv *lps = &dat->lps;
    struct itemview *iv = dat->iv;    
    int err = 0, len = 0;
    char *status;

    LOGD(TAG "%s: Start\n", __FUNCTION__);
    if ((err = alsps_open(lps))) {
    	memset(dat->info, 0x00, sizeof(dat->info));
        sprintf(dat->info, "INIT FAILED\n");
        iv->redraw(iv);
        FLPLOGE("alsps() err = %d(%s)\n", err, dat->info);
        pthread_exit(NULL);
        return NULL;
    }
        
    while (1) {
        
        if (dat->exit_thd)
            break;
            
        if ((err = alsps_update_info(lps)))
            continue;     

        len = 0;
        len += snprintf(dat->info+len, sizeof(dat->info)-len, "ALS: %4Xh (0:dark; +:bright)\n", lps->als_raw);      
        len += snprintf(dat->info+len, sizeof(dat->info)-len, "PS : %4Xh (0:far ; +:close)\n", lps->ps_raw);
        iv->set_text(iv, &dat->text);
        iv->redraw(iv);
    }
    alsps_close(lps);
    LOGD(TAG "%s: Exit\n", __FUNCTION__);    
    pthread_exit(NULL);    
    return NULL;
}
Exemple #3
0
/*---------------------------------------------------------------------------*/
static void *ps_update_iv_thread(void *priv)
{
    struct lps_data *dat = (struct lps_data *)priv;
    struct lps_priv *lps = &dat->lps;
    struct itemview *iv = dat->iv;
    int err = 0, len = 0;
    char *status;
    static int op = -1;
	unsigned int cleardata = 0;
    FLPLOGD(TAG "%s: Start\n", __FUNCTION__);
    if ((err = alsps_open(lps))) {
		memset(dat->info, 0x00, sizeof(dat->info));
        sprintf(dat->info, "INIT FAILED\n");
        iv->redraw(iv);
        FLPLOGE("alsps() err = %d(%s)\n", err, dat->info);
        pthread_exit(NULL);
        return NULL;
    }

    while (1) {
        if (dat->exit_thd)
            break;

	pthread_mutex_lock(&dat->lps.evtmutex);
	if(op != dat->lps.pending_op)
	{
		op = dat->lps.pending_op;
		FLPLOGD("op: %d\n", dat->lps.pending_op);
	}
	pthread_mutex_unlock(&dat->lps.evtmutex);

	err = 0;
	if(op == PS_OP_CLEAR){
	//TODO     Clear Part
		if(read_write(&cleardata)==0){
			//snprintf(dat->lps.status, sizeof(dat->lps.status), "清除成功!\n");
			snprintf(dat->lps.status, sizeof(dat->lps.status), "clear successful!\n");
		}

             bUpToDate = false; 
		pthread_mutex_lock(&dat->lps.evtmutex);
		dat->lps.pending_op = PS_OP_NONE;
		pthread_mutex_unlock(&dat->lps.evtmutex);
	}
	else if(op == PS_OP_CALI_PRE){
		//snprintf(dat->lps.status, sizeof(dat->lps.status), "执行校准中,请勿触碰!\n");
		snprintf(dat->lps.status, sizeof(dat->lps.status), "cali ongoing,don't touch!\n");
		pthread_mutex_lock(&dat->lps.evtmutex);
		dat->lps.pending_op = PS_OP_CALI;
		dat->lps.cali_delay= 50; //50ms
		dat->lps.cali_num = 20;
		pthread_mutex_unlock(&dat->lps.evtmutex);
	}
	else if(op == PS_OP_CALI){
		//TODO Calibration Part
		unsigned int value=do_ps_cali(&(dat->lps));

		if(0 == read_write(&value)){
			//len = snprintf(dat->lps.status, sizeof(dat->lps.status), "校准: 成功! 偏移寄存器设置为:%d\n",value);
			len = snprintf(dat->lps.status, sizeof(dat->lps.status), "cali successful! the offset_data is:%d\n",value);
			dat->mod->test_result = FTM_TEST_PASS;
		}
		else{
			//len = snprintf(dat->lps.status, sizeof(dat->lps.status), "校准: 失败!\n");
			len = snprintf(dat->lps.status, sizeof(dat->lps.status), "cali: fail!\n");
			dat->mod->test_result = FTM_TEST_FAIL;
		}
              bUpToDate = false;
		pthread_mutex_lock(&dat->lps.evtmutex);
		dat->lps.pending_op = PS_OP_NONE;
		pthread_mutex_unlock(&dat->lps.evtmutex);
	}


        if ((err = alsps_update_info(lps)))
            continue;

        len = 0;
	//Remove ALS part
        //len += snprintf(dat->info+len, sizeof(dat->info)-len, "ALS: %4Xh (0:dark; +:bright)\n", lps->als_raw);
        len += snprintf(dat->info+len, sizeof(dat->info)-len, "distance: %4d(0: faraway; +: close)\n", lps->ps_raw);
	len += snprintf(dat->info+len, sizeof(dat->info)-len, "%s", lps->status);

        iv->set_text(iv, &dat->text);
        iv->redraw(iv);
    }

    alsps_close(lps);
    FLPLOGD(TAG "%s: Exit\n", __FUNCTION__);
    pthread_exit(NULL);
    return NULL;
}