Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
416 changes: 82 additions & 334 deletions BoostRemote.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions BoostRemote/Action.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ enum SettingsAction: Action {
case step(SettingsState.Step)
case mode(SettingsState.Mode)
case direction(BoostBLEKit.Port, Bool)
case switchLeftRight(Bool)
}

struct ActionCenter {
Expand Down
5 changes: 0 additions & 5 deletions BoostRemote/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,9 @@ import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
MoveHubManager.shared.start()

window?.tintColor = .tint

return true
}

Expand Down
163 changes: 100 additions & 63 deletions BoostRemote/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

18 changes: 15 additions & 3 deletions BoostRemote/ControllerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,17 @@ class ControllerViewController: UIViewController {
}

private func setupSticks() {

for controller in controllers {
for (port, signal) in controller.signals {
signal
.withLatest(from: settingsState.signal.map { $0.step })
.map { (value: Double, step: Double) in Int8(round(value * step) * 100 / step) }
.skipRepeats()
.withLatest(from: settingsState.signal.map { $0.directions[port] ?? true })
.withLatest(from: settingsState.signal.map { $0.directions[port, default: true] })
.map { (power: Int8, direction: Bool) in direction ? power : -power }
.observeValues { [weak self] (value) in
self?.sendStartPowerCommand(port: port, power: value)
self?.sendCommand(port: port, power: value)
}
}
}
Expand All @@ -89,7 +90,18 @@ class ControllerViewController: UIViewController {
self?.twinSticksView.isHidden = state.mode != .twinsticks
}
}


private func sendCommand(port: BoostBLEKit.Port, power: Int8) {
let switchedLR = settingsState.value.switchedLR
let commandPort: BoostBLEKit.Port
if switchedLR && [.A, .B].contains(port) {
commandPort = (port == .A) ? .B : .A
} else {
commandPort = port
}
self.sendStartPowerCommand(port: commandPort, power: power)
}

private var timers: [BoostBLEKit.Port: Timer] = [:]
private var waitingCommands: [BoostBLEKit.Port: Command] = [:]

Expand Down
19 changes: 19 additions & 0 deletions BoostRemote/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,24 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>Main</string>
</dict>
</array>
</dict>
</dict>
</dict>
</plist>
9 changes: 6 additions & 3 deletions BoostRemote/MoveHubManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class MoveHubManager: NSObject {

static let shared = MoveHubManager()

private var centralManager: CBCentralManager!
private var centralManager: CBCentralManager?

private var peripheral: CBPeripheral?
private var characteristic: CBCharacteristic?

Expand All @@ -32,18 +32,21 @@ class MoveHubManager: NSObject {
}

func startScan() {
guard let centralManager else { return }
if centralManager.state == .poweredOn {
centralManager.scanForPeripherals(withServices: [MoveHubService.serviceUuid], options: nil)
}
}

func stopScan() {
guard let centralManager else { return }
centralManager.stopScan()
}

func connect(peripheral: CBPeripheral, advertisementData: [String : Any]) -> Bool {
guard let centralManager else { return false }
guard self.peripheral == nil else { return false }

guard let manufacturerData = advertisementData["kCBAdvDataManufacturerData"] as? Data else { return false }
guard let hubType = HubType(manufacturerData: manufacturerData) else { return false }

Expand Down
2 changes: 2 additions & 0 deletions BoostRemote/Reducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ struct Reducer {
state.step = step
case .mode(let mode):
state.mode = mode
case .switchLeftRight(let switchedLR):
state.switchedLR = switchedLR
case .direction(let port, let direction):
state.directions[port] = direction
}
Expand Down
55 changes: 55 additions & 0 deletions BoostRemote/SceneDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// SceneDelegate.swift
//
// Created by Bob Wakefield on 3/28/26.
// for BoostRemote
//
// Using Swift 6.0
// Running on macOS 26.3
//
// Copyright © 2026 bricklife.com. All rights reserved.
//

import UIKit

import UIKit

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let _ = (scene as? UIWindowScene) else { return }
}

func sceneDidDisconnect(_ scene: UIScene) {
// Called as the scene is being released by the system.
// This occurs shortly after the scene enters the background, or when its session is discarded.
// Release any resources associated with this scene that can be re-created the next time the scene connects.
// The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
}

func sceneDidBecomeActive(_ scene: UIScene) {
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}

func sceneWillResignActive(_ scene: UIScene) {
// Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call).
}

func sceneWillEnterForeground(_ scene: UIScene) {
// Called as the scene transitions from the background to the foreground.
// Use this method to undo the changes made on entering the background.
}

func sceneDidEnterBackground(_ scene: UIScene) {
// Called as the scene transitions from the foreground to the background.
// Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state.
}
}

15 changes: 11 additions & 4 deletions BoostRemote/SettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class SettingsViewController: UITableViewController {
@IBOutlet private weak var portBSegmentedControl: UISegmentedControl!
@IBOutlet private weak var portCSegmentedControl: UISegmentedControl!
@IBOutlet private weak var portDSegmentedControl: UISegmentedControl!


@IBOutlet private weak var switchABSegmentControl: UISegmentedControl!

@IBOutlet private weak var step1Cell: UITableViewCell!
@IBOutlet private weak var step2Cell: UITableViewCell!
@IBOutlet private weak var step5Cell: UITableViewCell!
Expand Down Expand Up @@ -64,7 +66,11 @@ class SettingsViewController: UITableViewController {

tableView.deselectRow(at: indexPath, animated: true)
}


@IBAction func switchLeftRight(_ sender: UISegmentedControl) {
StoreCenter.store.dispatch(SettingsAction.switchLeftRight(sender.selectedSegmentIndex != 0))
}

@IBAction func directionChanged(_ sender: UISegmentedControl) {
let direction = sender.selectedSegmentIndex == 1
switch sender {
Expand All @@ -89,7 +95,8 @@ extension SettingsViewController: StoreSubscriber {

joystickModeCell.accessoryType = (settings.mode == .joystick) ? .checkmark : .none
twinsticksModeCell.accessoryType = (settings.mode == .twinsticks) ? .checkmark : .none

switchABSegmentControl.selectedSegmentIndex = settings.switchedLR ? 1 : 0

step1Cell.accessoryType = (settings.step == 1) ? .checkmark : .none
step2Cell.accessoryType = (settings.step == 2) ? .checkmark : .none
step5Cell.accessoryType = (settings.step == 5) ? .checkmark : .none
Expand All @@ -99,7 +106,7 @@ extension SettingsViewController: StoreSubscriber {
portBSegmentedControl.selectedSegmentIndex = (settings.directions[.B] ?? true) ? 1 : 0
portCSegmentedControl.selectedSegmentIndex = (settings.directions[.C] ?? true) ? 1 : 0
portDSegmentedControl.selectedSegmentIndex = (settings.directions[.D] ?? true) ? 1 : 0

settingsState = settings
}
}
2 changes: 2 additions & 0 deletions BoostRemote/State.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ struct SettingsState {
}
}
var directions: [BoostBLEKit.Port: Bool]
var switchedLR: Bool

init() {
self.mode = .joystick
self.step = 5
self.directions = [.A: true, .B: true, .C: true, .D: true]
self.switchedLR = false
}
}
3 changes: 3 additions & 0 deletions BoostRemote/Store.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ struct StoreCenter {
settingsState.mode = mode
}

settingsState.switchedLR = UserDefaults.standard.bool(forKey: "switchedLR")

if let step = UserDefaults.standard.object(forKey: "step") as? SettingsState.Step {
settingsState.step = step
}
Expand All @@ -55,6 +57,7 @@ struct StoreCenter {

func save(state: State) {
UserDefaults.standard.set(state.settingsState.mode.rawValue, forKey: "mode")
UserDefaults.standard.set(state.settingsState.switchedLR, forKey: "switchedLR")
UserDefaults.standard.set(state.settingsState.step, forKey: "step")
for (port, direction) in state.settingsState.directions {
let key = "direction-\(port)"
Expand Down
3 changes: 0 additions & 3 deletions Cartfile

This file was deleted.

3 changes: 0 additions & 3 deletions Cartfile.resolved

This file was deleted.

1 change: 0 additions & 1 deletion Carthage/Checkouts/BoostBLEKit
Submodule BoostBLEKit deleted from 04f0cb
1 change: 0 additions & 1 deletion Carthage/Checkouts/ReSwift
Submodule ReSwift deleted from 96146a
1 change: 0 additions & 1 deletion Carthage/Checkouts/ReactiveSwift
Submodule ReactiveSwift deleted from c43bae