Skip to content

Commit

Permalink
Implemented first attempt to a minimal CHDK PTP interface.
Browse files Browse the repository at this point in the history
N.B.: This implementation (of both CHDK and ptpcam) is incompatible with the
original(/initial) CHDK PTP patch.
  • Loading branch information
mweerden committed Apr 5, 2010
1 parent c2bea02 commit da2ad4c
Show file tree
Hide file tree
Showing 17 changed files with 320 additions and 380 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -44,7 +44,7 @@ endif
ifdef NEED_ENCODED_DISKBOOT ifdef NEED_ENCODED_DISKBOOT
@echo dance \-\> DISKBOOT.BIN ver $(NEED_ENCODED_DISKBOOT) @echo dance \-\> DISKBOOT.BIN ver $(NEED_ENCODED_DISKBOOT)
$(ENCODE_DISKBOOT) $(topdir)bin/main.bin $(topdir)bin/DISKBOOT.BIN $(NEED_ENCODED_DISKBOOT) $(ENCODE_DISKBOOT) $(topdir)bin/main.bin $(topdir)bin/DISKBOOT.BIN $(NEED_ENCODED_DISKBOOT)
# rm $(topdir)bin/main.bin rm $(topdir)bin/main.bin
else else
mv $(topdir)bin/main.bin $(topdir)bin/DISKBOOT.BIN mv $(topdir)bin/main.bin $(topdir)bin/DISKBOOT.BIN
endif endif
Expand Down
2 changes: 1 addition & 1 deletion buildconf.inc
Expand Up @@ -17,7 +17,7 @@ OPT_LUA_STRLIB=1
#OPT_LUA_CALL_NATIVE=1 #OPT_LUA_CALL_NATIVE=1
#OPT_MD_DEBUG=1 #OPT_MD_DEBUG=1
# needs proper fi2.inc in platform/ !!! see http://chdk.setepontos.com/index.php/topic,2995.0.html # needs proper fi2.inc in platform/ !!! see http://chdk.setepontos.com/index.php/topic,2995.0.html
OPT_FI2=1 #OPT_FI2=1
# if enabled, compiler will produce a lot of warnings, maybe not always correct ones, see http://chdk.setepontos.com/index.php/topic,2509.msg32191.html#msg32191 # if enabled, compiler will produce a lot of warnings, maybe not always correct ones, see http://chdk.setepontos.com/index.php/topic,2509.msg32191.html#msg32191
#OPT_WARNINGS=1 #OPT_WARNINGS=1
# If enabled (and reference binaries are present in /tools), compiler will generate function signatures # If enabled (and reference binaries are present in /tools), compiler will generate function signatures
Expand Down
61 changes: 12 additions & 49 deletions core/gui.c
Expand Up @@ -2589,69 +2589,32 @@ void gui_draw_debug_vals_osd() {
// long v=get_file_counter(); // long v=get_file_counter();
// sprintf(osd_buf, "1:%03d-%04d ", (v>>18)&0x3FF, (v>>4)&0x3FFF); // sprintf(osd_buf, "1:%03d-%04d ", (v>>18)&0x3FF, (v>>4)&0x3FFF);
// sprintf(osd_buf, "1:%d, %08X ", xxxx, eeee); // sprintf(osd_buf, "1:%d, %08X ", xxxx, eeee);

/*
// extern long debug_long;
// sprintf(osd_buf, "8:%08x ", debug_long);
// draw_txt_string(28, 10, osd_buf, conf.osd_color);

// sprintf(osd_buf, "8:%08x ", *((int *)0xC02200F8));
// draw_txt_string(28, 10, osd_buf, conf.osd_color);
//
// sprintf(osd_buf, "C:%08x ", *((int *)0xC02200FC));
// draw_txt_string(28, 11, osd_buf, conf.osd_color);

// int zp=lens_get_zoom_point(), fl1=get_focal_length(zp);
// sprintf(osd_buf, "zp:%8i ", zp);
// draw_txt_string(28, 10, osd_buf, conf.osd_color);
//
// sprintf(osd_buf, "fl:%8i ", fl1);
// draw_txt_string(28, 11, osd_buf, conf.osd_color);

extern long physw_status[3]; extern long physw_status[3];
// sprintf(osd_buf, "0:%8x ", physw_status[0]); sprintf(osd_buf, "1:%8x ", physw_status[0]);
// draw_txt_string(28, 10, osd_buf, conf.osd_color);
//
// sprintf(osd_buf, "1:%8x ", physw_status[1]);
// draw_txt_string(28, 11, osd_buf, conf.osd_color);
//
sprintf(osd_buf, "2:%8x ", physw_status[2]);
draw_txt_string(28, 9, osd_buf, conf.osd_color);
short x;
sprintf(osd_buf, "zs:%8x ", zoom_status);
draw_txt_string(28, 10, osd_buf, conf.osd_color); draw_txt_string(28, 10, osd_buf, conf.osd_color);
get_property_case(PROPCASE_DIGITAL_ZOOM_STATE, &x, sizeof(x));
sprintf(osd_buf, "dzs:%8x ", x); sprintf(osd_buf, "2:%8x ", physw_status[1]);
draw_txt_string(28, 11, osd_buf, conf.osd_color); draw_txt_string(28, 11, osd_buf, conf.osd_color);
get_property_case(PROPCASE_DIGITAL_ZOOM_POSITION, &x, sizeof(x));
sprintf(osd_buf, "dzp:%8x ", x); sprintf(osd_buf, "3:%8x ", physw_status[2]);
draw_txt_string(28, 12, osd_buf, conf.osd_color); draw_txt_string(28, 12, osd_buf, conf.osd_color);
// sprintf(osd_buf, "4:%8x ", vid_get_viewport_fb_d()); // sprintf(osd_buf, "4:%8x ", vid_get_viewport_fb_d());

*/
// sprintf(osd_buf, "j:%8x ", Get_JogDial()); sprintf(osd_buf, "u:%8x ", get_usb_power(1));
// draw_txt_string(28, 9, osd_buf, conf.osd_color); draw_txt_string(28, 9, osd_buf, conf.osd_color);

// extern long movie_status;
// sprintf(osd_buf, "m:%8x ", movie_status);
// draw_txt_string(28, 9, osd_buf, conf.osd_color);

// extern long playrec_mode;
// sprintf(osd_buf, "m:%8x ", playrec_mode);
// draw_txt_string(28, 9, osd_buf, conf.osd_color);

//sprintf(osd_buf, "u:%8x ", get_usb_power(1));
//draw_txt_string(28, 9, osd_buf, conf.osd_color);


sprintf(osd_buf, "1:%8x ", (void*) (*(int*)conf.mem_view_addr_init)); sprintf(osd_buf, "1:%8x ", (void*) (*(int*)conf.mem_view_addr_init));
//draw_txt_string(28, 10, osd_buf, conf.osd_color); draw_txt_string(28, 10, osd_buf, conf.osd_color);


extern volatile long focus_busy; extern volatile long focus_busy;
sprintf(osd_buf, "f:%8x ", focus_busy); sprintf(osd_buf, "f:%8x ", focus_busy);
//draw_txt_string(28, 11, osd_buf, conf.osd_color); draw_txt_string(28, 11, osd_buf, conf.osd_color);


extern volatile long zoom_busy; extern volatile long zoom_busy;
sprintf(osd_buf, "z:%8x ", zoom_busy); sprintf(osd_buf, "z:%8x ", zoom_busy);
//draw_txt_string(28, 12, osd_buf, conf.osd_color); draw_txt_string(28, 12, osd_buf, conf.osd_color);


// some cameras missing zoom_status // some cameras missing zoom_status
#if 0 #if 0
Expand Down
2 changes: 0 additions & 2 deletions core/gui_draw.c
Expand Up @@ -389,9 +389,7 @@ void draw_clear() {


//------------------------------------------------------------------- //-------------------------------------------------------------------
void draw_restore() { void draw_restore() {
// if (gui_get_mode()!=GUI_MODE_NONE) vid_turn_on_updates();
vid_bitmap_refresh(); vid_bitmap_refresh();
// if (gui_get_mode()!=GUI_MODE_NONE) vid_turn_off_updates();
} }


//------------------------------------------------------------------- //-------------------------------------------------------------------
Expand Down
35 changes: 34 additions & 1 deletion core/luascript.c
Expand Up @@ -536,9 +536,15 @@ static int luaCB_exit_alt( lua_State* L )
return 0; return 0;
} }


// optional parameter is 0 for soft shutdown (default) or 1 for hard/immediate
static int luaCB_shut_down( lua_State* L ) static int luaCB_shut_down( lua_State* L )
{ {
camera_shutdown_in_a_second(); if ( luaL_optnumber(L,1,0) == 1 )
{
shutdown();
} else {
camera_shutdown_in_a_second();
}
return 0; return 0;
} }


Expand Down Expand Up @@ -1155,6 +1161,30 @@ static int luaCB_set_record( lua_State* L )
return 0; return 0;
} }


// reboot camera (with FI2 if supplied as arg)
static int luaCB_reboot( lua_State* L )
{
const char *fn = luaL_optstring(L,1,NULL);

reboot(fn);

return 0;
}

// switch mode (0 = playback, 1 = record)
// XXX currently only for when USB is connected
static int luaCB_switch_mode( lua_State* L )
{
int mode = luaL_checknumber(L,1);

if ( mode != 0 && mode != 1 )
{
return 0;
}

return switch_mode(mode);
}

/* /*
pack the lua args into a buffer to pass to the native code calling functions pack the lua args into a buffer to pass to the native code calling functions
currently only handles strings/numbers currently only handles strings/numbers
Expand Down Expand Up @@ -1434,6 +1464,9 @@ void register_lua_funcs( lua_State* L )


FUNC(set_record); FUNC(set_record);


FUNC(reboot);
FUNC(switch_mode);

#ifdef OPT_LUA_CALL_NATIVE #ifdef OPT_LUA_CALL_NATIVE
FUNC(call_event_proc); FUNC(call_event_proc);
FUNC(call_func_ptr); FUNC(call_func_ptr);
Expand Down

0 comments on commit da2ad4c

Please sign in to comment.