Fixing the vanishing CHDK menu issue(s). - DryOS Development - CHDK Forum

Fixing the vanishing CHDK menu issue(s).

  • 8 Replies
  • 3285 Views
*

Offline philmoz

  • *****
  • 3073
    • Photos
Fixing the vanishing CHDK menu issue(s).
« on: 19 / July / 2011, 08:32:05 »
Advertisements
One annoying feature of CHDK, that seems to be fairly common, is the occasional vanishing act done by the menu display.

On the G12 and SX30 I assumed this was due to the camera firmware refreshing the display and CHDK not knowing about it - this seemed to happen most often in record mode.

On the IXUS 310 this problem is even more of an issue because the CHDK buttons are also on screen - if they disappear it makes it a bit hard to control.

So I implemented a simple system to set the top left pixel of the screen bitmap to a known value and then test the value each time gui_redraw is called. If the pixel has changed then I force the touchscreen buttons and menu to redraw.

This worked quite well (so long as there are no CHDK OSD elements in the top left corner); but the darn menu still randomly disappears.

After working through the menu code (ugh! serious overhaul needed here) I think I've figured out this second cause of the menu vanishing.
Basically the menu system is built around two functions 'gui_menu_kbd_process' which handles the button presses and is called in the kbd task, and 'gui_menu_draw' which is called from gui_redraw in the spytask task.

Unfortunately these two aren't cleanly seperated and 'gui_menu_kbd_process' does a lot of screen erasing and redrawing. It attempts to synchronise with 'gui_menu_draw' through the gui_menu_redraw and gui_restore variables; but in some cases this fails and gui_menu_kbd_process ends up erasing the menu after it has been drawn and forgetting to tell gui_menu_draw to redraw it.

I've come up with a workaround to this problem that works on the G12, SX30 and IXUS 310; but I want to make sure it works more widely before submitting a patch.

To see if the problem affects your camera try this:
- enter ALT mode (in playback mode on the camera) and open the menu
- scroll down to the Miscellaneous stuff menu
- repeatedly press Set to enter the misc stuff menu followed by Disp to go back to the top menu

The firmware doesn't seem to refresh the screen very often in playback mode which makes it easier to test for this problem.

If during the above the menu vanishes occasionally then try the fix below and retest. If this helps please report back here.

The following changes are needed.

gui_menu.h - add the following at the end
Code: [Select]
extern void gui_menu_force_redraw();

gui_menu.c - add the following function
Code: [Select]
void gui_menu_force_redraw()
{
    if (gui_get_mode() == GUI_MODE_MENU)
    {
        gui_menu_redraw=2;
    }
}

gui.c - change the code at the end of gui_redraw to the following (one line added)
Code: [Select]
    gui_in_redraw = 0;
    if ((gui_mode_old != gui_mode && (gui_mode_old != GUI_MODE_NONE && gui_mode_old != GUI_MODE_ALT) && (gui_mode != GUI_MODE_MBOX && gui_mode != GUI_MODE_MPOPUP)) || gui_restore) {
        if (gui_restore) gui_menu_force_redraw();
        gui_restore = 0;
        if (gui_mode != GUI_MODE_REVERSI && gui_mode != GUI_MODE_SOKOBAN && gui_mode != GUI_MODE_4WINS && gui_mode != GUI_MODE_MASTERMIND)
            draw_restore();
    }

What this is doing is, at the end of gui_redraw, if qui_restore is set it means that gui_menu_kbd_process wants to refresh the menu. The call to gui_menu_force_redraw will force the menu to get redrawn next time round.

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)

*

Offline philmoz

  • *****
  • 3073
    • Photos
Re: Fixing the vanishing CHDK menu issue(s).
« Reply #1 on: 19 / July / 2011, 08:51:30 »
Part 2:

If anyone wants to try it, the code I'm using to detect if the camera has refreshed the screen is below:

In gui_draw.c - add this (the guard values are hard wired at the moment, should probably be part of the palette):
Code: [Select]
#define GUARD_VAL1  0xe1
#define GUARD_VAL2  0xe3

void draw_set_guard()
{
    *((unsigned char*)(frame_buffer[0])) = GUARD_VAL2;
    *((unsigned char*)(frame_buffer[1])) = GUARD_VAL1;
}

int draw_test_guard()
{
    if (*((unsigned char*)(frame_buffer[0])) != GUARD_VAL2) return 0;
    if (*((unsigned char*)(frame_buffer[1])) != GUARD_VAL1) return 0;
    return 1;
}

At the end of draw_init and draw_restore (in gui_draw.c) add this line to both functions:
Code: [Select]
    draw_set_guard();

In gui.c at the start of gui_redraw add:
Code: [Select]
    if (!draw_test_guard())
    {
        draw_set_guard();
        gui_menu_force_redraw();
    }

Note this change requires the function in gui_menu.c from the previous post.

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)

*

Offline funnel

  • ****
  • 349
Re: Fixing the vanishing CHDK menu issue(s).
« Reply #2 on: 19 / July / 2011, 09:57:13 »
Good work. Now is perfect.

*

Offline msl

  • *****
  • 1255
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: Fixing the vanishing CHDK menu issue(s).
« Reply #3 on: 19 / July / 2011, 16:23:04 »
Great work.

With the second part are the changes very usefull for me (for my A720).

For the A720 is the vanishing CHDK menu issue not a great problem. But with these changes I never lose the CHDK menu, e.g. when using dialmode with open CHDK menu.

msl
CHDK-DE:  CHDK-DE links


Re: Fixing the vanishing CHDK menu issue(s).
« Reply #4 on: 21 / July / 2011, 17:09:13 »
Hi Phil.

I would love to try those changes on my sx130, but I dont know where to start!

Please tell me how I can access to "gui_menu.h" and all these files. (I'm sure it's a stupid question!)

I will be happy to report to you how those changes affect the behavior of my screen.

Thank you for the good work!

Jeff
« Last Edit: 21 / July / 2011, 17:13:03 by NovaJeff »
La parcimonie, c'est bien beau, mais faut pas trop en mettre.

*

Offline blackhole

  • *****
  • 654
  • A590IS 101b
    • Planetary astrophotography
Re: Fixing the vanishing CHDK menu issue(s).
« Reply #5 on: 05 / August / 2011, 13:54:58 »
With this has definitely solved the disappearance of the menu in the video mode on the A590.
Perhaps CAM_DETECT_SCREEN_ERASE should be enabled by default for the A590 because it works without any problems.

*

Offline msl

  • *****
  • 1255
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: Fixing the vanishing CHDK menu issue(s).
« Reply #6 on: 03 / September / 2011, 03:56:57 »
I don't know, if this issue is here right.

I have a problem with the function "compare propcases" in the debug menu. With my A720 the function works fine. But with the SX220 the list of changed propcase variable disappears immediately after displaying. I have no chance to read the informations.

Have other newer cameras also this problem? Is there a way to redraw the list?

msl
CHDK-DE:  CHDK-DE links

*

Offline philmoz

  • *****
  • 3073
    • Photos
Re: Fixing the vanishing CHDK menu issue(s).
« Reply #7 on: 03 / September / 2011, 04:38:33 »
I don't know, if this issue is here right.

I have a problem with the function "compare propcases" in the debug menu. With my A720 the function works fine. But with the SX220 the list of changed propcase variable disappears immediately after displaying. I have no chance to read the informations.

Have other newer cameras also this problem? Is there a way to redraw the list?

msl

In gui.c function gui_kbd_process() try this. Find the code shown below and change the ' if (!shooting_get_common_focus_mode())' line to ' else if (!shooting_get_common_focus_mode())'

Code: [Select]
            if (kbd_is_key_clicked(SHORTCUT_TOGGLE_RAW)) {
                if (conf.debug_shortcut_action > 0) {
#ifdef OPT_DEBUGGING
gui_debug_shortcut();
#endif
}
#if !CAM_HAS_ERASE_BUTTON && CAM_CAN_SD_OVERRIDE
                if (!shooting_get_common_focus_mode())
#else
else
#endif
   {conf.save_raw = !conf.save_raw;
                    draw_restore();
                   }

It looks like in the current code for cameras without an 'Erase' button the 'Display' button activates the debug shortcut action; but this is also toggling the raw mode and forcing a screen erase/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)


*

Offline msl

  • *****
  • 1255
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: Fixing the vanishing CHDK menu issue(s).
« Reply #8 on: 03 / September / 2011, 05:08:18 »
In gui.c function gui_kbd_process() try this. Find the code shown below and change the ' if (!shooting_get_common_focus_mode())' line to ' else if (!shooting_get_common_focus_mode())'

Thank you very much. That was it.

msl
CHDK-DE:  CHDK-DE links

 

Related Topics