1

I have an app that requires precise control of the torch output level. The level is set through this function:

setTorchModeOnWithLevel(_:)

The function asks for a continuous float between 0 and 1 but only seems to have 4 different output levels from 0 - 1.

Is this correct? I cannot find any documentation on whether the change is continuous or discrete across the input range.

aforward
  • 133
  • 1
  • 11

1 Answers1

1

How the underlying OS and hardware interpret the torch level value you pass is an implementation detail. In other words, the value is best understood as merely an advisory to the underlying system, with magnitude relevant only when compared against itself. That is, you can expect 1.0 to be as bright or brighter than 0.5, but only on the same hardware and the same OS version. (Max brightness on iPhone 7 is brighter than on iPhone 6, for example.) And the API makes no guarantees as to how many discrete brightness levels the underlying system supports.

(Aside: floats are not continuous. Okay, there's about 100 million discrete values between 0.0 and 1.0, not counting subnormals, which is smooth enough for a lot of use cases... but definitely not the same as continuous.)

rickster
  • 124,678
  • 26
  • 272
  • 326
  • Thanks for the answer. I'm new to developing for iPhone and I'm just surprised there is no documentation stating that! As far as I'm aware there isn't such a thing as a truly continuous data format, but floats/doubles come the closest. I was just expecting much more granularity than that! – aforward Dec 01 '16 at 15:15