Commit d3f3ad9c authored by howland's avatar howland
Browse files

added project files

parent 3bdc0796
# Built application files
*.ap_
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# Intellij
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/dictionaries
.idea/libraries
# Keystore files
# Uncomment the following line if you do not want to check your keystore files in.
#*.jks
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
# Google Services (e.g. APIs or Firebase)
google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
<component name="CopyrightManager">
<settings default="" />
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<option name="myLocal" value="true" />
<inspection_tool class="AndroidLintNewApi" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false">
<option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" />
<option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" />
</inspection_tool>
</profile>
</component>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="PROJECT_PROFILE" value="Project Default" />
<option name="USE_PROJECT_PROFILE" value="true" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/FlightController.iml" filepath="$PROJECT_DIR$/FlightController.iml" />
<module fileurl="file://$PROJECT_DIR$/LARIX Android Control Software.iml" filepath="$PROJECT_DIR$/LARIX Android Control Software.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
</component>
</project>
\ No newline at end of file
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "steurer.infineon.com.flightcontroller_gui"
minSdkVersion 18
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services-appindexing:8.1.0'
}
-- Merging decision tree log ---
manifest
ADDED from AndroidManifest.xml:2:1
package
ADDED from AndroidManifest.xml:3:5
INJECTED from AndroidManifest.xml:0:0
INJECTED from AndroidManifest.xml:0:0
android:versionName
INJECTED from AndroidManifest.xml:0:0
INJECTED from AndroidManifest.xml:0:0
xmlns:android
ADDED from AndroidManifest.xml:2:11
android:versionCode
INJECTED from AndroidManifest.xml:0:0
INJECTED from AndroidManifest.xml:0:0
uses-permission#android.permission.BLUETOOTH
ADDED from AndroidManifest.xml:6:5
android:name
ADDED from AndroidManifest.xml:6:22
uses-permission#android.permission.BLUETOOTH_ADMIN
ADDED from AndroidManifest.xml:7:5
android:name
ADDED from AndroidManifest.xml:7:22
application
ADDED from AndroidManifest.xml:9:6
MERGED from com.android.support:appcompat-v7:21.0.3:16:5
MERGED from com.android.support:support-v4:21.0.3:16:5
android:screenOrientation
ADDED from AndroidManifest.xml:15:9
android:label
ADDED from AndroidManifest.xml:13:9
android:allowBackup
ADDED from AndroidManifest.xml:10:9
android:icon
ADDED from AndroidManifest.xml:11:9
android:theme
ADDED from AndroidManifest.xml:14:9
android:name
ADDED from AndroidManifest.xml:12:9
activity#steurer.infineon.com.flightcontroller_gui.MainActivity
ADDED from AndroidManifest.xml:16:9
android:label
ADDED from AndroidManifest.xml:18:13
android:name
ADDED from AndroidManifest.xml:17:13
intent-filter#android.intent.action.MAIN+android.intent.category.LAUNCHER
ADDED from AndroidManifest.xml:19:13
action#android.intent.action.MAIN
ADDED from AndroidManifest.xml:20:17
android:name
ADDED from AndroidManifest.xml:20:25
category#android.intent.category.LAUNCHER
ADDED from AndroidManifest.xml:22:17
android:name
ADDED from AndroidManifest.xml:22:27
uses-sdk
INJECTED from AndroidManifest.xml:0:0 reason: use-sdk injection requested
MERGED from com.android.support:appcompat-v7:21.0.3:15:5
MERGED from com.android.support:support-v4:21.0.3:15:5
android:targetSdkVersion
INJECTED from AndroidManifest.xml:0:0
INJECTED from AndroidManifest.xml:0:0
android:minSdkVersion
INJECTED from AndroidManifest.xml:0:0
INJECTED from AndroidManifest.xml:0:0
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\Users\SteurerE\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
package steurer.infineon.com.flightcontroller_gui;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="steurer.infineon.com.flightcontroller_gui" >
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:name=".FlightControllerApp"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.NoActionBar">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:configChanges="orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
package steurer.infineon.com.flightcontroller_gui;
import java.util.ArrayList;
import java.util.List;
/**
* Created by SteurerE on 03.02.2015.
* <p/>
* Class for implementing a Communication Protocol
* based on byte-streams.
* <p/>
* It's for Communication with a XMC4500 Microcontroller
* over a Bluetooth Serial Connection
*/
public class BluetoothProtocol {
public static boolean USE_MSP_PROTOCOL = false;
public static final int PACKET_SIZE = 16; //19 bytes for the Protocol
public static final int DATA_SIZE = 14; //14 bytes data for data-package
public static final int HEADER_SIZE = 1; //1 byte header
public static final int CHECKSUM_SIZE = 4; //4 bytes checksum
public static final byte CONTROL_HEADER = 0x00;
public static byte[] prepareControlPackage(ControlPacket packet) {
byte[] b = new byte[PACKET_SIZE];
if (USE_MSP_PROTOCOL) {
int speed = 10*packet.getSpeed()+1000;
byte arm = packet.getArm();
int azimuth = (int)(-1000.0/360.0*packet.getAzimuth()+1500);
int pitch = (int)(-1000.0/90.0*packet.getPitch()+1500);
int roll = (int)(-1000.0/90.0*packet.getRoll()+1500);
b[0] = (byte) 0x24;
b[1] = (byte) 0x4D;
b[2] = (byte) 0x3C;
b[3] = (byte) 0x0A;
b[4] = (byte) 0xC8;
b[5] = (byte) pitch;
b[6] = (byte) (pitch >> 8);
b[7] = (byte) roll;
b[8] = (byte) (roll >> 8);
b[9] = (byte) speed;
b[10] = (byte) (speed >> 8);
b[11] = (byte) azimuth;
b[12] = (byte) (azimuth >> 8);
if (arm == 0x01) {
b[13] = (byte) 0xd0;
b[14] = (byte) 0x07;
} else {
b[13] = (byte) 0xe8;
b[14] = (byte) 0x03;
}
byte checksum = 0;
for (int i = 3; i < PACKET_SIZE - 1; i++)
checksum ^= b[i];
b[15] = checksum;
}
else
{
int speed = (int)((1738.0-306.0)/100.0*packet.getSpeed()+306.0);
byte arm = packet.getArm();
int roll = (int)(-(3786.0-2352.0)/90.0*packet.getPitch()+3070);
int pitch = (int)(-(5836.0-4404.0)/90.0*packet.getRoll()+5118);
int azimuth = (int)(-(7878.0-6446.0)/180.0*packet.getAzimuth()+7162);
if (roll < 2352)
roll = 2352;
if (roll > 3786)
roll = 3786;
if (pitch < 4404)
pitch = 4404;
if (pitch > 5836)
pitch = 5836;
b[0] = (byte) 0x00;
b[1] = (byte) 0xa2;
b[2] = (byte) (roll >> 8);
b[3] = (byte) roll;
b[4] = (byte) 0x30;
b[5] = (byte) 0x00;
b[6] = (byte) (pitch >> 8);
b[7] = (byte) pitch;
if (arm == 0x01) {
b[8] = (byte) 0x26;
b[9] = (byte) 0xCA;
}
else {
b[8] = (byte) 0x21;
b[9] = (byte) 0x32;
}
b[10] = (byte) (azimuth >> 8);;
b[11] = (byte) azimuth;
b[12] = (byte) 0x2b;
b[13] = (byte) 0xfe;
b[14] = (byte) (speed >> 8);
b[15] = (byte) speed;
}
return b;
}
public static List<byte[]> prepareDataPackages(DataPacket packet) {
String all_data = packet.getData();
List<String> packetlist = new ArrayList<String>();
List<byte[]> bytelist = new ArrayList<byte[]>();
int mod = 0;
if (all_data.length() > DATA_SIZE) {
int length = all_data.length() / DATA_SIZE;
mod = all_data.length() % DATA_SIZE;
if (mod == 0) {
for (int i = 0; i < length; i++) {
packetlist.add(all_data.substring(i * DATA_SIZE, (i + 1) * DATA_SIZE));
}
} else {
for (int i = 0; i < (length + 1); i++) {
if (i == length) {
String s = all_data.substring(i * DATA_SIZE, i * DATA_SIZE + mod);
char[] stringbuffer = s.toCharArray();
char[] last_packet = new char[DATA_SIZE];
System.arraycopy(stringbuffer, 0, last_packet, 0, mod);
String last_packet_s = new String(last_packet);
packetlist.add(last_packet_s);
} else {
packetlist.add(all_data.substring(i * DATA_SIZE, (i + 1) * DATA_SIZE));
}
}
}
} else {
mod = all_data.length();
char[] stringbuffer = all_data.toCharArray();
char[] last_packet = new char[DATA_SIZE];
System.arraycopy(stringbuffer, 0, last_packet, 0, stringbuffer.length);
String last_packet_s = new String(last_packet);
packetlist.add(last_packet_s);
}
int start_byte_count = 0;
if (packetlist.size() == 1) {
start_byte_count = mod;
} else if (mod == 0) {
start_byte_count = DATA_SIZE * packetlist.size();
} else if (mod != 0) {
start_byte_count = DATA_SIZE * (packetlist.size() - 1) + mod;
}
for (int i = 0; i < packetlist.size(); i++) {
byte[] dest = new byte[PACKET_SIZE];
byte[] src = packetlist.get(i).getBytes();
byte[] header = new byte[1];
header[0] = (byte) start_byte_count;
System.arraycopy(header, 0, dest, 0, 1);
System.arraycopy(src, 0, dest, 1, src.length);
bytelist.add(dest);
start_byte_count = start_byte_count - DATA_SIZE;
}
for (int i = 0; i < bytelist.size(); i++) {
byte[] checksum_byte = new byte[CHECKSUM_SIZE];
byte[] checksum_helper = bytelist.get(i);
int checksum = checksum_helper[0];
for (int j = HEADER_SIZE; j < PACKET_SIZE - CHECKSUM_SIZE; j += 4) {
checksum ^= (checksum_helper[j] << 24) | (checksum_helper[j + 1] << 16) | (checksum_helper[j + 2] << 8) | (checksum_helper[j + 3]);
}
checksum_byte[0] = (byte) ((checksum >> 24) & 0xFF);
checksum_byte[1] = (byte) ((checksum >> 16) & 0xFF);
checksum_byte[2] = (byte) ((checksum >> 8) & 0xFF);
checksum_byte[3] = (byte) (checksum & 0xFF);
System.arraycopy(checksum_byte, 0, checksum_helper, PACKET_SIZE - CHECKSUM_SIZE, checksum_byte.length);
}
return bytelist;
}
}
package steurer.infineon.com.flightcontroller_gui;
/**
* Created by SteurerE on 04.02.2015.
*/
public class ControlPacket
{
private byte speed;
private byte arm;
private float azimuth;
private float pitch;
private float roll;
public byte getArm() {
return arm;
}
public void setArm(byte arm) {
this.arm = arm;
}
public ControlPacket(byte speed,byte arm, float azimuth, float pitch, float roll)
{
this.speed = speed;
this.arm = arm;
this.azimuth = azimuth;
this.pitch = pitch;
this.roll = roll;
}
public ControlPacket(){}
public byte getSpeed() {
return speed;
}
public void setSpeed(byte speed) {
this.speed = speed;
}
public float getAzimuth() {
return azimuth;
}
public void setAzimuth(float azimuth) {
this.azimuth = azimuth;
}
public float getPitch() {
return pitch;
}
public void setPitch(float pitch) {
this.pitch = pitch;
}
public float getRoll() {
return roll;
}
public void setRoll(float roll) {
this.roll = roll;
}