Skip to content

Commit

Permalink
1.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
JazzJackrabbit committed Oct 1, 2021
1 parent 635269d commit 3951bd0
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 57 deletions.
4 changes: 2 additions & 2 deletions Eyewear Hub.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@
INFOPLIST_FILE = "Eyewear Hub/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 1.2.2;
MARKETING_VERSION = 1.2.3;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.kirillragozin.eyewearhub;
Expand Down Expand Up @@ -671,7 +671,7 @@
INFOPLIST_FILE = "Eyewear Hub/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 1.2.2;
MARKETING_VERSION = 1.2.3;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.kirillragozin.eyewearhub;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
89 changes: 68 additions & 21 deletions Eyewear Hub/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

14 changes: 6 additions & 8 deletions Eyewear Hub/Shared/GeistExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public extension NSControl.StateValue {
}

public extension MEMEAcademicFullData {
func rawDataString(_ withBlink: Bool = false) -> String{
func rawDataString(_ withLabel: Bool = false, _ label: String = "") -> String{
var result = ""

result.append(String(self.rawAccX))
Expand All @@ -34,16 +34,15 @@ public extension MEMEAcademicFullData {
result.append(String(self.rawLeft))
result.append(",")
result.append(String(self.rawRight))
if (withBlink == true){
if (withLabel == true){
result.append(",")
result.append(String(0))
// result.append(String(self.vh))
result.append(label)
}

return result
}

func processedDataString(_ withBlink: Bool = false) -> String{
func processedDataString(_ withLabel: Bool = false, _ label: String = "") -> String{

var result = ""

Expand All @@ -62,10 +61,9 @@ public extension MEMEAcademicFullData {
result.append(String(self.vv))
result.append(",")
result.append(String(self.vh))
if (withBlink == true){
if (withLabel == true){
result.append(",")
result.append(String(0))
// result.append(String(self.vh))
result.append(label)
}

return result
Expand Down
2 changes: 2 additions & 0 deletions Eyewear Hub/Shared/SharedData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class SharedData: NSObject {

public var streamProcessed : Bool = true
public var includeBlink : Bool = false
public var label : String = ""
public var includeLabel : Bool = true
public var blinkDetected: Int = 0

override private init() {
Expand Down
43 changes: 43 additions & 0 deletions Eyewear Hub/Shared/UDPWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,47 @@ public class UDPWrapper: NSObject {
}
return result
}

func wrapWithLabel(data: MEMEAcademicFullData, raw: Bool, label: String) -> String {
var result = ""

if (raw) {
result.append(String(data.rawAccX))
result.append(",")
result.append(String(data.rawAccY))
result.append(",")
result.append(String(data.rawAccZ))
result.append(",")
result.append(String(data.rawRoll))
result.append(",")
result.append(String(data.rawPitch))
result.append(",")
result.append(String(data.rawYaw))
result.append(",")
result.append(String(data.rawLeft))
result.append(",")
result.append(String(data.rawRight))
result.append(",")
result.append(label)
} else {
result.append(String(data.accX))
result.append(",")
result.append(String(data.accY))
result.append(",")
result.append(String(data.accZ))
result.append(",")
result.append(String(data.roll))
result.append(",")
result.append(String(data.pitch))
result.append(",")
result.append(String(data.yaw))
result.append(",")
result.append(String(data.vv))
result.append(",")
result.append(String(data.vh))
result.append(",")
result.append(label)
}
return result
}
}
24 changes: 18 additions & 6 deletions Eyewear Hub/Tab Controllers/DeviceTabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class DeviceTabViewController: NSViewController, MEMEAcademicDeviceManagerDelega
@IBOutlet weak var udpStopButton: NSButton!
@IBOutlet weak var udpStartAutomaticallyCheckbox: NSButton!
@IBOutlet weak var searchAutomaticallyCheckbox: NSButton!
@IBOutlet weak var udpLabelField: NSTextField!

// CODE

Expand Down Expand Up @@ -358,6 +359,15 @@ class DeviceTabViewController: NSViewController, MEMEAcademicDeviceManagerDelega
udpIPAddressField.cell?.title = String(udpClient.address)
udpPortField.cell?.title = String(udpClient.port)
udpIPAddressField.isEnabled = false


if (udpLabelField.cell?.title.count ?? 0 > 0) {
SharedData.instance.label = String(udpLabelField.cell?.title ?? "??")
} else {
SharedData.instance.label = String(deviceStatusLabel.cell?.title ?? "?")
}
udpLabelField.cell?.title = SharedData.instance.label
udpLabelField.isEnabled = false
udpPortField.isEnabled = false
udpStartButton.isEnabled = false
udpStopButton.isEnabled = true
Expand All @@ -379,6 +389,7 @@ class DeviceTabViewController: NSViewController, MEMEAcademicDeviceManagerDelega

udpIPAddressField.isEnabled = true
udpPortField.isEnabled = true
udpLabelField.isEnabled = true
udpStartButton.isEnabled = true
udpStopButton.isEnabled = false
udpStatusLabel.cell?.title = stateLabels.off.rawValue
Expand Down Expand Up @@ -435,14 +446,15 @@ class DeviceTabViewController: NSViewController, MEMEAcademicDeviceManagerDelega
SharedData.instance.memeAcademicFullData = data

// detect blink
let blinkDetected = detectBlink(device, data: data)
SharedData.instance.blinkDetected = blinkDetected ? 1 : 0
// let blinkDetected = detectBlink(device, data: data)
// SharedData.instance.blinkDetected = blinkDetected ? 1 : 0

// send udp message
var dataString: String = ""

if (udpClient.isOpened) {
if (SharedData.instance.includeBlink == true){
dataString = udpClient.wrapWithBlink(data: data, raw: !SharedData.instance.streamProcessed, blink: blinkDetected)
if (SharedData.instance.includeLabel == true){
dataString = udpClient.wrapWithLabel(data: data, raw: !SharedData.instance.streamProcessed, label: SharedData.instance.label)
} else {
dataString = udpClient.wrap(data: data, raw: !SharedData.instance.streamProcessed)
}
Expand Down Expand Up @@ -534,8 +546,8 @@ class DeviceTabViewController: NSViewController, MEMEAcademicDeviceManagerDelega
formatter.dateFormat = "yyyy-MM-dd-hh-mm-ss"
return (formatter.string(from: Date()) as NSString) as String
}
// func validateIpAddress(ipToValidate: String) -> Bool {

// func validateIpAddress(ipToValidate: String) -> Bool {
//
// var sin = sockaddr_in()
// var sin6 = sockaddr_in6()
Expand Down
62 changes: 42 additions & 20 deletions Eyewear Hub/Tab Controllers/RawDataViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class RawDataViewController: NSViewController {
@IBOutlet weak var streamProcessedDataCheckbox: NSButton!
@IBOutlet weak var includeBlinkCheckbox: NSButton!

@IBOutlet weak var labelValue: NSTextField!
@IBOutlet weak var includeLabelCheckbox: NSButton!


@objc var sharedData: SharedData {
get { return SharedData.instance }
Expand All @@ -47,6 +50,8 @@ class RawDataViewController: NSViewController {
// Do view setup here.

streamProcessedDataCheckbox.cell?.state = NSControl.StateValue.fromBool(sharedData.streamProcessed)
includeLabelCheckbox.cell?.state = NSControl.StateValue.fromBool(sharedData.includeLabel)
// labelValue.cell?.title = String(sharedData.label)

streamProcessedTriggered(self);

Expand All @@ -69,10 +74,10 @@ class RawDataViewController: NSViewController {
yawField.cell?.title = String(sharedData.memeAcademicFullData.yaw)
vvField.cell?.title = String(sharedData.memeAcademicFullData.vv)
vhField.cell?.title = String(sharedData.memeAcademicFullData.vh)
blinkField.cell?.title = String(sharedData.blinkDetected)
// blinkField.cell?.title = String(sharedData.blinkDetected)

if (SharedData.instance.udpClient.isOpened){
streamPreviewField.cell?.title = String(sharedData.memeAcademicFullData.processedDataString(SharedData.instance.includeBlink))
streamPreviewField.cell?.title = String(sharedData.memeAcademicFullData.processedDataString(SharedData.instance.includeLabel, SharedData.instance.label))
} else {
streamPreviewField.cell?.title = "Not Available"
}
Expand All @@ -86,10 +91,10 @@ class RawDataViewController: NSViewController {
yawField.cell?.title = String(sharedData.memeAcademicFullData.rawYaw)
vvField.cell?.title = String(sharedData.memeAcademicFullData.rawLeft)
vhField.cell?.title = String(sharedData.memeAcademicFullData.rawRight)
blinkField.cell?.title = String(sharedData.blinkDetected)
// blinkField.cell?.title = String(sharedData.blinkDetected)

if (SharedData.instance.udpClient.isOpened){
streamPreviewField.cell?.title = String(sharedData.memeAcademicFullData.rawDataString(SharedData.instance.includeBlink))
streamPreviewField.cell?.title = String(sharedData.memeAcademicFullData.rawDataString(SharedData.instance.includeLabel, SharedData.instance.label))
} else {
streamPreviewField.cell?.title = "Not Available"
}
Expand All @@ -102,31 +107,48 @@ class RawDataViewController: NSViewController {
sharedData.streamProcessed = false
leftLabel.cell?.title = "Left"
rightLabel.cell?.title = "Right"
streamFormatLabel.cell?.title = "AccX,AccY,AccZ,Roll,Pitch,Yaw,Left,Right"
streamFormatLabel.cell?.title = "AccX,AccY,AccZ,Roll,Pitch,Yaw,Left,Right,(label)"
} else {
sharedData.streamProcessed = true
leftLabel.cell?.title = "Vv"
rightLabel.cell?.title = "Vh"
streamFormatLabel.cell?.title = "AccX,AccY,AccZ,Roll,Pitch,Yaw,Vv,Vh"
streamFormatLabel.cell?.title = "AccX,AccY,AccZ,Roll,Pitch,Yaw,Vv,Vh,(label)"
}
}

@IBAction func includeBlinkTriggered(_ sender: Any) {
if (includeBlinkCheckbox.cell?.state == NSControl.StateValue.off) {
sharedData.includeBlink = false
if (streamProcessedDataCheckbox.cell?.state == NSControl.StateValue.off) {
streamFormatLabel.cell?.title = "AccX,AccY,AccZ,Roll,Pitch,Yaw,Left,Right"
} else {
streamFormatLabel.cell?.title = "AccX,AccY,AccZ,Roll,Pitch,Yaw,Vv,Vh"
}
// @IBAction func includeBlinkTriggered(_ sender: Any) {
// if (includeBlinkCheckbox.cell?.state == NSControl.StateValue.off) {
// sharedData.includeBlink = false
// if (streamProcessedDataCheckbox.cell?.state == NSControl.StateValue.off) {
// streamFormatLabel.cell?.title = "AccX,AccY,AccZ,Roll,Pitch,Yaw,Left,Right"
// } else {
// streamFormatLabel.cell?.title = "AccX,AccY,AccZ,Roll,Pitch,Yaw,Vv,Vh"
// }
// } else {
// sharedData.includeBlink = true
// if (streamProcessedDataCheckbox.cell?.state == NSControl.StateValue.off) {
// streamFormatLabel.cell?.title = "AccX,AccY,AccZ,Roll,Pitch,Yaw,Left,Right,Blink"
// } else {
// streamFormatLabel.cell?.title = "AccX,AccY,AccZ,Roll,Pitch,Yaw,Vv,Vh,Blink"
// }
// }
// }

@IBAction func includeLabelTriggered(_ sender: Any) {
if (includeLabelCheckbox.cell?.state == NSControl.StateValue.off) {
sharedData.includeLabel = false
} else {
sharedData.includeBlink = true
if (streamProcessedDataCheckbox.cell?.state == NSControl.StateValue.off) {
streamFormatLabel.cell?.title = "AccX,AccY,AccZ,Roll,Pitch,Yaw,Left,Right,Blink"
} else {
streamFormatLabel.cell?.title = "AccX,AccY,AccZ,Roll,Pitch,Yaw,Vv,Vh,Blink"
}
sharedData.includeLabel = true
}

if (streamProcessedDataCheckbox.cell?.state == NSControl.StateValue.off) {
streamFormatLabel.cell?.title = "AccX,AccY,AccZ,Roll,Pitch,Yaw,Left,Right,(label)"
} else {
streamFormatLabel.cell?.title = "AccX,AccY,AccZ,Roll,Pitch,Yaw,Vv,Vh,(label)"
}
}

// @IBAction func labelValueChanged(_ sender: NSTextField) {
// sharedData.label = labelValue.cell?.title ?? ""
// }
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Install external plugins before building the project.
```
git clone [email protected]:JazzJackrabbit/EyewearHub.git
cd EyewearHub
gem install cocoapods
pod install
open Eyewear\ Hub.xcworkspace
```

0 comments on commit 3951bd0

Please sign in to comment.