Ejemplo n.º 1
0
int nest_wait_pull_out(void)
{
    int light, err;
    time_t timer_restart = time_get(1000 * 60 * 3);

    err = nest_error_get() -> type;
    light = (nest_pass()) ? PASS_CMPLT_ON : FAIL_ABORT_ON;
    nest_light(light);

#if CONFIG_NEST_LOG_SIZE > 0
    //save the log message to flash
    if(nest_fail())
        nvm_save();
#endif

    while(! cncb_detect(0)) {
        nest_light_flash(err);
#ifdef CONFIG_NEST_AUTORESTART
        if(time_left(timer_restart) < 0) {
            if(nest_pass())
                break;
        }
#endif
    }

    nest_light(ALL_OFF);
    return 0;
}
static int8_t parse_save_nvm_params()
{
	nvm_data.direction_null_value = get_direction_null_value();
	nvm_data.motor_timeout = get_motor_timeout();
	if (ERR_NONE == nvm_save())
	{
		send_response_P(PSTR(":OK\n"));
		return ERR_NONE;
	}
	else
	{
		send_response_P(PSTR(":ERR EXEC\n"));
		return ERR_EXEC;
	}
}
Ejemplo n.º 3
0
Archivo: nvm.c Proyecto: miaofng/ulp
int cmd_nvm_func(int argc, char *argv[])
{
	const char *usage = {
		"nvm save	.nvm.ram -> .nvm.rom\n"
		"nvm clear	.nvm.rom = 0xff\n"
	};

	if((argc == 2) && (!strncmp("save", argv[1], 2))) {
		nvm_save();
		return 0;
	}

	if((argc == 2) && (!strncmp("clear", argv[1], 2))) {
		nvm_clear();
		return 0;
	}

	printf("%s", usage);
	return 0;
}
Ejemplo n.º 4
0
Archivo: dlg.c Proyecto: miaofng/ulp
static int dlg_ChangeAutoSteps(const osd_command_t *cmd)
{
	int result = -1;
	int steps = sm_GetAutoSteps();
	
	switch(cmd->event){
	case KEY_LEFT:
		steps --;
		result = sm_SetAutoSteps(steps);
		key_SetKeyScenario(DELAY_MS, REPEAT_MS);
		break;
	case KEY_RIGHT:
		steps ++;
		result = sm_SetAutoSteps(steps);
		key_SetKeyScenario(DELAY_MS, REPEAT_MS);
		break;
	case KEY_RESET:
	case KEY_MENU:
		/*get config from flash*/
		nvm_init();
		steps = sm_GetAutoSteps();
		result = sm_SetAutoSteps(steps);
		break;
	case KEY_ENTER:
	case KEY_OSD:
		/*store config to flash*/
		nvm_save();
		break;
	default:
		steps = key_SetEntryAndGetDigit();
		result = sm_SetAutoSteps(steps);
		break;
	}
	
	return result;
}
Ejemplo n.º 5
0
Archivo: pd_cal.c Proyecto: miaofng/ulp
int pd_Calibration(void)
{
	int xres, yres, ret;
	pdl_cal_t cal;
	struct lcd_s *lcd = lcd_get(NULL);

	lcd_get_res(lcd, &xres, &yres);
	printf("xres = %d, yres = %d\n", xres, yres);
	lcd_init(lcd);
	lcd_clear_all(lcd);
	get_sample(&cal, 0, 50, 50, "top left");
	get_sample(&cal, 1, xres - 50, 50, "top right");
	get_sample(&cal, 2, xres - 50, yres - 50, "bot right");
	get_sample(&cal, 3, 50, yres - 50, "bot left");
	get_sample(&cal, 4, xres >> 1,  yres >> 1,  "center");
	pdl_cal(&cal, &pd_pdl);

	//visual verify calibration result
	ret = verify(xres, yres);
	if(!ret)
		nvm_save();
	lcd_clear_all(lcd);
	return ret;
}
Ejemplo n.º 6
0
Archivo: nvm.c Proyecto: miaofng/ulp
//for power-down auto save function
void nvm_isr(void)
{
	nvm_save();
}
Ejemplo n.º 7
0
//nest shell command
static int cmd_nest_func(int argc, char *argv[])
{
    const char *usage = {
        "nest help\n"
        "nest save                              save settings to nvm\n"
        "nest log                               print log message\n"
        "nest ignore psv bmr rly pkt fail all non    ignore some event for debug\n"
        "nest id                                set nest id eg.(001)\n"
        "nest cond_flag                         write nest cond_flag by hex eg.(0xff)\n"
    };

    if(argc > 1) {
        if(!strcmp(argv[1], "save")) {
            nvm_save();
            return 0;
        }
        if(!strcmp(argv[1], "log"))
            return cmd_nest_log_func(argc, argv);
        if(!strcmp(argv[1], "ignore")) {
            int ignore = 0, ok = 1;
            for(int i = 2; i < argc; i ++) {
                if(!strcmp(argv[i], "psv")) {
                    ignore |= PSV;
                }
                else if(!strcmp(argv[i], "bmr")) {
                    ignore |= BMR;
                }
                else if(!strcmp(argv[i], "rly")) {
                    ignore |= RLY;
                }
                else if(!strcmp(argv[i], "pkt")) {
                    ignore |= PKT;
                }
                else if(!strcmp(argv[i], "fail")) {
                    ignore |= FAIL;
                }
                else if(!strcmp(argv[i], "all")) {
                    ignore |= (PSV | BMR | RLY | PKT);
                }
                else if(!strcmp(argv[i], "non")) {
                    ignore = 0;
                }
                else {
                    ok = 0;
                    break;
                }
            }

            //display current settings
            if(ok) {
                if(argc > 2)
                    nest_flag_ignore = ignore;
                nest_message("nest_ignore = ");
                if(nest_ignore(PKT))
                    nest_message("|PKT");
                else
                    nest_message("|   ");
                if(nest_ignore(RLY))
                    nest_message("|RLY");
                else
                    nest_message("|   ");

                if(nest_ignore(BMR))
                    nest_message("|BMR");
                else
                    nest_message("|   ");

                if(nest_ignore(PSV))
                    nest_message("|PSV");
                else
                    nest_message("|   ");
                if(nest_ignore(FAIL))
                    nest_message("|FAIL");
                else
                    nest_message("|   ");
                nest_message("|\n");
                return 0;
            }
        }
#ifdef CONFIG_NEST_ID
        if(!strcmp(argv[1], "id")) {
            if(argc == 3) {
                nest_id = atoi(argv[2]);
                nest_info.id_base = nest_id;
            }
            nest_message("nest id %03d \n",nest_info.id_base);
            return 0;
        }
#endif
#ifdef CONFIG_NEST_MT80_OLD
        if(!strcmp(argv[1], "cond_flag")) {
            int fail = write_nest_psv(argc , argv);
            if(fail) return -1;
            return 0;
        }
#endif
    }
    printf("%s", usage);
    return 0;
}