CHDK_DE Vorschauversion  Trunk Rev. 5456
 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 
231  while (1)
232  {
233  // Set up camera mode & state variables
234  mode_get();
235 
236 #ifdef CAM_CLEAN_OVERLAY
237  extern void handle_clean_overlay();
238  handle_clean_overlay();
239 #endif
240  // update HDMI power override based on mode and remote settings
241 #ifdef CAM_REMOTE_HDMI_POWER_OVERRIDE
242  extern void update_hdmi_power_override(void);
243  update_hdmi_power_override();
244 #endif
245 
246  extern void set_palette();
247  set_palette();
248 
249 #if (OPT_DISABLE_CAM_ERROR)
250  dce_nowmode = camera_info.state.mode_play;
251  if (dce_prevmode==dce_nowmode)
252  { //no mode change
253  dce_cnt++; // overflow is not a concern here
254  }
255  else
256  { //mode has changed
257  dce_cnt=0;
258  }
259  if (dce_cnt==100)
260  { // 1..2s past play <-> rec mode change
261  DisableCamError();
262  }
263  dce_prevmode=dce_nowmode;
264 #endif
265 
266  if ( memdmptick && (get_tick_count() >= memdmptick) )
267  {
268  memdmptick = 0;
269  dump_memory();
270  }
271 
272 #ifdef CAM_HAS_GPS
273  if ( --gps_delay_timer == 0 )
274  {
275  gps_delay_timer = 50 ;
276  if ( gps_state != (int)conf.gps_on_off )
277  {
278  gps_state = (int)conf.gps_on_off ;
279  init_gps_startup(!gps_state) ;
280  }
281  }
282 #endif
283 
284  // Change ALT mode if the KBD task has flagged a state change
286 
287 #ifdef CAM_LOAD_CUSTOM_COLORS
288  // Color palette function
289  extern void load_chdk_palette();
291 #endif
292 
293  if (raw_data_available)
294  {
295  raw_process();
296  extern void hook_raw_save_complete();
298  raw_data_available = 0;
299 #ifdef CAM_HAS_GPS
300  if (((int)conf.gps_on_off == 1) && ((int)conf.gps_waypoint_save == 1)) gps_waypoint();
301 #endif
302 #if defined(CAM_CALC_BLACK_LEVEL)
303  // Reset to default in case used by non-RAW process code (e.g. raw merge)
305 #endif
306  continue;
307  }
308 
310  {
311 #ifdef CAM_DETECT_BITMAP_UPDATE
312  extern int check_gui_needs_redraw();
313  int gui_force_redraw = check_gui_needs_redraw();
314 #else
315  int gui_force_redraw = 0;
316 #endif
317  if (gui_force_redraw || (((cnt++) & 3) == 0))
318  gui_redraw(gui_force_redraw);
319  }
320 
322  {
323  if (conf.show_histo)
325 
327  {
328  // We need to skip first tick because stability
329  if (chdk_started_flag)
330  {
332  }
333  }
334  }
335 
337  {
339  }
340 
341  i = 0;
342 
343 #ifdef DEBUG_PRINT_TO_LCD
344  sprintf(osd_buf, "%d", cnt ); // modify cnt to what you want to display
346 #endif
347 #if defined(OPT_FILEIO_STATS)
348  sprintf(osd_buf, "%3d %3d %3d %3d %3d %3d %3d %4d",
349  camera_info.fileio_stats.fileio_semaphore_errors, camera_info.fileio_stats.close_badfile_count,
350  camera_info.fileio_stats.write_badfile_count, camera_info.fileio_stats.open_count,
351  camera_info.fileio_stats.close_count, camera_info.fileio_stats.open_fail_count,
352  camera_info.fileio_stats.close_fail_count, camera_info.fileio_stats.max_semaphore_timeout);
354 #endif
355 
357  {
358  sprintf(osd_buf, "MD last %-4d min %-4d max %-4d avg %-4d",
362  }
363 
364  // Process async module unload requests
366 
367  msleep(20);
369  }
370 }
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 372 der Datei main.c.

372  {
373  if(!file) return -1;
374  return file->pos;
375 }
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.