A better(?) way to control display off - page 5 - General Discussion and Assistance - CHDK Forum

A better(?) way to control display off

  • 81 Replies
  • 42605 Views
*

Offline lapser

  • *****
  • 1093
Re: A better(?) way to control display off
« Reply #40 on: 02 / September / 2013, 15:20:51 »
Advertisements
I got the new display/backlight off technique working as a C function using event_procs from C as reyalp described.

Code: [Select]
extern unsigned _ExecuteEventProcedure(const char *name,...);
//new set backlight function
// 0 off | 1 on | -1 toggle
static void backlight(int newbl)
{
  static int bl=1; //current backlight state starts out ON
  static int eproc=2; //0=use TurnOffBackLight() / 1=use event proc / 2=initial call
  if(newbl<0)newbl=bl^1;
  newbl&=1;
  if(newbl==bl)return;
  bl=newbl;
  if(eproc)
  {
    unsigned args[1];   
    if(eproc==2) //first call
    {
      eproc=1;
      args[0]=(unsigned)"DispDev_EnableEventProc";
      if (call_func_ptr(_ExecuteEventProcedure,args,1)==-1)
      {
        args[0]=(unsigned)"DispDev.Create";
        if (call_func_ptr(_ExecuteEventProcedure,args,1) == -1)eproc=0;
      }
    }
    if(eproc)
    {
      if(bl)args[0]=(unsigned)"DispCon_TurnOnDisplay";
      else args[0]=(unsigned)"DispCon_TurnOffDisplay";
      call_func_ptr(_ExecuteEventProcedure,args,1);
      return;
    }
    if(bl)TurnOnBackLight();
    else TurnOffBackLight();
  }
}
I was able to add it entirely in luascript.c, but it should probably be somewhere else to work with ubasic too. You need to call backlight(1) if the script ends, is aborted by shoot_full, or error aborts. Attached is a diff file of the luascript.c changes.

A nice addition is set_backlight(-1) which toggles the backlight. That's usually what a script wants to do, so this makes it a lot easier. I need to keep track of the current backlight state anyway, so I can skip turning on the backlight when it's already on, in case this could cause problems on some cameras.

Here's a simple test script:

Code: [Select]
--[[
@title Backlight Test
--]]
press("shoot_full");
repeat wait_click(10)
  if(is_key("set"))then set_backlight(-1) end
  if(is_key("video"))then Force_Error() end
until is_key("menu")
Start in record mode, continuous drive to take pictures while the script is running. You have to set the review time to 0 or the screen will still flash. In continuous mode, the review time >0 is apparently ignored, except to turn on the display between pictures.

Press "set" to toggle the backlight
"menu" to exit normally
"video" to force a script error abort
"shoot_full" to abort,
<ALT> to exit alt mode with the script running

This tests all possible ways to exit a script. Pressing <alt> leaves the backlight off with the script running. So you still toggle the backlight pressing set, as well as go through the Canon menus with <ALT> off. This is really messed up, and one reason I think <ALT> should replace "shoot_full" as the script abort key like I did in my other patch.

I'm not sure how to add the new functions to CHDK as opposed to calling them as event procs. If reyalp or phil would be kind enough to show how it's done specifically for this case, I can modify the changes to work that way.

I think it's worth putting into the trunk, as a modification to set_backlight() instead of a new function. That way, all the old scripts will work without flashing as well, without any changes. I don't think it matters to the script what Canon calls the backlight (display) off function. For clarity, we can include a comment in the C code that makes it clear the the script set_backlight() is actually using the display off Canon firmware code.

I do think I notice that the screen takes a little longer to light up again when turning the "backlight" back on this way. Also, my battery tests showed a 14% to 19% increase in run time with the new method. waterwingz tests only showed about 10% with the old method as I recall. It looks like it's turning the power to the display off, instead of just the light.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Offline Pier

  • ***
  • 128
Re: A better(?) way to control display off
« Reply #41 on: 02 / September / 2013, 17:45:12 »
Tested with trunk3060-Patched with Backlight_T3060.diff and BLTest.lua on SX130 IS
in record mode, continuous drive.
All was O'key, no issues.Very nice and thanks to lapser and all developers.
Pier.

*

Offline lapser

  • *****
  • 1093
Re: A better(?) way to control display off
« Reply #42 on: 07 / September / 2013, 13:47:43 »
After thinking about it, I agree with reyalp that the display off function is different from the set_backlight(0) function. The display function seems to turn off the power to the display providing more power saving and stopping the flashing between pictures, but it takes longer to turn it back on. It's possible that someone will want to have the backlight come on immediately, and we may figure out a better fix for the backlight flashing problem in the future.

So I'll do this as a new function:

set_display(-1 | 0 | 1)

-1 toggles the display on and off. I'll also add this to set_backlight. This is usually what a script will want to do, i.e. when you press the SET key.

I'm still looking for some help on how to add the 2 new display functions to CHDK without using event_proc. Can anyone point me in the right direction? It looks like I could add them to stubs.s for my specific cameras, but is there a way to add them to other cameras automatically?
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #43 on: 21 / October / 2013, 11:29:28 »
lapser, I'd like to know more about your method of turning off the display.  I've just been shoving a connector into the A/V port to make the display dark and prevent the flicker after each shot, but that doesn't seem to save much power.   But just to be clear - does your method work for both autofocus and manual focus?  Actually, I never understood why the camera turned off manual focus when you turn off the display.  Do you understand why it does that?  And if there's a good reason, how does your method get around it?

Thanks

*

Offline lapser

  • *****
  • 1093
Re: Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #44 on: 21 / October / 2013, 13:03:50 »
lapser, I'd like to know more about your method of turning off the display.  I've just been shoving a connector into the A/V port to make the display dark and prevent the flicker after each shot, but that doesn't seem to save much power.   But just to be clear - does your method work for both autofocus and manual focus?  Actually, I never understood why the camera turned off manual focus when you turn off the display.  Do you understand why it does that?  And if there's a good reason, how does your method get around it?
I think the rational behind Canon turning off manual focus when you press the <display> button is that you can't see the screen to focus manually. Manual focus is preserved on the SX50, which has a powered viewfinder that comes on when the screen goes off. Turning the display off with the script function also keeps the viewfinder off, which is important too.

The event_proc method calls the Canon firmware display function directly, which turns off only the display. When Canon turns off the display, it must also be calling other functions besides this one, including the function that changes to auto-focus mode.

Try putting your camera in manual focus (record) mode, and run the attached script. It should turn the display off and back on. Then see if your camera is still in manual focus mode. It still is on all my cameras.

'believe' was a careless use of words, my conclusions are not based on belief but on practical experience and the hard data presented above.

By all means ignore the technical conclusions drawn from the data if you feel more comfortable with that.
Amen to that!  :)
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

Re: Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #45 on: 21 / October / 2013, 18:52:01 »
Thanks very much, lapser.  I'll give it a try.

Re: Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #46 on: 21 / October / 2013, 19:40:41 »
I tried the display test script, with mixed results.  First, I had to turn on native lua calls, which always makes me a bit queasy what with the warning message and all.

But after changing that setting, I ran the script.  It did turn off the display, and then turned it back on.  But when it came back on, all of the normal info overlays were gone, and there didn't appear to be a way to get them back.  Hitting the display button only turned off the display again.  But I tried instead shifting into Play mode, then back to Record, and everything came back, including MF.  So it appears to work with respect to MF, but I need my overlays back.

*

Offline reyalp

  • ******
  • 14126
Re: Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #47 on: 21 / October / 2013, 22:27:38 »
But after changing that setting, I ran the script.  It did turn off the display, and then turned it back on.  But when it came back on, all of the normal info overlays were gone, and there didn't appear to be a way to get them back.
Anything that causes the canon UI to update should get it back, for example, entering the FUNC/ SET menu.

See http://chdk.setepontos.com/index.php?topic=10551.0 for some discussion of these functions.
Don't forget what the H stands for.

*

Offline lapser

  • *****
  • 1093
Re: Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #48 on: 22 / October / 2013, 01:43:15 »
it appears to work with respect to MF, but I need my overlays back.
It needs to be added as a CHDK function to avoid the Native Lua Calls issue. I've added it to my CHDK custom build using event_proc, but I'll need Phil or reyalp to show me how to convert it to a firmware call, like TurnOffBacklight(). Or maybe one of them could just write the set_display() function patterned after set_backlight(). I think it would be a very worthwhile CHDK trunk addition.

I've also added a call to console_redraw() when a script ends, in my custom builds, so I didn't notice the problem with the overlays staying off. In standard CHDK, you can just end the script by calling the Lua function:

console_redraw()

I've attached the test script with that added, for you to try again.

[EDIT] Phil just created a CHDK patch that adds set_display(0|1), so you won't need to enable native Lua calls after it gets included in the CHDK 1.3 builds. After that happens, download the new CHDK build and try this simple test script:
Code: [Select]
--[[
@title Display On/Off Test
--]]
sleep(2000)
set_LCDdisplay(0)
sleep(2000)
set_LCDdisplay(1)
console_redraw()
Further info is here:
http://chdk.setepontos.com/index.php?topic=10551.msg106514#msg106514
« Last Edit: 22 / October / 2013, 12:17:41 by lapser »
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: A better(?) way to control display off
« Reply #49 on: 22 / October / 2013, 07:20:35 »
After thinking about it, I agree with reyalp that the display off function is different from the set_backlight(0) function. The display function seems to turn off the power to the display providing more power saving and stopping the flashing between pictures, but it takes longer to turn it back on. It's possible that someone will want to have the backlight come on immediately, and we may figure out a better fix for the backlight flashing problem in the future.

So I'll do this as a new function:

set_display(-1 | 0 | 1)

-1 toggles the display on and off. I'll also add this to set_backlight. This is usually what a script will want to do, i.e. when you press the SET key.

I'm still looking for some help on how to add the 2 new display functions to CHDK without using event_proc. Can anyone point me in the right direction? It looks like I could add them to stubs.s for my specific cameras, but is there a way to add them to other cameras automatically?

Attached patch adds:
- C wrapper functions TurnOnDisplay & TurnOffDisplay (wrappers for DispCon_TurnOnDisplay_FW & DispCon_TurnOffDisplay_FW)
- Lua and uBasic function set_LCDdisplay, works the same as set_backlight; but calls new display control functions.

Only implemented for DryOS cameras (except for S5IS).

For VxWorks and S5IS the new functions just do the same as TurnOnBackLight and TurnOffBackLight.

On the DryOS cameras I checked, the firmware functions for display on/off also call the backlight on/off code.

The test script becomes:
Code: [Select]
--[[
@title Display On/Off Test
--]]

sleep(2000)
set_LCDdisplay(0)
sleep(2000)
set_LCDdisplay(1)
console_redraw()

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

 

Related Topics


SimplePortal © 2008-2014, SimplePortal