CHDK_DE Vorschauversion  Trunk Rev. 6014
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
script.c-Dateireferenz
#include "camera_info.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 105 der Datei script.c.

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

Definiert in Zeile 192 der Datei script.c.

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

Definiert in Zeile 172 der Datei script.c.

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

Definiert in Zeile 162 der Datei script.c.

void script_console_add_error ( long  str_id)

Definiert in Zeile 94 der Datei script.c.

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

Definiert in Zeile 81 der Datei script.c.

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

Definiert in Zeile 230 der Datei script.c.

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

Definiert in Zeile 148 der Datei script.c.

149 {
151  {
153  }
154  else
155  {
156  strcpy(buf,"<ALT>");
157  }
158 }
int script_is_running ( )

Definiert in Zeile 135 der Datei script.c.

136 {
138 }
static void script_print_screen_end ( )
static

Definiert in Zeile 51 der Datei script.c.

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

Definiert in Zeile 42 der Datei script.c.

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

Definiert in Zeile 60 der Datei script.c.

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

Definiert in Zeile 141 der Datei script.c.

long script_stack_start ( )

Definiert in Zeile 126 der Datei script.c.

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

Definiert in Zeile 274 der Datei script.c.

275 {
276  if (conf.script_file[0] == 0) return 0;
277 
280 
281  // Kill high speed USB timer if running
283 
284  // Keyboard init
288 
289  // Close old console, will be re-opened when first line added
290  console_close();
292 
294 
296 
299  {
300  return -1;
301  }
302 
303  sc_param *p = script_params;
304  while (p)
305  {
306  if (p->name != 0)
307  {
308  libscriptapi->set_variable(p->name, p->val, (p->range == 1), (p->data_type == DTYPE_TABLE), p->option_count, p->options);
309  }
310  p = p->next;
311  }
312 
314 
316 
317  return script_stack_start();
318 }
void script_wait_terminate ( void  )

Definiert in Zeile 217 der Datei script.c.

218 {
220  return;
221  }
223  // TODO timeout?
225  msleep(10);
226  }
227 }

Variablen-Dokumentation

gui_handler* old_gui_handler = 0
static

Definiert in Zeile 212 der Datei script.c.

int print_screen_d = -1
static

Definiert in Zeile 39 der Datei script.c.

char print_screen_file[25]

Definiert in Zeile 40 der Datei script.c.

int print_screen_p
static

Definiert in Zeile 38 der Datei script.c.

AS_ID running_script_stack_name = 0
static

Definiert in Zeile 21 der Datei script.c.

int script_terminate_key = KEY_SHOOT_FULL
static

Definiert in Zeile 25 der Datei script.c.

char script_terminate_key_name[20]
static

Definiert in Zeile 26 der Datei script.c.

int script_terminate_request = 0
static

Definiert in Zeile 28 der Datei script.c.

Definiert in Zeile 210 der Datei script.c.