Simple Controller UI/gRPC working
This commit is contained in:
@@ -10,25 +10,27 @@ import SwiftUI
|
||||
|
||||
struct SimpleControllerView: View {
|
||||
@EnvironmentObject var server: ServerData
|
||||
@State var throttle: Float = 0.5
|
||||
@State var steering: Float = 0.5
|
||||
|
||||
|
||||
// Need lazy so that we can initialise with local properties.
|
||||
@ObservedObject var grpcController: PiLoader = PiLoader()
|
||||
|
||||
var body: some View {
|
||||
HStack{
|
||||
Slider(value: $throttle, in: 0...1){_ in
|
||||
self.throttle = 0.5}
|
||||
Slider(value: $grpcController.throttle, in: 0...1){_ in
|
||||
self.grpcController.throttle = 0.5
|
||||
}
|
||||
.rotationEffect(.degrees(270))
|
||||
|
||||
Slider(value: $steering, in: 0...1){
|
||||
_ in self.steering = 0.5
|
||||
|
||||
Slider(value: $grpcController.steering, in: 0...1){_ in
|
||||
self.grpcController.steering = 0.5
|
||||
}
|
||||
}
|
||||
.onAppear(){
|
||||
// Start the gRPC updater. Should be in a separate class/struct to be easier to implement for SLAM Controller after.
|
||||
self.grpcController.startUpdating()
|
||||
}
|
||||
.onDisappear(){
|
||||
|
||||
// Stop the gRPC updater.
|
||||
self.grpcController.stop()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user