Dataghost already experimented with LCD things a while back with some cameras and his code is available in his branch in svn. I think we should put TurnOffBackLight / TurnOnBackLight to Lua and uBASIC. I experimented with it a bit and it seems like a good way to cut power consumption of timelapse and motion detect scripts.
There are no backlight brightness settings in the A570IS (except in Dataghost experimental branch), and adding these simple calls will not bring that PWM control to us.
The effect of TurnOffBackLight wears off quite easily (for example after each mode change and after each shot or release of shoot_half), but this is sort of a good thing as it will not cause permanently difficult situations of dark displays after interrupting scripts. To keep a script dark, this just needs to be called after each shot and whatever commands are found to reset the backlight. The backlight stays off during half shoot, exposures and during dark frame reduction, important in night time timelapses and motion detectors. The LCD getting ready to show live view again is probably what re-enableds backlight.
Note that even if the effect doesn't wear off on your camera no matter what you do other than powering off (remember you may need to exit ALT mode to be able to do things), you can still see what's on the LCD if you point a bright light at it and look carefully.
Aside from increasing battery life, this control should be good for
- eliminating stray light from LCD (which ruins long exposures when shooting out of a window at night... LEDs must still be taped shut, though, but that's less troublesome than covering the LCD and uncovering it each time you need to tweak).
- making the camera draw less attention during script runs by making it spend significantly less time with a shiningly bright LCD
- slightly lowering heat dissipation of the camera, which theoretically could very very slightly reduce sensor noise in long script runs even though the reduced heat is nowhere near the CCD.
So, what sort of effect on battery life are we talking about? I measured it on my a570is (simple 4-lead lab PSU measurement supplied to the DC jack).
LCD backlight of A570IS requires 200 mW of power, give or take a 5 % or so. On empty batteries the camera's PSU is a bit less efficient, I measured at nominal DC input (3.15 VDC) and at nominal NiMH input (2.4 VDC), the difference in efficiency is about 2 units of %.
During idle REC mode (e.g. slow mode MD or timelapse script wait) this is 15 % of total power consumption of this idle time.
During half shoot REC mode (e.g. fast mode MD) this is 13 % of total power consumtion of this half shoot "idle" time.
During PLAY mode with lens out (after REC mode for a while) this is 30 % of total power consumption.
During PLAY mode with lens in (hidden) this is 37 % of total power consumption.
This is significantly better than using the already proven but a bit disappointing AV plug method, whose power savings are about 7 % in REC mode during half shoot, 10 % in idle REC mode and 25 % in PLAY mode (don't remember if the lens was in or out), probably because the video output circuitry requires some power.
To add the function to CHDK, these additions are required:
==========================================================
platform/a570/sub/100e/stubs_entry_2.S:
NHSTUB(TurnOnBackLight, 0xFFC34D40)
NHSTUB(TurnOffBackLight, 0xFFC34D70)
Entry points for some other cameras, including the reference firmwares. For vxworks cameras the signature finder should probably find the functions well. For dryos not so much I guess. All I looked for were simple, but is IDA able to do this automatically? Going thru all dissassemblies manually is pretty tiring.
TurnOnBackLight
a450 100d 0xffc4e3b8
a570 100e 0xFFC34D40
a570 101a 0xffc34d40
a610 100e 0xffd93428
s3is 100a 0xff9e6afc
ixus70_sd1000 100c 0xff8462a4
a650 100d 0xffc69378
a710 100a 0xffdbd720
a720 100c 0xffc676dc
s5is 101a 0xff888450
s5is 101b 0xff888388
TurnOffBackLight
a450 100d 0xffc4e3e8
a570 100e 0xFFC34D70
a570 101a 0xffc34d70
a610 100e 0xffd93454
s3is 100a 0xff9e6b2c
ixus70_sd1000 100c 0xff8462d4
a650 100d 0xffc69390
a710 100a 0xffdbd750
a720 100c 0xffc676f4
s5is 101a 0xff888468
s5is 101b 0xff8883a0
include/lolevel.h:
extern void _TurnOnBackLight(void);
extern void _TurnOffBackLight(void);
include/platform.h:
void TurnOnBackLight(void);
void TurnOffBackLight(void);
platform/generic/wrappers.c:
void TurnOnBackLight(void)
{
_TurnOnBackLight();
}
void TurnOffBackLight(void)
{
_TurnOffBackLight();
}
To add a new command set_backlight to Lua:
==========================================
core/luascript.c:
// Enable/disable LCD back light (input argument 1/0)
static int luaCB_set_backlight( lua_State* L )
{
int val = (luaL_checknumber(L,1));
if (val > 0) TurnOnBackLight();
else TurnOffBackLight();
return 0;
}
and to the end of core/luascript.c function register_lua_funcs, add the line:
FUNC(set_backlight);
To add the same command to uBASIC:
==================================
lib/ubasic/ubasic.c (somewhere before the function static void statement(void)):
static void set_backlight_statement(void)
{
int val;
accept(TOKENIZER_SET_BACKLIGHT);
val = expr();
if (val > 0) TurnOnBackLight();
else TurnOffBackLight();
accept_cr();
}
add to the switch/case statement near the end of ubasic.c:
case TOKENIZER_SET_BACKLIGHT:
set_backlight_statement();
break;
add to struct keyword_token keywords[] in lib/ubasic/tokenizer.c:
{"set_backlight", TOKENIZER_SET_BACKLIGHT},
add to enum ubasic_token in lib/ubasic/tokenizer.h:
TOKENIZER_SET_BACKLIGHT,
That should be it.
set_backlight(0) turns off the backlight
set_backlight(1) turns on the backlight (as do some operations such as shoot() and release(("shoot_half"))
In ubasic no paranthesis in syntax, obviously. I didn't actually test the ubasic command, just the Lua ones but it compiles fine and follows my old example from
http://chdk.wikia.com/wiki/Adding_Firmware_Features.
(and as a side note, from the above you can see one more reason I now prefer Lua...it's way easier to add funky new experimental functions to Lua
).