|
|
@ -147,11 +147,16 @@ class ControlActivity : AppCompatActivity() {
|
|
|
|
currentState = "standby"
|
|
|
|
currentState = "standby"
|
|
|
|
controlImage!!.setImageResource(R.drawable.ic_control_circle_standby)
|
|
|
|
controlImage!!.setImageResource(R.drawable.ic_control_circle_standby)
|
|
|
|
|
|
|
|
|
|
|
|
buttonRotateX!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateX!!.backgroundTintList =
|
|
|
|
buttonRotateY!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateZ!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateY!!.backgroundTintList =
|
|
|
|
buttonClimb!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonTwist!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateZ!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
|
|
|
|
buttonClimb!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
|
|
|
|
buttonTwist!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (length >= radius / 3 && length < 2 * radius / 3) {
|
|
|
|
} else if (length >= radius / 3 && length < 2 * radius / 3) {
|
|
|
|
val angle = atan2(coorY, coorX)
|
|
|
|
val angle = atan2(coorY, coorX)
|
|
|
@ -184,11 +189,16 @@ class ControlActivity : AppCompatActivity() {
|
|
|
|
controlImage!!.setImageResource(R.drawable.ic_control_circle_left)
|
|
|
|
controlImage!!.setImageResource(R.drawable.ic_control_circle_left)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
buttonRotateX!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateX!!.backgroundTintList =
|
|
|
|
buttonRotateY!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateZ!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateY!!.backgroundTintList =
|
|
|
|
buttonClimb!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonTwist!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateZ!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
|
|
|
|
buttonClimb!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
|
|
|
|
buttonTwist!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
} else if (length >= 2 * radius / 3 && length < radius) {
|
|
|
|
} else if (length >= 2 * radius / 3 && length < radius) {
|
|
|
|
val angle = atan2(coorY, coorX)
|
|
|
|
val angle = atan2(coorY, coorX)
|
|
|
|
if (angle > -PI / 4 && angle <= PI / 4) {
|
|
|
|
if (angle > -PI / 4 && angle <= PI / 4) {
|
|
|
@ -220,11 +230,16 @@ class ControlActivity : AppCompatActivity() {
|
|
|
|
controlImage!!.setImageResource(R.drawable.ic_control_circle_turnleft)
|
|
|
|
controlImage!!.setImageResource(R.drawable.ic_control_circle_turnleft)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
buttonRotateX!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateX!!.backgroundTintList =
|
|
|
|
buttonRotateY!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateZ!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateY!!.backgroundTintList =
|
|
|
|
buttonClimb!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonTwist!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateZ!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
|
|
|
|
buttonClimb!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
|
|
|
|
buttonTwist!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -236,11 +251,16 @@ class ControlActivity : AppCompatActivity() {
|
|
|
|
sendMessageAsync("rotatex")
|
|
|
|
sendMessageAsync("rotatex")
|
|
|
|
currentState = "rotatex"
|
|
|
|
currentState = "rotatex"
|
|
|
|
controlImage!!.setImageResource(R.drawable.ic_control_circle)
|
|
|
|
controlImage!!.setImageResource(R.drawable.ic_control_circle)
|
|
|
|
buttonRotateX!!.backgroundTintList = applicationContext.getColorStateList(R.color.purple_500)
|
|
|
|
buttonRotateX!!.backgroundTintList =
|
|
|
|
buttonRotateY!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
applicationContext.getColorStateList(R.color.purple_500)
|
|
|
|
buttonRotateZ!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateY!!.backgroundTintList =
|
|
|
|
buttonClimb!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonTwist!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateZ!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
|
|
|
|
buttonClimb!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
|
|
|
|
buttonTwist!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -249,11 +269,16 @@ class ControlActivity : AppCompatActivity() {
|
|
|
|
sendMessageAsync("rotatey")
|
|
|
|
sendMessageAsync("rotatey")
|
|
|
|
currentState = "rotatey"
|
|
|
|
currentState = "rotatey"
|
|
|
|
controlImage!!.setImageResource(R.drawable.ic_control_circle)
|
|
|
|
controlImage!!.setImageResource(R.drawable.ic_control_circle)
|
|
|
|
buttonRotateX!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateX!!.backgroundTintList =
|
|
|
|
buttonRotateY!!.backgroundTintList = applicationContext.getColorStateList(R.color.purple_500)
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateZ!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateY!!.backgroundTintList =
|
|
|
|
buttonClimb!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
applicationContext.getColorStateList(R.color.purple_500)
|
|
|
|
buttonTwist!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateZ!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
|
|
|
|
buttonClimb!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
|
|
|
|
buttonTwist!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -262,11 +287,16 @@ class ControlActivity : AppCompatActivity() {
|
|
|
|
sendMessageAsync("rotatez")
|
|
|
|
sendMessageAsync("rotatez")
|
|
|
|
currentState = "rotatez"
|
|
|
|
currentState = "rotatez"
|
|
|
|
controlImage!!.setImageResource(R.drawable.ic_control_circle)
|
|
|
|
controlImage!!.setImageResource(R.drawable.ic_control_circle)
|
|
|
|
buttonRotateX!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateX!!.backgroundTintList =
|
|
|
|
buttonRotateY!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateZ!!.backgroundTintList = applicationContext.getColorStateList(R.color.purple_500)
|
|
|
|
buttonRotateY!!.backgroundTintList =
|
|
|
|
buttonClimb!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonTwist!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateZ!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.purple_500)
|
|
|
|
|
|
|
|
buttonClimb!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
|
|
|
|
buttonTwist!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -275,11 +305,16 @@ class ControlActivity : AppCompatActivity() {
|
|
|
|
sendMessageAsync("climb")
|
|
|
|
sendMessageAsync("climb")
|
|
|
|
currentState = "climb"
|
|
|
|
currentState = "climb"
|
|
|
|
controlImage!!.setImageResource(R.drawable.ic_control_circle)
|
|
|
|
controlImage!!.setImageResource(R.drawable.ic_control_circle)
|
|
|
|
buttonRotateX!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateX!!.backgroundTintList =
|
|
|
|
buttonRotateY!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateZ!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateY!!.backgroundTintList =
|
|
|
|
buttonClimb!!.backgroundTintList = applicationContext.getColorStateList(R.color.purple_500)
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonTwist!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateZ!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
|
|
|
|
buttonClimb!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.purple_500)
|
|
|
|
|
|
|
|
buttonTwist!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -288,11 +323,16 @@ class ControlActivity : AppCompatActivity() {
|
|
|
|
sendMessageAsync("twist")
|
|
|
|
sendMessageAsync("twist")
|
|
|
|
currentState = "twist"
|
|
|
|
currentState = "twist"
|
|
|
|
controlImage!!.setImageResource(R.drawable.ic_control_circle)
|
|
|
|
controlImage!!.setImageResource(R.drawable.ic_control_circle)
|
|
|
|
buttonRotateX!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateX!!.backgroundTintList =
|
|
|
|
buttonRotateY!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateZ!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonRotateY!!.backgroundTintList =
|
|
|
|
buttonClimb!!.backgroundTintList = applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
buttonTwist!!.backgroundTintList = applicationContext.getColorStateList(R.color.purple_500)
|
|
|
|
buttonRotateZ!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
|
|
|
|
buttonClimb!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
|
|
|
|
buttonTwist!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.purple_500)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -327,6 +367,20 @@ class ControlActivity : AppCompatActivity() {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
this.tcpClient!!.start()
|
|
|
|
this.tcpClient!!.start()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
currentState = "standby"
|
|
|
|
|
|
|
|
controlImage!!.setImageResource(R.drawable.ic_control_circle_standby)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buttonRotateX!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
|
|
|
|
buttonRotateY!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
|
|
|
|
buttonRotateZ!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
|
|
|
|
buttonClimb!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
|
|
|
|
buttonTwist!!.backgroundTintList =
|
|
|
|
|
|
|
|
applicationContext.getColorStateList(R.color.grey_500)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
override fun onPause() {
|
|
|
|
override fun onPause() {
|
|
|
|