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

A better(?) way to control display off

  • 81 Replies
  • 23287 Views
Re: A better(?) way to control display off
« Reply #70 on: 28 / December / 2013, 13:29:15 »
Advertisements
Quote
- the bitmap ui overlay (both chdk and canon) may not display after turning on, until you do something that causes the canon firmware to refresh it.
IIRC the "do something" can be as simple as opening and closing the func menu. Presumably there's an underlying function somewhere that has the same effect, but it didn't seem like a big deal to me.
There is a famous quote that says something like "Be careful what you ask for, you might just get it."

Copied below is a little script that demonstrates the problem I am having with converting from set_backlight() to set_lcd_display().
Code: [Select]
--[[
@title Display On/Off Test
--]]
set_console_layout(1, 1, 44, 6)
print("Test started")
print(" - press any key to toggle display")
print(" - press menu to exit")
lcd_state = 1
repeat
    repeat wait_click(100) until not( is_key("no_key"))
    if ( lcd_state == 0 ) then lcd_state = 1 else lcd_state = 0 end
    set_lcd_display(lcd_state)     
    print("display="..lcd_state)
until is_key("menu")
set_lcd_display(1)
print("menu key exit")
When the display is toggled to the "On" state,  the script console is not displayed.  With my scripts, the Lua drawing stuff does not display either.   I believe that this is actually a serious limitation for anything but trivial scripts. For example,  scripts that have a "toggle" function to let you briefly enable the display to see what is happening with the script will no longer be able to do that.

Nothing new here - reyalp & philmoz both discussed it and I quoted that here.  But I've noticed somebody has been converting several of the scripts on the wiki already  :'(

So does anyone have a good idea about how to "do something" from within a script that will cause the overlays to re-appear?  I was trying to think of a "safe" key to press() or something like that.


Update :  a little function to toggle the display clears this up - but it introduces a lag and seem like overkill :
Code: [Select]
function restore_display()
    local disp = get_prop(props.DISPLAY_MODE)
    local clicks=0
    repeat
        click("display")
        clicks=clicks+1
        sleep(500)
    until (( disp == get_prop(props.DISPLAY_MODE)) or (clicks> 5))
end
« Last Edit: 28 / December / 2013, 13:58:37 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 12887
Re: A better(?) way to control display off
« Reply #71 on: 28 / December / 2013, 14:59:17 »
Update :  a little function to toggle the display clears this up - but it introduces a lag and seem like overkill :
Also, 'display' is sometimes shared with one of the arrow keys, and so can't necessarily be called by name.

I was going to suggest the func/set buttons since entering and leaving the func menu should be harmless, but unfortunately the canon UI is not consistent:
On older cams like my a540 and and d10, clicking set once opens the menu and clicking again closes it.
On elph130, you need to press menu to cancel the func menu, pressing set again descends into the menu :(

The menu key might work. It's ugly but I think it will always enter/leave the settings menu if you click it twice.

The +/- button might also work, but it won't do anything in auto mode, and what key it's on varies. You might be able to get around the second problem using a logicalevent rather than a chdk key.

The alternative is to go hunting in the firmware for a function to force the display to refresh.
Don't forget what the H stands for.

Re: A better(?) way to control display off
« Reply #72 on: 28 / December / 2013, 15:01:38 »
The alternative is to go hunting in the firmware for a function to force the display to refresh.
Curiously, as I was playing with this, I noticed that the display overlays seem to restore when the script exits. Can't figure out why that is different but somehow it is.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline lapser

  • *****
  • 1093
Re: A better(?) way to control display off
« Reply #73 on: 29 / December / 2013, 14:21:42 »
Curiously, as I was playing with this, I noticed that the display overlays seem to restore when the script exits. Can't figure out why that is different but somehow it is.
I'm out of CHDK mode at the moment, but I didn't have this problem with my display off CHDK patch. One possibility is that I call: gui_set_need_restore()  when I turn off the display. Does Phil's new function do that? CHDK may not be sensing that it needs to draw itself after the display comes back on because the screen buffer hasn't changed.

Another possibility is that I've only turned the display off and on during time lapses. Does everything come back when you take a picture?
« Last Edit: 29 / December / 2013, 14:27:17 by lapser »
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos


Re: A better(?) way to control display off
« Reply #74 on: 29 / December / 2013, 14:27:53 »
I'm out of CHDK mode at the moment, but I didn't have this problem with my display off CHDK patch. One possibility is that I call: gui_set_need_restore()  when I turn off the display. Does Phil's new function do that? CHDK may not be sensing that it needs to draw itself after the display comes back on because the screen buffer hasn't changed.
I'll take a look at that but my scripts are continuously writing to the screen - drawing functions and console.

Update:  seems to make a big difference - screen now redraws properly when set_lcd_display(1) is called  - although I added it to where it turns on the display!  Patch file attached.  Thanks to lapser!

This probably answers my earlier question too :
Curiously, as I was playing with this, I noticed that the display overlays seem to restore when the script exits. Can't figure out why that is different but somehow it is.

Update 2  :  changed above to read set_lcd_display(1) - i.e. turn on lcd
« Last Edit: 29 / December / 2013, 15:58:12 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline lapser

  • *****
  • 1093
Re: A better(?) way to control display off
« Reply #75 on: 29 / December / 2013, 15:18:07 »
Update: screen now redraws properly when set_lcd_display(0) is called!  Patch file attached.
Great! Another minor quirk I discovered is that turning the display back on also turns on the backlight, at least on all my cameras. Scripts that toggle backlight and display and keep track of the backlight state might want to know this.

EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Offline reyalp

  • ******
  • 12887
Re: A better(?) way to control display off
« Reply #76 on: 29 / December / 2013, 18:31:34 »
Update:  seems to make a big difference - screen now redraws properly when set_lcd_display(1) is called  - although I added it to where it turns on the display!  Patch file attached.  Thanks to lapser!
Added, trunk changeset 3283, release changeset 3284

This fixes the issue on for me on d10, not on a540.
Don't forget what the H stands for.

Re: A better(?) way to control display off
« Reply #77 on: 26 / November / 2017, 19:19:14 »
This fixes the issue on for me on d10, not on a540.
Bumping an old post for reference only.  I ran into this issue again today running ultimate.lua on my old A560.

The only way I could find to get around this was to switch from shooting mode to playback mode and then back to shooting mode each time I re-enabled the display with set_lcd_display( 1 )   

That seems to work although it's a clumsy hack.  But it might be helpful to anyone someday finding this thread while researching the same problem.

Ported :   A1200    SD940   G10    Powershot N    G16


Re: A better(?) way to control display off
« Reply #78 on: 24 / March / 2018, 10:34:37 »
Bumping this old thread again.  Based on a bug report starting here, it seems the crash issue discussed here :
...
Issues I've seen so far:
- Switching between rec and play with the display off seems to crash.
...
On further testing, I'm not sure the crashing on mode switch with display off was real. I was able to do it a few times (using the original DispCon_ functions, not the Switch* mentioned above) on a540 without seeing it again.

is real - at least for some cameras.

If I run the attached script on my A1200 or G16, it runs fine.  But on my A560 and G10, it "hangs" with the lens extended after doing the set_lcd_display(false) / set_record(false)  sequence.  I say "hang" rather than "crash" because it takes a battery pull to reset but there is no ROMLOG created.
Code: [Select]
--[[
@title set_lcd_display test
@chdk_version 1.4
# led     0     "Status LED"   { 0 1 2 3 4 5 6 7 8 }
--]]
function blink( count )
    sleep(2000)
    for i=1,count,1 do
        set_led(led,1)
        sleep(200)
        set_led(led,0)
        sleep(100)       
    end
    sleep(2000)
end
blink(1)
set_record(true)    -- switch to shooting mode
blink(2)
set_lcd_display(false)
blink(3)
set_record(false)   -- switch to playback mode
blink(4)
set_lcd_display(true)
blink(5)

Doing the set_lcd_display(false) after a set_record(false) works fine.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 12887
Re: A better(?) way to control display off
« Reply #79 on: 24 / March / 2018, 22:42:19 »
I tried this on a few cameras. elph130, sx160, d10 all work correctly. a540 completes the script and ends up with the display on, but completely blank. Exiting alt and pressing menu brings it back. This issue is discussed earlier in the thread.

We could make the mode switching functions turn the display on before switching, but we'd need to track the original state to know to turn it back off after the switch completed. It's also possible that the mode switch isn't fully complete when the function returns, which might cause problems if we tried to immediately change the LCD state.
Don't forget what the H stands for.

 

Related Topics