Skip to content

Commit

Permalink
Merge branch 'android-blockly-v2-updates' of https://github.com/3dwes…
Browse files Browse the repository at this point in the history
…upport/OpenBot into react-blockly
  • Loading branch information
Hardik Garg committed Jun 21, 2024
2 parents bd40920 + bde4ab1 commit ac47f5f
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 8 deletions.
Binary file removed docs/images/continue_to_console_ios.jpg
Binary file not shown.
Binary file removed docs/images/create_project.jpg
Binary file not shown.
Binary file removed docs/images/disable_analytics.jpg
Binary file not shown.
Binary file added docs/images/edit_profile_screen.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/firebase_add_sha1.jpg.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file removed docs/images/google_service_Info_plist.jpg
Binary file not shown.
Binary file removed docs/images/google_signin_enable.jpg
Binary file not shown.
Empty file.
2 changes: 1 addition & 1 deletion ios/OpenBot/OpenBot/Data/SharedPreferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class SharedPreferencesManager {
}

public func setDriveMode(value:String){
userDefaults.set(value, forKey: drive_mode)
userDefaults.set(value, forKey: drive_mode);
}

public func getDriveMode() -> String? {
Expand Down
2 changes: 1 addition & 1 deletion ios/OpenBot/OpenBot/Data/SignalingMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ struct CandidateEvent: Codable {

struct OpenBotSignal : Codable {
var openbot : Int
}
}
38 changes: 32 additions & 6 deletions ios/OpenBot/OpenBot/JsEvaluator/JsEvaluator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class jsEvaluator {
runOpenBotThreadClass = nil
bluetooth.sendDataFromJs(payloadData: "c" + String(0) + "," + String(0) + "\n");
}

/**
function defined for all the methods of openBot blockly
*/
Expand Down Expand Up @@ -107,8 +107,8 @@ class jsEvaluator {
let moveRight: @convention(block) (Float) -> Void = { (speed) in
self.runOpenBotThreadClass?.moveRight(speed: speed)
}
let playSound: @convention(block) (Bool) -> Void = { (isPlaySound) in
self.runOpenBotThreadClass?.playSound(isPlaySound: isPlaySound);
let playSound: @convention(block) (String) -> Void = { (inputString) in
self.runOpenBotThreadClass?.playSound(inputString: inputString);
}
let playSoundSpeed: @convention(block) (String) -> Void = { (speed) in
self.runOpenBotThreadClass?.playSoundSpeed(speedMode: speed);
Expand Down Expand Up @@ -272,6 +272,14 @@ class jsEvaluator {
let onLostFrames: @convention(block) (String, Int, String) -> Void = { (object, frames, task) in
self.runOpenBotThreadClass?.onLostFrames(object: object, frames: frames, task: task);
}

let displaySensorData: @convention(block) (String) -> Void = { (inputString) in
self.runOpenBotThreadClass?.displaySensorData(inputString: inputString);
}

let displayString: @convention(block) (String) -> Void = { (inputString) in
self.runOpenBotThreadClass?.displayString(inputString: inputString);
}

context.setObject(moveForward,
forKeyedSubscript: Strings.moveForward as NSString)
Expand Down Expand Up @@ -377,6 +385,10 @@ class jsEvaluator {
forKeyedSubscript: "onDetect" as NSString);
context.setObject(onLostFrames,
forKeyedSubscript: "onLostFrames" as NSString);
context.setObject(displaySensorData,
forKeyedSubscript: "displaySensorData" as NSString);
context.setObject(displayString,
forKeyedSubscript: "displayString" as NSString);
/// evaluateScript should be called below of setObject
context.evaluateScript(self.command);
}
Expand Down Expand Up @@ -577,11 +589,12 @@ class jsEvaluator {
sendControl(control: carControl);
}

func playSound(isPlaySound: Bool) {
func playSound(inputString: String) {
if isCancelled {
return
}
print("inside playsound");
NotificationCenter.default.post(name: .commandName, object: "Play input sound");
audioPlayer.playInputString(input: inputString);
}

func playSoundSpeed(speedMode: String) {
Expand Down Expand Up @@ -1045,7 +1058,6 @@ class jsEvaluator {
if isCancelled {
return
}
print("object::::", object);
runRobot.onDetection(object: object, model: model, task: task);
taskStorage.addAttribute(classType: object, task: task, frames: 0, type: "detect");
NotificationCenter.default.post(name: .createCameraView, object: "");
Expand All @@ -1064,6 +1076,20 @@ class jsEvaluator {
}
taskStorage.addAttribute(classType: object, task: task, frames: frames, type: "unDetect");
}

func displaySensorData(inputString: String){
if isCancelled {
return
}
NotificationCenter.default.post(name: .displayItems, object: inputString);
}

func displayString(inputString: String){
if isCancelled {
return
}
NotificationCenter.default.post(name: .displayItems, object: inputString);
}
}
}

0 comments on commit ac47f5f

Please sign in to comment.