This commit is contained in:
Tim Zeuner 2023-02-23 11:12:40 +01:00
commit fe4af52380
2 changed files with 8 additions and 16 deletions

View File

@ -29,12 +29,12 @@ public class Communication {
} }
public String telegram(boolean startStop, ArrayList<String> list){ public String telegram(boolean startStop, ArrayList<String> list){
String tel = ""; String tel = "aa";
tel += "1"; //Autonomous mode tel += "1"; //Autonomous mode
if(startStop){ if(startStop){
tel += ";1"; tel += ";1";
}else{ }else{
tel += ";0"; return "aa0;0.0;0.0;0.0;0.0zz";
} }
for (String i : list) { for (String i : list) {
@ -44,6 +44,7 @@ public class Communication {
tel += ";1"; tel += ";1";
} }
} }
tel += "zz";
return tel; return tel;
} }

View File

@ -75,18 +75,13 @@ public class HomeFragment extends Fragment {
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
boolean send = false; if (mainActivity.connected) {
if (System.currentTimeMillis() - lastOnMoveCall > 250){
send = true;
lastOnMoveCall = System.currentTimeMillis();
}
if (send && mainActivity.connected) {
if (event.getAction() == MotionEvent.ACTION_UP) { if (event.getAction() == MotionEvent.ACTION_UP) {
binding.rotateLeft.performClick(); binding.rotateLeft.performClick();
mainActivity.sendTelegram(com.telegram(new int[]{0, 0, 0, 0}, 0)); mainActivity.sendTelegram(com.telegram(new int[]{0, 0, 0, 0}, 0));
return true; return true;
} else { } else {
mainActivity.sendTelegram(com.telegram(new int[]{-1, 1, -1, 1}, 100)); mainActivity.sendTelegram(com.telegram(new int[]{-1, 1, -1, 1}, 50));
} }
} }
return false; return false;
@ -97,18 +92,13 @@ public class HomeFragment extends Fragment {
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
boolean send = false; if (mainActivity.connected){
if (System.currentTimeMillis() - lastOnMoveCall > 250){
send = true;
lastOnMoveCall = System.currentTimeMillis();
}
if (send && mainActivity.connected){
if(event.getAction() == MotionEvent.ACTION_UP){ if(event.getAction() == MotionEvent.ACTION_UP){
binding.rotateRight.performClick(); binding.rotateRight.performClick();
mainActivity.sendTelegram(com.telegram(new int[]{0, 0, 0, 0}, 0)); mainActivity.sendTelegram(com.telegram(new int[]{0, 0, 0, 0}, 0));
return true; return true;
}else{ }else{
mainActivity.sendTelegram(com.telegram(new int[]{1, -1, 1, -1}, 100)); mainActivity.sendTelegram(com.telegram(new int[]{1, -1, 1, -1}, 50));
} }
} }
return false; return false;
@ -157,6 +147,7 @@ public class HomeFragment extends Fragment {
else{ else{
joystick.setBackgroundResource(R.mipmap.blank); joystick.setBackgroundResource(R.mipmap.blank);
telegram = com.telegram(new int[]{0, 0, 0, 0}, strength); telegram = com.telegram(new int[]{0, 0, 0, 0}, strength);
send=true;
} }
if (send && mainActivity.connected) if (send && mainActivity.connected)
{ {