开发者

Is there a way to dim the LED light on the iPhone 4?

Is there a method or proper开发者_如何学编程ty that allows you to set the brightness of the LED light on the iPhone 4?


There is a brightness method available for iOS 6 and later.

[AVCaptureDevice setTorchModeOnWithLevel:1.0 error:&error];

The 'level' is a float from 0 to ~1, AVCaptureMaxAvailableTorchLevel. Fluctuating this will allow us to modify brightness.


The LED light intensity never seems to vary when using it as a camera flash no matter what the external lighting conditions, so I speculate that the hardware only supports a fixed on/off switch for the light with a constant brightness.

If there is a way to alter the brightness, at the moment it is not exposed via any public API.


In principle, brightness can be varied using a PWM (pulse width modulation) technique: For example, for 50% brightness, turn the LED on for some period of time, then turn it off for the same period of time, and so on and so on. If performed fast enough, no flicker will be seen, and brightness will appear to be 50%.

Unfortunately, I have not found a way to toggle the iPhone's LED at a high enough frequency, yet. Toggling AVCaptureTorchModeOn / AVCaptureTorchModeOff does not appear to be fast enough - or maybe the main thread (on which I tried) just has a too low priority in iOS.

Edit: There now is an API for setting the torch level in iOS 6.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜