void xyzsh_init(enum eAppType app_type, BOOL no_runtime_script) { setenv("XYZSH_VERSION", "1.5.8", 1); setenv("XYZSH_DOCDIR", DOCDIR, 1); setenv("XYZSH_DATAROOTDIR", DOCDIR, 1); setenv("XYZSH_EXT_PATH", EXTDIR, 1); setenv("XYZSH_SYSCONFDIR", SYSCONFDIR, 1); char* home = getenv("HOME"); if(home) { char home_library[PATH_MAX]; snprintf(home_library, PATH_MAX, "%s/.xyzsh/lib/", home); char* ld_library_path = getenv("LD_LIBRARY_PATH"); if(ld_library_path) { char ld_library_path2[512]; snprintf(ld_library_path2, 512, "%s:%s:%s", ld_library_path, EXTDIR, home_library); setenv("LD_LIBRARY_PATH", ld_library_path2, 1); } else { char ld_library_path2[512]; snprintf(ld_library_path2, 512, "%s:%s", EXTDIR, home_library); setenv("LD_LIBRARY_PATH", ld_library_path2, 1); } } else { char* ld_library_path = getenv("LD_LIBRARY_PATH"); if(ld_library_path) { char ld_library_path2[512]; snprintf(ld_library_path2, 512, "%s:%s", ld_library_path, EXTDIR); setenv("LD_LIBRARY_PATH", ld_library_path2, 1); } else { char ld_library_path2[512]; snprintf(ld_library_path2, 512, "%s", EXTDIR); setenv("LD_LIBRARY_PATH", ld_library_path2, 1); } } setlocale(LC_ALL, ""); stack_init(1);; stack_start_stack(); gErrMsg = STRING_NEW_STACK(""); gXyzshSigInt = FALSE; gXyzshSigUser = FALSE; gXyzshSigTstp = FALSE; gXyzshSigCont = FALSE; xyzsh_set_signal_other = NULL; gc_init(1); run_init(app_type); load_init(); xyzsh_editline_init(); gDirStack = VECTOR_NEW_GC(10, FALSE); uobject_put(gXyzshObject, "_dir_stack", gDirStack); char* term_env = getenv("TERM"); if(term_env != NULL && strcmp(term_env, "") != 0) { mcurses_init(); } if(!xyzsh_rehash("init", 0)) { fprintf(stderr, "run time error\n"); fprintf(stderr, "%s", string_c_str(gErrMsg)); exit(1); } if(!no_runtime_script) { xyzsh_read_rc(); } else { xyzsh_read_rc_mini(); } }
static void task_calibration_entry(void) { int16_t autoboot_ms = 3000; int c; uint8_t quit = 0; /* wait for keypress, or schedule */ while (!usart_is_data_arrived(&USART_CONSOLE)) { cons_printf("Press a key to enter calibration... %ds remaining\r", autoboot_ms / 1000); kos_set_next_schedule_delay_ms(250); autoboot_ms -= 250; if (autoboot_ms > 0) kos_yield(); else /* time elapsed, we bypass calibration * and continue to game mode. */ goto exit_point; } cons_printf("\n\n"); getchar(); mcurses_init(); mach_calibration_usage(); while (!quit) { /* display prompt */ cons_printf("$ "); /* wait for command */ c = cons_getchar(); cons_printf("%c\n", c); switch (c) { #if defined(CONFIG_ANALOG_SENSORS) case 'a': analog_sensor_enter_calibration(&ana_sensors); break; #endif case 'o': encoder_enter_calibration(); /* TODO; odometry_enter_calibration */ break; case 'p': hbridge_enter_calibration(&hbridges); break; #if defined(CONFIG_SD21) case 's': sd21_enter_calibration(&sd21); break; #endif case 'r': controller_enter_calibration(); break; case 'g': planner_enter_calibration(); break; case 'h': mach_calibration_usage(); break; case 'e': quit = 1; break; default: cons_printf("\n"); break; } } exit_point: cons_printf("calibration ended\n"); planner_start_game(); kos_task_exit(); }