Commit e3962153 authored by a1ex's avatar a1ex
Browse files

Removed duplicate console_printf/printf implementations (replaced by printf...

Removed duplicate console_printf/printf implementations (replaced by printf everywhere); larger buffer for printf

--HG--
branch : printf
parent c8c0c20253e8
......@@ -126,7 +126,7 @@ static void post_deflicker_task()
deflicker_waiting--;
int raw_fast = raw_hist_get_percentile_level(post_deflicker_percentile*10, GRAY_PROJECTION_GREEN, 4);
//~ console_printf("fast deflick: %d\n", raw_fast);
//~ printf("fast deflick: %d\n", raw_fast);
int raw = raw_fast;
/* no rush? do a precise deflicker */
......@@ -138,10 +138,10 @@ static void post_deflicker_task()
if (!deflicker_waiting)
{
int raw_precise = raw_hist_get_percentile_level(post_deflicker_percentile*10, GRAY_PROJECTION_GREEN, 0);
//~ console_printf("precise deflick: %d\n", raw_precise);
//~ printf("precise deflick: %d\n", raw_precise);
if (raw_precise > 0 && raw_precise < 16384) raw = raw_precise;
}
//~ else console_printf("hurry, hurry\n");
//~ else printf("hurry, hurry\n");
if (raw <= 0 || raw >= 16384)
{
......@@ -158,7 +158,7 @@ static void post_deflicker_task()
float correction = post_deflicker_target_level - ev;
deflicker_last_correction_x100 = (int)roundf(correction * 100);
console_printf("deflick corr: %s%d.%02d\n", FMT_FIXEDPOINT2S(deflicker_last_correction_x100));
printf("deflick corr: %s%d.%02d\n", FMT_FIXEDPOINT2S(deflicker_last_correction_x100));
post_deflicker_save_sidecar_file_for_cr2(post_deflicker_sidecar_type, get_shooting_card()->file_number, correction);
give_semaphore(deflicker_sem);
}
......
......@@ -159,7 +159,7 @@ static void clear_file_menu()
{
struct file_entry * next = file_entries->next;
menu_remove("File Manager", file_entries->menu_entry, 1);
//console_printf("%s\n", file_entries->name);
//printf("%s\n", file_entries->name);
free(file_entries);
file_entries = next;
}
......@@ -377,8 +377,8 @@ static void ScanDir(char *path)
while (p > srcpath && *p != '/') p--;
*(p+1) = 0;
console_printf("src: %s\n",srcpath);
console_printf("dst: %s\n",path);
printf("src: %s\n",srcpath);
printf("dst: %s\n",path);
if(strcmp(path,srcpath) != 0)
{
......
......@@ -39,7 +39,7 @@ static int luaCB_console_hide(lua_State * L)
*/
static int luaCB_console_write(lua_State * L)
{
if(lua_isstring(L, 1)) console_puts(lua_tostring(L, 1));
if(lua_isstring(L, 1)) puts(lua_tostring(L, 1));
return 0;
}
......
......@@ -632,7 +632,7 @@ static int add_mem_suite(struct memSuite * mem_suite, int buf_size, int chunk_in
ptr += frame_size;
size -= frame_size;
slot_count++;
//~ console_printf("slot #%d: %d %x\n", slot_count, tag, ptr);
//~ printf("slot #%d: %d %x\n", slot_count, tag, ptr);
}
}
chunk = GetNextMemoryChunk(mem_suite, chunk);
......@@ -1309,7 +1309,7 @@ static int FAST process_frame()
return 0;
}
//~ console_printf("saving frame %d: slot %d ptr %x\n", frame_count, capture_slot, ptr);
//~ printf("saving frame %d: slot %d ptr %x\n", frame_count, capture_slot, ptr);
int ans = (int) edmac_copy_rectangle_start(ptr, fullSizeBuffer, raw_info.pitch, (skip_x+7)/8*14, skip_y/2*2, res_x*14/8, res_y);
......@@ -1568,7 +1568,7 @@ static void raw_video_rec_task()
int frame_limit = overflow_time * 1024 / 10 * (measured_write_speed * 9 / 100) * 1024 / frame_size / 10;
if (frame_limit >= 0 && frame_limit < num_frames)
{
//~ console_printf("careful, will overflow in %d.%d seconds, better write only %d frames\n", overflow_time/10, overflow_time%10, frame_limit);
//~ printf("careful, will overflow in %d.%d seconds, better write only %d frames\n", overflow_time/10, overflow_time%10, frame_limit);
num_frames = MAX(1, frame_limit - 1);
}
}
......
......@@ -337,7 +337,7 @@ static void script_define_param_variables(void* tcc, void* script_state)
p--;
int _varname = 'a' + p;
char* varname = (char*)&_varname;
console_printf(" Param %s = %d; // %s\n", varname, conf_script_vars[p], script_params[p]);
printf(" Param %s = %d; // %s\n", varname, conf_script_vars[p], script_params[p]);
module_exec(tcc, "tcc_add_symbol", 3, script_state, varname, &conf_script_vars[p]);
}
}
......@@ -18,20 +18,20 @@ static int script_load_symbols(void* tcc, void* script_state, char *filename)
if( FIO_GetFileSize( filename, &size ) != 0 )
{
console_printf("Error loading '%s': File does not exist\n", filename);
printf("Error loading '%s': File does not exist\n", filename);
return -1;
}
buf = fio_malloc(size);
if(!buf)
{
console_printf("Error loading '%s': File too large\n", filename);
printf("Error loading '%s': File too large\n", filename);
return -1;
}
file = FIO_OpenFile(filename, O_RDONLY | O_SYNC);
if(!file)
{
console_printf("Error loading '%s': File does not exist\n", filename);
printf("Error loading '%s': File does not exist\n", filename);
fio_free(buf);
return -1;
}
......@@ -85,7 +85,7 @@ static int script_load_symbols(void* tcc, void* script_state, char *filename)
static int tcc_compile_and_run(char* filename)
{
console_printf("Compiling script %s...\n", filename);
printf("Compiling script %s...\n", filename);
void* tcc = NULL;
TCCState * script_state = NULL;
......@@ -94,14 +94,14 @@ static int tcc_compile_and_run(char* filename)
tcc = module_load("ML/MODULES/tcc.mo");
if (!tcc)
{
console_printf("Could not load TCC compiler.\n");
printf("Could not load TCC compiler.\n");
goto err;
}
script_state = (void*) module_exec(tcc, "tcc_new", 0);
if (!script_state)
{
console_printf("Could not initialize TCC compiler.\n");
printf("Could not initialize TCC compiler.\n");
goto err;
}
......@@ -113,7 +113,7 @@ static int tcc_compile_and_run(char* filename)
int ret_compile = module_exec(tcc, "tcc_add_file", 2, script_state, filename);
if (ret_compile < 0)
{
console_printf("Compilation error.\n");
printf("Compilation error.\n");
goto err;
}
......@@ -122,28 +122,28 @@ static int tcc_compile_and_run(char* filename)
int size = module_exec(tcc, "tcc_relocate", 2, script_state, NULL);
if (size <= 0)
{
console_printf("Linking error.\n");
printf("Linking error.\n");
goto err;
}
script_buf = (void*) tcc_malloc(size);
if (!script_buf)
{
console_printf("Malloc error.\n");
printf("Malloc error.\n");
goto err;
}
int ret_link = module_exec(tcc, "tcc_relocate", 2, script_state, script_buf);
if (ret_link < 0)
{
console_printf("Relocate error.\n");
printf("Relocate error.\n");
goto err;
}
void (*script_main)() = (void*) module_exec(tcc, "tcc_get_symbol", 2, script_state, "main");
if (!script_main)
{
console_printf("Your script should have a main function.\n");
printf("Your script should have a main function.\n");
goto err;
}
......@@ -152,7 +152,7 @@ static int tcc_compile_and_run(char* filename)
module_exec(tcc, "tcc_delete", 1, script_state); script_state = NULL;
module_unload(tcc); tcc = NULL;
console_printf("Running script %s...\n", filename);
printf("Running script %s...\n", filename);
/* http://repo.or.cz/w/tinycc.git/commit/6ed6a36a51065060bd5e9bb516b85ff796e05f30 */
sync_caches();
......@@ -398,11 +398,11 @@ static void run_script(const char *script)
int exit_code = tcc_compile_and_run(get_script_path(script_selected));
if (exit_code == 0)
{
console_puts( "Script finished.\n");
puts( "Script finished.\n");
}
else
{
console_printf( "Script error: %d.\n", exit_code);
printf( "Script error: %d.\n", exit_code);
msleep(500);
gui_stop_menu();
msleep(500);
......
......@@ -807,7 +807,7 @@ static int silent_pic_raw_prepare_buffers(struct memSuite * hSuite)
int size = GetSizeOfMemoryChunk(hChunk);
int used = ptr - ptr0;
int remain = size - used;
//~ console_printf("remain: %x\n", remain);
//~ printf("remain: %x\n", remain);
/* the EDMAC might write a bit more than that, so we'll use a small safety margin */
if (remain < raw_info.frame_size * 33/32)
......@@ -816,22 +816,22 @@ static int silent_pic_raw_prepare_buffers(struct memSuite * hSuite)
hChunk = GetNextMemoryChunk(hSuite, hChunk);
if (!hChunk)
{
//~ console_printf("no more memory\n");
//~ printf("no more memory\n");
break;
}
ptr = (void*) GetMemoryAddressOfMemoryChunk(hChunk);
//~ console_printf("next chunk: %x %x\n", hChunk, ptr);
//~ printf("next chunk: %x %x\n", hChunk, ptr);
continue;
}
else /* alright, a new frame fits here */
{
//~ console_printf("FRAME %d: hSuite=%x hChunk=%x ptr=%x\n", count, hSuite, hChunk, ptr);
//~ printf("FRAME %d: hSuite=%x hChunk=%x ptr=%x\n", count, hSuite, hChunk, ptr);
sp_frames[count] = ptr;
count++;
ptr = ptr + raw_info.frame_size;
if (count >= SP_BUFFER_SIZE)
{
//~ console_printf("we have lots of RAM, lol\n");
//~ printf("we have lots of RAM, lol\n");
break;
}
}
......
......@@ -43,7 +43,7 @@ unsigned int tinypy_deinit()
{
while (tinypy_running)
{
console_printf("waiting for script...\n");
printf("waiting for script...\n");
msleep(1000);
}
......
......@@ -776,6 +776,6 @@ INIT_FUNC("audio.init", audio_menus_init);
#ifdef FEATURE_MIC_POWER
void mic_out(int val)
{
console_printf("Fixme: not implemented\n");
printf("Fixme: not implemented\n");
}
#endif
......@@ -19,9 +19,6 @@
#undef CONSOLE_DEBUG // logs things to file etc
int console_printf(const char* fmt, ...); // how to replace the normal printf?
#define printf console_printf
#define CONSOLE_W 80
#define CONSOLE_H 21
#define CONSOLE_FONT FONT_MONO_20
......@@ -108,7 +105,7 @@ static void console_init()
#endif
}
void console_puts(const char* str) // don't DebugMsg from here!
static void console_puts(const char* str) // don't DebugMsg from here!
{
#define NEW_CHAR(c) CONSOLE_BUFFER(console_buffer_index++) = (c)
......@@ -177,26 +174,6 @@ void console_puts(const char* str) // don't DebugMsg from here!
console_buffer_index = MOD(console_buffer_index, BUFSIZE);
}
int console_printf(const char* fmt, ...) // don't DebugMsg from here!
{
char buf[256];
va_list ap;
va_start( ap, fmt );
int len = vsnprintf( buf, 255, fmt, ap );
va_end( ap );
console_puts(buf);
return len;
}
// used from Lua
int console_vprintf(const char* fmt, va_list ap) // don't DebugMsg from here!
{
char buf[256];
int len = vsnprintf( buf, 255, fmt, ap );
console_puts(buf);
return len;
}
void console_show_status()
{
int fnt = FONT(CONSOLE_FONT,60, COLOR_BLACK);
......@@ -357,3 +334,35 @@ console_task( void* unused )
}
TASK_CREATE( "console_task", console_task, 0, 0x1d, 0x1000 );
/* some functions from standard I/O */
int printf(const char* fmt, ...)
{
char buf[512];
va_list ap;
va_start( ap, fmt );
int len = vsnprintf( buf, sizeof(buf)-1, fmt, ap );
va_end( ap );
console_puts(buf);
return len;
}
int puts(const char * fmt)
{
console_puts(fmt);
console_puts("\n");
return 0;
}
int fputs(FILE* unused, const char * fmt)
{
console_puts(fmt);
return 0;
}
int putchar(int c)
{
console_puts((char*)&c);
return c;
}
......@@ -2,10 +2,6 @@
#define _CONSOLE_H_
// console
void console_puts( const char* str );
int console_vprintf( const char* fmt, va_list ap );
int console_printf( const char* fmt, ... );
void console_show();
void console_hide();
......
......@@ -434,14 +434,14 @@ static void run_test()
/* check for memory leaks */
for (int i = 0; i < 1000; i++)
{
console_printf("%d/1000\n", i);
printf("%d/1000\n", i);
/* with this large size, the backend will use fio_malloc, which returns uncacheable pointers */
void* p = malloc(16*1024*1024 + 64);
if (!p)
{
console_printf("malloc err\n");
printf("malloc err\n");
continue;
}
......@@ -462,7 +462,7 @@ static void run_test()
//~ bfnt_test();
#ifdef FEATURE_SHOW_SIGNATURE
console_show();
console_printf("FW Signature: 0x%08x", compute_signature((int*)SIG_START, SIG_LEN));
printf("FW Signature: 0x%08x", compute_signature((int*)SIG_START, SIG_LEN));
msleep(1000);
return;
#endif
......@@ -506,15 +506,15 @@ static void run_test()
#ifdef CONFIG_MODULES
console_show();
console_printf("Loading modules...\n");
printf("Loading modules...\n");
msleep(1000);
module_load_all();
return;
console_printf("\n");
printf("\n");
console_printf("Testing TCC executable...\n");
console_printf(" [i] this may take some time\n");
printf("Testing TCC executable...\n");
printf(" [i] this may take some time\n");
msleep(1000);
for(int try = 0; try < 100; try++)
......@@ -528,7 +528,7 @@ static void run_test()
ret = module_exec(module, "tcc_new", 0);
if(!(ret & 0x40000000))
{
console_printf("tcc_new() returned: 0x%08X\n", ret);
printf("tcc_new() returned: 0x%08X\n", ret);
}
else
{
......@@ -538,11 +538,11 @@ static void run_test()
}
else
{
console_printf(" [E] load failed\n");
printf(" [E] load failed\n");
}
}
console_printf("Done!\n");
printf("Done!\n");
#endif
}
......@@ -1001,7 +1001,7 @@ static void next_tick_cbr(int arg1, void* arg2)
SetHPTimerNextTick(arg1, 100000, timer_cbr, overrun_cbr, 0);
}
#define TEST_MSG(fmt, ...) { if (!silence || !ok) log_len += snprintf(log_buf + log_len, maxlen - log_len, fmt, ## __VA_ARGS__); console_printf(fmt, ## __VA_ARGS__); }
#define TEST_MSG(fmt, ...) { if (!silence || !ok) log_len += snprintf(log_buf + log_len, maxlen - log_len, fmt, ## __VA_ARGS__); printf(fmt, ## __VA_ARGS__); }
#define TEST_TRY_VOID(x) { x; ok = 1; TEST_MSG(" %s\n", #x); }
#define TEST_TRY_FUNC(x) { int ans = (int)(x); ok = 1; TEST_MSG(" %s => 0x%x\n", #x, ans); }
#define TEST_TRY_FUNC_CHECK(x, condition) { int ans = (int)(x); ok = ans condition; TEST_MSG("[%s] %s => 0x%x\n", ok ? "Pass" : "FAIL", #x, ans); if (ok) passed_tests++; else failed_tests++; }
......@@ -1501,7 +1501,7 @@ static void stub_test_task(void* arg)
}
fio_free(log_buf);
console_printf(
printf(
"=========================================================\n"
"Test complete, %d passed, %d failed.\n.",
passed_tests, failed_tests
......@@ -2266,7 +2266,7 @@ static void save_crash_log()
}
else
{
console_printf("%s\n", get_assert_msg());
printf("%s\n", get_assert_msg());
console_show();
}
......@@ -3232,7 +3232,7 @@ debug_property_handler(
{
const uint32_t * const addr = buf;
/*console_printf("Prop %08x: %2x: %08x %08x %08x %08x\n",
/*printf("Prop %08x: %2x: %08x %08x %08x %08x\n",
property,
len,
len > 0x00 ? addr[0] : 0,
......
......@@ -127,7 +127,6 @@ LoadCalendarFromRTC(
);
extern void DryosDebugMsg(int,int,const char *,...);
//~ #define DebugMsg(a,b,fmt,...) { console_printf(fmt "\n", ## __VA_ARGS__); DryosDebugMsg(a,b,fmt, ## __VA_ARGS__); }
/** custom functions */
// group starts from 0, number starts from 1
......@@ -165,6 +164,7 @@ extern int call( const char* name, ... );
// stdio
extern int vsnprintf( char* str, size_t n, const char* fmt, va_list ap ); // non-standard; don't export it
extern int printf(const char* fmt, ... );
extern int puts(const char* s);
extern size_t strlen( const char* str );
extern int snprintf( char* str, size_t n, const char* fmt, ... );
......
......@@ -341,7 +341,7 @@ void find_free_edmac_channels()
if (lv)
{
bmp_printf(FONT_MED, 50, 70, "Write channel #%d seems to work", ch);
console_printf("Write channel #%d seems to work\n", ch);
printf("Write channel #%d seems to work\n", ch);
beep();
}
msleep(2000);
......@@ -363,7 +363,7 @@ void find_free_edmac_channels()
if (lv)
{
bmp_printf(FONT_MED, 50, 70, "Read channel #%d seems to work", ch);
console_printf("Read channel #%d seems to work\n", ch);
printf("Read channel #%d seems to work\n", ch);
beep();
}
msleep(2000);
......
......@@ -1255,12 +1255,12 @@ static void menu_remove_entry(struct menu * menu, struct menu_entry * entry)
}
if (entry->prev)
{
// console_printf("link %s to %x\n", entry->prev->name, entry->next);
// printf("link %s to %x\n", entry->prev->name, entry->next);
entry->prev->next = entry->next;
}
if (entry->next)
{
// console_printf("link %s to %x\n", entry->next->name, entry->prev);
// printf("link %s to %x\n", entry->next->name, entry->prev);
entry->next->prev = entry->prev;
}
......@@ -1271,7 +1271,7 @@ static void menu_remove_entry(struct menu * menu, struct menu_entry * entry)
struct menu * submenu = menu_find_by_name( entry->name, ICON_ML_SUBMENU);
if (submenu)
{
// console_printf("unlink submenu %s\n", submenu->name);
// printf("unlink submenu %s\n", submenu->name);
submenu->children = 0;
}
}
......@@ -1281,7 +1281,7 @@ static void menu_remove_entry(struct menu * menu, struct menu_entry * entry)
{
if (streq(placeholder->name, entry->name))
{
// console_printf("restore placeholder %s\n", entry->name);
// printf("restore placeholder %s\n", entry->name);
struct menu_entry restored_placeholder = MENU_PLACEHOLDER(placeholder->name);
placeholder_copy(placeholder, &restored_placeholder);
break;
......@@ -5584,7 +5584,7 @@ end:
int menu_get_value_from_script(const char* name, const char* entry_name)
{
struct menu_entry * entry = entry_find_by_name(name, entry_name);
if (!entry) { console_printf("Menu not found: %s -> %s\n", name, entry->name); return 0; }
if (!entry) { printf("Menu not found: %s -> %s\n", name, entry->name); return 0; }
return CURRENT_VALUE;
}
......@@ -5592,7 +5592,7 @@ int menu_get_value_from_script(const char* name, const char* entry_name)
char* menu_get_str_value_from_script(const char* name, const char* entry_name)
{
struct menu_entry * entry = entry_find_by_name(name, entry_name);
if (!entry) { console_printf("Menu not found: %s -> %s\n", name, entry->name); return 0; }
if (!entry) { printf("Menu not found: %s -> %s\n", name, entry->name); return 0; }
// this won't work with ML menu on (race condition)
static struct menu_display_info info;
......@@ -5604,7 +5604,7 @@ char* menu_get_str_value_from_script(const char* name, const char* entry_name)
int menu_set_str_value_from_script(const char* name, const char* entry_name, char* value, int value_int)
{
struct menu_entry * entry = entry_find_by_name(name, entry_name);
if (!entry) { console_printf("Menu not found: %s -> %s\n", name, entry->name); return 0; }
if (!entry) { printf("Menu not found: %s -> %s\n", name, entry->name); return 0; }
// we will need exclusive access to menu_display_info
take_semaphore(menu_sem, 0);
......@@ -5629,7 +5629,7 @@ int menu_set_str_value_from_script(const char* name, const char* entry_name, cha
if (i > 0 && streq(current, last)) // value not changing? stop here
{
console_printf("Value not changing: %s.\n", current);
printf("Value not changing: %s.\n", current);
break;
}
......@@ -5638,7 +5638,7 @@ int menu_set_str_value_from_script(const char* name, const char* entry_name, cha
// for debugging, print this always
if (i > 50 && i % 10 == 0) // it's getting fishy, maybe it's good to show some progress
console_printf("menu_set_str('%s', '%s', '%s'): trying %s (%d), was %s...\n", name, entry_name, value, current, CURRENT_VALUE, last);
printf("menu_set_str('%s', '%s', '%s'): trying %s (%d), was %s...\n", name, entry_name, value, current, CURRENT_VALUE, last);
snprintf(last, sizeof(last), "%s", current);
......@@ -5648,7 +5648,7 @@ int menu_set_str_value_from_script(const char* name, const char* entry_name, cha
msleep(20); // we may need to wait for property handlers to update
}
console_printf("Could not set value '%s' for menu %s -> %s\n", value, name, entry_name);
printf("Could not set value '%s' for menu %s -> %s\n", value, name, entry_name);
give_semaphore(menu_sem);
return 0; // boo :(
......@@ -5660,7 +5660,7 @@ ok:
int menu_set_value_from_script(const char* name, const char* entry_name, int value)
{
struct menu_entry * entry = entry_find_by_name(name, entry_name);
if (!entry) { console_printf("Menu not found: %s -> %s\n", name, entry->name); return 0; }
if (!entry) { printf("Menu not found: %s -> %s\n", name, entry->name); return 0; }
if( entry->select ) // special item, we need some heuristics
{
......@@ -5676,7 +5676,7 @@ int menu_set_value_from_script(const char* name, const char* entry_name, int val
}
else // unknown
{
console_printf("Cannot set value for %s -> %s\n", name, entry->name);
printf("Cannot set value for %s -> %s\n", name, entry->name);
return 0; // boo :(
}
}
......
......@@ -24,7 +24,7 @@
#define UNLOCK give_semaphore
#if ML_CBR_DEBUG
#define dbg_printf(fmt,...) do { console_printf(fmt, ## __VA_ARGS__); } while(0)
#define dbg_printf(fmt,...) do { printf(fmt, ## __VA_ARGS__); } while(0)
#else
#define dbg_printf(fmt,...) do {} while(0)
#endif
......
......@@ -54,20 +54,20 @@ static int module_load_symbols(TCCState *s, char *filename)
if( FIO_GetFileSize( filename, &size ) != 0 )
{
console_printf("Error loading '%s': File does not exist\n", filename);
printf("Error loading '%s': File does not exist\n", filename);
return -1;
}
buf = fio_malloc(size);
if(!buf)
{
console_printf("Error loading '%s': File too large\n", filename);
printf("Error loading '%s': File too large\n", filename);
return -1;
}
file = FIO_OpenFile(filename, O_RDONLY | O_SYNC);
if (!file)
{
console_printf("Error loading '%s': File does not exist\n", filename);