-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
990 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
app/src/main/java/com/fewlaps/flone/DesiredPitchRollCalculator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.fewlaps.flone; | ||
|
||
/** | ||
* A tool to get the pitch and yaw the user wants to send to the drone. | ||
* <p/> | ||
* Usually, users won't want to send a 2000 or a 1000, because it's a too high value. So, | ||
* we'll have to map the input of the user to the bounds he previously set. | ||
* <p/> | ||
* A limit of 100 makes the min to be 1100 and the max to be 1900. | ||
*/ | ||
public class DesiredPitchRollCalculator { | ||
|
||
public static final int MID = 1500; | ||
|
||
public static final int MIN_LIMIT = 0; | ||
public static final int MAX_LIMIT = 500; | ||
|
||
private int limit = 0; | ||
|
||
public DesiredPitchRollCalculator(int limit) { | ||
this.limit = limit; | ||
} | ||
|
||
public void setLimit(int limit) { | ||
this.limit = limit; | ||
} | ||
|
||
public int getValue(int value) { | ||
int absolute = getAbsolute(value); | ||
|
||
int calculatedValue = map(absolute, MIN_LIMIT, MAX_LIMIT, MIN_LIMIT, MAX_LIMIT - limit); | ||
|
||
if (value > MID) { | ||
return MID + calculatedValue; | ||
} else { | ||
return MID - calculatedValue; | ||
} | ||
} | ||
|
||
public int getAbsolute(int value) { | ||
if (value > MID) { | ||
return value - MID; | ||
} else { | ||
int absolute = value - MID; | ||
return absolute * -1; | ||
} | ||
} | ||
|
||
/** | ||
* This is the common Arduino map() function, expressed in Java | ||
* http://stackoverflow.com/questions/7505991/arduino-map-equivalent-function-in-java | ||
*/ | ||
private int map(int x, int inMin, int inMax, int outMin, int outMax) { | ||
return (x - inMin) * (outMax - outMin) / (inMax - inMin) + outMin; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.fewlaps.flone.data; | ||
|
||
public class DefaultValues { | ||
|
||
public static final double DEFAULT_PHONE_PITCH_ROLL = 100; | ||
|
||
public static final int DEFAULT_PITCH_ROLL_LIMIT = 300; //low = expert, high = beginner, min = 0, max = 500 | ||
} |
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/fewlaps/flone/data/bean/DroneCalibrationData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.fewlaps.flone.data.bean; | ||
|
||
public class DroneCalibrationData { | ||
|
||
private double headingDifference = 0; | ||
|
||
public double getHeadingDifference() { | ||
return headingDifference; | ||
} | ||
|
||
public void setHeadingDifference(double headingDifference) { | ||
this.headingDifference = headingDifference; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
app/src/main/java/com/fewlaps/flone/io/bean/CalibrateDroneAccelerometerRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.fewlaps.flone.io.bean; | ||
|
||
public class CalibrateDroneAccelerometerRequest { | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/com/fewlaps/flone/io/bean/CalibrateDroneMagnetometerRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.fewlaps.flone.io.bean; | ||
|
||
public class CalibrateDroneMagnetometerRequest { | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/com/fewlaps/flone/io/bean/CalibrationDataChangedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.fewlaps.flone.io.bean; | ||
|
||
public class CalibrationDataChangedEvent { | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/fewlaps/flone/io/bean/DelayData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.fewlaps.flone.io.bean; | ||
|
||
public class DelayData { | ||
|
||
public int delay; | ||
|
||
public DelayData(int delay) { | ||
this.delay = delay; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.