img_address = 0xaf7d0function get_path_from_address(address) --path contains 8*4 characters local path="" for v=1,8 do local value=peek(address) for i=1, 4 do value2=value/(256) n=value-value2*256 value=value2 c=string.char(n) path=path..c --print(n.." "..c) --sleep(1000) end address=address+4 end return(path)endprint(get_path_from_address(img_address))wait_click(0)[/lua]
Next step would be to replace the jpg name with corresponding raw file to remove it. Or do some other operations. It would be even nice to have a CHDK option like 'remove RAW when JPG is removed'.
function file_exists(name) local f=io.open(name,"r") if f~=nil then io.close(f) return true else return false endend
--[[@title remove raw of displayed jpg@param s Safe test (1=don't delete)@default s 0@param a img address (in decimal)@default a 718800--]]require "drawings"--address has to be obtained from RAM dump,--see: [url]http://chdk.setepontos.com/index.php?topic=6897.msg73715#msg73715[/url] (thx, srsa_4c & heinzM)--for SX130 IS = 0xaf7d0; in decimal 718800--for SX200 IS = 0x508e0; in decimal 329952--good idea is to set this param in code, not in paramsimg_address = aset_console_layout(0,0,40,2)function get_path_from_address(address) --path contains 7*4 characters local path="" for v=1,7 do local value=peek(address) for i=1, 4 do value2=value/(256) n=value-value2*256 value=value2 c=string.char(n) path=path..c --print(n.." "..c) --sleep(1000) end address=address+4 end return(path)end--print(get_path_from_address(img_address))--wait_click(0)function get_input() KEYS_TABLE={"left","up","right","down","set","shoot_half","shoot_full","menu","display","erase","zoom_in","zoom_out"} REPEATABLE_KEYS_TABLE={"left","up","right","down","zoom_out","zoom_in"} PRESSED_KEY=nil for key_nr=1, table.getn(REPEATABLE_KEYS_TABLE) do if is_pressed(REPEATABLE_KEYS_TABLE[key_nr]) then PRESSED_KEY=REPEATABLE_KEYS_TABLE[key_nr] end end if PRESSED_KEY~=nil then repeat if get_tick_count()-PRESSED_TIME>350 then sleep(10); return PRESSED_KEY end until not is_pressed(PRESSED_KEY) end wait_click(60000) PRESSED_TIME=get_tick_count() for key_nr=1, table.getn(KEYS_TABLE) do if is_key(KEYS_TABLE[key_nr]) then PRESSED_KEY=KEYS_TABLE[key_nr]; return KEYS_TABLE[key_nr] end end endfunction file_exists(name) local f=io.open(name,"r") if f~=nil then io.close(f) return true else return false endendfunction ask_about_remove(jpg_file,raw_file) local running=true local input local selected=0 local status="none" local x0=50 local y0=15 local raw_color="green" if (raw_file=="not found") then raw_color="red" end gui_window=draw.add("rectf",x0,y0,x0+250,y0+200,"white","grey",2) gui_winbar=draw.add("rectf",x0,y0,x0+250,y0+20,"white","grey",2) gui_title=draw.add("string",x0+10,y0+2,"What you want to do?","white","grey") gui_mess1=draw.add("string",x0+10,y0+25,"You have selected:","white","grey") gui_mess2=draw.add("string",x0+10,y0+45,jpg_file,"green","grey") gui_mess3=draw.add("string",x0+10,y0+65,"Appropriate RAW:","white","grey") gui_mess4=draw.add("string",x0+10,y0+85,raw_file,raw_color,"grey") gui_mess5=draw.add("string",x0+10,y0+110,"What to do?","white","grey") gui_ans1=draw.add("string",x0+10,y0+130," Remove both ","green","black") gui_ans2=draw.add("string",x0+10,y0+150," Remove RAW ","white","grey") gui_ans3=draw.add("string",x0+10,y0+170," Remove JPG ","white","grey") draw.overdraw() while (running) do input=get_input() if(input=="up" or input=="left") then selected=selected-1 end if(input=="down" or input=="right") then selected=selected+1 end if(selected>2) then selected=0 end if(selected<0) then selected=2 end if(selected==0) then status="both" draw.replace(gui_ans1,"string",x0+10,y0+130," Remove both ","green","black") draw.replace(gui_ans2,"string",x0+10,y0+150," Remove RAW ","white","grey") draw.replace(gui_ans3,"string",x0+10,y0+170," Remove JPG ","white","grey") end if(selected==1) then status="raw" draw.replace(gui_ans1,"string",x0+10,y0+130," Remove both ","white","grey") draw.replace(gui_ans2,"string",x0+10,y0+150," Remove RAW ","green","black") draw.replace(gui_ans3,"string",x0+10,y0+170," Remove JPG ","white","grey") end if(selected==2) then status="jpg" draw.replace(gui_ans1,"string",x0+10,y0+130," Remove both ","white","grey") draw.replace(gui_ans2,"string",x0+10,y0+150," Remove RAW ","white","grey") draw.replace(gui_ans3,"string",x0+10,y0+170," Remove JPG ","green","black") end draw.overdraw() if(input=="set") then running=false end if(input=="menu") then running=false status="none" end end draw.clear() draw_clear() return(status)end ----- loop -----running=truewhile (running) do input=get_input() if (input=="left" or input=="right" or input=="zoom_in" or input=="zoom_out" or input=="set") then click(input) end jpg_path=get_path_from_address(img_address) raw_path="not found" --there could be other methods to check the other raw filename formats. --IMG_XXXX.DNG raw_path_check=string.sub(jpg_path,1,string.len(jpg_path)-3).."DNG" if(file_exists(raw_path_check)) then raw_path=raw_path_check end --IMG_XXXX.CRW raw_path_check=string.sub(jpg_path,1,string.len(jpg_path)-3).."CRW" if(file_exists(raw_path_check)) then raw_path=raw_path_check end --IMG_XXXX.CR2 raw_path_check=string.sub(jpg_path,1,string.len(jpg_path)-3).."CR2" if(file_exists(raw_path_check)) then raw_path=raw_path_check end --print("JPG: "..jpg_path) --print("RAW: "..raw_path) if (input=="erase" or input=="shoot_half") then --sleep helps camera to refresh the image file data sleep(1000) shall_we_remove=ask_about_remove(jpg_path,raw_path) print(shall_we_remove) wait_click(0) end end
I was playing with os.stat but I see, that stat can't be executed on file that doesn't exist.
Quote from: outslider on 04 / May / 2012, 11:45:16I was playing with os.stat but I see, that stat can't be executed on file that doesn't exist.It will return nil if the file doesn't exist.
On later dryos cameras, not having the A/ at the front will trigger an assert. Don't do that
Started by Chris710 Hello, I'm a NEWBIE - HELP!! (Newbies assistance, User Guides and thank you notes)
Started by husel General Chat
Started by reyalp Archived Issues
Started by thepanoguy Archived Issues
Started by waterwingz Archived Issues