Flash Toggle Slider Update Bug Fix#2
Open
TrevorDohm wants to merge 1 commit intoSMU-MSLC:6_AV_OpenCVExamplesfrom
Open
Flash Toggle Slider Update Bug Fix#2TrevorDohm wants to merge 1 commit intoSMU-MSLC:6_AV_OpenCVExamplesfrom
TrevorDohm wants to merge 1 commit intoSMU-MSLC:6_AV_OpenCVExamplesfrom
Conversation
|
IMO - Over-engineered functionality. Can re-factor torch to below implementation. Additional features should be implemented separately in View Controller or other section(s). Also, implements no other Delegates or classes. Should be located in original class VisionAnalgesic or, recommended, separate Torch class. Extension is not necessary. enum TorchState {
case on
case off
}
var torch: TorchState {
get {
guard let device = self.videoDevice, device.hasTorch else { return .off }
return device.torchMode == .on ? .on : .off
}
set {
guard let device = self.videoDevice, device.hasTorch else { return }
do {
try device.lockForConfiguration()
switch newValue {
case .on:
device.torchMode = .on
case .off:
device.torchMode = .off
}
device.unlockForConfiguration()
} catch {
Logger().error("Torch could not be used")
}
}
}
func torchBrightness(_ brightness: Float) {
guard let device = self.videoDevice, device.hasTorch else { return }
do {
try device.lockForConfiguration()
try device.setTorchModeOn(level: brightness)
device.unlockForConfiguration()
} catch {
Logger().error("Torch could not be used")
}
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current implementation of the
flashIBAction inViewController.swiftdoes not update the slider value when the flash is toggled using the button. This is due to the reliance on the return value of the toggleFlash function, which indicates the overheating status rather than the actual flashlight state. AddedisFlashOnparameter and some other toggling to fix.