CHDK_DE Vorschauversion  Trunk Rev. 5234
 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-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 84 der Datei main.c.

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

Definiert in Zeile 94 der Datei main.c.

95 {
97 }
void core_spytask ( )

Definiert in Zeile 114 der Datei main.c.

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

Definiert in Zeile 99 der Datei main.c.

99  {
100  spytask_can_start = 1;
101 }
void dump_memory ( )

Definiert in Zeile 39 der Datei main.c.

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

Definiert in Zeile 352 der Datei main.c.

352  {
353  if(!file) return -1;
354  return file->pos;
355 }
void schedule_memdump ( )

Definiert in Zeile 34 der Datei main.c.

35 {
37 }
void script_autostart ( )

Definiert in Zeile 104 der Datei main.c.

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

Variablen-Dokumentation

volatile int chdk_started_flag =0

Definiert in Zeile 25 der Datei main.c.

volatile int memdmp_delay = 0

Definiert in Zeile 32 der Datei main.c.

unsigned int memdmptick = 0
static

Definiert in Zeile 31 der Datei main.c.

int no_modules_flag

Definiert in Zeile 27 der Datei main.c.

char osd_buf[50]
static

Definiert in Zeile 21 der Datei main.c.

volatile long raw_data_available
static

Definiert in Zeile 91 der Datei main.c.

volatile int spytask_can_start
static

Definiert in Zeile 29 der Datei main.c.