# 4k Camera Zoom/Focus rate of change

**URL:** <https://discuss.bluerobotics.com/t/4k-camera-zoom-focus-rate-of-change/23636>\
**Category:** Cameras\
**Created:** [September 24, 2026, 10:56am UTC](https://discuss.bluerobotics.com/t/4k-camera-zoom-focus-rate-of-change/23636 "2026-09-24T10:56:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![3dMB](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/3dmb/32/13905_2.png) [@3dMB](https://discuss.bluerobotics.com/u/3dMB)\
**Post date:** [September 24, 2026, 10:56am UTC](https://discuss.bluerobotics.com/t/4k-camera-zoom-focus-rate-of-change/23636/1 "2026-09-24T10:56:51Z")

</div>

Is there a way to increase the rate/speed of change of the zoom & focus on the new 4k camera, on x-box controller? If I use the cockpit widget sliders to go from say 1x to 2x magnification, the change is pretty quick (around 4 seconds), if I use the x-box buttons, the change takes 20 seconds. If I go to the PWM setup in BlueOS, there are the min/trim/max variables - which set the range, but not the speed. In Cockpit Joystick Configuration I can bind the buttons to the function, but no mention of speed/rate.

---

<div class="post-metadata">

**Author:** ![mattcmgb](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@mattcmgb](https://discuss.bluerobotics.com/u/mattcmgb)\
**Post date:** [September 25, 2026, 12:22pm UTC](https://discuss.bluerobotics.com/t/4k-camera-zoom-focus-rate-of-change/23636/2 "2026-09-25T12:22:49Z")

</div>

Agree that this would be a welcome change. I would also like the option to have preset zoom levels and option to bind to a button, so the camera just goes to a preset on button press.

---

<div class="post-metadata">

**Author:** ![tony-white](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/tony-white/32/18385_2.png) [@tony-white](https://discuss.bluerobotics.com/u/tony-white)\
**Post date:** [September 25, 2026, 10:52pm UTC](https://discuss.bluerobotics.com/t/4k-camera-zoom-focus-rate-of-change/23636/3 "2026-09-25T22:52:59Z")

</div>

Hi @3dMB -  
Yes, it is quite easy to adjust the speed. Simply search the datalake for Camera Zoom / Focus:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/bluerobotics/original/3X/b/5/b57a45e65abf455fedbf5761a01ec2ba991d754d.png)  
Click the pencil icon to edit:  
 ![image](https://us1.discourse-cdn.com/flex019/uploads/bluerobotics/original/3X/5/e/5e75fa8f5fa8192a5630020bb0998a0ecbe12914.png)

adjust the code to have the speed factor multiplier you’d like:

```auto
const speedFactor = 5
const zoom = {{camera-zoom-increase}} -
{{camera-zoom-decrease}}
return zoom < 0.05 && zoom > -0.05 ? 0: speedFactor * zoom

```

@mattcmgb  
You can potentially get that sort of functionality from buttons on-screen in Cockpit (not a game controller button, but maybe that too?) You’re simply wanting to set servo output(s) to a pre-determined value via a [custom action](https://blueos.cloud/cockpit/docs/latest/usage/advanced/#custom-actions) for [DO\_set\_servo](https://mavlink.io/en/messages/common.html#MAV_CMD_DO_SET_SERVO) - Eliot has [detailed](https://discuss.bluerobotics.com/t/cockpit-slider-to-control-light-brightness/20722) how that is accomplished in Cockpit before for a vaguely similar case, but we can provide some specific documentation to this case if it would be helpful!

---

<div class="post-metadata">

**Author:** ![EliotBR](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/eliotbr/32/6937_2.png) [@EliotBR](https://discuss.bluerobotics.com/u/EliotBR)\
**Post date:** [September 25, 2026, 11:59pm UTC](https://discuss.bluerobotics.com/t/4k-camera-zoom-focus-rate-of-change/23636/4 "2026-09-25T23:59:46Z")

</div>

Noting there’s [an incoming firmware change](https://github.com/ArduPilot/ardupilot/pull/34428) to enable more correctly implemented speed changes going forwards, but that doesn’t work yet, so we’re holding off including this functionality in our official guides until the implementation is stabilised.

If you want the behaviour in the meantime then Tony’s Cockpit multiplication approach is the way to go (possibly using an extra data-lake variable for the speed instead of a fixed factor, if you want it to be readily adjustable), but that method involves sending values that are technically outside the MAVLink spec, so will stop working in a future firmware update (when the autopilot parameter approach becomes available).

---

<div class="post-metadata">

**Author:** ![3dMB](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/3dmb/32/13905_2.png) [@3dMB](https://discuss.bluerobotics.com/u/3dMB)\
**Post date:** [October 3, 2026, 11:26am UTC](https://discuss.bluerobotics.com/t/4k-camera-zoom-focus-rate-of-change/23636/5 "2026-10-03T11:26:03Z")

</div>

> [@tony-white](#):
>
> `const speedFactor = 5`

Adding this to the focus does not seem to have any effect on focus speed. I have changed the number upto 5000 and no change. For clarity, the expression is as follows:

const speedFactor = 5  
const focus = {{camera-focus-increase}} -  
{{camera-focus-decrease}}  
return focus \< 0.05 && focus \> -0.05 ? 0: Math.max (Math.min(1, focus), -1)

---

<div class="post-metadata">

**Author:** ![tony-white](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/tony-white/32/18385_2.png) [@tony-white](https://discuss.bluerobotics.com/u/tony-white)\
**Post date:** [October 3, 2026, 12:15pm UTC](https://discuss.bluerobotics.com/t/4k-camera-zoom-focus-rate-of-change/23636/6 "2026-10-03T12:15:57Z")

</div>

Hi @3dMB -  
Your expression does not include the second instance of the speed factor multiplying the output, you only define it. Without multiplying by it, you see no increase!

---

<div class="post-metadata">

**Author:** ![3dMB](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/3dmb/32/13905_2.png) [@3dMB](https://discuss.bluerobotics.com/u/3dMB)\
**Post date:** [October 3, 2026, 12:46pm UTC](https://discuss.bluerobotics.com/t/4k-camera-zoom-focus-rate-of-change/23636/7 "2026-10-03T12:46:52Z")

</div>

I appreciate the reply @tony-white but you may as well have written it in Chinese for what it is worth.

So going on your zoom example, the expression started with:

> [@tony-white](#):
>
> ```auto
> const zoom = {{camera-zoom-increase}} -
> {{camera-zoom-decrease}}
> return zoom < 0.05 && zoom > -0.05 ? 0: zoom
> 
> ```

then changed to:

> [@tony-white](#):
>
> ```auto
> const speedFactor = 5
> const zoom = {{camera-zoom-increase}} -
> {{camera-zoom-decrease}}
> return zoom < 0.05 && zoom > -0.05 ? 0: speedFactor * zoom
> 
> ```

So I can see that you have added the “const speedFactor = 5” in line 1. I now also see that you have added "speedfactor \* " between 0: and zoom, at the end.

The focus expression has the addition of “Math.max (Math.min(1, focus), -1)”, that the zoom expression does not have.

I can only assume that when you say “Your expression does not include the second instance of the speed factor multiplying the output,” - does this refer to the "speedfactor \* " that was added to the zoom expression? If so, where does it go?

---

<div class="post-metadata">

**Author:** ![3dMB](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/3dmb/32/13905_2.png) [@3dMB](https://discuss.bluerobotics.com/u/3dMB)\
**Post date:** [October 3, 2026, 3:58pm UTC](https://discuss.bluerobotics.com/t/4k-camera-zoom-focus-rate-of-change/23636/8 "2026-10-03T15:58:25Z")

</div>

@tony-white due to your recommendations on previous topics, I have used AI, which went around the houses a bit, however it has now come up with a workable solution. Simply adding the second instance did not work. This failed due to the extra clamp of “Math.max(Math.min(1, focus), -1)”. The final working expressions should be:

Zoom:

```java
const speedFactor = 5
const zoom = {{camera-zoom-increase}} -
{{camera-zoom-decrease}}
return zoom < 0.05 && zoom > -0.05 ? 0 : speedFactor * zoom

```

Focus:

```java
const speedFactor = 5
const focus = {{camera-focus-increase}} -
{{camera-focus-decrease}}
return focus < 0.05 && focus > -0.05 ? 0 : speedFactor * focus

```
