set_zoom problems in uBASIC & Lua scripts - page 9 - General Discussion and Assistance - CHDK Forum

set_zoom problems in uBASIC & Lua scripts

  • 91 Replies
  • 49243 Views
*

Offline Caefix

  • *****
  • 948
  • Sorry, busy deleting test shots...
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #80 on: 19 / October / 2019, 11:55:02 »
Advertisements
 :haha Romlogs tell a lot: :o

00155540: UI:FailReason : Fail(ETC)
Code: [Select]
zoom moving looks like (GoTo speed 3)

get_tick_count();
00119470: SS:OptAt=10 3
00119470: UI:LogicalEvent:0x00003169:adr:0x14,Para:20
00119540: UI:LogicalEvent:0x00003169:adr:0x13,Para:19
00119610: UI:LogicalEvent:0x00003169:adr:0x10,Para:16
00119670: UI:LogicalEvent:0x00003169:adr:0xd,Para:13
00119740: UI:LogicalEvent:0x00003169:adr:0xa,Para:10
00119810: UI:LogicalEvent:0x00003169:adr:0xa,Para:10
00119820: UI:LogicalEvent:0x00003169:adr:0xa,Para:10
00119870: UI:LogicalEvent:0x00003169:adr:0xa,Para:10
00119890: UI:ShootSeqToUI:0x0000200b:adr:0xa,Para:10
00120150: SS:OptAt=0 3
00120150: UI:LogicalEvent:0x00003169:adr:0xa,Para:10
00120220: UI:LogicalEvent:0x00003169:adr:0x9,Para:9
00120290: UI:LogicalEvent:0x00003169:adr:0x6,Para:6
00120360: UI:LogicalEvent:0x00003169:adr:0x2,Para:2
00120420: UI:LogicalEvent:0x00003169:adr:0x1,Para:1
00120490: UI:LogicalEvent:0x00003169:adr:0,Para:0
00120560: UI:LogicalEvent:0x00003169:adr:0,Para:0
00120600: UI:LogicalEvent:0x00003169:adr:0,Para:0
00120690: UI:LogicalEvent:0x00003169:adr:0,Para:0
00120710: UI:ShootSeqToUI:0x0000200b:adr:0,Para:0
00120710: UI:ShootSeqToUI:0x0000200c:adr:0,Para:0
00121050: SS:OptAt=10 3
The sx710 & 610hs tell more then others, some kind of glossary or dendrochronology was nice.
Code: [Select]
00154440: SS:AFUL
00154440: UI:cs m:22 rb:0x41574352 i:3371
00154440: UI:cs end m:22 rb:0x41574352 i:3371
00154440: SS:AFUL*
All lifetime is a loan from eternity.

*

Offline reyalp

  • ******
  • 14128
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #81 on: 19 / October / 2019, 16:19:31 »
Again, I have no idea what you think the above shows.

What were you doing when the crash that generated the romlog happened? Is the crash reproducible?

The sx710 & 610hs tell more then others, some kind of glossary or dendrochronology was nice.
Code: [Select]
00154440: SS:AFUL
00154440: UI:cs m:22 rb:0x41574352 i:3371
00154440: UI:cs end m:22 rb:0x41574352 i:3371
00154440: SS:AFUL*
The UI:cs lines on sx710 are some debugging code I forgot to disable. It's very unlikely they tell you anything interesting but FWIW
The cs m:  and cs m: end lines indicate the start and end of the CaptSeq handling that particular message.
m: is the number of the message being handled
rb: is the current raw buffer address. Probably not meaningful outside of messages that involve capture
i: is the current image counter

edit:
I should add the recent camera log items included in the romlog, like "00119470: UI:LogicalEvent:0x00003169:adr:0x14,Para:20" mostly don't indicate any error, they are just normal camera chatter.
« Last Edit: 19 / October / 2019, 21:06:25 by reyalp »
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 14128
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #82 on: 19 / October / 2019, 21:04:14 »
So, v3 of this patch sets the default speed to 3 and translates the 0..100 range of lens_set_zoom_speed() to 0..3.
Single speed cameras ignore the speed parameter, so 3 doesn't hurt them.
Did some more testing with v3 on elph130. Speed fixes seems good.

More observations. None of this necessarily needs to be fixed, just notes:

In digital teleconverter mode (digital zoom set to 1.6 or 2)
set_zoom after powersave display off crashes
Code: [Select]
ASSERT!! Imager.c Line 756
Task name: CZ
CZ = "computer zoom", aka digital zoom.
If digital zoom is off or normal (max optical + digital), set_zoom with screen off seems to be fine. The screen comes back on at the end of the zoom change. This might be worth checking on cameras that allow shooting with screen off.

In digital tele or if digital zoom is active, the first call to set_zoom returns after ~70-80 ms, rather than after optical zoom is complete. I suspect the digital zoom takes some time to turn off, so the call can return before zoom_busy is set. This could probably be avoided by either turning digital zoom off beforehand, or a hard coded wait. Since this zoom method already turns off digital zoom anyway, the first would be better.

SS.MoveDigitalZoomAt (registered by SS.Create) can be used to set digital zoom position, regardless of optical position or menu digital zoom setting. So we could restore digital setting, but there will probably be a momentary glitch that would be ugly in video.
Aside, if this is used when digital tele was enabled, the UI shows non-standard values 1.3x, 2.6x, 4x.

edit:
Here's a quick and dirty update that handles digital teleconverter mode. I just added the SS.MoveDigitalZoomAt eventproc to stubs_entry_2.s manually, so it expects a pointer. This appears to avoids both the non-waiting issue (for both digital tele and regular) and the crash then with display is off, as well as restoring the digital tele position.

Also, FWIW, the old CAM_USE_ALT_PT_MoveOpticalZoomAt code appears to work in screen-off, and doesn't interfere with the digital teleconverter mode.
« Last Edit: 20 / October / 2019, 02:36:39 by reyalp »
Don't forget what the H stands for.

*

Offline Caefix

  • *****
  • 948
  • Sorry, busy deleting test shots...
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #83 on: 21 / October / 2019, 14:30:45 »
Code: [Select]
Start Autozum7.lua with Romlog on Demand setting
af_lock, test 1 (#CSH):...i....1....;....2....;....3....;....4..

00006380: UI:Button:0x000009A1:PressSwOne
00006410: UI:Button:0x000009A2:UnpressSwOne
... -- >>.zip
Zoom : fine movement :...i....1....;....2....;....3....;....4..
00006540: SS:OptAt=111 3
00006550: UI:LogicalEvent:0x00003169:adr:0,Para:0
00006610: UI:LogicalEvent:0x00003169:adr:0,Para:0
00006680: UI:LogicalEvent:0x00003169:adr:0x1,Para:1
00006750: UI:LogicalEvent:0x00003169:adr:0x2,Para:2
00006810: UI:LogicalEvent:0x00003169:adr:0x6,Para:6
00006880: UI:LogicalEvent:0x00003169:adr:0x9,Para:9
00006950: UI:LogicalEvent:0x00003169:adr:0xc,Para:12
00007010: UI:LogicalEvent:0x00003169:adr:0x10,Para:16
00007080: UI:LogicalEvent:0x00003169:adr:0x13,Para:19
00007150: UI:LogicalEvent:0x00003169:adr:0x16,Para:22
00007210: UI:LogicalEvent:0x00003169:adr:0x1a,Para:26
00007280: UI:LogicalEvent:0x00003169:adr:0x1d,Para:29
00007350: UI:LogicalEvent:0x00003169:adr:0x21,Para:33
00007410: UI:LogicalEvent:0x00003169:adr:0x25,Para:37
00007480: UI:LogicalEvent:0x00003169:adr:0x2a,Para:42
00007550: UI:LogicalEvent:0x00003169:adr:0x2f,Para:47
00007620: UI:LogicalEvent:0x00003169:adr:0x34,Para:52
00007680: UI:LogicalEvent:0x00003169:adr:0x39,Para:57
00007750: UI:LogicalEvent:0x00003169:adr:0x3f,Para:63
00007810: UI:LogicalEvent:0x00003169:adr:0x45,Para:69
00007880: UI:LogicalEvent:0x00003169:adr:0x4a,Para:74
00007950: UI:LogicalEvent:0x00003169:adr:0x4f,Para:79
00008010: UI:LogicalEvent:0x00003169:adr:0x53,Para:83
00008080: UI:LogicalEvent:0x00003169:adr:0x57,Para:87
00008150: UI:LogicalEvent:0x00003169:adr:0x5b,Para:91
00008210: UI:LogicalEvent:0x00003169:adr:0x5e,Para:94
00008280: UI:LogicalEvent:0x00003169:adr:0x61,Para:97
00008350: UI:LogicalEvent:0x00003169:adr:0x64,Para:100
00008420: UI:LogicalEvent:0x00003169:adr:0x68,Para:104
00008470: UI:VTMLock
00008470: UI:DSIC:d8,0
00008470: UI:VTMUnLock
00008480: UI:LogicalEvent:0x00003169:adr:0x6c,Para:108
00008550: UI:LogicalEvent:0x00003169:adr:0x6e,Para:110
00008620: UI:LogicalEvent:0x00003169:adr:0x6f,Para:111
00008680: UI:LogicalEvent:0x00003169:adr:0x6f,Para:111
00008710: UI:LogicalEvent:0x00003169:adr:0x6f,Para:111
00008720: UI:LogicalEvent:0x00003169:adr:0x6f,Para:111
00008730: UI:ShootSeqToUI:0x0000200b:adr:0x6f,Para:111
00008730: UI:ShootSeqToUI:0x0000200d:adr:0x6f,Para:111
----6540=2190 ms for full move.

if A==1 then af_lock(0)
00009030: SS:AFUL
00009030: UI:cs m:22 rb:0x41574352 i:3414
00009030: UI:cs end m:22 rb:0x41574352 i:3414
00009030: SS:AFUL*

if t==1 then click "shoot_half"
00009160: UI:Button:0x000009A1:PressSwOne
00009160: SS:PreBuf
00009160: SS:BitR
00009160: UI:ShtCon_ResetShootingNumber
00009160: UI:ShootState:0x1
00009160: UI:ShtCon_Activate
00009160: UI:DispSw: Lock
00009160: UI:VTMLock
00009160: UI:VTMUnLock
00009160: UI:ShtCon_ShutDownRecModeMenu
00009160: UI:DSIC:61,0
00009160: UI:VTMLock
00009160: UI:DSIC:d,0
00009160: UI:VTMReduuce
00009160: UI:VTMLock
00009170: UI:VTMReduuce
00009170: UI:LogicalEvent:0x00003136:adr:0,Para:0
00009170: UI:DSIC:d,0
00009170: UI:ShtCon_PrepareCapture
00009170: SS:PreCapt:3
00009170: UI:cs m:0 rb:0x41574352 i:3414
00009170: UI:ShootState:0x2
00009170: UI:ClearEventComp
00009170: UI:VTM SW
00009170: UI:VTMUnLock
00009190: UI:Button:0x000009A2:UnpressSwOne

00009190: UI:DSIC:6a,0
00009190: UI:_CancelSequence
00009190: UI:Sht_CancelStrobeChargeTimer
00009190: UI:DSIC:4c,0
00009190: UI:VTMLock
00009190: UI:VTMReduuce
00009190: SS:CancelPre:3

That all my "crashes on demand" have in common
if A==1 then af_lock(1)
00009200: SS:AFL
00009250: UI:cs "override" <<-- rb:0x41574352  <<---most suspicious at the moment.
00009250: UI:ShootSeqToUI:0x00002006:adr:0x8350,Para:33616
00009250: UI:cs end m:0 rb:0x41574352 i:3414
00009250: UI:cs m:42 rb:0x41574352 i:3414
00009250: UI:cs end m:42 rb:0x41574352 i:3414
00009250: UI:cs m:21 rb:0x41574352 i:3414

  ???

Missing AFL* (crash)

:...i....1....;....2....;....3....;....4..

Without AFL it would continue like this
00510560: UI:VTMLock
00510560: UI:VTMReduuce
00510560: SS:CancelPre:3
("Missing AFL")
00510610: UI:cs override rb:0x41574352 i:3417
00510610: UI:ShootSeqToUI:0x00002006:adr:0x8350,Para:33616
00510610: UI:cs end m:0 rb:0x41574352 i:3417
00510610: UI:cs m:42 rb:0x41574352 i:3417
00510610: UI:cs end m:42 rb:0x41574352 i:3417
00510610: UI:cs m:3 rb:0x41574352 i:3417
00510720: UI:cs end m:3 rb:0x41574352 i:3417
00510720: SS:ChargeComplete
00510720: UI:DispSwCon_MuteOffPhysicalScreen
« Last Edit: 21 / October / 2019, 14:50:56 by Caefix »
All lifetime is a loan from eternity.

*

Offline srsa_4c

  • ******
  • 4451
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #84 on: 21 / October / 2019, 19:36:02 »
Thanks for doing all this research.
In digital teleconverter mode (digital zoom set to 1.6 or 2)
set_zoom after powersave display off crashes
Although you solved this, there are a few operations that crash while in powersave mode (none specific comes to my mind right now). Since we now have the imager_active fw variable for all cameras, we could use it in similar cases.
Quote
I just added the SS.MoveDigitalZoomAt eventproc to stubs_entry_2.s manually, so it expects a pointer. This appears to avoids both the non-waiting issue (for both digital tele and regular) and the crash then with display is off, as well as restoring the digital tele position.
If you decide to keep this, it can be added to stubs with
Code: [Select]
Index: tools/finsig_dryos.c
===================================================================
--- tools/finsig_dryos.c (revision 5283)
+++ tools/finsig_dryos.c (working copy)
@@ -345,6 +345,8 @@
     { "get_current_nd_value", OPTIONAL },
     { "GetUsableAvRange", OPTIONAL|UNUSED },
     { "GetBaseSv", OPTIONAL|UNUSED },
+    { "MoveZoomTo", OPTIONAL },
+    { "MoveDigitalZoomAt", OPTIONAL },
 
     { "kbd_p1_f" },
     { "kbd_p1_f_cont" },
@@ -2125,6 +2127,9 @@
     {20, "HwOcReadICAPCounter", "GetCurrentMachineTime", 1 },
     {20, "DisableISDriveError", "DisableISDriveError_FW", 1},
     {20, "SetImageMode", "SetImageMode_FW", 0x01000002 },
+    {20, "MoveZoomTo", "UIFS_MoveZoomTo_FW", 1 },
+    {20, "MoveDigitalZoomAt", "PT_MoveDigitalZoomAt_FW", 1 },
+    {20, "MoveDigitalZoomAt", "SS.MoveDigitalZoomAt_FW", 1 },
 
     { 1, "ExportToEventProcedure_FW", "ExportToEventProcedure", 1 },
     { 1, "AllocateMemory", "AllocateMemory", 1 },
Quote
Also, FWIW, the old CAM_USE_ALT_PT_MoveOpticalZoomAt code appears to work in screen-off, and doesn't interfere with the digital teleconverter mode.
It appears to me that MoveZoomTo uses MoveOpticalZoomAt (the inner function from the eventproc) to do the optical part. In the firmwares I looked, MoveOpticalZoomAt takes a speed parameter too.
When trying it without focus manipulation, I had the impression that MoveOpticalZoomAt also attempts to keep the focus distance, so it's possible that CAM_USE_ALT_PT_MoveOpticalZoomAt cams don't need focus adjustments after zooming.

*

Offline Caefix

  • *****
  • 948
  • Sorry, busy deleting test shots...
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #85 on: 23 / October / 2019, 14:38:57 »
 :( Not again! SD-card splitted, switch gone, not logged.

Romlogs record a lot of passed&working stuff, each cam some other topics or runs expanded.
So the one log may explain the fail of the other & vice versa.
Still trying to get it a bit readable stuctured...

How to get Romlogs on demand, if Autozum7.lua fails that exercise?

CZ = "computer zoom", aka digital zoom. AHA!
On sx710 this happens often (disabled in setting or not) on demand.
cs = captSec. = SsPrepareSeqBase.c ?
rb: rawbuffer, could that be replaced with a sd: subject_distance value?

edit:... & Lua scripts  :-*
Code: [Select]
--[[
@title MegaAutozoom28
@chdk_version 1.4
@param    r zoom delay 100*
 @default r 0
@param    d lock delay 100*
 @default d 0
@param    z zoom steps
 @default z 10
@param  A  ---  af_lock  set_mf  !MF
 @default A 1
@values  A  ---  af_lock  set_mf  !MF
@param    u Logfile
 @default u -2
@param    t test Nr.
 @default t 0
]]


function test_of_the_day()
sleep(r*100) ;
if A==1 then set_aflock(0) end
if A==2 then set_mf(1) end
if A==3 then set_mf(0) end
if A>0 then sleep(d*100) end
if t==1 then click "shoot_half" end
if t==2 then shoot() end
if is_key "set" or is_pressed "set" then romlog() end
if is_key "right" or is_pressed "right" then shoot(); sleep(11)
   print(os.date(),'#sht',get_exp_count()) end
if A==1 then set_aflock(1) end
if A==2 then set_mf(0) end
if A==3 then set_mf(1) end
wait_click(11)
end

function romlog()
-- set_aflock(0)
-- set_zoom(0)
 click "shoot_half"; sleep(11)
   print(get_tick_count(),'#csh',get_focus(),is_pressed "set",-get_exp_count())
end
   
function restore()
set_aflock(0)
set_mf(0)
    set_console_layout(0,0,25,5)
print_screen(0)
sleep(999)
end

 
function zoomout()
  p=get_zoom()
  if p<s-z then p=p+z else p=s end
  print(get_tick_count(),-get_focus(),"zoom>",p)
  set_zoom(p)
end


function zoomin()
  p=get_zoom()
  if p>=z then p=p-z end
  if p<0 then p=0 end
  print(get_tick_count(),-get_focus(),"zoom>",p)
  set_zoom(p)
end


--start script

set_console_layout(0, 0, 25, 12)
print_screen(u)
print(os.date(),'#27#',-get_exp_count())

set_aflock(1)
s=get_zoom_steps()
if z<1 then z=s-z-1 end
print (10*t+A,"started - zoom steps=", s)
set_zoom_speed(r*10%100)
print(get_tick_count(),"zoom delay set to ",r*100)

click "shoot_half"
sleep(1000)
set_zoom(0)

repeat
  sleep(100)
  for i = 1,(s/z) do
zoomout() ;
test_of_the_day()
  end
  for i = 1,(s/z) do
  if get_zoom()<1 then break end
zoomin() ;
test_of_the_day()
  end
  until false
[code]
« Last Edit: 23 / October / 2019, 15:06:40 by Caefix »
All lifetime is a loan from eternity.

*

Offline reyalp

  • ******
  • 14128
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #86 on: 25 / October / 2019, 00:43:18 »
It appears to me that MoveZoomTo uses MoveOpticalZoomAt (the inner function from the eventproc) to do the optical part. In the firmwares I looked, MoveOpticalZoomAt takes a speed parameter too.
Agreed. That's a good observation.
Quote
When trying it without focus manipulation, I had the impression that MoveOpticalZoomAt also attempts to keep the focus distance, so it's possible that CAM_USE_ALT_PT_MoveOpticalZoomAt cams don't need focus adjustments after zooming.
Tested in both MF and AF on elph130, ixus175, and sx710,  this seems correct.

In this case, maybe we don't need MoveZoomTo at all.

We can still have the variable speed control just by switching to the underlying MoveOpticalZoomAt function with the same logic you used for MoveZoomTo, and the various quirks with digital zoom go away. Attached patch does this, stubs manually added as MoveOpticalZoomAtWithSpeed for now.

Note in this code CAM_NEED_SET_ZOOM_DELAY is ignored now for CAM_USE_ALT_PT_MoveOpticalZoomAt. AFAIK it only existed to avoid crashes in the focus code.

We might also be able to detect if the cam supports variable speed, in D10 firmware (single speed, AFAIK) MoveOpticalZoomAt sets it to 0. Multi-speed cameras seem to use 3 regardless of how many speeds they have, unfortunately.

SX710 appears to have 3  speeds: Full range zoom movement speed 0 = ~7.3, speed 1 or 2 = ~3.7, speed 3 = ~2.2
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 14128
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #87 on: 26 / October / 2019, 19:24:04 »
Here's a patch that just removes set focus for CAM_USE_ALT_PT_MoveOpticalZoomAt.  I made an additional define CAM_REFOCUS_AFTER_ZOOM which we could use to override this per camera if needed. It also makes things clearer if we end up using MoveZoomTo or other methods for some cams. It currently defaults to 0 for CAM_USE_ALT_PT_MoveOpticalZoomAt and 1 for the others.

I tested this on all my dryos cameras: D10, sx160, elph130, elph180, sx710, g7x. In the trunk, D10 doesn't currently define CAM_USE_ALT_PT_MoveOpticalZoomAt, but the new code works both with and without.

Also attached is a CSV listing which cameras use what zoom defines, as of r5283. A relatively small number of cameras use CAM_USE_ALT_SET_ZOOM_POINT without CAM_USE_ALT_PT_MoveOpticalZoomAt. I don't have any of those, and haven't tried that combination on any of the cameras I have.

I'm inclined to check this in if there are no objections, and add the speed control separately later.
Don't forget what the H stands for.

*

Offline srsa_4c

  • ******
  • 4451
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #88 on: 27 / October / 2019, 13:56:36 »
I'm inclined to check this in if there are no objections, and add the speed control separately later.
No objections here.
Quote
We can still have the variable speed control just by switching to the underlying MoveOpticalZoomAt function
I'll do the sigfinder part (dry and maybe vx), hopefully soon.

*

Offline srsa_4c

  • ******
  • 4451
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #89 on: 29 / October / 2019, 13:41:47 »
MoveOpticalZoomAt for finsig_dryos
Code: [Select]
Index: tools/finsig_dryos.c
===================================================================
--- tools/finsig_dryos.c (revision 5284)
+++ tools/finsig_dryos.c (working copy)
@@ -282,6 +282,7 @@
     { "MoveFocusLensToDistance" },
     { "MoveIrisWithAv", OPTIONAL },
     { "MoveZoomLensWithPoint" },
+    { "MoveOpticalZoomAt", OPTIONAL },
     { "NewTaskShell", UNUSED },
     { "Open" },
     { "PB2Rec" },
@@ -2370,6 +2371,9 @@
     { 9, "_fdiv", "ConvertApexToApexStd_FW", 0,                           -3,   -3,   -3,   -3,   -3,   -3,   -3,   -3,   -3,   -3,   -3,   -3,   -3,   -3,   -3,   -3 },
     { 9, "GetSRAndDisableInterrupt", "_GetSystemTime", 0,                  9,    9,    9,    9,    9,    9,    9,    9,    9,    9,    9,    9,    9,    9,    9,    9 },
     { 9, "SetSR", "_GetSystemTime", 0,                                    12,   12,   12,   12,   12,   12,   12,   12,   12,   12,   12,   12,   12,   12,   12,   12 },
+    { 9, "MoveOpticalZoomAt", "PT_MoveOpticalZoomAt_FW", 0,                1,    2,    3,    3,    3,    3,    3,    3,    3,    3,    3,    3,    3,    3,    3,    3 },
+    { 9, "MoveOpticalZoomAt", "PT_MoveOpticalZoomAt_FW", 0,                1,    3,    3,    3,    3,    3,    3,    3,    3,    3,    3,    3,    3,    3,    3,    3 },
+    { 9, "MoveOpticalZoomAt", "SS.MoveOpticalZoomAt_FW", 0,                0,    0,    0,    0,    0,    0,    0,    0,    0,    3,    5,    5,    5,    5,    5,    5 },
 
     //                                                                   R20   R23   R31   R39   R43   R45   R47   R49   R50   R51   R52   R54   R55   R57   R58   R59
 //    { 11, "DebugAssert", "\nAssert: File %s Line %d\n", 0,                 5,    5,    5,    5,    5,    5,    5,    5,    5,    5,    1,    6 },

 

Related Topics


SimplePortal © 2008-2014, SimplePortal