1. I don't see any need for a new Lua function. Just modify set_backight in C so it tries to use call_event_proc first, and if that fails, it uses the current function (with backlight fix).
2. You should turn the backlight on when the script terminates, or when the script encounters an error. I already have this in my backlight fix. If there's a timing problem, just save the tick_count when you turn the backlight off, and make sure a minimum time has passed before turning it back on.
Turning of the display is not the same thing as turning off the backlight, I don't think we should combine them. If we were going to try to fix set_backlight, it would be better to use LcdCon_SetLcdBackLightBrightness(0)
This isn't always desirable. For example, if you are executing script code over ptp, you want to be able to turn the display off and have it stay off, not turn right back on when the call ends. In some applications, turning the display on for errors would also be undesirable. I'm not sure what the best way to handle this is. Theoretically, scripts that want to restore camera state should use restore() but it's not very reliable, and puts the onus on script writers to figure out keep track of what they need to restore.
I should have some time to try it out by this weekend.
blight=1 -- backlight on / current statebldisp=true -- turn off display with eventproc if trueif call_event_proc('DispDev_EnableEventProc') == -1 then if call_event_proc('DispDev.Create') == -1 then bldisp=false -- must turn off display with set_backlight endendfunction backlight(bl) -- bl=0 off, 1 on, -1 toggle if(bl<0)then bl=bitxor(blight,1) -- toggles 0 or 1 elseif (bl>1)then bl=1 end if(bl==blight)then return end -- don't double set to current state blight=bl if(bldisp)then if(bl==0)then call_event_proc('DispCon_TurnOffDisplay') else call_event_proc('DispCon_TurnOnDisplay') end else set_backlight(bl) -- do the old way if no event_proc available endendfunction restore() backlight(1)--etcend--then in my time lapse loop:repeat wait_click(10) if(is_key("set"))then backlight(-1) --toggle elseif --etc. enduntil get_shot_ready() --wait for shot
Also, I seem to recall a menu option to enable native calls, but I can't find it now. Maybe I'm enabling them with a compile option? Will this Lua function method work on unmodified CHDK?
--CHDK version 1.3--set_config_value(999, 1)core = require("gen/cnf_core")set_config_value(core.script_allow_lua_native_calls, 1)--CHDK version 1.2--set_config_value(119, 1)
Quote from: lapser on 24 / August / 2013, 21:24:57Also, I seem to recall a menu option to enable native calls, but I can't find it now. Maybe I'm enabling them with a compile option? Will this Lua function method work on unmodified CHDK?Miscellaneous Stuff => Enable Lua Native Calls' http://chdk.wikia.com/wiki/CHDK_1.2.0_User_Manual#Enable_Lua_Native_Calls.27(Thanks to waterwingz, the manual is on the latest standing.)There is also a script solution: Code: (lua) [Select]--CHDK version 1.3--set_config_value(999, 1)core = require("gen/cnf_core")set_config_value(core.script_allow_lua_native_calls, 1)--CHDK version 1.2--set_config_value(119, 1)msl
The 'set_config_value' function doesn't allow a script to enable native calls.The 'script_allow_lua_native_calls' entry should not be included in cnf_core.lua.
Quote from: philmoz on 25 / August / 2013, 06:02:54The 'set_config_value' function doesn't allow a script to enable native calls.The 'script_allow_lua_native_calls' entry should not be included in cnf_core.lua. Why not?It's a pain to test scripts without this. When I use a PTP connection for script test (e.g. hostlua) it is difficult everytime to activate 'native calls' via CHDK menu. I think a CHDK script author should have the responsibility and not CHDK in such cases.msl
To try and limit the damage a malicious script could do.
Started by Michael L General Help and Assistance on using CHDK stable releases
Started by danielkun General Help and Assistance on using CHDK stable releases
Started by bugsplatter Script Writing
Started by vihar1 « 1 2 » General Discussion and Assistance
Started by muhlisgursoy General Discussion and Assistance