diff --git a/BluefruitPlayground-SimulatedBluetooth-Info.plist b/BluefruitPlayground-SimulatedBluetooth-Info.plist
index 8eac424..b94dfcf 100644
--- a/BluefruitPlayground-SimulatedBluetooth-Info.plist
+++ b/BluefruitPlayground-SimulatedBluetooth-Info.plist
@@ -28,6 +28,8 @@
This app needs access to Bluetooth to connect to Circuit Playground Bluefruit devices
NSBluetoothPeripheralUsageDescription
This app needs access to Bluetooth to connect to Circuit Playground Bluefruit devices
+ NSCameraUsageDescription
+ Puppet module requires access to the camera
UILaunchStoryboardName
LaunchScreen
UIMainStoryboardFile
diff --git a/BluefruitPlayground.xcodeproj/project.pbxproj b/BluefruitPlayground.xcodeproj/project.pbxproj
index bc36463..3642e4f 100644
--- a/BluefruitPlayground.xcodeproj/project.pbxproj
+++ b/BluefruitPlayground.xcodeproj/project.pbxproj
@@ -1347,7 +1347,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 12;
+ CURRENT_PROJECT_VERSION = 13;
DEVELOPMENT_TEAM = 2X94RM7457;
INFOPLIST_FILE = BluefruitPlayground/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
@@ -1372,7 +1372,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 12;
+ CURRENT_PROJECT_VERSION = 13;
DEVELOPMENT_TEAM = 2X94RM7457;
INFOPLIST_FILE = BluefruitPlayground/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
@@ -1436,7 +1436,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 12;
+ CURRENT_PROJECT_VERSION = 13;
DEVELOPMENT_TEAM = 2X94RM7457;
INFOPLIST_FILE = "BluefruitPlayground-SimulatedBluetooth-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
@@ -1446,7 +1446,7 @@
);
MARKETING_VERSION = 1.2.0;
OTHER_SWIFT_FLAGS = "$(inherited) -D COCOAPODS -D SIMULATEBLUETOOTH";
- PRODUCT_BUNDLE_IDENTIFIER = com.adafruit.BluefruitPlayground;
+ PRODUCT_BUNDLE_IDENTIFIER = com.adafruit.BluefruitPlayground.simulated;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "BluefruitPlayground/BluefruitPlayground-SimulateBluetooth-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -1462,7 +1462,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 12;
+ CURRENT_PROJECT_VERSION = 13;
DEVELOPMENT_TEAM = 2X94RM7457;
INFOPLIST_FILE = "BluefruitPlayground-SimulatedBluetooth-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
@@ -1472,7 +1472,7 @@
);
MARKETING_VERSION = 1.2.0;
OTHER_SWIFT_FLAGS = "$(inherited) -D COCOAPODS -D SIMULATEBLUETOOTH";
- PRODUCT_BUNDLE_IDENTIFIER = com.adafruit.BluefruitPlayground;
+ PRODUCT_BUNDLE_IDENTIFIER = com.adafruit.BluefruitPlayground.simulated;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "BluefruitPlayground/BluefruitPlayground-SimulateBluetooth-Bridging-Header.h";
SWIFT_VERSION = 5.0;
diff --git a/BluefruitPlayground/AdafruitKit/Ble/BleCentralMode/BleManager.swift b/BluefruitPlayground/AdafruitKit/Ble/BleCentralMode/BleManager.swift
index 8addc22..c5515b8 100644
--- a/BluefruitPlayground/AdafruitKit/Ble/BleCentralMode/BleManager.swift
+++ b/BluefruitPlayground/AdafruitKit/Ble/BleCentralMode/BleManager.swift
@@ -38,7 +38,7 @@ class BleManager: NSObject {
internal var scanningStartTime: TimeInterval? // Time when the scanning started. nil if stopped
private var scanningServicesFilter: [CBUUID]?
internal var peripheralsFound = [UUID: BlePeripheral]()
- private var peripheralsFoundLock = NSLock()
+ internal var peripheralsFoundLock = NSLock()
// Connecting
private var connectionTimeoutTimers = [UUID: MSWeakTimer]()
@@ -353,6 +353,10 @@ extension BleManager: CBCentralManagerDelegate {
func centralManager(_ central: CBCentralManager, didFailToConnect peripheral: CBPeripheral, error: Error?) {
DLog("didFailToConnect")
+ // Clean
+ peripheralsFound[peripheral.identifier]?.reset()
+
+ // Notify
NotificationCenter.default.post(name: .didDisconnectFromPeripheral, object: nil, userInfo: [NotificationUserInfoKey.uuid.rawValue: peripheral.identifier])
}
diff --git a/BluefruitPlayground/AdafruitKit/Ble/BleCentralMode/BlePeripheral.swift b/BluefruitPlayground/AdafruitKit/Ble/BleCentralMode/BlePeripheral.swift
index 9de31b4..cbf8ae1 100644
--- a/BluefruitPlayground/AdafruitKit/Ble/BleCentralMode/BlePeripheral.swift
+++ b/BluefruitPlayground/AdafruitKit/Ble/BleCentralMode/BlePeripheral.swift
@@ -337,7 +337,7 @@ class BlePeripheral: NSObject {
}
// MARK: - Command Queue
- private class BleCommand: Equatable {
+ internal class BleCommand: Equatable {
enum CommandType {
case discoverService
case discoverCharacteristic
@@ -404,7 +404,7 @@ class BlePeripheral: NSObject {
return "\(descriptor.characteristic.service.uuid.uuidString)-\(descriptor.characteristic.uuid.uuidString)-\(descriptor.uuid.uuidString)"
}
- private func finishedExecutingCommand(error: Error?) {
+ internal func finishedExecutingCommand(error: Error?) {
//DLog("finishedExecutingCommand")
// Result Callback
@@ -523,7 +523,7 @@ class BlePeripheral: NSObject {
peripheral.readValue(for: descriptor)
}
- private func disconnect(with command: BleCommand) {
+ internal func disconnect(with command: BleCommand) {
let centralManager = command.parameters!.first as! CBCentralManager
centralManager.cancelPeripheralConnection(self.peripheral)
finishedExecutingCommand(error: nil)
diff --git a/BluefruitPlayground/AdafruitKit/Ble/Tests/BleManagerSimulated.swift b/BluefruitPlayground/AdafruitKit/Ble/Tests/BleManagerSimulated.swift
index fb35ded..530836f 100644
--- a/BluefruitPlayground/AdafruitKit/Ble/Tests/BleManagerSimulated.swift
+++ b/BluefruitPlayground/AdafruitKit/Ble/Tests/BleManagerSimulated.swift
@@ -19,6 +19,7 @@ class BleManagerSimulated: BleManager {
}
+ // MARK: - Scanning
override func startScan(withServices services: [CBUUID]? = nil) {
scanningStartTime = CACurrentMediaTime()
@@ -31,8 +32,12 @@ class BleManagerSimulated: BleManager {
override func stopScan() {
}
+ // MARK: - Connect
override func connect(to peripheral: BlePeripheral, timeout: TimeInterval? = nil, shouldNotifyOnConnection: Bool = false, shouldNotifyOnDisconnection: Bool = false, shouldNotifyOnNotification: Bool = false) {
+ guard let blePeripheral = peripheral as? BlePeripheralSimulated else { return }
+ blePeripheral.simulateConnect()
+
// Send notification
NotificationCenter.default.post(name: .didConnectToPeripheral, object: nil, userInfo: [NotificationUserInfoKey.uuid.rawValue: peripheral.identifier])
}
@@ -40,4 +45,34 @@ class BleManagerSimulated: BleManager {
override func reconnecToPeripherals(withIdentifiers identifiers: [UUID], withServices services: [CBUUID], timeout: Double? = nil) -> Bool {
return false
}
+
+ // MARK: - Disconnect
+ override func disconnect(from peripheral: BlePeripheral, waitForQueuedCommands: Bool = false) {
+ guard let blePeripheral = peripheral as? BlePeripheralSimulated else { return }
+
+ DLog("disconnect")
+ NotificationCenter.default.post(name: .willDisconnectFromPeripheral, object: nil, userInfo: [NotificationUserInfoKey.uuid.rawValue: peripheral.identifier])
+
+ if waitForQueuedCommands {
+ // Send the disconnection to the command queue, so all the previous command are executed before disconnecting
+ if let centralManager = centralManager {
+ blePeripheral.disconnect(centralManager: centralManager)
+ }
+ }
+ else {
+ didDisconnectPeripheral(blePeripheral: blePeripheral)
+ }
+ }
+
+ func didDisconnectPeripheral(blePeripheral: BlePeripheralSimulated) {
+ DLog("didDisconnectPeripheral")
+
+ // Clean
+ peripheralsFound[blePeripheral.identifier]?.reset()
+
+ // Notify
+ NotificationCenter.default.post(name: .didDisconnectFromPeripheral, object: nil, userInfo: [NotificationUserInfoKey.uuid.rawValue: blePeripheral.identifier])
+
+ // Don't remove the peripheral from the peripheral list (so we can select again the simulated peripheral)
+ }
}
diff --git a/BluefruitPlayground/AdafruitKit/Ble/Tests/BlePeripheralSimulated.swift b/BluefruitPlayground/AdafruitKit/Ble/Tests/BlePeripheralSimulated.swift
index 121e024..2302864 100644
--- a/BluefruitPlayground/AdafruitKit/Ble/Tests/BlePeripheralSimulated.swift
+++ b/BluefruitPlayground/AdafruitKit/Ble/Tests/BlePeripheralSimulated.swift
@@ -10,20 +10,19 @@ import Foundation
import CoreBluetooth
class BlePeripheralSimulated: BlePeripheral {
- // Constants
- private static let kSimulatedUUID = UUID(uuidString: "E621E1F8-C36C-495A-93FC-0C247A3E6E5F")!
-
// Data
+ private var simulatedIdentifier = UUID()
override var identifier: UUID {
- return BlePeripheralSimulated.kSimulatedUUID
+ return simulatedIdentifier
}
override var name: String? {
return "Simulated Peripheral"
}
-
+
+ private var simulatedState: CBPeripheralState = .disconnected
override var state: CBPeripheralState {
- return .connected
+ return simulatedState
}
// MARK: - Lifecycle
@@ -46,5 +45,20 @@ class BlePeripheralSimulated: BlePeripheral {
override func discover(serviceUuids: [CBUUID]?, completion: ((Error?) -> Void)?) {
completion?(nil)
}
+
+ // MARK: - Connect
+ func simulateConnect() {
+ simulatedState = .connected
+ }
+
+ // MARK: - Disconnect
+ override internal func disconnect(with command: BleCommand) {
+ // Simulate disconnection
+ simulatedState = .disconnected
+ BleManagerSimulated.simulated.didDisconnectPeripheral(blePeripheral: self)
+
+ // Finished
+ finishedExecutingCommand(error: nil)
+ }
}
diff --git a/BluefruitPlayground/Assets.xcassets/puppet/puppet_hand.imageset/puppet_hand.png b/BluefruitPlayground/Assets.xcassets/puppet/puppet_hand.imageset/puppet_hand.png
index a83c41b..9d7499c 100644
Binary files a/BluefruitPlayground/Assets.xcassets/puppet/puppet_hand.imageset/puppet_hand.png and b/BluefruitPlayground/Assets.xcassets/puppet/puppet_hand.imageset/puppet_hand.png differ
diff --git a/BluefruitPlayground/Assets.xcassets/puppet/puppet_hand.imageset/puppet_hand@2x.png b/BluefruitPlayground/Assets.xcassets/puppet/puppet_hand.imageset/puppet_hand@2x.png
index 63c7634..3b46162 100644
Binary files a/BluefruitPlayground/Assets.xcassets/puppet/puppet_hand.imageset/puppet_hand@2x.png and b/BluefruitPlayground/Assets.xcassets/puppet/puppet_hand.imageset/puppet_hand@2x.png differ
diff --git a/BluefruitPlayground/Assets.xcassets/puppet/puppet_hand.imageset/puppet_hand@3x.png b/BluefruitPlayground/Assets.xcassets/puppet/puppet_hand.imageset/puppet_hand@3x.png
index 7e514f6..9cb39e8 100644
Binary files a/BluefruitPlayground/Assets.xcassets/puppet/puppet_hand.imageset/puppet_hand@3x.png and b/BluefruitPlayground/Assets.xcassets/puppet/puppet_hand.imageset/puppet_hand@3x.png differ
diff --git a/BluefruitPlayground/Assets.xcassets/scan_problems/scanproblems_powerup.imageset/Contents.json b/BluefruitPlayground/Assets.xcassets/scan_problems/scanproblems_powerup.imageset/Contents.json
index 1f52187..6233972 100644
--- a/BluefruitPlayground/Assets.xcassets/scan_problems/scanproblems_powerup.imageset/Contents.json
+++ b/BluefruitPlayground/Assets.xcassets/scan_problems/scanproblems_powerup.imageset/Contents.json
@@ -12,6 +12,7 @@
},
{
"idiom" : "universal",
+ "filename" : "scanproblems_powerup@3x.png",
"scale" : "3x"
}
],
diff --git a/BluefruitPlayground/Assets.xcassets/scan_problems/scanproblems_powerup.imageset/scanproblems_powerup.png b/BluefruitPlayground/Assets.xcassets/scan_problems/scanproblems_powerup.imageset/scanproblems_powerup.png
index 2e38487..c5ad969 100644
Binary files a/BluefruitPlayground/Assets.xcassets/scan_problems/scanproblems_powerup.imageset/scanproblems_powerup.png and b/BluefruitPlayground/Assets.xcassets/scan_problems/scanproblems_powerup.imageset/scanproblems_powerup.png differ
diff --git a/BluefruitPlayground/Assets.xcassets/scan_problems/scanproblems_powerup.imageset/scanproblems_powerup@2x.png b/BluefruitPlayground/Assets.xcassets/scan_problems/scanproblems_powerup.imageset/scanproblems_powerup@2x.png
index 99e046d..ca8a38c 100644
Binary files a/BluefruitPlayground/Assets.xcassets/scan_problems/scanproblems_powerup.imageset/scanproblems_powerup@2x.png and b/BluefruitPlayground/Assets.xcassets/scan_problems/scanproblems_powerup.imageset/scanproblems_powerup@2x.png differ
diff --git a/BluefruitPlayground/Assets.xcassets/scan_problems/scanproblems_powerup.imageset/scanproblems_powerup@3x.png b/BluefruitPlayground/Assets.xcassets/scan_problems/scanproblems_powerup.imageset/scanproblems_powerup@3x.png
new file mode 100644
index 0000000..d88f7a2
Binary files /dev/null and b/BluefruitPlayground/Assets.xcassets/scan_problems/scanproblems_powerup.imageset/scanproblems_powerup@3x.png differ
diff --git a/BluefruitPlayground/Assets.xcassets/splash/welcome_logo.imageset/welcome_logo.png b/BluefruitPlayground/Assets.xcassets/splash/welcome_logo.imageset/welcome_logo.png
index 3bc3303..1d787e0 100644
Binary files a/BluefruitPlayground/Assets.xcassets/splash/welcome_logo.imageset/welcome_logo.png and b/BluefruitPlayground/Assets.xcassets/splash/welcome_logo.imageset/welcome_logo.png differ
diff --git a/BluefruitPlayground/Assets.xcassets/splash/welcome_logo.imageset/welcome_logo@2x.png b/BluefruitPlayground/Assets.xcassets/splash/welcome_logo.imageset/welcome_logo@2x.png
index 3db9480..19ddd35 100644
Binary files a/BluefruitPlayground/Assets.xcassets/splash/welcome_logo.imageset/welcome_logo@2x.png and b/BluefruitPlayground/Assets.xcassets/splash/welcome_logo.imageset/welcome_logo@2x.png differ
diff --git a/BluefruitPlayground/Assets.xcassets/splash/welcome_logo.imageset/welcome_logo@3x.png b/BluefruitPlayground/Assets.xcassets/splash/welcome_logo.imageset/welcome_logo@3x.png
index 608460a..0058af7 100644
Binary files a/BluefruitPlayground/Assets.xcassets/splash/welcome_logo.imageset/welcome_logo@3x.png and b/BluefruitPlayground/Assets.xcassets/splash/welcome_logo.imageset/welcome_logo@3x.png differ
diff --git a/BluefruitPlayground/Base.lproj/Main.storyboard b/BluefruitPlayground/Base.lproj/Main.storyboard
index 1e64a5b..934c058 100644
--- a/BluefruitPlayground/Base.lproj/Main.storyboard
+++ b/BluefruitPlayground/Base.lproj/Main.storyboard
@@ -1,6 +1,6 @@
-
+
@@ -18,16 +18,19 @@
-
+
+
+
+
-
+
@@ -36,9 +39,10 @@
-
-
+
+
+
@@ -194,10 +198,10 @@
-
+
-
+
@@ -704,7 +708,7 @@
-
+
@@ -718,7 +722,7 @@
-
+
@@ -776,19 +780,19 @@
-
+
-
+
@@ -900,11 +904,11 @@
-
+
-
-
+
+
@@ -917,7 +921,7 @@
-
+
@@ -927,10 +931,10 @@
-
+
-
+
@@ -938,7 +942,7 @@
-
+
@@ -946,7 +950,7 @@
-
+
@@ -954,7 +958,7 @@
-
+
@@ -962,7 +966,7 @@
-
+
@@ -970,7 +974,7 @@
-
+
@@ -980,10 +984,10 @@
-
+
-
+
@@ -991,7 +995,7 @@
-
+
@@ -999,7 +1003,7 @@
-
+
@@ -1007,7 +1011,7 @@
-
+
@@ -1015,7 +1019,7 @@
-
+
@@ -1023,7 +1027,7 @@
-
+
@@ -1043,14 +1047,14 @@
-
+
-
+
@@ -1064,7 +1068,7 @@
-
+
@@ -1079,7 +1083,7 @@
-
+
@@ -1087,21 +1091,21 @@
-
+
-
+
-
+
@@ -1149,7 +1153,7 @@
-
+
@@ -1227,14 +1231,14 @@
-
+
-
+
-
+
@@ -1310,13 +1314,13 @@
-
+
-
+
-
+
-
+
-
+
@@ -1936,19 +1941,19 @@
-
+
-
+
-
+
@@ -2035,14 +2040,14 @@
-
+
-
+
-
+
@@ -2061,36 +2066,36 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -2224,7 +2229,7 @@
-
+
@@ -2323,7 +2328,7 @@
-
+
@@ -2433,16 +2438,16 @@
-
+
-
+
-
+
@@ -2521,31 +2526,31 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -2553,16 +2558,16 @@
-
+
-
+
-
+
@@ -2572,10 +2577,10 @@
-
+
-
+
@@ -2813,38 +2818,38 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -2859,27 +2864,27 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -2900,7 +2905,7 @@
-
+
@@ -2984,25 +2989,25 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -3015,7 +3020,7 @@
-
+
@@ -3023,13 +3028,13 @@
-
+
-
+
-
+
@@ -3042,7 +3047,7 @@
-
+
@@ -3050,13 +3055,13 @@
-
+
-
+
-
+
@@ -3069,7 +3074,7 @@
-
+
@@ -3150,51 +3155,51 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -3202,16 +3207,16 @@
-
+
-
+
-
+
@@ -3219,16 +3224,16 @@
-
+
-
+
-
+
@@ -3241,28 +3246,28 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -3270,16 +3275,16 @@
-
+
-
+
-
+
@@ -3287,16 +3292,16 @@
-
+
-
+
-
+
@@ -3392,46 +3397,46 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -3440,31 +3445,31 @@
-
+
-
+
-
+
-
+
-
+
@@ -3473,31 +3478,31 @@
-
+
-
+
-
+
-
+
-
+
@@ -3508,16 +3513,16 @@
-
+
-
+
-
+
@@ -3595,25 +3600,25 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -3631,7 +3636,7 @@
-
+
@@ -3661,16 +3666,16 @@
-
+
-
+
-
+
@@ -3982,24 +3987,24 @@
-
+
-
+
-
+
-
+
-
+
@@ -4021,7 +4026,7 @@
-
+
@@ -4206,13 +4211,13 @@
-
+
-
+
@@ -4284,22 +4289,22 @@
-
+
-
+
-
+
-
+
-
+
@@ -4307,7 +4312,7 @@
-
+
@@ -4383,13 +4388,13 @@
-
+
-
+
@@ -4437,7 +4442,7 @@
-
+
@@ -4454,8 +4459,8 @@
-
-
+
+
@@ -4466,7 +4471,7 @@
-
+
@@ -4496,9 +4501,9 @@
-
+
-
+
diff --git a/BluefruitPlayground/Resources/localization/en.lproj/Localizable.strings b/BluefruitPlayground/Resources/localization/en.lproj/Localizable.strings
index 6353064..6576f06 100644
--- a/BluefruitPlayground/Resources/localization/en.lproj/Localizable.strings
+++ b/BluefruitPlayground/Resources/localization/en.lproj/Localizable.strings
@@ -205,14 +205,13 @@ Download it from the Bluefruit Playground guide at learn.adafruit.com";
// Puppet
"puppet_title" = "Puppets";
-"puppet_help_header" = "This Puppet module allows you to animate a 3D puppets in real time using the Circuit Playground Bluefruit board.
+"puppet_help_header" = "The Puppets module allows you to animate a 3D puppet in real time using Circuit Playground Bluefruit.
-To control the puppet, attach Circuit Playground Bluefruit to the back of your fingers using a rubber band as seen below:";
-"puppet_help_details" = "• Tilt your board forward or backwards to open and close the mouth of the puppet(Sparky The Blue Smoke Monster).
-• Try turning your board to turn your puppet’s head left and right.
-• Press the A or B button on the board to trigger present animations.
-
-You can also screen record and share your interaction with the puppet.";
+To control Sparky the Blue Smoke Monster, attach Circuit Playground Bluefruit to the back of your fingers using a rubber band as seen below:";
+"puppet_help_details" = "• Tilt your board forward or backwards to open and close the mouth of the puppet.
+• Try tilting your board to tilt the puppet’s head left or right.
+• Press the A or B button on Circuit Playground Bluefruit to trigger preset animations.
+• Use the buttons at the bottom to record the screen, change background, camera, & fullscreen mode. ";
"puppet_recording_error_title" = "Recording Error";
diff --git a/BluefruitPlayground/ViewControllers/Common/HelpViewController.swift b/BluefruitPlayground/ViewControllers/Common/HelpViewController.swift
index b9e0304..b0282cb 100644
--- a/BluefruitPlayground/ViewControllers/Common/HelpViewController.swift
+++ b/BluefruitPlayground/ViewControllers/Common/HelpViewController.swift
@@ -43,7 +43,32 @@ class HelpViewController: UIViewController {
loadViewIfNeeded()
let imageView = UIImageView(image: image)
- contentStackView.addArrangedSubview(imageView)
+ imageView.tintColor = UIColor(named: "text_default")
+ imageView.contentMode = .scaleAspectFit
+ imageView.translatesAutoresizingMaskIntoConstraints = false
+ imageView.setContentHuggingPriority(UILayoutPriority(rawValue: 1000), for: .vertical)
+
+ // Add imageView inside container to adjust proportions
+ let containerView = UIView()
+ containerView.backgroundColor = .clear
+ containerView.addSubview(imageView)
+
+ imageView.topAnchor.constraint(equalTo: containerView.topAnchor).isActive = true
+ imageView.bottomAnchor.constraint(equalTo: containerView.bottomAnchor).isActive = true
+
+ imageView.centerXAnchor.constraint(equalTo: containerView.centerXAnchor).isActive = true
+ //imageView.leadingAnchor.constraint(greaterThanOrEqualTo: containerView.leadingAnchor).isActive = true
+ //imageView.trailingAnchor.constraint(greaterThanOrEqualTo: containerView.trailingAnchor).isActive = true
+
+ let proportionalWidthConstraint = imageView.widthAnchor.constraint(equalTo: containerView.widthAnchor, multiplier: 0.75)
+ proportionalWidthConstraint.priority = UILayoutPriority(rawValue: 999)
+ proportionalWidthConstraint.isActive = true
+ imageView.widthAnchor.constraint(lessThanOrEqualToConstant: 350).isActive = true // Limit image to 350 width
+
+ imageView.heightAnchor.constraint(equalTo: imageView.widthAnchor, multiplier: image.size.height / image.size.width).isActive = true
+
+
+ contentStackView.addArrangedSubview(containerView)
}
// MARK: - Actions
diff --git a/BluefruitPlayground/ViewControllers/Scanner/ScannerViewController.swift b/BluefruitPlayground/ViewControllers/Scanner/ScannerViewController.swift
index 27e7d17..d0cc7f4 100644
--- a/BluefruitPlayground/ViewControllers/Scanner/ScannerViewController.swift
+++ b/BluefruitPlayground/ViewControllers/Scanner/ScannerViewController.swift
@@ -62,8 +62,6 @@ class ScannerViewController: UIViewController {
// Hide automatic scanning if needed
scanAutomaticallyButton.isHidden = !Config.isAutomaticConnectionEnabled
- // Ble Notifications
- registerNotifications(enabled: true)
// Localization
let localizationManager = LocalizationManager.shared
@@ -82,7 +80,15 @@ class ScannerViewController: UIViewController {
if let customNavigationBar = navigationController?.navigationBar as? NavigationBarWithScrollAwareRightButton {
customNavigationBar.setRightButton(topViewController: self, image: UIImage(named: "info"), target: self, action: #selector(about(_:)))
}
+
+ // Ble Notifications
+ registerNotifications(enabled: true)
+ }
+
+ override func viewDidAppear(_ animated: Bool) {
+ super.viewDidAppear(animated)
+
// Disconnect if needed
let connectedPeripherals = bleManager.connectedPeripherals()
if connectedPeripherals.count == 1, let peripheral = connectedPeripherals.first {
@@ -90,10 +96,6 @@ class ScannerViewController: UIViewController {
// Disconnect from peripheral
disconnect(peripheral: peripheral)
}
- }
-
- override func viewDidAppear(_ animated: Bool) {
- super.viewDidAppear(animated)
// Update UI
updateScannedPeripherals()
@@ -111,6 +113,9 @@ class ScannerViewController: UIViewController {
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
+ // Ble Notifications
+ registerNotifications(enabled: false)
+
// Stop scanning
bleManager.stopScan()
@@ -118,11 +123,6 @@ class ScannerViewController: UIViewController {
peripheralList.clear()
}
- deinit {
- // Ble Notifications
- registerNotifications(enabled: false)
- }
-
// MARK: - BLE Notifications
private weak var didDiscoverPeripheralObserver: NSObjectProtocol?
private weak var willConnectToPeripheralObserver: NSObjectProtocol?