CHDK_DE Vorschauversion  Trunk Rev. 5232
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
script.c-Dateireferenz
#include "camera_info.h"
#include "stdlib.h"
#include "keyboard.h"
#include "modes.h"
#include "viewport.h"
#include "conf.h"
#include "script.h"
#include "console.h"
#include "action_stack.h"
#include "shot_histogram.h"
#include "lang.h"
#include "gui.h"
#include "gui_lang.h"
#include "ptp.h"
#include "clock.h"
#include "usb_remote.h"
#include "script_api.h"
#include "motion_detector.h"
+ Include-Abhängigkeitsdiagramm für script.c:

gehe zum Quellcode dieser Datei

Funktionen

void script_end ()
 
static void script_print_screen_init ()
 
static void script_print_screen_end ()
 
void script_print_screen_statement (int val)
 
void script_console_add_line (long str_id)
 
void script_console_add_error (long str_id)
 
static int action_stack_AS_SCRIPT_RUN ()
 
long script_stack_start ()
 
int script_is_running ()
 
void script_set_terminate_key (int key, const char *keyname)
 
void script_get_alt_text (char *buf)
 
void script_check_terminate (void)
 
static int gui_script_kbd_process ()
 
void gui_script_draw ()
 
void script_wait_terminate (void)
 
long script_start_gui (int autostart)
 

Variablen

static AS_ID running_script_stack_name = 0
 
static int script_terminate_key = KEY_SHOOT_FULL
 
static char script_terminate_key_name [20]
 
static int script_terminate_request = 0
 
static int print_screen_p
 
static int print_screen_d = -1
 
char print_screen_file [25]
 
gui_handler scriptGuiHandler = { GUI_MODE_SCRIPT, gui_script_draw, gui_script_kbd_process, 0, 0, 0 }
 
static gui_handlerold_gui_handler = 0
 

Dokumentation der Funktionen

static int action_stack_AS_SCRIPT_RUN ( )
static

Definiert in Zeile 106 der Datei script.c.

107 {
109  {
110  int rv = libscriptapi->script_run();
111  if (rv != SCRIPT_RUN_RUNNING)
112  {
113  // Script language is responsible for displaying 'Finished' or error
114  // messages so all we need to do is shutdown the script engine
115  script_end();
116  return 1;
117  }
118  }
119  else
120  {
121  action_pop_func(0);
122  return 1;
123  }
124  return 0;
125 }
void gui_script_draw ( )

Definiert in Zeile 193 der Datei script.c.

194 {
195  extern void gui_chdk_draw();
196  gui_chdk_draw();
197 
199  {
200  static int show_md_grid=0;
201  if (camera_info.state.state_kbd_script_run) show_md_grid=5;
202  if (show_md_grid)
203  {
204  --show_md_grid;
206  }
207  }
208 }
static int gui_script_kbd_process ( )
static

Definiert in Zeile 173 der Datei script.c.

174 {
175  // Stop a script if the shutter button pressed in Script mode
177  {
180  script_end();
181  else
182  {
184  if (libscriptapi->run_restore() == 0)
185  script_end();
186  }
187  }
188 
189  return 0;
190 }
void script_check_terminate ( void  )

Definiert in Zeile 163 der Datei script.c.

void script_console_add_error ( long  str_id)

Definiert in Zeile 95 der Datei script.c.

96 {
97  console_set_autoredraw(1); // Force console display on
99 }
void script_console_add_line ( long  str_id)

Definiert in Zeile 82 der Datei script.c.

83 {
84  const char* str = lang_str(str_id);
85  console_add_line(str);
86 
87  if (print_screen_p && (print_screen_d >= 0)) {
88  char nl = '\n';
89  // TODO this should be uncached memory
90  write(print_screen_d, str, strlen(str) );
91  write(print_screen_d, &nl, 1);
92  }
93 }
void script_end ( )

Definiert in Zeile 231 der Datei script.c.

232 {
233  // Tell other code that script has ended
236 
237  // reset the script terminate key
239 
241  console_set_autoredraw(1); // Force console display on in case script turned it off
242 
243  // Restore old handler - prevent calling MD draw after module unloaded
244  if (old_gui_handler)
245  {
247  // if script switched in or out of alt, try to preserve
248  // TODO is there ever a situation where it should be something other than default or alt?
250  gui_set_mode(&defaultGuiHandler);
251  } else if(old_gui_handler == &defaultGuiHandler && camera_info.state.gui_mode_alt) {
253  } else {
255  }
256  old_gui_handler = 0;
257  }
258 
259  // Reset script language module
261 
262  // Kill off the action_stack for the script, since we've just reset the script
263  // language and unloaded the MD module, we don't need to let the stack empty
264  // itself.
267 
270 
271  conf_setAutosave(1); // Turn on autosave of config file in conf_setValue in case script turned it off
273 }
void script_get_alt_text ( char *  buf)

Definiert in Zeile 149 der Datei script.c.

150 {
152  {
154  }
155  else
156  {
157  strcpy(buf,"<ALT>");
158  }
159 }
int script_is_running ( )

Definiert in Zeile 136 der Datei script.c.

137 {
139 }
static void script_print_screen_end ( )
static

Definiert in Zeile 52 der Datei script.c.

53 {
54  if (print_screen_d >= 0) {
56  print_screen_d = -1;
57  print_screen_p = 0;
58  }
59 }
static void script_print_screen_init ( )
static

Definiert in Zeile 43 der Datei script.c.

44 {
45  print_screen_p = 0;
46  if (print_screen_d >= 0) {
48  print_screen_d = -1;
49  }
50 }
void script_print_screen_statement ( int  val)

Definiert in Zeile 61 der Datei script.c.

62 {
63  // Negative values for 'val' parameter will append to log file,
64  // positive values will truncate the log file
65  int flag_trunc = O_TRUNC;
66 
67  print_screen_p = val;
68  if (val) {
70  if (val<0) {
71  flag_trunc = 0;
72  val = -val;
73  }
74  while (val > 9999) val -= 10000;
75  sprintf(print_screen_file, "A/CHDK/LOGS/LOG_%04d.TXT", val);
78  }
80 }
void script_set_terminate_key ( int  key,
const char *  keyname 
)

Definiert in Zeile 142 der Datei script.c.

long script_stack_start ( )

Definiert in Zeile 127 der Datei script.c.

128 {
129  script_terminate_request = 0; // ensure any previous terminate request is cleared
130 
134 }
long script_start_gui ( int  autostart)

Definiert in Zeile 275 der Datei script.c.

276 {
277  int i;
278 
279  if (conf.script_file[0] == 0) return 0;
280 
282  camera_info.state.auto_started = autostart;
283 
284  // Kill high speed USB timer if running
286 
287  // Keyboard init
291 
292  // Close old console, will be re-opened when first line added
293  console_close();
295 
297 
299 
302  {
303  return -1;
304  }
305 
306  sc_param *p = script_params;
307  while (p)
308  {
309  if (p->name != 0)
310  {
311  libscriptapi->set_variable(p->name, p->val, (p->range == 1), (p->data_type == DTYPE_TABLE), p->option_count, p->options);
312  }
313  p = p->next;
314  }
315 
317 
319 
320  return script_stack_start();
321 }
void script_wait_terminate ( void  )

Definiert in Zeile 218 der Datei script.c.

219 {
221  return;
222  }
224  // TODO timeout?
226  msleep(10);
227  }
228 }

Variablen-Dokumentation

gui_handler* old_gui_handler = 0
static

Definiert in Zeile 213 der Datei script.c.

int print_screen_d = -1
static

Definiert in Zeile 40 der Datei script.c.

char print_screen_file[25]

Definiert in Zeile 41 der Datei script.c.

int print_screen_p
static

Definiert in Zeile 39 der Datei script.c.

AS_ID running_script_stack_name = 0
static

Definiert in Zeile 22 der Datei script.c.

int script_terminate_key = KEY_SHOOT_FULL
static

Definiert in Zeile 26 der Datei script.c.

char script_terminate_key_name[20]
static

Definiert in Zeile 27 der Datei script.c.

int script_terminate_request = 0
static

Definiert in Zeile 29 der Datei script.c.

Definiert in Zeile 211 der Datei script.c.