hide_osd() script function - General Discussion and Assistance - CHDK Forum

hide_osd() script function

  • 98 Replies
  • 34542 Views
*

Offline lapser

  • *****
  • 1093
hide_osd() script function
« on: 28 / September / 2013, 18:22:17 »
Advertisements
Purpose: Hide all CHDK overlays, including OSD, Console, and bottom "<ALT>" line. This gives scripts a "clean slate" to draw on.

The attached patch adds this new Lua function to CHDK:

hide_osd(-1 | 0 | 1)
  -1 toggles OSD
   1 hides OSD
   0 shows OSD

The function works by setting a flag that signals core_spytask() in main.c to skip gui.redraw(), and clear the overlay screen on the first skipped gui_redraw().

I also added a test to do gui_redraw() in continuous mode even while processing a picture, since the last picture is being displayed along with the un-updated OSD and console. Try watching the OSD (without the patch) while taking pictures in continuous mode and you'll see it's not updating, and showing confusing info sometimes.

Code: [Select]
        if ((((cnt++) & 3) == 0) &&
          ((camera_info.state.state_shooting_progress != SHOOTING_PROGRESS_PROCESSING) ||
          recreview_hold || shooting_get_drive_mode())) // also redraw in continuous modes
        {
          if(camera_info.state.osd_off)
          {
            if(camera_info.state.osd_off&2)
            {
              draw_restore(); //clear screen first time
              camera_info.state.osd_off=1; //clear first time flag
            }
          }
          else gui_redraw();
        }
« Last Edit: 28 / September / 2013, 18:23:48 by lapser »
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

Re: hide_osd() script function
« Reply #1 on: 28 / September / 2013, 18:31:26 »
Nice - thanks for posting this.

Purpose: Hide all CHDK overlays, including OSD, Console, and bottom "<ALT>" line. This gives scripts a "clean slate" to draw on.
Including the currently loaded script title?

Quote
The attached patch adds this new Lua function to CHDK:
Not available for uBASIC?  I guess its not so useful there as uBASIC does not have the Lua drawing functions.  Still, there might be cases where a uBASIC script simply wants to clear the display area and leave it that way.  A function to toggle CHDK stuff on/off based on a button push is possible in uBASIC for example.

Quote
hide_osd(-1 | 0 | 1)
  -1 toggles OSD
   1 hides OSD
   0 shows OSD
I guess the toggle function is mostly useful if you tie it to a specific button and thus don't have to remember the current state?

Quote
I also added a test to do gui_redraw() in continuous mode even while processing a picture, since the last picture is being displayed along with the un-updated OSD and console. Try watching the OSD (without the patch) while taking pictures in continuous mode and you'll see it's not updating, and showing confusing info sometimes.
Is this your continuous mode stuff or something generic?
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline lapser

  • *****
  • 1093
Re: hide_osd() script function
« Reply #2 on: 28 / September / 2013, 19:08:28 »
Including the currently loaded script title?
Yes, everything. Totally clean slate.
Quote
Not available for uBASIC?
We can add that later, if needed. Since uBasic and Lua are in modules, we could just repeat the luascript.c code in uBasic.
Quote
I guess the toggle function is mostly useful if you tie it to a specific button and thus don't have to remember the current state?
Right. I use it that way in my scripts (see attached test script). CHDK has to save the osd_off state anyway, so the script doesn't need to save it too.
Quote
Is this your continuous mode stuff or something generic?
It's a problem outside of scripts too. Set the clock display to "seconds" and hold the shutter down in continuous mode to demonstrate. I think the screen display buffer address keeps changing with every new picture. Sometimes the clock even jumps back a little. I think that's when the camera wraps to an older screen display, and CHDK doesn't update the clock display. The patch seems to fix that.

This problem also applies to the Lua drawing functions when you're drawing while taking pictures in continuous mode. You have to keep redrawing with the script.

It might be better to check the screen buffer address, and force a redraw whenever it changes, rather than test for continuous mode. I haven't experimented with this idea, though.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

Re: hide_osd() script function
« Reply #3 on: 28 / September / 2013, 19:33:52 »
We can add that later, if needed. Since uBasic and Lua are in modules, we could just repeat the luascript.c code in uBasic.
Then for completeness,  the patch file should include Lua and uBASIC code prior to submission I guess.

It's a problem outside of scripts too. Set the clock display to "seconds" and hold the shutter down in continuous mode to demonstrate. I think the screen display buffer address keeps changing with every new picture. Sometimes the clock even jumps back a little. I think that's when the camera wraps to an older screen display, and CHDK doesn't update the clock display. The patch seems to fix that.

This problem also applies to the Lua drawing functions when you're drawing while taking pictures in continuous mode. You have to keep redrawing with the script.

It might be better to check the screen buffer address, and force a redraw whenever it changes, rather than test for continuous mode. I haven't experimented with this idea, though.
So, per my previous posts about one change per patch file,  this is seems to be something that belongs in a seperate patch / discussion?  When you say "The patch seems to fix that" I don't get a warm fuzzy feeling it belongs in a discussion about hide_osd().
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline lapser

  • *****
  • 1093
Re: hide_osd() script function
« Reply #4 on: 28 / September / 2013, 20:07:15 »
So, per my previous posts about one change per patch file,  this is seems to be something that belongs in a seperate patch / discussion?  When you say "The patch seems to fix that" I don't get a warm fuzzy feeling it belongs in a discussion about hide_osd().
Yes, I was thinking that too. I'll take it out if you want. Both patches go in the same C statement, but I guess they are somewhat unrelated. Maybe Phil or reyalp can figure out a better way to refresh the CHDK overlays in continuous mode? It seems like we might as well talk about it here, though, since both patches are so closely related.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

Re: hide_osd() script function
« Reply #5 on: 28 / September / 2013, 21:23:42 »
I'll take it out if you want. Both patches go in the same C statement, but I guess they are somewhat unrelated.
Based on this discussion,  I'd say please take it out.

On a related note,  I've been trying to find a "use case" for making this a CHDK menu option rather than a script command.   Is there a case where you would want the CHDK icons off when you are not running a script but are in <ALT> mode?   I can't think of any but its worth asking before committing this patch as just for scripts.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline lapser

  • *****
  • 1093
Re: hide_osd() script function
« Reply #6 on: 28 / September / 2013, 22:31:56 »
Based on this discussion,  I'd say please take it out.
OK, all that needs to be done is to remove this part:

|| shooting_get_drive_mode()

I've been experimenting with "active_bitmap_buffer" a little. It has potential, but it's unrelated to hide_osd().  It does look like that discussion should go in a new topic, after we resolve this problem.

I'd like to hear from Phil and reyalp about the hide_osd() function. Maybe they know a better way of accomplishing the same thing?

Quote
On a related note,  I've been trying to find a "use case" for making this a CHDK menu option rather than a script command.   Is there a case where you would want the CHDK icons off when you are not running a script but are in <ALT> mode?   I can't think of any but its worth asking before committing this patch as just for scripts.
I don't see any reason to hide the OSD in <ALT> mode outside of a script, and it might be really confusing. There are already a lot of OSD display options in the menu for regular (not ALT) mode. Those might be improved somehow, but in a new topic  :)
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Offline lapser

  • *****
  • 1093
Re: hide_osd() script function
« Reply #7 on: 29 / September / 2013, 09:31:12 »
I decided it was cleaner to put the hide_osd test at the beginning of gui_redraw() instead of in core_spytask(). I also took out the unrelated test for continuous mode, so main.c is unchanged now.

The new patch is attached.

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

Re: hide_osd() script function
« Reply #8 on: 29 / September / 2013, 09:49:46 »
I'd like to hear from Phil and reyalp about the hide_osd() function. Maybe they know a better way of accomplishing the same thing?
I'd venture to suggest you have found a clean and simple way to do this on your own.

I decided it was cleaner to put the hide_osd test at the beginning of gui_redraw() instead of in core_spytask(). I also took out the unrelated test for continuous mode, so main.c is unchanged now.
I've take the liberty to update your patch a bit.  Two principal changes are :

1) Added code to support the function in uBASIC (with a test script).
2) Added an enum for the OSD state.   I get nervous when code has "magic numbers"  like 0,1,2 rather than #defined (or enum) constants - especially when the same magic numbers are used in different source files.

If you are okay with these changes,  and lacking any other feedback,  I'd suggest submitting this patch for inclusion in the 1.3.0 trunk.


Update : I almost hate to bring this up,  but would it be better to extend this so that you can selectively turn off the <ALT> & script name and/or the OSD icons.  For example, I can see wanting the colored battery icon visible but nothing else.  Or am I complicating this too much?
« Last Edit: 29 / September / 2013, 10:15:28 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: hide_osd() script function
« Reply #9 on: 29 / September / 2013, 12:17:37 »
Update 2 : added the new uBASIC function to camera_functions.c and fixed a path error in run_ubasic.c .

I suspect run_ubasic.c  will still not build "as is" with the new modules versions of CHDK unless further work is done.   This has nothing to do with the hide_osd() patch.   Does anybody actually care anymore?


Ported :   A1200    SD940   G10    Powershot N    G16

 

Related Topics


SimplePortal © 2008-2014, SimplePortal