Skip to content

Commit

Permalink
renames and cleanup in preparation for making script optional. From u…
Browse files Browse the repository at this point in the history
  • Loading branch information
reyalp committed Nov 16, 2010
1 parent eaea51f commit 9fcd476
Show file tree
Hide file tree
Showing 61 changed files with 93 additions and 95 deletions.
10 changes: 5 additions & 5 deletions core/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,29 @@ static void conf_change_grid_file();
static void conf_change_video_bitrate();
static void conf_change_dng_ext();

void ubasic_camera_set_raw(int mode)
void camera_set_raw(int mode)
{
conf.save_raw = mode;
}

void ubasic_camera_set_nr(int mode)
void camera_set_nr(int mode)
{
// "Auto", "Off", "On"
conf.raw_nr = mode;
}
int ubasic_camera_script_autostart()
int camera_get_script_autostart()
{
// 1 = Autostarted
return auto_started;
}

void ubasic_camera_set_script_autostart(int state)
void camera_set_script_autostart(int state)
{
// 1 = Autostarted
auto_started = state;
}

int ubasic_camera_get_nr()
int camera_get_nr()
{
// "Auto", "Off", "On"
return conf.raw_nr;
Expand Down
1 change: 0 additions & 1 deletion core/gui_palette.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "keyboard.h"
#include "conf.h"
#include "lang.h"
#include "ubasic.h"
#include "gui.h"
#include "gui_draw.h"
#include "gui_lang.h"
Expand Down
1 change: 0 additions & 1 deletion core/histogram.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "keyboard.h"
#include "conf.h"
#include "math.h"
#include "ubasic.h"
#include "gui.h"
#include "gui_draw.h"
#include "histogram.h"
Expand Down
4 changes: 2 additions & 2 deletions core/kbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ void script_start( int autostart )
script_console_add_line(lang_str(LANG_CONSOLE_TEXT_STARTED));

if( is_lua() ) {
if( !lua_script_start(state_ubasic_script) ) {
if( !lua_script_start(script_source_str) ) {
script_print_screen_end();
wait_and_end();
return;
Expand All @@ -345,7 +345,7 @@ void script_start( int autostart )
}
state_lua_kbd_first_call_to_resume = 1;
} else { // ubasic
ubasic_init(state_ubasic_script);
ubasic_init(script_source_str);

for (i=0; i<SCRIPT_NUM_PARAMS; ++i) {
ubasic_set_variable(i, conf.ubasic_vars[i]);
Expand Down
10 changes: 5 additions & 5 deletions core/luascript.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ static int luaCB_set_led( lua_State* L )
to2 = 200;
if( lua_isnumber( L, 3 ) )
to2 = lua_tonumber( L, 3 );
ubasic_set_led(to, to1, to2);
camera_set_led(to, to1, to2);
return 0;
}

Expand All @@ -352,19 +352,19 @@ static int luaCB_set_prop( lua_State* L )

static int luaCB_set_raw_nr( lua_State* L )
{
ubasic_camera_set_nr(luaL_checknumber( L, 1 ));
camera_set_nr(luaL_checknumber( L, 1 ));
return 0;
}

static int luaCB_get_raw_nr( lua_State* L )
{
lua_pushnumber( L, ubasic_camera_get_nr() );
lua_pushnumber( L, camera_get_nr() );
return 1;
}

static int luaCB_set_raw( lua_State* L )
{
ubasic_camera_set_raw(luaL_checknumber( L, 1 ));
camera_set_raw(luaL_checknumber( L, 1 ));
return 0;
}

Expand Down Expand Up @@ -521,7 +521,7 @@ static int luaCB_md_detect_motion( lua_State* L )

static int luaCB_autostarted( lua_State* L )
{
lua_pushboolean( L, ubasic_camera_script_autostart() );
lua_pushboolean( L, camera_get_script_autostart() );
return 1;
}

Expand Down
12 changes: 6 additions & 6 deletions core/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define SCRIPT_MAX_LINE_LENGTH 45

//-------------------------------------------------------------------
const char *state_ubasic_script=NULL; //ERR99
const char *script_source_str=NULL; //ERR99
char cfg_name[100] = "\0";
char cfg_set_name[100] = "\0";
int script_console_num_lines, script_console_line_length, script_console_x, script_console_y, auto_redraw=1;
Expand Down Expand Up @@ -134,7 +134,7 @@ static void process_default(const char *param, char update) {

//-------------------------------------------------------------------
static void script_scan(const char *fn, int update_vars) {
register const char *ptr = state_ubasic_script;
register const char *ptr = script_source_str;
register int i, j=0, n;
char *c;

Expand Down Expand Up @@ -335,10 +335,10 @@ void script_load(const char *fn, int saved_params) {

// save_params_values(0);

if(state_ubasic_script && state_ubasic_script != ubasic_script_default)
free((void *)state_ubasic_script);
if(script_source_str && script_source_str != ubasic_script_default)
free((void *)script_source_str);

state_ubasic_script = ubasic_script_default;
script_source_str = ubasic_script_default;
update_vars = (strcmp(fn, conf.script_file) != 0) || !saved_params || (saved_params == 2); // update if new file

if (!fn[0]) { // load internal script
Expand Down Expand Up @@ -380,7 +380,7 @@ void script_load(const char *fn, int saved_params) {
rcnt = fread(buf, 1, st.st_size,fd);
if (rcnt > 0){
buf[rcnt] = 0;
state_ubasic_script = buf;
script_source_str = buf;
strcpy(conf.script_file, fn);
}
else {
Expand Down
12 changes: 6 additions & 6 deletions include/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,11 @@ int get_battery_temp();
long get_vbatt_min();
long get_vbatt_max();
void play_sound(unsigned sound);
void ubasic_camera_set_raw(int mode);
void ubasic_camera_set_nr(int mode);
int ubasic_camera_get_nr();
int ubasic_camera_script_autostart();
void ubasic_camera_set_script_autostart();
void camera_set_raw(int mode);
void camera_set_nr(int mode);
int camera_get_nr();
int camera_get_script_autostart();
void camera_set_script_autostart();
void exit_alt();
void camera_shutdown_in_a_second(void);

Expand All @@ -420,7 +420,7 @@ int get_flash_params_count(void);

/******************************************************************/
void __attribute__((noreturn)) shutdown();
void ubasic_set_led(int led, int state, int bright);
void camera_set_led(int led, int state, int bright);
void debug_led(int state);
/****************************************/
extern int canon_menu_active;
Expand Down
2 changes: 1 addition & 1 deletion include/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define SCRIPT_DATA_PATH "A/CHDK/DATA/"

//-------------------------------------------------------------------
extern const char *state_ubasic_script;
extern const char *script_source_str;

extern char script_title[36];
extern char script_params[SCRIPT_NUM_PARAMS][28];
Expand Down
12 changes: 6 additions & 6 deletions lib/ubasic/camera_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,19 @@ int md_init_motion_detector()
printf("*** md_init_motion_detector ***\n");
return 0;
}
void ubasic_camera_set_nr(to)
void camera_set_nr(to)
{
raw_nr = to;
printf("*** set raw nr %d ***\n",raw_nr);
};

int ubasic_camera_get_nr(to)
int camera_get_nr(to)
{
printf("*** get raw nr ***\n");
return raw_nr;
};

void ubasic_camera_set_raw(int mode)
void camera_set_raw(int mode)
{
raw = mode;
printf("*** set raw %d ***\n",raw);
Expand All @@ -196,7 +196,7 @@ long stat_get_vbatt()
{
return 4085;
}
void ubasic_set_led(int led, int state, int bright)
void camera_set_led(int led, int state, int bright)
{
printf("*** set led %d %d %d ***\n",led, state, bright);
}
Expand All @@ -209,11 +209,11 @@ int shooting_get_tick_count()
{
return 0;
}
int ubasic_camera_script_autostart()
int camera_get_script_autostart()
{
return 0;
}
void ubasic_camera_set_script_autostart(int state)
void camera_set_script_autostart(int state)
{
autostart = state;
printf("*** set autostart %d ***\n",autostart);
Expand Down
10 changes: 5 additions & 5 deletions lib/ubasic/camera_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ void ubasic_camera_shoot();
int md_detect_motion(void);
int md_get_cell_diff(int column, int row);
int md_init_motion_detector();
void ubasic_camera_set_raw(int mode);
void camera_set_raw(int mode);
void ubasic_camera_get_raw();
void ubasic_camera_set_nr(int to);
int ubasic_camera_get_nr();
void camera_set_nr(int to);
int camera_get_nr();
void shooting_set_prop(int id, int v);
int shooting_get_prop(int id);
long stat_get_vbatt();
void ubasic_set_led(int led, int state, int bright);
void camera_set_led(int led, int state, int bright);
int shooting_get_day_seconds();
int shooting_get_tick_count();
int ubasic_camera_script_autostart();
int get_usb_power(int edge);
void ubasic_camera_set_script_autostart(int state);
void camera_set_script_autostart(int state);
void exit_alt();
//#include "../../core/motion_detector.h"

Expand Down
10 changes: 5 additions & 5 deletions lib/ubasic/ubasic.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ case TOKENIZER_GET_VBATT:
break;
case TOKENIZER_GET_RAW_NR:
accept(TOKENIZER_GET_RAW_NR);
r = ubasic_camera_get_nr();
r = camera_get_nr();
break;
case TOKENIZER_IS_KEY:
accept(TOKENIZER_IS_KEY);
Expand All @@ -253,7 +253,7 @@ case TOKENIZER_GET_VBATT:
break;
case TOKENIZER_SCRIPT_AUTOSTARTED:
accept(TOKENIZER_SCRIPT_AUTOSTARTED);
r = ubasic_camera_script_autostart();
r = camera_get_script_autostart();
break;
case TOKENIZER_GET_SCRIPT_AUTOSTART:
accept(TOKENIZER_GET_SCRIPT_AUTOSTART);
Expand Down Expand Up @@ -1964,7 +1964,7 @@ static void set_led_statement()
if (tokenizer_token() != TOKENIZER_CR && tokenizer_token() != TOKENIZER_ELSE ) {
to2 = expr();
}
ubasic_set_led(to, to1, to2);
camera_set_led(to, to1, to2);
accept_cr();
}
static void set_prop_statement()
Expand Down Expand Up @@ -2026,15 +2026,15 @@ static void set_raw_statement()
int to;
accept(TOKENIZER_SET_RAW);
to = expr();
ubasic_camera_set_raw(to);
camera_set_raw(to);
accept_cr();
}
static void set_raw_nr_statement()
{
int to;
accept(TOKENIZER_SET_RAW_NR);
to = expr();
ubasic_camera_set_nr(to);
camera_set_nr(to);
accept_cr();
}

Expand Down
2 changes: 1 addition & 1 deletion platform/a2000/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int get_flash_params_count(void){
return 120;
}

void ubasic_set_led(int led, int state, int bright) {
void camera_set_led(int led, int state, int bright) {
struct led_control led_c;
char convert_table[11]={0,1,2,3,0,2,3,1,8,10,10}; // s3 to a710 (and a720) convert table

Expand Down
2 changes: 1 addition & 1 deletion platform/a470/wrappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ long lens_get_target_distance()
}


void ubasic_set_led(int led, int state, int bright)
void camera_set_led(int led, int state, int bright)
{
struct led_control led_c;
char convert_table[11]={0,1,2,3,0,2,3,1,8,10,10}; // s3 to a710 (and a720) convert table
Expand Down
2 changes: 1 addition & 1 deletion platform/a480/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void debug_led(int state)
*(int*)LED_PR=state ? 0x46 : 0x44;
}

void ubasic_set_led(int led, int state, int bright) {
void camera_set_led(int led, int state, int bright) {
static char led_table[]={7,9};
_LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
}
Expand Down
2 changes: 1 addition & 1 deletion platform/a530/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int get_flash_params_count(void){

#define LED_BASE 0xc0220080

void ubasic_set_led(int led, int state, int bright)
void camera_set_led(int led, int state, int bright)

{
int leds[] = {12,16,4,8,4,0,4};
Expand Down
2 changes: 1 addition & 1 deletion platform/a560/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int get_flash_params_count(void){

#define LED_BASE 0xc02200C0

void ubasic_set_led(int led, int state, int bright)
void camera_set_led(int led, int state, int bright)

{
int leds[] = {12,16,4,8,4,0,4};
Expand Down
2 changes: 1 addition & 1 deletion platform/a570/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int get_flash_params_count(void){

#define LED_BASE 0xc02200C0

void ubasic_set_led(int led, int state, int bright)
void camera_set_led(int led, int state, int bright)

{
int leds[] = {12,16,4,8,4,0,4};
Expand Down
2 changes: 1 addition & 1 deletion platform/a590/wrappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ long lens_get_target_distance()
}


void ubasic_set_led(int led, int state, int bright)
void camera_set_led(int led, int state, int bright)
{
// 0 gr
// 1 orange
Expand Down
2 changes: 1 addition & 1 deletion platform/a650/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void debug_led(int state)

#define LED_AF 0xc0220080

void ubasic_set_led(int led, int state, int bright)
void camera_set_led(int led, int state, int bright)

{
int leds[] = {12,16,4,8,4,0,4};
Expand Down
2 changes: 1 addition & 1 deletion platform/a700/wrappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ long lens_get_target_distance()
}

// copied from a710
void ubasic_set_led(int led, int state, int bright)
void camera_set_led(int led, int state, int bright)
{
struct led_control led_c;
char convert_table[11]={0,1,2,3,0,2,3,1,8,10,10}; // s3 to a710 convert table
Expand Down
2 changes: 1 addition & 1 deletion platform/a710/wrappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ long lens_get_target_distance()
return _GetCurrentTargetDistance();
}

void ubasic_set_led(int led, int state, int bright)
void camera_set_led(int led, int state, int bright)
{
struct led_control led_c;
char convert_table[11]={0,1,2,3,0,2,3,1,8,10,10}; // s3 to a710 convert table
Expand Down
Loading

0 comments on commit 9fcd476

Please sign in to comment.