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

set_zoom problems in uBASIC & Lua scripts

  • 91 Replies
  • 30849 Views
*

Offline srsa_4c

  • ******
  • 4426
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #70 on: 15 / October / 2019, 16:26:01 »
Advertisements
Preliminary patch, requires platform_camera.h modification and stubs rebuild. DryOS r23 or later. Did not do a full rebuild to check whether MoveZoomTo is always identified. Also missing is the t2 sigfinder mod.
Code: [Select]
Index: core/shooting.c
===================================================================
--- core/shooting.c (revision 5279)
+++ core/shooting.c (working copy)
@@ -1209,6 +1209,9 @@
     int dist;
     if (!camera_info.state.mode_play)
     {
+#if defined(CAM_USE_MOVEZOOMTO)
+        lens_set_zoom_point(v);
+#else
         dist = shooting_get_subject_distance();
         lens_set_zoom_point(v);
 #if defined(CAM_NEED_SET_ZOOM_DELAY)
@@ -1215,6 +1218,7 @@
         msleep(CAM_NEED_SET_ZOOM_DELAY);
 #endif
         shooting_set_focus(dist, SET_NOW);
+#endif // !CAM_USE_MOVEZOOMTO
     }
 }
 
Index: include/camera.h
===================================================================
--- include/camera.h (revision 5279)
+++ include/camera.h (working copy)
@@ -242,6 +242,8 @@
     #undef  CAM_USE_ALT_PT_MoveOpticalZoomAt    // Define to use the PT_MoveOpticalZoomAt() function in lens_set_zoom_point()
     #undef  CAM_USE_OPTICAL_MAX_ZOOM_STATUS     // Use ZOOM_OPTICAL_MAX to reset zoom_status when switching from digital to optical zoom in gui_std_kbd_process()
 
+    #undef  CAM_USE_MOVEZOOMTO                  // Define to use the all-in-one UIFS_MoveZoomTo eventproc in lens_set_zoom_point()
+
     #undef  CAM_HAS_HI_ISO_AUTO_MODE            // Define if camera has 'HI ISO Auto' mode (as well as Auto ISO mode), needed for adjustment in user auto ISO menu
 
     #define CAMERA_MIN_DIST         0           // Define min distance that can be set in _MoveFocusLensToDistance (allow override - e.g. G12 min dist = 1)
Index: platform/generic/wrappers.c
===================================================================
--- platform/generic/wrappers.c (revision 5279)
+++ platform/generic/wrappers.c (working copy)
@@ -189,6 +189,8 @@
     return _GetZoomLensCurrentPoint();
 }
 
+static int mzt_speed = 1;
+
 void lens_set_zoom_point(long newpt)
 {
     if (newpt < 0) {
@@ -196,9 +198,11 @@
     } else if (newpt >= zoom_points) {
         newpt = zoom_points-1;
     }
+#if defined(CAM_USE_MOVEZOOMTO)
+    extern int _MoveZoomTo(int zoompoint, int speed, void* cbfunc);
+    _MoveZoomTo(newpt,mzt_speed,0);
+#elif defined(CAM_USE_ALT_SET_ZOOM_POINT)
 
-#if defined(CAM_USE_ALT_SET_ZOOM_POINT)
-
  if (lens_get_zoom_point() != newpt)
  {
  int digizoom_pos;
@@ -249,6 +253,15 @@
 
 void lens_set_zoom_speed(long newspd)
 {
+#if defined(CAM_USE_MOVEZOOMTO)
+    if (newspd < 34) {
+        mzt_speed = 1;
+    } else if (newspd < 67) {
+        mzt_speed = 2;
+    } else {
+        mzt_speed = 3;
+    }
+#else // !CAM_USE_MOVEZOOMTO
     if (newspd < 5) {
         newspd = 5;
     } else if (newspd > 100) {
@@ -255,6 +268,7 @@
         newspd = 100;
     }
     _SetZoomActuatorSpeedPercent((short*)&newspd);
+#endif // !CAM_USE_MOVEZOOMTO
 }
 
 void lens_set_focus_pos(long newpos)
Index: platform/ixus150_elph140/platform_camera.h
===================================================================
--- platform/ixus150_elph140/platform_camera.h (revision 5279)
+++ platform/ixus150_elph140/platform_camera.h (working copy)
@@ -91,9 +91,7 @@
 
     #define CAM_DISABLE_RAW_IN_LOW_LIGHT_MODE   1   // For cameras with 'low light' mode that does not work with raw define this
 
-    #define CAM_USE_ALT_SET_ZOOM_POINT          1   // Define to use the alternate code in lens_set_zoom_point()
-    #define CAM_USE_ALT_PT_MoveOpticalZoomAt    1   // Define to use the PT_MoveOpticalZoomAt() function in lens_set_zoom_point()
-    #define CAM_NEED_SET_ZOOM_DELAY             300 // Define to add a delay after setting the zoom position
+    #define CAM_USE_MOVEZOOMTO                  1
     
     #undef  CAM_HAS_ERASE_BUTTON
     #undef  CAM_HAS_DISP_BUTTON
Index: platform/ixus150_elph140/sub/100c/funcs_by_address.csv
===================================================================
--- platform/ixus150_elph140/sub/100c/funcs_by_address.csv (revision 5279)
+++ platform/ixus150_elph140/sub/100c/funcs_by_address.csv (working copy)
@@ -297,6 +297,7 @@
 0xff85b3fc,UIFS_StartMovieRecord_FW
 0xff85b420,UIFS_StopMovieRecord_FW
 0xff85d180,UIFS_GetNumOfOptZoomPos_FW
+0xff85d2a4,MoveZoomTo
 0xff85d2a4,UIFS_MoveZoomTo_FW
 0xff85fbf4,UIFS_IsAvailableShots_FW
 0xff86010c,UIFS_GetStillShotableNumber_FW
Index: platform/ixus150_elph140/sub/100c/funcs_by_name.csv
===================================================================
--- platform/ixus150_elph140/sub/100c/funcs_by_name.csv (revision 5279)
+++ platform/ixus150_elph140/sub/100c/funcs_by_name.csv (working copy)
@@ -1120,6 +1120,7 @@
 0xffabf5f0,MoveZoomLensWithPosition_FW
 0xffa91968,MoveZoomPoint_FW
 0xffa91928,MoveZoomPosition_FW
+0xff85d2a4,MoveZoomTo
 0xff8f3ecc,MovieAF.Resume_FW
 0xff8f3eb8,MovieAF.Suspend_FW
 0xff8361ec,NewTaskShell
Index: platform/ixus150_elph140/sub/100c/stubs_entry.S
===================================================================
--- platform/ixus150_elph140/sub/100c/stubs_entry.S (revision 5279)
+++ platform/ixus150_elph140/sub/100c/stubs_entry.S (working copy)
@@ -271,6 +271,7 @@
 NHSTUB(free                                   ,0xff825220) //112
 NHSTUB(get_nd_value                           ,0xffab1314) //123
 NHSTUB(get_current_nd_value                   ,0xffab12b4) //122
+NHSTUB(MoveZoomTo                             ,0xff85d2a4) //120
 NHSTUB(kbd_p1_f                               ,0xff82bdf8) //109
 NHSTUB(kbd_p1_f_cont                          ,0xff82be04) //109
 NHSTUB(kbd_p2_f                               ,0xff82b598) //109
Index: tools/finsig_dryos.c
===================================================================
--- tools/finsig_dryos.c (revision 5279)
+++ tools/finsig_dryos.c (working copy)
@@ -345,6 +345,7 @@
     { "get_current_nd_value", OPTIONAL },
     { "GetUsableAvRange", OPTIONAL|UNUSED },
     { "GetBaseSv", OPTIONAL|UNUSED },
+    { "MoveZoomTo", OPTIONAL },
 
     { "kbd_p1_f" },
     { "kbd_p1_f_cont" },
@@ -2125,6 +2126,7 @@
     {20, "HwOcReadICAPCounter", "GetCurrentMachineTime", 1 },
     {20, "DisableISDriveError", "DisableISDriveError_FW", 1},
     {20, "SetImageMode", "SetImageMode_FW", 0x01000002 },
+    {20, "MoveZoomTo", "UIFS_MoveZoomTo_FW", 1 },
 
     { 1, "ExportToEventProcedure_FW", "ExportToEventProcedure", 1 },
     { 1, "AllocateMemory", "AllocateMemory", 1 },

*

Offline reyalp

  • ******
  • 13391
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #71 on: 15 / October / 2019, 23:57:40 »
Here's the trivial t2 sigfinder patch.  The EOS M cameras just return, as expected.

Initial observations on sx710
With CAM_USE_MOVEZOOMTO, set_zoom returns immediately, where the previous versions block until the zoom finished. Keeping compatible behavior would be good, presumably the zoom_busy loop could be used.

Using set_zoom cancels digital zoom from the "digital teleconverter" setting

Distortion correction appears to be equivalent between set_zoom and manual zooming. I only checked one focal length (50mm equiv, zoom pos 19).

edit:
attach the file   :-[
« Last Edit: 16 / October / 2019, 00:16:20 by reyalp »
Don't forget what the H stands for.

*

Offline srsa_4c

  • ******
  • 4426
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #72 on: 16 / October / 2019, 19:38:17 »
Here's the trivial t2 sigfinder patch.
Thanks.
Quote
Initial observations on sx710
With CAM_USE_MOVEZOOMTO, set_zoom returns immediately, where the previous versions block until the zoom finished. Keeping compatible behavior would be good, presumably the zoom_busy loop could be used.
Added.

*

Offline reyalp

  • ******
  • 13391
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #73 on: 17 / October / 2019, 02:41:18 »
Zoom wait seems good.
I tested on elph130. Results mostly similar to sx710. One thing I noticed, there only seem to be 2 zoom speeds. with < 34, a moving full zoom range takes ~7 seconds. At larger values, it takes ~1.5. Tested like
Code: [Select]
=set_zoom_speed(32) t=get_tick_count() set_zoom(get_zoom_steps()) return get_tick_count()-t
=set_zoom_speed(32) t=get_tick_count() set_zoom(0) return get_tick_count()-t

The initial value of mzt_speed is 1, which corresponds to the slow speed. The fast speed seem to be the one you get using the zoom lever or the old set_zoom.

SX710 also shows only two speeds, but the first two are slow: <= 66 takes ~3.7 seconds, while > takes 2.2. Again the faster speed seems like the "normal" one to me.

Don't forget what the H stands for.


Re: set_zoom problems in uBASIC & Lua scripts
« Reply #74 on: 17 / October / 2019, 08:40:32 »

Forgive my ignorance, but will this approach allow one to move from a known position in mm to another position in mm.


Or 'just' move with no positional feedback?


...and on a G1X and G7X  ;)

*

Offline reyalp

  • ******
  • 13391
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #75 on: 17 / October / 2019, 12:58:20 »

Forgive my ignorance, but will this approach allow one to move from a known position in mm to another position in mm.
This change mainly affects zoom, not focus. It exposes the same zoom steps as the existing set_zoom. The impact on focus is only related to what happens to the focus position during / after zoom, and crashes connected to trying to set focus.
Don't forget what the H stands for.

Re: set_zoom problems in uBASIC & Lua scripts
« Reply #76 on: 17 / October / 2019, 13:00:22 »
@reyalp


Many thanks for the insight.


Cheers


Garry

*

Online Caefix

  • *****
  • 600
  • Sorry, busy deleting test shots...
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #77 on: 17 / October / 2019, 14:24:28 »
 ??? Sx710 noise.

if %~x1?==? (cmd /T:4E/Kdir/b/s/on %1) else (cmd /T:1F/K type %0 %*|find /N "OptAt")
« Last Edit: 17 / October / 2019, 15:14:42 by Caefix »
All lifetime is a loan from eternity.


*

Offline srsa_4c

  • ******
  • 4426
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #78 on: 17 / October / 2019, 14:45:07 »
I tested on elph130. Results mostly similar to sx710. One thing I noticed, there only seem to be 2 zoom speeds.
Ixus150: this one has a single speed zoom lever. Zooms fast when not recording video, slow while recording. Those 2 speeds are available for MoveZoomTo.
sx280: multi-speed zoom, but only 2 speeds are available at a given time when rotating the zoom ring. (slower when recording). Did not test all possible speeds with MoveZoomTo.

Quote
The initial value of mzt_speed is 1, which corresponds to the slow speed. The fast speed seem to be the one you get using the zoom lever or the old set_zoom.
Indeed, I looked up PT_MoveOpticalZoomAt in one (multi-speed) firmware and it sets zoom speed to 3.

I checked a few firmwares and the highest zoom speed is 3, in all multi-speed cases. Zero also seems a valid speed.

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.

*

Offline reyalp

  • ******
  • 13391
Re: set_zoom problems in uBASIC & Lua scripts
« Reply #79 on: 19 / October / 2019, 00:01:28 »
??? Sx710 noise.
Romlogs without any information about how the crash occurred are not useful. If you want a bug fixed, give us enough information to do something.
Don't forget what the H stands for.

 

Related Topics