CHDK_DE Vorschauversion  Trunk Rev. 5573
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
main.c-Dateireferenz
#include "platform.h"
#include "stdlib.h"
#include "core.h"
#include "conf.h"
#include "gui.h"
#include "gui_draw.h"
#include "histogram.h"
#include "raw.h"
#include "console.h"
#include "shooting.h"
#include "edgeoverlay.h"
#include "module_load.h"
#include "kbd_common.h"
+ Include-Abhängigkeitsdiagramm für main.c:

gehe zum Quellcode dieser Datei

Funktionen

void schedule_memdump ()
 
void dump_memory ()
 
int core_get_free_memory ()
 
void core_rawdata_available ()
 
void core_spytask_can_start ()
 
void script_autostart ()
 
void core_spytask ()
 
long ftell (FILE *file)
 

Variablen

static char osd_buf [50]
 
volatile int chdk_started_flag =0
 
int no_modules_flag
 
static volatile int spytask_can_start
 
static unsigned int memdmptick = 0
 
volatile int memdmp_delay = 0
 
static volatile long raw_data_available
 

Dokumentation der Funktionen

int core_get_free_memory ( )

Definiert in Zeile 86 der Datei main.c.

87 {
88  cam_meminfo camera_meminfo;
89  GetCombinedMemInfo(&camera_meminfo);
90  return camera_meminfo.free_block_max_size;
91 }
void core_rawdata_available ( )

Definiert in Zeile 96 der Datei main.c.

97 {
99 }
void core_spytask ( )

Definiert in Zeile 116 der Datei main.c.

117 {
118  int cnt = 1;
119  int i=0;
120 #ifdef CAM_HAS_GPS
121  int gps_delay_timer = 200 ;
122  int gps_state = -1 ;
123 #endif
124 #if (OPT_DISABLE_CAM_ERROR)
125  extern void DisableCamError();
126  int dce_cnt=0;
127  int dce_prevmode=0;
128  int dce_nowmode;
129 #endif
130 
131  parse_version(&chdk_version, BUILD_NUMBER, BUILD_SVNREV);
132 
133  // Init camera_info bits that can't be done statically
135 
137 
138 #if !defined(CAM_DRYOS)
139 // create semaphore to protect Canon memory malloc/free/memPartInfo
140 // on VxWorks, spytask should start before any other CHDK tasks
141  extern void canon_malloc_init(void);
143 #endif
144 
145  extern void aram_malloc_init(void);
147 
148  extern void exmem_malloc_init(void);
150 
151 #ifdef CAM_CHDK_PTP
152  extern void init_chdk_ptp_task();
154 #endif
155 
156  while((i++<1000) && !spytask_can_start) msleep(10);
157 
158  started();
159  msleep(50);
160  finished();
161 
162 #if !CAM_DRYOS
163  drv_self_unhide();
164 #endif
165 
166  conf_restore();
167 
168  extern void gui_init();
169  gui_init();
170 
171 #if CAM_CONSOLE_LOG_ENABLED
172  extern void cam_console_init();
173  cam_console_init();
174 #endif
175 
176  static char *chdk_dirs[] =
177  {
178  "A/CHDK",
179  "A/CHDK/FONTS",
180  "A/CHDK/SYMBOLS",
181  "A/CHDK/SCRIPTS",
182  "A/CHDK/LANG",
183  "A/CHDK/BOOKS",
184  "A/CHDK/MODULES",
185  "A/CHDK/MODULES/CFG",
186  "A/CHDK/GRIDS",
187  "A/CHDK/CURVES",
188  "A/CHDK/DATA",
189  "A/CHDK/LOGS",
190  "A/CHDK/EDGE",
191  };
192  for (i = 0; i < sizeof(chdk_dirs) / sizeof(char*); i++)
193  mkdir_if_not_exist(chdk_dirs[i]);
194 
195  no_modules_flag = stat("A/CHDK/MODULES/FSELECT.FLT",0) ? 1 : 0 ;
196 
197  // Calculate the value of get_tick_count() when the clock ticks over to the next second
198  // Used to calculate the SubSecondTime value when saving DNG files.
199  long t1, t2;
200  t2 = time(0);
201  do
202  {
203  t1 = t2;
205  t2 = time(0);
206  msleep(10);
207  } while (t1 != t2);
209 
210  // remote autostart
212  {
214  }
216  {
218  conf_save();
220  }
221 
222  shooting_init();
223 
224  // if starting with HDMI connected, suspend drawing for 3s to avoid crashes
225 #ifdef HDMI_HPD_FLAG
226  if(get_hdmi_hpd_physw_mod()) {
227  draw_suspend(3000);
228  }
229 #endif
230 
232  module_run("fwcrc.flt");
233  }
234 
235  while (1)
236  {
237  // Set up camera mode & state variables
238  mode_get();
239 
240 #ifdef CAM_CLEAN_OVERLAY
241  extern void handle_clean_overlay();
242  handle_clean_overlay();
243 #endif
244 
245 #ifdef CAM_UNLOCK_ANALOG_AV_IN_REC
246  extern void handle_analog_av_in_rec();
247  handle_analog_av_in_rec();
248 #endif
249  // update HDMI power override based on mode and remote settings
250 #ifdef CAM_REMOTE_HDMI_POWER_OVERRIDE
251  extern void update_hdmi_power_override(void);
252  update_hdmi_power_override();
253 #endif
254 
255  extern void set_palette();
256  set_palette();
257 
258 #if (OPT_DISABLE_CAM_ERROR)
259  dce_nowmode = camera_info.state.mode_play;
260  if (dce_prevmode==dce_nowmode)
261  { //no mode change
262  dce_cnt++; // overflow is not a concern here
263  }
264  else
265  { //mode has changed
266  dce_cnt=0;
267  }
268  if (dce_cnt==100)
269  { // 1..2s past play <-> rec mode change
270  DisableCamError();
271  }
272  dce_prevmode=dce_nowmode;
273 #endif
274 
275  if ( memdmptick && (get_tick_count() >= memdmptick) )
276  {
277  memdmptick = 0;
278  dump_memory();
279  }
280 
281 #ifdef CAM_HAS_GPS
282  if ( --gps_delay_timer == 0 )
283  {
284  gps_delay_timer = 50 ;
285  if ( gps_state != (int)conf.gps_on_off )
286  {
287  gps_state = (int)conf.gps_on_off ;
288  init_gps_startup(!gps_state) ;
289  }
290  }
291 #endif
292 
293  // Change ALT mode if the KBD task has flagged a state change
295 
296 #ifdef CAM_LOAD_CUSTOM_COLORS
297  // Color palette function
298  extern void load_chdk_palette();
300 #endif
301 
302  if (raw_data_available)
303  {
304  raw_process();
305  extern void hook_raw_save_complete();
307  raw_data_available = 0;
308 #ifdef CAM_HAS_GPS
309  if (((int)conf.gps_on_off == 1) && ((int)conf.gps_waypoint_save == 1)) gps_waypoint();
310 #endif
311 #if defined(CAM_CALC_BLACK_LEVEL)
312  // Reset to default in case used by non-RAW process code (e.g. raw merge)
314 #endif
315  continue;
316  }
317 
319  {
320 #ifdef CAM_DETECT_BITMAP_UPDATE
321  extern int check_gui_needs_redraw();
322  int gui_force_redraw = check_gui_needs_redraw();
323 #else
324  int gui_force_redraw = 0;
325 #endif
326  if (gui_force_redraw || (((cnt++) & 3) == 0))
327  gui_redraw(gui_force_redraw);
328  }
329 
331  {
332  if (conf.show_histo)
334 
336  {
337  // We need to skip first tick because stability
338  if (chdk_started_flag)
339  {
341  }
342  }
343  }
344 
346  {
348  }
349 
350  i = 0;
351 
352 #ifdef DEBUG_PRINT_TO_LCD
353  sprintf(osd_buf, "%d", cnt ); // modify cnt to what you want to display
355 #endif
356 #if defined(OPT_FILEIO_STATS)
357  sprintf(osd_buf, "%3d %3d %3d %3d %3d %3d %3d %4d",
358  camera_info.fileio_stats.fileio_semaphore_errors, camera_info.fileio_stats.close_badfile_count,
359  camera_info.fileio_stats.write_badfile_count, camera_info.fileio_stats.open_count,
360  camera_info.fileio_stats.close_count, camera_info.fileio_stats.open_fail_count,
361  camera_info.fileio_stats.close_fail_count, camera_info.fileio_stats.max_semaphore_timeout);
363 #endif
364 
366  {
367  sprintf(osd_buf, "MD last %-4d min %-4d max %-4d avg %-4d",
371  }
372 
373  // Process async module unload requests
375 
376  msleep(20);
378  }
379 }
void core_spytask_can_start ( )

Definiert in Zeile 101 der Datei main.c.

101  {
102  spytask_can_start = 1;
103 }
void dump_memory ( )

Definiert in Zeile 41 der Datei main.c.

42 {
43  int fd;
44  static int cnt=1;
45  static char fn[32];
46 
47  // zero size means all RAM
48  if (conf.memdmp_size == 0) conf.memdmp_size = (unsigned int)camera_info.maxramaddr + 1;
49  // enforce RAM area
50  if ((unsigned int)conf.memdmp_start > (unsigned int)camera_info.maxramaddr)
51  conf.memdmp_start = 0;
52  if ( (unsigned int)conf.memdmp_start + (unsigned int)conf.memdmp_size > ((unsigned int)camera_info.maxramaddr+1) )
53  conf.memdmp_size = (unsigned int)camera_info.maxramaddr + 1 - (unsigned int)conf.memdmp_start;
54 
55  started();
56  // try to avoid hanging the camera
57  if ( !is_video_recording() ) {
58  mkdir("A/DCIM");
59  mkdir("A/DCIM/100CANON");
60  fd = -1;
61  do {
62  sprintf(fn, "A/DCIM/100CANON/CRW_%04d.JPG", cnt++);
63  if (stat(fn,0) != 0) {
64  fd = open(fn, O_WRONLY|O_CREAT, 0777);
65  break;
66  }
67  } while(cnt<9999);
68  if (fd>=0) {
69  if ( conf.memdmp_start == 0 ) {
70  long val0 = *((long*)(0|CAM_UNCACHED_BIT));
71  write(fd, &val0, 4);
72  if (conf.memdmp_size > 4) {
73  write(fd, (void*)4, conf.memdmp_size - 4);
74  }
75  }
76  else {
77  write(fd, (void*)conf.memdmp_start, conf.memdmp_size);
78  }
79  close(fd);
80  }
82  }
83  finished();
84 }
long ftell ( FILE file)

Definiert in Zeile 381 der Datei main.c.

381  {
382  if(!file) return -1;
383  return file->pos;
384 }
void schedule_memdump ( )

Definiert in Zeile 36 der Datei main.c.

37 {
39 }
void script_autostart ( )

Definiert in Zeile 106 der Datei main.c.

107 {
108  // Tell keyboard task we are in <ALT> mode
109  enter_alt();
110  // We were called from the GUI task so switch to <ALT> mode before switching to Script mode
112  // Switch to script mode and start the script running
113  script_start_gui( 1 );
114 }

Variablen-Dokumentation

volatile int chdk_started_flag =0

Definiert in Zeile 27 der Datei main.c.

volatile int memdmp_delay = 0

Definiert in Zeile 34 der Datei main.c.

unsigned int memdmptick = 0
static

Definiert in Zeile 33 der Datei main.c.

int no_modules_flag

Definiert in Zeile 29 der Datei main.c.

char osd_buf[50]
static

Definiert in Zeile 23 der Datei main.c.

volatile long raw_data_available
static

Definiert in Zeile 93 der Datei main.c.

volatile int spytask_can_start
static

Definiert in Zeile 31 der Datei main.c.