From 831639decca688b717be4b215b7df025184512e9 Mon Sep 17 00:00:00 2001 From: Roc Boronat Date: Sun, 7 Feb 2016 21:50:11 +0100 Subject: [PATCH 1/2] The AUX2 value is related with the user touching the throtte area, to ease the BARO mode --- .../flone/io/bean/UserTouchModeChangedEvent.java | 13 +++++++++++++ .../com/fewlaps/flone/service/DroneService.java | 13 +++++++++++++ .../fewlaps/flone/view/activity/FlyActivity.java | 7 ++++++- 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/com/fewlaps/flone/io/bean/UserTouchModeChangedEvent.java diff --git a/app/src/main/java/com/fewlaps/flone/io/bean/UserTouchModeChangedEvent.java b/app/src/main/java/com/fewlaps/flone/io/bean/UserTouchModeChangedEvent.java new file mode 100644 index 0000000..c495d7a --- /dev/null +++ b/app/src/main/java/com/fewlaps/flone/io/bean/UserTouchModeChangedEvent.java @@ -0,0 +1,13 @@ +package com.fewlaps.flone.io.bean; + +public class UserTouchModeChangedEvent { + private boolean isTouching = false; + + public UserTouchModeChangedEvent(boolean isTouching) { + this.isTouching = isTouching; + } + + public boolean isTouching() { + return isTouching; + } +} diff --git a/app/src/main/java/com/fewlaps/flone/service/DroneService.java b/app/src/main/java/com/fewlaps/flone/service/DroneService.java index e8c61a2..ff8d442 100644 --- a/app/src/main/java/com/fewlaps/flone/service/DroneService.java +++ b/app/src/main/java/com/fewlaps/flone/service/DroneService.java @@ -19,6 +19,7 @@ import com.fewlaps.flone.io.bean.DroneConnectionStatusChanged; import com.fewlaps.flone.io.bean.DroneSensorData; import com.fewlaps.flone.io.bean.MultiWiiValues; +import com.fewlaps.flone.io.bean.UserTouchModeChangedEvent; import com.fewlaps.flone.io.bean.UsingRawDataChangeRequest; import com.fewlaps.flone.io.communication.Bluetooth; import com.fewlaps.flone.io.communication.Communication; @@ -61,6 +62,7 @@ public class DroneService extends BaseService { public MultirotorData protocol; public boolean running = false; + public boolean isUserTouching = false; private Handler connectTask = new Handler(); private Handler telemetryTask = new Handler(); @@ -155,6 +157,10 @@ public void onEventMainThread(CalibrateDroneMagnetometerRequest event) { protocol.SendRequestMSP_MAG_CALIBRATION(); } + public void onEventMainThread(UserTouchModeChangedEvent event) { + isUserTouching = event.isTouching(); + } + private final Runnable reconnectRunnable = new Runnable() { public void run() { Log.d("RUNNABLE", "reconnectRunnable.run()"); @@ -217,6 +223,13 @@ private void updateRcWithInputData() { } else { if (armed) { rc.set(RCSignals.AUX1, RCSignals.RC_MAX); + if (isUserTouching) { + rc.set(RCSignals.AUX2, RCSignals.RC_MIN); + } else { + rc.set(RCSignals.AUX2, RCSignals.RC_MAX); + } + Log.i("AUX2", "" + rc.get(RCSignals.AUX2)); + rc.setThrottle((int) phoneSensorsInput.getThrottle()); yaw = RCSignals.RC_MID + ((int) yawCalculator.getYaw(droneSensorInput.getHeading() + headingDifference, phoneSensorsInput.getHeading())); diff --git a/app/src/main/java/com/fewlaps/flone/view/activity/FlyActivity.java b/app/src/main/java/com/fewlaps/flone/view/activity/FlyActivity.java index 85a5509..a94e015 100644 --- a/app/src/main/java/com/fewlaps/flone/view/activity/FlyActivity.java +++ b/app/src/main/java/com/fewlaps/flone/view/activity/FlyActivity.java @@ -23,6 +23,7 @@ import com.fewlaps.flone.io.bean.ArmedDataChangeRequest; import com.fewlaps.flone.io.bean.DelayData; import com.fewlaps.flone.io.bean.DroneSensorData; +import com.fewlaps.flone.io.bean.UserTouchModeChangedEvent; import com.fewlaps.flone.io.communication.RCSignals; import com.fewlaps.flone.io.input.phone.PhoneOutputData; import com.fewlaps.flone.io.input.phone.ScreenThrottleData; @@ -93,7 +94,10 @@ protected void onCreate(Bundle savedInstanceState) { @Override public boolean onTouch(View v, MotionEvent event) { int action = event.getAction(); - if (action == MotionEvent.ACTION_MOVE || action == MotionEvent.ACTION_DOWN) { + if (action == MotionEvent.ACTION_DOWN) { + ScreenThrottleData.instance.setThrottle((int) event.getY()); + EventBus.getDefault().post(new UserTouchModeChangedEvent(true)); + } else if (action == MotionEvent.ACTION_MOVE) { ScreenThrottleData.instance.setThrottle((int) event.getY()); } else if (action == MotionEvent.ACTION_UP) { if (ScreenThrottleData.instance.getThrottlePorcentage() < 90) { @@ -103,6 +107,7 @@ public boolean onTouch(View v, MotionEvent event) { ScreenThrottleData.instance.setThrottleAtMid(); } } + EventBus.getDefault().post(new UserTouchModeChangedEvent(false)); } updateThrottleLabel(); From 953cf48c1bde14919e059c52b7d5a392f646e1da Mon Sep 17 00:00:00 2001 From: Roc Boronat Date: Sun, 7 Feb 2016 21:51:04 +0100 Subject: [PATCH 2/2] Version++ --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index a204ff6..0da7cc7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "com.fewlaps.flone" minSdkVersion 15 targetSdkVersion 23 - versionCode 7 - versionName "1.0" + versionCode 8 + versionName "1.1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } lintOptions {