Skip to content

Commit

Permalink
✨ (RobotKit): Add first (empty) implementation of Robot class
Browse files Browse the repository at this point in the history
This commit defines the public interface of the Robot class

Methods don't do anything except from printing to the console. Detailed
implementation will follow
  • Loading branch information
ladislas committed Sep 25, 2023
1 parent 4f41b98 commit 3da15ce
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 4 deletions.
48 changes: 48 additions & 0 deletions Modules/RobotKit/Sources/Robot+Lights.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Leka - iOS Monorepo
// Copyright 2023 APF France handicap
// SPDX-License-Identifier: Apache-2.0

// swiftlint:disable identifier_name

extension Robot {

public enum Lights {
case full
case halfLeft
case halfRight
case quarterFrontLeft
case quarterFrontRight
case quarterBackLeft
case quarterBackRight

case range(start: Int, end: Int)
case spot(ids: [Int])

}

public struct Color {

public var data: [UInt8]

public var red: UInt8 {
data[0]
}

public var green: UInt8 {
data[1]
}

public var blue: UInt8 {
data[2]
}

// TODO(@hugo): Add all colors decided w/ Lucie, Hortense

Check failure on line 39 in Modules/RobotKit/Sources/Robot+Lights.swift

View workflow job for this annotation

GitHub Actions / lint

TODOs should be resolved ((@hugo): Add all colors decide...) (todo)
public static let red: Color = Color(data: [255, 0, 0])
public static let green: Color = Color(data: [0, 255, 0])
public static let blue: Color = Color(data: [0, 0, 255])

}

}

// swiftlint:enable identifier_name
21 changes: 21 additions & 0 deletions Modules/RobotKit/Sources/Robot+Motion.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Leka - iOS Monorepo
// Copyright 2023 APF France handicap
// SPDX-License-Identifier: Apache-2.0

extension Robot {

public enum Direction {
case forward
case forwardLeft
case forwardRight
case backward
case backwardLeft
case backwardRight
}

public enum Rotation {
case clockwise
case counterclockwise
}

}
15 changes: 15 additions & 0 deletions Modules/RobotKit/Sources/Robot+Reinforcers.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Leka - iOS Monorepo
// Copyright 2023 APF France handicap
// SPDX-License-Identifier: Apache-2.0

extension Robot {

public enum Reinforcer {
case spinBlinkGreenOff
case spinBlinkBlueViolet
case fire
case sprinkles
case rainbow
}

}
49 changes: 45 additions & 4 deletions Modules/RobotKit/Sources/Robot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,55 @@
// Copyright 2023 APF France handicap
// SPDX-License-Identifier: Apache-2.0

import CombineCoreBluetooth
import Combine

public class Robot {

// MARK: - Public variables
// MARK: - General

// MARK: - Private variables
public func stop() {
print("πŸ€– STOP πŸ›‘ - Everything")
}

// MARK: - Public functions
public func reboot() {
print("πŸ€– REBOOT πŸ’«")
}

// MARK: - Motion

public func move(_ direction: Direction, speed: Float) {
print("πŸ€– MOVE \(direction) at \(speed)")
}

public func spin(_ rotation: Rotation, speed: Float) {
print("πŸ€– SPIN \(rotation) at \(speed)")
}

public func stopMotion() {
print("πŸ€– STOP πŸ›‘ - Motion")
}

// MARK: - Lights

public func shine(_ lights: Lights, color: Color) {
print("πŸ€– SHINE \(lights) in \(color)")
}

public func stopLights() {
print("πŸ€– STOP πŸ›‘ - Lights")
}

// MARK: - Reinforcers

public func run(_ reinforcer: Reinforcer) {
print("πŸ€– RUN reinforcer \(reinforcer)")
}

// MARK: - Magic Cards

public func onMagicCard() -> AnyPublisher<MagicCard, Never> {
Just(MagicCard.dice_roll)
.eraseToAnyPublisher()
}

}

0 comments on commit 3da15ce

Please sign in to comment.