void save_z80file() { unsigned char *videomem; int ancho,retorno; unsigned char nombre2[MAX_PATH_LENGTH]; char *name; videomem=screen->pixels; ancho=screen->w; clean_screen(); print_string(videomem,"Choose a name for the Z80 snapshot",-1,32,14,0,ancho); print_string(videomem,"(up to 30 characters)",-1,52,14,0,ancho); print_string(videomem,"Snapshot will be saved in:",-1,132,12,0,ancho); print_string(videomem,path_snaps,0,152,12,0,ancho); if (strlen(ordenador.current_tap)) { name=strrchr(ordenador.current_tap,'/'); if (name) name++; else name = ordenador.current_tap; } else name=NULL; retorno=ask_filename(nombre2,84,"z80", path_snaps, name); clean_screen(); if(retorno==2) // abort return; retorno=save_z80(nombre2,0); switch(retorno) { case 0: break; case -1: print_string(videomem,"File already exists",-1,80,10,0,ancho); wait_key(); break; case -2: print_string(videomem,"Can't create file",-1,80,10,0,ancho); wait_key(); break; } clean_screen(); }
static int resize_test() { IplImage* src = load_iplimage( "d:/user/vp/archive/art/greatwave.jpg" ); IplImage* image = cvCreateImage( cvGetSize( src ), 8, 1 ); cvCvtColor( src, image, CV_BGR2GRAY ); named_window( "image", 1 ); show_iplimage( "image", image ); wait_key( 0 ); named_window( "result", 1 ); for( int i = 0; i < 30; i++ ) { IplImage* dst = cvCreateImage( cvSize( (rand() % 1000) + 1, (rand() % 1000) + 1), 8, image->nChannels ); cvResize( image, dst, CV_INTER_LINEAR ); show_iplimage( "result", dst ); wait_key_ex( 0, 1000 ); cvReleaseImage( &dst ); } cvReleaseImage( &image ); destroy_window( "image" ); destroy_window( "result" ); return CV_OK; }
void version_info() { int pos_y = draw_loading("Version info", "CakesFW version " CAKES_VERSION) + SPACING_VERT; int version_pos_x = SPACING_HORIZ * 21; draw_string(screen_top_left, "NATIVE_FIRM version:", 0, pos_y, COLOR_NEUTRAL); draw_string(screen_top_left, current_firm->version_string, version_pos_x, pos_y, COLOR_NEUTRAL); if (current_twl_firm) { pos_y += SPACING_VERT; draw_string(screen_top_left, "TWL_FIRM version:", 0, pos_y, COLOR_NEUTRAL); draw_string(screen_top_left, current_twl_firm->version_string, version_pos_x, pos_y, COLOR_NEUTRAL); } if (current_agb_firm) { pos_y += SPACING_VERT; draw_string(screen_top_left, "AGB_FIRM version:", 0, pos_y, COLOR_NEUTRAL); draw_string(screen_top_left, current_agb_firm->version_string, version_pos_x, pos_y, COLOR_NEUTRAL); } draw_string(screen_top_left, "Press B to return", 0, pos_y + 20, COLOR_SELECTED); while (1) { uint16_t key = wait_key(); if (key == (key_released | key_b)) { return; } } }
int main(int ac, char **av) { t_env envir; char read_char[5]; t_list *list; int i; tab_zero(read_char); i = 1; list = NULL; if (ac > 1) { while (i < ac) { list = list_add_end(list, list_new(av[i])); i++; } i = 1; } init_shell(&envir); print_ft_list(list); wait_key(read_char, &list, &envir); restore_term(&envir); exit(EXIT_SUCCESS); return (0); }
int main() { long old_ff; if (!nf_init()) { wait_key(); return 1; } old_ff = nf_fastforward(1); nf_print("Emulator name:\n"); nf_showname(); nf_print("Shutting down...\n"); nf_fastforward(old_ff); nf_exit(0); wait_key(); return 0; }
void *referee() { set_cpu(0); if (config.flags & FL_MUTEX) if ((errno = pthread_mutex_lock(&mutex)) != 0) handle_error("pthread_mutex_lock referee"); /* infinite loop */ for (;;) { if ((rand_r(&seed)) < config.referee_end_prob) { prtflu("REFEREE: game is over\n"); if (config.flags & FL_MUTEX) if ((errno = pthread_mutex_unlock(&mutex)) != 0) handle_error("pthread_mutex_unlock referee"); pthread_exit(NULL); } else { hand[0] = hand[1] = NONE; prtflu("REFEREE: game is starting...\n"); notify_players(); wait_players(); evaluate_player(); game_response(); } wait_key(); } }
s32 menu_cb_choose_file (s32 idx, void *param) { s32 curidx = idx; s32 loaded = 0; while (aptMainLoop()) { gspWaitForVBlank(); curidx = print_file_list(curidx, &g_file_list); u32 kDown = wait_key(); if (kDown & KEY_B) { break; } else if (kDown & KEY_A) { consoleClear(); loaded = menu_execute_function(curidx, &g_file_list, &curidx); printf("%s\n", loaded? "[+] Success":"[!] Failure"); wait_any_key(); if (loaded) break; } else if (kDown & KEY_UP) { curidx--; } else if (kDown & KEY_DOWN) { curidx++; } gfxFlushBuffers(); gfxSwapBuffers(); } return 0; }
void load_scrfile() { unsigned char *videomem,*filename,value; int ancho,retorno,loop; FILE *fichero; unsigned char paleta_tmp[64]; videomem=screen->pixels; ancho=screen->w; clean_screen(); print_string(videomem,"Choose the SCR snapshot file to load",-1,32,13,0,ancho); filename=select_file(load_path_scr1,FILETYPE_SCR); if(filename==NULL) { // Aborted clean_screen(); return; } ordenador.osd_text[0]=0; fichero=fopen(filename,"rb"); retorno=0; if (!fichero) { retorno=-1; } else { for(loop=0;loop<6912;loop++) { if (1==fread(&value,1,1,fichero)) { *(ordenador.block1 + 0x04000 + loop) = value; } else { retorno=-1; break; } } if (1==fread(paleta_tmp,64,1,fichero)) { memcpy(ordenador.ulaplus_palete,paleta_tmp,64); ordenador.ulaplus=1; } else { ordenador.ulaplus=0; } fclose(fichero); } free(filename); clean_screen(); switch(retorno) { case 0: // all right break; default: print_string(videomem,"Error: Can't load that file",-1,232,10,0,ancho); print_string(videomem,"Press any key",-1,248,10,0,ancho); wait_key(); break; } clean_screen(); }
// choose a key static void pick_key(int screen) { KeyCode kc; unsigned int mods; char buf[512]; if (wait_key(screen, &kc, &mods)) printf("%s\n", format_key(kc, mods, buf)); }
void snapshots_menu() { unsigned char *fbuffer,fin; int ancho=screen->w; fbuffer=screen->pixels; clean_screen(); print_string(fbuffer,"SNAPSHOTS",-1,30,15,0,ancho); print_string(fbuffer,"1:",14,100,12,0,ancho); print_string(fbuffer,"load a Z80/SNA snapshot",62,100,15,0,ancho); if(ordenador.mode128k!=3) { // not in +3 mode print_string(fbuffer,"2:",14,160,12,0,ancho); print_string(fbuffer,"make a Z80 snapshot",62,160,15,0,ancho); } else { print_string(fbuffer,"Can't make snapshots in +3 mode",14,160,15,0,ancho); } print_string(fbuffer,"3: \001\017load a SCR snapshot",14,220,12,0,ancho); print_string(fbuffer,"4: \001\017save a SCR snapshot",14,280,12,0,ancho); print_string(fbuffer,"ESC: \001\017return to emulator",-1,400,12,0,ancho); //print_copy(fbuffer,ancho); fin=1; do { switch(wait_key()) { case SDLK_ESCAPE: // to exit the help fin=0; break; case SDLK_1: fin=0; load_z80file(); break; case SDLK_2: fin=0; if(ordenador.mode128k!=3) // not in +3 mode save_z80file(); break; case SDLK_3: fin=0; load_scrfile(); break; case SDLK_4: fin=0; create_scrfile(); break; default: break; } } while(fin); clean_screen(); }
void wait(void) { if (get_opt_u32(OPTION_TRACE) && !doing_autoboot) { fprintf(stderr, "[Waiting...]"); wait_key(); // No delay on traces. } fprintf(stderr, "\r \r"); }
void load_z80file() { unsigned char *videomem,*filename; int ancho,retorno; videomem=screen->pixels; ancho=screen->w; clean_screen(); print_string(videomem,"Choose the Z80 snapshot file to load",-1,32,13,0,ancho); filename=select_file(load_path_snaps,FILETYPE_Z80); if(filename==NULL) { // Aborted clean_screen(); return; } retorno=load_z80(filename); free(filename); clean_screen(); switch(retorno) { case 0: // all right break; case -1: print_string(videomem,"Error: Can't load that file",-1,232,10,0,ancho); print_string(videomem,"Press any key",-1,248,10,0,ancho); wait_key(); break; case -2: case -3: print_string(videomem,"Error: unsupported snap file",-1,232,10,0,ancho); print_string(videomem,"Press any key",-1,248,10,0,ancho); wait_key(); break; } clean_screen(); }
u32 wait_key_specific(const char* message, u32 key) { printf(message); while (true) { u32 keys = wait_key(); if (keys & key) { return keys; } } }
/** * Display a message box. * This function displays the specified message in a text box * centered in the screen and waits until a key is pressed. * @param p The text to be displayed */ int TextMan::message_box(const char *s) { int k; _sprites->erase_both(); blit_textbox(s, -1, -1, -1); _sprites->blit_both(); k = wait_key(); debugC(4, kDebugLevelText, "wait_key returned %02x", k); close_window(); return k; }
static int run_bootmenu(void) { time_t start = time(NULL); LOGI("Starting bootmenu on %s", ctime(&start)); if (bypass_check()) { int status = INSTALL_SUCCESS; exec_script(FILE_PRE_MENU, DISABLE); led_alert("blue", ENABLE); status = wait_key(KEY_VOLUMEDOWN); if (status != INSTALL_ERROR) { int mode = get_bootmode(); switch (mode) { case MODE_2NDINIT: led_alert("blue", DISABLE); led_alert("green", ENABLE); snd_init(DISABLE); led_alert("green", DISABLE); break; case MODE_2NDBOOT: led_alert("blue", DISABLE); led_alert("red", ENABLE); snd_boot(DISABLE); led_alert("red", DISABLE); break; case MODE_BOOTMENU: status = INSTALL_ERROR; break; } } if (status != INSTALL_SUCCESS) { ui_init(); ui_set_background(BACKGROUND_ICON_ERROR); ui_show_text(ENABLE); LOGI("Start Android BootMenu....\n"); prompt_and_wait(); ui_finish(); } led_alert("blue", DISABLE); return EXIT_SUCCESS; } return EXIT_SUCCESS; }
int TextMan::print(const char *p, int lin, int col, int len) { if (p == NULL) return 0; debugC(4, kDebugLevelText, "lin = %d, col = %d, len = %d", lin, col, len); if (col == 0 && lin == 0 && len == 0) lin = col = -1; if (len == 0) len = 30; blit_textbox(p, lin, col, len); if (getflag(F_output_mode)) { /* non-blocking window */ setflag(F_output_mode, false); return 1; } /* blocking */ if (game.vars[V_window_reset] == 0) { int k; setvar(V_key, 0); k = wait_key(); close_window(); return k; } /* timed window */ debugC(3, kDebugLevelText, "f15==0, v21==%d => timed", getvar(21)); game.msg_box_ticks = getvar(V_window_reset) * 10; setvar(V_key, 0); do { main_cycle(); if (game.keypress == KEY_ENTER) { debugC(4, kDebugLevelText, "KEY_ENTER"); setvar(V_window_reset, 0); game.keypress = 0; break; } } while (game.msg_box_ticks > 0); setvar(V_window_reset, 0); close_window(); return 0; }
void draw_message(char *title, char *text) { int pos_y = draw_loading(title, text); draw_string(screen_top_left, "Press A to continue", 10, pos_y + 20, COLOR_SELECTED); while (1) { uint16_t key = wait_key(); if (key == (key_released | key_a)) { return; } } }
void select_mdrfile() { unsigned char *videomem,*filename; int ancho,retorno,retval; // unsigned char char_id[11]; videomem=screen->pixels; ancho=screen->w; clean_screen(); print_string(videomem,"Choose the MICRODRIVE file to load",-1,32,13,0,ancho); filename=select_file(path_mdrs,FILETYPE_MDR); // MDR files if(filename==NULL) { // Aborted clean_screen(); return; } ordenador.mdr_file=fopen(filename,"rb"); // read if(ordenador.mdr_file==NULL) retorno=-1; else { retorno=0; retval=fread(ordenador.mdr_cartridge,137923,1,ordenador.mdr_file); // read the cartridge in memory ordenador.mdr_modified=0; // not modified fclose(ordenador.mdr_file); ordenador.mdr_tapehead=0; } clean_screen(); strcpy(ordenador.mdr_current_mdr,filename); free(filename); switch(retorno) { case 0: // all right break; case -1: print_string(videomem,"Error: Can't load that file",-1,232,10,0,ancho); print_string(videomem,"Press any key",-1,248,10,0,ancho); ordenador.mdr_current_mdr[0]=0; wait_key(); break; } clean_screen(); }
void debug(const char *msg, ...) { consoleInit(GFX_BOTTOM, NULL); printf("DEBUG:\n"); va_list args; va_start(args, msg); vprintf(msg, args); va_end(args); printf("\n\nPress START to continue...\n"); wait_key(KEY_START); }
void chg_dir() { extern int fd; WINDOW *ch_win, *newwin(); char *ans, *dir, *expand(), *cwd, *getcwd(), cwdbuf[200]; char *get_str(); cwd = getcwd(cwdbuf, 200); ch_win = newwin(6, 70, 5, 5); mvwprintw(ch_win, 2, 4, "Current directory: %s", cwd); mvwaddstr(ch_win, 3, 4, "New directory: "); box(ch_win, VERT, HORZ); mvwattrstr(ch_win, 0, 3, A_BOLD, " Change directory "); wmove(ch_win, 3, 19); wrefresh(ch_win); /* get the answer */ while ((ans = get_str(ch_win, 80, "", " \t\n")) != NULL) { /* a CR means no change */ if (*ans == '\0') break; /* expand the input */ dir = expand(ans); /* if you have search permission */ if (!access(dir, 1)) { if (!chdir(dir)) break; } beep(); mvwattrstr(ch_win, 4, 15, A_BOLD, "No such directory or no access permission"); wrefresh(ch_win); wait_key(ch_win, 3); /* clean up the mess */ clear_line(ch_win, 3, 19, TRUE); clear_line(ch_win, 4, 14, TRUE); wmove(ch_win, 3, 19); wrefresh(ch_win); } if (fd == -1) { werase(ch_win); wrefresh(ch_win); } delwin(ch_win); return; }
void panic(const char *msg, ...) { consoleInit(GFX_BOTTOM, NULL); printf("ERROR:\n"); va_list args; va_start(args, msg); vprintf(msg, args); va_end(args); printf("\n\nPress START to reboot...\n"); wait_key(KEY_START); reboot(); }
void action_about() { consoleClear(); printf(CONSOLE_RED "CIAngel\n\n" CONSOLE_RESET); printf("Download, create, and install CIAs directly\n"); printf("from Nintendo's CDN servers. Grabbing the\n"); printf("latest games has never been so easy.\n\n"); printf("Contributors: Cearp, Drakia, superbudvar,\n"); printf(" mysamdog, cerea1killer\n"); printf("\n\nCommit: " REVISION_STRING "\n\n"); printf("\nPress any button to continue."); wait_key(); }
void action_prompt_queue() { consoleClear(); std::string mode_text; switch (config.GetMode()) { case CConfig::Mode::DOWNLOAD_CIA: mode_text = "download"; break; case CConfig::Mode::INSTALL_CIA: mode_text = "install"; break; case CConfig::Mode::INSTALL_TICKET: mode_text = "create tickets for"; break; } printf("Queue contains %d items.\n", game_queue.size()); printf("Press A to %s queue.\n", mode_text.c_str()); printf("Press B to return to menu.\n"); printf("Press X to clear queue.\n"); while (aptMainLoop()) { u32 key = wait_key(); if (key & KEY_B) { break; } if (key & KEY_X) { game_queue.clear(); break; } if (key & KEY_A) { ProcessGameQueue(); break; } } }
void tools_menu() { unsigned char *fbuffer,fin; int ancho=screen->w; fbuffer=screen->pixels; fin=1; do { clean_screen(); print_string(fbuffer,"Tools",-1,20,15,0,ancho); print_string(fbuffer,"1:",14,60,12,0,ancho); print_string(fbuffer,"show keyboard template",62,60,15,0,ancho); print_string(fbuffer,"2:",14,100,12,0,ancho); print_string(fbuffer,"insert POKEs",62,100,15,0,ancho); print_string(fbuffer,"ESC:",14,250,12,0,ancho); print_string(fbuffer,"return emulator",78,250,15,0,ancho); //print_copy(fbuffer,ancho); switch(wait_key()) { case SDLK_ESCAPE: // to exit the help fin=0; break; case SDLK_1: fin=0; keyboard_menu(); break; case SDLK_2: fin=0; do_poke(); break; default: break; } } while(fin); clean_screen(); }
// TODO: Clean up the first two functions. They have too much in common. // No boundary checks, use this responsibly. int draw_menu(char *title, int back, int count, char *options[]) { int current = 0; clear_screen(screen_top_left); draw_string(screen_top_left, title, 10, 10, COLOR_TITLE); draw_string(screen_top_left, options[0], 10, 40, COLOR_SELECTED); for (int i = 1; i < count; i++) { draw_string(screen_top_left, options[i], 10, 40 + SPACING_VERT * i, COLOR_NEUTRAL); } while (1) { uint16_t key = wait_key(); if (key == (key_released | key_up)) { draw_string(screen_top_left, options[current], 10, 40 + SPACING_VERT * current, COLOR_NEUTRAL); if (current <= 0) { current = count - 1; } else { current--; } draw_string(screen_top_left, options[current], 10, 40 + SPACING_VERT * current, COLOR_SELECTED); } else if (key == (key_released | key_down)) { draw_string(screen_top_left, options[current], 10, 40 + SPACING_VERT * current, COLOR_NEUTRAL); if (current >= count - 1) { current = 0; } else { current++; } draw_string(screen_top_left, options[current], 10, 40 + SPACING_VERT * current, COLOR_SELECTED); } else if (key == (key_released | key_a)) { return current; } else if (key == (key_released | key_b) && back) { return -1; } } }
void choose_mode(int sd_ok) { int i = 0; console_gotoxy(9,10); if (sd_ok) { //console_puts("load from SD card"); pick_and_load_rom(); } else { console_puts("retry SD/MMC card"); } //console_gotoxy(9,12); //console_puts("boot SRAM"); for (;;) { int key; console_gotoxy(6,10); if (i==0) { console_puts(">"); } else { console_puts(" "); } console_gotoxy(6,12); if (i==1) { console_puts(">"); } else { console_puts(" "); } key = wait_key(); switch (key) { case JOY_UP: i = 0; break; // case JOY_DOWN: // i = 1; // break; case JOY_FIREA: case JOY_FIREB: if (i==0) { if (sd_ok) { pick_and_load_rom(); } } else { start_rom(); } return; } } }
void keyboard_menu() { FILE *fichero; int bucle1,bucle2,retval; unsigned char *buffer,*buffer2,valor; buffer=screen->pixels; clean_screen(); fichero=myfopen("fbzx/keymap.bmp","rb"); if (fichero==NULL) { strcpy(ordenador.osd_text,"Keymap picture not found"); ordenador.osd_time=100; return; } if (ordenador.zaurus_mini==0) { for (bucle1=0;bucle1<344;bucle1++) for(bucle2=0;bucle2<640;bucle2++) { retval=fscanf(fichero,"%c",&valor); paint_one_pixel((unsigned char *)(colors+valor),buffer); buffer+=ordenador.bpp; } } else { buffer+=(479*ordenador.bpp); for(bucle1=0;bucle1<344;bucle1++) { buffer2=buffer; for(bucle2=0;bucle2<640;bucle2++) { retval=fscanf(fichero,"%c",&valor); paint_one_pixel((unsigned char *)(colors+valor),buffer); buffer+=(480*ordenador.bpp); } buffer=buffer2-ordenador.bpp; } } //print_copy(screen->pixels,screen->w); wait_key(); clean_screen(); }
void ss_sampl_H() { // Choose sampling method. //#define SAMP_METHOD_SWING #define SAMP_METHOD_SWING_S // SWING mm #if defined(SAMP_METHOD_SWING) #define toR2 24+1 //20 #define toR3 12+2 //10 #define toR1 23 //15 #define toL1 23-2 //20 #define toL3 23 //20 #define toL2 12+3 //15 #define toC1 24+3 //20 #elif defined(SAMP_METHOD_SWING_S) #define toR2 40 #define toR3 20 #define toR1 40 #define toL1 40 #define toL3 40 #define toL2 20 #define toC1 40 #else #error Choose Sampling Method #endif led_off(PIO_LED_ALL); led_on (PIO_LED_2 | PIO_LED_6 | PIO_LED_3); // sys_delay(1000); ss_on(); // show LEDs to find the center of block int ss_diff; while( !( get_key_state()==(PORT_CANCEL) || get_key_state()==(PORT_SELECT) ) ) { ss_diff = ((int)ss_value[SS_L45]) - ((int)ss_value[SS_R45]); led_off(PIO_LED_ALL); if ( ss_diff > 10) led_on(PIO_LED_3); else if ( ss_diff > 5) led_on(PIO_LED_4 | PIO_LED_1); else if ( ss_diff < -10) led_on(PIO_LED_2); else if ( ss_diff < -5 ) led_on(PIO_LED_5 | PIO_LED_0); else led_on(PIO_LED_6); } // wait_key(); torque_on(); wait_key(); // ss_on(); led_count_down( 5, 1000 ); // debug //#define DEBUG_SAMPL disable_adj(); reset_spd_ptr(); // C1 led_off( PIO_LED_0 |PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6); led_on ( PIO_LED_6 ); sys_delay(100); sampl_value( sC1 ); motor_start(); #ifdef DEBUG_SAMPL motor_stop(); wait_key(); motor_start(); #endif // R2 led_off( PIO_LED_0|PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6); led_on ( PIO_LED_0|PIO_LED_5|PIO_LED_2 ); #if defined(SAMP_METHOD_SWING) swing(toR2); #elif defined(SAMP_METHOD_SWING_S) swing_S(toR2); #else #error Choose Sampling Method #endif sampl_value( sR2 ); #ifdef DEBUG_SAMPL motor_stop(); wait_key(); motor_start(); #endif // R3 led_off( PIO_LED_0|PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6); led_on ( PIO_LED_2 ); #if defined(SAMP_METHOD_SWING) swing(toR3); #elif defined(SAMP_METHOD_SWING_S) swing_S(toR3); #else #error Choose Sampling Method #endif sampl_value( sR3 ); #ifdef DEBUG_SAMPL motor_stop(); wait_key(); motor_start(); #endif // R1 led_off( PIO_LED_0 |PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6); led_on ( PIO_LED_0 | PIO_LED_5); #if defined(SAMP_METHOD_SWING) swing(-toR1); #elif defined(SAMP_METHOD_SWING_S) swing_S(-toR1); #else #error Choose Sampling Method #endif sampl_value( sR1 ); #ifdef DEBUG_SAMPL motor_stop(); wait_key(); motor_start(); #endif // L1 led_off( PIO_LED_0 |PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6); led_on ( PIO_LED_1 | PIO_LED_4); #if defined(SAMP_METHOD_SWING) swing(-toL1); #elif defined(SAMP_METHOD_SWING_S) swing_S(-toL1); #else #error Choose Sampling Method #endif sampl_value( sL1 ); #ifdef DEBUG_SAMPL motor_stop(); wait_key(); motor_start(); #endif // L3 led_off( PIO_LED_0 |PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6); led_on ( PIO_LED_3); #if defined(SAMP_METHOD_SWING) swing(-toL3); #elif defined(SAMP_METHOD_SWING_S) swing_S(-toL3); #else #error Choose Sampling Method #endif sampl_value( sL3 ); #ifdef DEBUG_SAMPL motor_stop(); wait_key(); motor_start(); #endif // L2 led_off( PIO_LED_0 |PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6); led_on ( PIO_LED_1|PIO_LED_3|PIO_LED_4 ); #if defined(SAMP_METHOD_SWING) swing(toL2); #elif defined(SAMP_METHOD_SWING_S) swing_S(toL2); #else #error Choose Sampling Method #endif sampl_value( sL2 ); #ifdef DEBUG_SAMPL motor_stop(); wait_key(); motor_start(); #endif // C1 led_off( PIO_LED_0 |PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6); led_on ( PIO_LED_6 ); #if defined(SAMP_METHOD_SWING) swing(toC1); #elif defined(SAMP_METHOD_SWING_S) swing_S(toC1); #else #error Choose Sampling Method #endif #ifdef DEBUG_SAMPL motor_stop(); wait_key(); motor_start(); #endif motor_stop(); ss_off(); torque_off(); }
void ss_sampl() { while( 1 ) { // Sampling Vertical ////////////////////////////////////// led_off(PIO_LED_ALL); led_on (PIO_LED_0|PIO_LED_1|PIO_LED_5|PIO_LED_4); if ( L_KEY == read_key() ) { Sound_Select(); ss_sampl_V(); process_sampl_V(); save_sampl_value(); } else Sound_Beep(); // Sampling Horizonal ////////////////////////////////////// led_off(PIO_LED_ALL); led_on (PIO_LED_2|PIO_LED_6|PIO_LED_3); if ( L_KEY == read_key() ) { Sound_Select(); ss_sampl_H(); process_sampl_V(); save_sampl_value(); } else Sound_Beep(); } END_SEL: } void ss_sampl_V() { led_off(PIO_LED_ALL); led_on (PIO_LED_0 | PIO_LED_1 | PIO_LED_5 | PIO_LED_4); wait_key(); torque_on(); wait_key(); led_count_down( 5, 1000 ); disable_adj(); spd_ptr = 0; spd_diff = 0; reverse_LR(); ss_on(); sys_delay(300); unsigned int ref_L; unsigned int ref_R; ref_L = ss_value[SS_L0]; ref_R = ss_value[SS_R0]; int i=0; reset_spd_ptr(); spd_diff = 1; motor_start(); while(i < SAMPL_VSTEP) { #define SAM_SPD 20 //25 if ( spd_ptr_L >= SAM_SPD ) { spd_diff = 0; equal_spd_ptr(); } reset_steps(); while( steps == 0 ); ref_L = ss_value[SS_L0]; ref_R = ss_value[SS_R0]; sFL0[i] = (unsigned char)ref_L; sFR0[i] = (unsigned char)ref_R; i++; } ss_off(); spd_diff = -1; while (spd_ptr_L > 0); reset_spd_ptr(); motor_stop(); sys_delay(200); reverse_LR(); torque_off(); }
main ( int argc, char *argv[] ) { long cnt = 1000L ; int needPause = 0 ; for ( int i = 1 ; i < argc ; i++ ) { switch( argv[i][0] ) { case 'P' : case 'p' : needPause = 1 ; break ; case 'V' : case 'v' : directvideo = 1 ; break ; case 'B' : case 'b' : directvideo = 0 ; break ; default : if ( argv[i][0] >= '0' && argv[i][0] <= '9' ) cnt = atol(argv[i]) ; break ; } } stdscr.cursor_off() ; stdscr.set_toVideo(directvideo) ; stdscr.set_toBios(directvideo^1) ; // stdscr.set_attr(0x10) ; set_attr(0x10) ; // stdscr.clr_scr() ; clr_scr() ; { twin X( 1, 1,10,80) ; twin L(11, 1,20,40) ; twin R(11,41,20,80) ; test1(X,L,R,cnt) ; X.save_image() ; L.save_image() ; R.save_image() ; test2(X,L,R,cnt) ; test3(X,L,R,cnt) ; // stdscr.set_attr(0x07) ; set_attr(0x07) ; if ( needPause ) { // stdscr.clr_scr(24,25) ; clr_scr(24,25) ; // stdscr.locate(24,1) ; locate(24,1) ; // stdscr.outs(">>>> press any key to continue ...") ; outs(">>>> press any key to continue ...") ; clr_key() ; wait_key() ; } X.restore_image() ; L.restore_image() ; R.restore_image() ; if ( needPause ) { // stdscr.clr_scr(24,25) ; clr_scr(24,25) ; // stdscr.locate(24,1) ; locate(24,1) ; // stdscr.outs(">>>> press any key to continue ...") ; outs(">>>> press any key to continue ...") ; clr_key() ; wait_key() ; } } { twin A( 6,28,10,47) ; twin B( 8,31,12,50) ; twin C(10,34,14,53) ; Wfptr p[3] ; p[0] = A.save_screen() ; p[1] = B.save_screen() ; p[2] = C.save_screen() ; int k = 0 ; for ( int n = 0 ; n < 100 ; n++ ) { for ( int i = 1 ; i <= 20 ; i += 5 ) { for ( int j = 1 ; j <= 80 ; j += 20 ) { twin D(i,j,i+4,j+19) ; D.restore_screen(p[k]) ; k = (k+1) % 3 ; } } } } stdscr.cursor_on() ; // stdscr.clr_scr(24,25) ; clr_scr(24,25) ; // stdscr.locate(24,1) ; locate(24,1) ; // stdscr.outs(">>>> end of testing ...") ; outs(">>>> end of testing ...") ; clr_key() ; return 0 ; }