@@ -218,6 +218,23 @@ local furthest_points = {
218218-- SRV_Channels:set_range(zoom_channel, 1000)
219219-- SRV_Channels:set_output_scaled(zoom_channel, 0)
220220
221+ local function set_zoom_focus_to_trim()
222+ local focus_channel = SRV_Channels:find_channel(92)
223+ local focus_max = param:get("SERVO" .. focus_channel + 1 .. "_MAX")
224+ local focus_min = param:get("SERVO" .. focus_channel + 1 .. "_MIN")
225+ local focus_trim = param:get("SERVO" .. focus_channel + 1 .. "_TRIM")
226+ local focus_scaled = 1000 * (focus_trim - focus_min) / (focus_max - focus_min)
227+ SRV_Channels:set_output_scaled(K_FOCUS, focus_scaled)
228+
229+ local zoom_channel = SRV_Channels:find_channel(180)
230+ local zoom_max = param:get("SERVO" .. zoom_channel + 1 .. "_MAX")
231+ local zoom_min = param:get("SERVO" .. zoom_channel + 1 .. "_MIN")
232+ local zoom_trim = param:get("SERVO" .. zoom_channel + 1 .. "_TRIM")
233+
234+ local zoom_scaled = 1000 * (zoom_trim - zoom_min) / (zoom_max - zoom_min)
235+ SRV_Channels:set_output_scaled(K_ZOOM, zoom_scaled)
236+ end
237+
221238-- Linear interpolation function
222239local function lerp(x, x1, y1, x2, y2)
223240 return y1 + (x - x1) * (y2 - y1) / (x2 - x1)
@@ -258,13 +275,20 @@ local function calculate_focus()
258275 return math.floor(closest_focus + focus_delta * (furthest_focus - closest_focus))
259276end
260277
278+ function start()
279+ if millis() <= 100000 then
280+ set_zoom_focus_to_trim()
281+ end
282+ return update, 100
283+ end
284+
261285function update()
262286 local focus_pos = calculate_focus()
263287 SRV_Channels:set_output_pwm(K_SCRIPTING1, focus_pos)
264288 return update, 100
265289end
266290
267- return update, 100
291+ return start, 1000
268292 "# ;
269293
270294 Ok ( file. to_string ( ) )
0 commit comments