Auto refresh - General Help and Assistance on using CHDK stable releases - CHDK Forum

Auto refresh

  • 19 Replies
  • 1074 Views
Auto refresh
« on: 12 / April / 2021, 15:19:27 »
Advertisements
@reyalp @waterwingz

I’m trying to implement a graphic auto refresh function, that looks out to see if my drawing is still there, and, if not, eg removed my the Canon side, auto redraws things.

I’m using the draw module and have four objects, ie the dummy objects are:
Code: [Select]
obj1 = draw.add("rectf", 0, 0, 0, 0, "black","black")
obj2 = draw.add("string", 0, 0, "","white","black")
obj3 = draw.add("string", 0,0,"","white","black")
obj4 = draw.add("string",0,0,"","white","black")

One thought I have is to draw a particular colour pixel at, say, two locations, and look to see that these are there. If not, I’ll know I need to redraw.


But I’m not sure how to get a pixel colour, ie I can draw to the screen with draw_pixel( x, y, cl ), but how do I read the location?

So my question is, have either of you any ideas on how to achieve such an auto redraw function, ie watching within an infinite loop? Is my idea sound? Or is there another way?


*

Offline reyalp

  • ******
  • 13353
Re: Auto refresh
« Reply #1 on: 12 / April / 2021, 16:16:17 »
But I’m not sure how to get a pixel colour, ie I can draw to the screen with draw_pixel( x, y, cl ), but how do I read the location?
Short of using peek (which would be VERY platform specific), I don't believe there's currently a way to read the bitmap buffers from Lua.

Quote
One thought I have is to draw a particular colour pixel at, say, two locations, and look to see that these are there.
The normal (non-script) CHDK GUI code actually uses this "guard pixel" technique, but it's not currently available from script.

Both of the above would potentially be useful features.

Quote
So my question is, have either of you any ideas on how to achieve such an auto redraw function, ie watching within an infinite loop? Is my idea sound? Or is there another way?
You could just draw periodically. If you can track whether your GUI has changed, you could use draw.overdraw in the cases it has not.
Don't forget what the H stands for.

Re: Auto refresh
« Reply #2 on: 12 / April / 2021, 16:33:53 »
@reyalp

I do use draw.overdraw, but manually triggered.

Quote
If you can track whether your GUI has changed

Any hint how I might track my GUI, ie that it’s not there?

Cheers

Garry

*

Offline reyalp

  • ******
  • 13353
Re: Auto refresh
« Reply #3 on: 12 / April / 2021, 16:50:30 »
Any hint how I might track my GUI, ie that it’s not there?
What I meant was track whether the content your script wants to draw on the screen has changed, which would be entirely dependent on the logic of the script. Or you could just use overdraw all the time, and not worry about it unless you see ghosting.
Don't forget what the H stands for.


Re: Auto refresh
« Reply #4 on: 12 / April / 2021, 16:53:39 »
Ok I understand.


I’ll play around with a few ideas.

Re: Auto refresh
« Reply #5 on: 13 / April / 2021, 02:39:38 »
@reyalp

Once again thanks for your previous pointers. I now have my drawing auto updating as LCD and EVF switch.

What I'm still struggling with is how to detect MENU or INFO mode.

I've looked at prop_case but I can't see a solution there.

Do you know if one can detect INFO, PLAY, MENU mode is active, ie so I can switch off my drawing.

Cheers

Garry
« Last Edit: 13 / April / 2021, 02:48:04 by pigeonhill »

*

Offline reyalp

  • ******
  • 13353
Re: Auto refresh
« Reply #6 on: 13 / April / 2021, 03:05:28 »
Do you know if one can detect INFO, PLAY, MENU mode is active, ie so I can switch off my drawing.
If you mean playback mode, that can be detected with get_mode(). AFAIK nothing exposed to script that gives you the Canon menu state, although the CHDK core does know if the main menu is open, at least.

Are you manually leaving alt mode while the script is running to access the Canon menus? Or using simulated key presses to manipulate menus from script?

In the first case, you could use get_alt_mode to detect when you aren't in alt mode, and disable drawing. In the second, you could set some flag yourself when the script is manipulating menus.
Don't forget what the H stands for.

Re: Auto refresh
« Reply #7 on: 13 / April / 2021, 03:21:33 »
@reyalp

Yes, my M3 Bracketing script has an infinite pause point, where you can manually come in and out of ALT mode, eg change settings or take an image.

If out of ALT mode, the focus display remains, for obvious reasons. So I cant’t unfortunately stop drawing.

It’s not important to me, ie having my info bar displayed in Canon MENU mode, I’m just polishing things off ;-)
« Last Edit: 13 / April / 2021, 04:01:57 by pigeonhill »


*

Offline Caefix

  • *****
  • 562
  • Sorry, busy deleting test shots...
Re: Auto refresh
« Reply #8 on: 13 / April / 2021, 10:51:14 »
Quote
* Note: exiting and entering ALT mode with M3 Bracketing running MAY trigger the script to 'crash'.
Using <alt>key often behaves unexpected. At Edi.lua the cursor moves on in background (could probably be logged). With calling (edited) snippet from !Edi.Lua this looping, returning to script with <alt>key should be save. :D
 https://forum.chdk-treff.de/viewtopic.php?f=7&t=3540&start=15#p31935
Code: [Select]
function exitalt(x) -- keeps cursor on place
x=x or 1
sleep(99); wait_click(22)
if x~=0 then exit_alt() end; wait_click(22)
repeat sleep(333) until get_alt_mode()
if get_mode() then set_record(false) end  --<-- true to rec
-- update values
EXP_COUNT=string.format("_%04d.",get_exp_count() or 0)
INSERT_MAP[1][3]=EXP_COUNT
sleep(1000)
play_sound(4)
end
All lifetime is a loan from eternity.

Re: Auto refresh
« Reply #9 on: 30 / April / 2021, 07:02:29 »
@reyalp

Now that I’ve got the fmath library running in my M3 script, the ‘only’ thing that alludes me is implementing an auto refresh of my DoF info bar.

At the moment I’ve coded a triggered refresh, eg half shutter press or ALT state change, and a timed refresh, ie every 3 seconds.

Of course every refresh generates a slight flickering, which, by the way I don’t get over in ML, where a1ex coded a double buffering function to draw stuff.

What I would like to do is implement an auto refresh. As you said before:

Quote
The normal (non-script) CHDK GUI code actually uses this "guard pixel" technique, but it's not currently available from script.

Both of the above would potentially be useful features.

Is there any chance you could introduce a pixel level read function into Lua, or even tell me what the camera specific poke/peek solution is for the M3. That is poke a colour on the CHDK drawing layer and peek to see if it’s there. If not there, then I need to refresh my drawing.

My script will only ever run on the M3.

Cheers

Garry

 

Related Topics