Skip to content

Commit

Permalink
Merge branch 'release/v1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
rocboronat committed Feb 7, 2016
2 parents 53e9303 + 953cf48 commit c069331
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
13 changes: 13 additions & 0 deletions app/src/main/java/com/fewlaps/flone/service/DroneService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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()");
Expand Down Expand Up @@ -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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -103,6 +107,7 @@ public boolean onTouch(View v, MotionEvent event) {
ScreenThrottleData.instance.setThrottleAtMid();
}
}
EventBus.getDefault().post(new UserTouchModeChangedEvent(false));
}

updateThrottleLabel();
Expand Down

0 comments on commit c069331

Please sign in to comment.