Пример #1
0
void script_start( int autostart )
{
    int i;

    shot_histogram_set(0);
    if (autostart) auto_started = 1; else auto_started = 0;
    delay_target_ticks = 0;
    kbd_int_stack_ptr = 0;
    kbd_last_clicked = 0;
    /*if (!autostart)*/ kbd_key_release_all();

    script_console_clear();
    script_print_screen_init();

			if (conf.script_param_save)
				{
        save_params_values(0);
      }
    if( autostart )
      script_console_add_line("***Autostart***");
    else
      script_console_add_line(lang_str(LANG_CONSOLE_TEXT_STARTED));

    if( is_lua() ) {
      
      if( !lua_script_start(state_ubasic_script) ) {
    script_print_screen_end();
    wait_and_end();
    return;
      }
      for (i=0; i<SCRIPT_NUM_PARAMS; ++i) {
    if( script_params[i][0] ) {
    char var = 'a'+i;
    lua_pushlstring( L, &var, 1 );
    lua_pushnumber( L, conf.ubasic_vars[i] );
    lua_settable( L, LUA_GLOBALSINDEX );
    }
      }
      state_lua_kbd_first_call_to_resume = 1;
    }
    else {
      ubasic_init(state_ubasic_script);

      for (i=0; i<SCRIPT_NUM_PARAMS; ++i) {
        ubasic_set_variable(i, conf.ubasic_vars[i]);
      }
    }

    state_kbd_script_run = 1;

    if (conf.alt_prevent_shutdown != ALT_PREVENT_SHUTDOWN_ALT_SCRIPT) {
        enable_shutdown();
    }
}
Пример #2
0
void script_end()
{
    script_print_screen_end();
    if( L ) {
      lua_script_reset( L );
    }
    else {
      ubasic_end();
    }
	md_close_motion_detector();
	shot_histogram_set(0);
    if (conf.alt_prevent_shutdown != ALT_PREVENT_SHUTDOWN_NO) {
        disable_shutdown();
    }
    kbd_key_release_all();
    state_kbd_script_run = 0;
    vid_bitmap_refresh();
}
Пример #3
0
// Terminate a script, either because of error, or the script finished
void script_end()
{
    // Tell other code that script has ended
    camera_info.state.state_kbd_script_run = SCRIPT_STATE_INACTIVE;
    camera_info.state.osd_title_line = 1 ;

    // reset the script terminate key
    script_terminate_key = KEY_SHOOT_FULL ;

    script_print_screen_end();
    console_set_autoredraw(1);          // Force console display on in case script turned it off

    // Restore old handler - prevent calling MD draw after module unloaded
    if (old_gui_handler)
    {
        extern gui_handler defaultGuiHandler; 
        // if script switched in or out of alt, try to preserve
        // TODO is there ever a situation where it should be something other than default or alt?
        if(old_gui_handler == &altGuiHandler && camera_info.state.gui_mode_none) {
            gui_set_mode(&defaultGuiHandler);
        } else if(old_gui_handler == &defaultGuiHandler && camera_info.state.gui_mode_alt) {
            gui_set_mode(&altGuiHandler);
        } else {
            gui_set_mode(old_gui_handler);
        }
        old_gui_handler = 0;
    }

    // Reset script language module
    libscriptapi->script_reset();

    // Kill off the action_stack for the script, since we've just reset the script
    // language and unloaded the MD module, we don't need to let the stack empty
    // itself.
    action_stack_kill(running_script_stack_name);
    running_script_stack_name = -1;

	libshothisto->shot_histogram_set(0);
    kbd_key_release_all();

    conf_setAutosave(1);    // Turn on autosave of config file in conf_setValue in case script turned it off
    conf_update_prevent_shutdown();
}
Пример #4
0
void script_print_screen_statement(int val)
{
  // Negative values for 'val' parameter will append to log file,
  // positive values will truncate the log file
  int flag_trunc = O_TRUNC;

  print_screen_p = val;
  if (val) {
    if (print_screen_d>=0) close(print_screen_d);
    if (val<0) {
       flag_trunc = 0;
       val = -val;
    }
    while (val > 9999) val -= 10000;
    sprintf(print_screen_file, "A/CHDK/LOGS/LOG_%04d.TXT", val);
    print_screen_d = open(print_screen_file, O_WRONLY|O_CREAT|flag_trunc, 0777);
    if (print_screen_d>=0) lseek(print_screen_d,0,SEEK_END);
  }
  else script_print_screen_end() ;
}
Пример #5
0
void lua_script_error(lua_State *Lt,int runtime)
{
    const char *err = lua_tostring( Lt, -1 );
    script_console_add_line( err );
    if(lua_script_is_ptp) {
#ifdef CAM_CHDK_PTP
        lua_script_error_ptp(runtime,err);
#endif
    } else {
        if(runtime) {
            if(conf.debug_lua_restart_on_error) {
                lua_script_reset();
                script_start_gui(0);
            } else {
                script_wait_and_end();
            }
        } else {
            script_print_screen_end();
            script_wait_and_end();
        }
    }
}