Initial revision

This commit is contained in:
Adrian Rumpold
2017-06-11 11:02:11 +02:00
commit 38ee7c490d
39 changed files with 2326 additions and 0 deletions

55
.gitignore vendored Executable file
View File

@@ -0,0 +1,55 @@
# Built application files
*.apk
*.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
*.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

1
.idea/.name generated Executable file
View File

@@ -0,0 +1 @@
androidDSKY

21
.idea/compiler.xml generated Executable file
View File

@@ -0,0 +1,21 @@
<?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" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>

3
.idea/copyright/profiles_settings.xml generated Executable file
View File

@@ -0,0 +1,3 @@
<component name="CopyrightManager">
<settings default="" />
</component>

6
.idea/encodings.xml generated Executable file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

246
.idea/misc.xml generated Executable file
View File

@@ -0,0 +1,246 @@
<?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="ProjectInspectionProfilesVisibleTreeState">
<entry key="Project Default">
<profile-state>
<expanded-state>
<State>
<id />
</State>
<State>
<id>Abstraction issuesJava</id>
</State>
<State>
<id>Android Lint</id>
</State>
<State>
<id>Assignment issuesJava</id>
</State>
<State>
<id>Bitwise operation issuesJava</id>
</State>
<State>
<id>Class metricsJava</id>
</State>
<State>
<id>Class structureJava</id>
</State>
<State>
<id>Cloning issuesJava</id>
</State>
<State>
<id>Code maturity issuesJava</id>
</State>
<State>
<id>Code style issuesJava</id>
</State>
<State>
<id>Compiler issuesJava</id>
</State>
<State>
<id>Concurrency annotation issuesJava</id>
</State>
<State>
<id>Control flow issuesJava</id>
</State>
<State>
<id>Data flow issuesJava</id>
</State>
<State>
<id>Declaration redundancyJava</id>
</State>
<State>
<id>Dependency issuesJava</id>
</State>
<State>
<id>Encapsulation issuesJava</id>
</State>
<State>
<id>Error handlingJava</id>
</State>
<State>
<id>Finalization issuesJava</id>
</State>
<State>
<id>GPath inspectionsGroovy</id>
</State>
<State>
<id>General</id>
</State>
<State>
<id>GeneralJava</id>
</State>
<State>
<id>Google Cloud Endpoints</id>
</State>
<State>
<id>Groovy</id>
</State>
<State>
<id>ImportsJava</id>
</State>
<State>
<id>Inheritance issuesJava</id>
</State>
<State>
<id>Initialization issuesJava</id>
</State>
<State>
<id>Internationalization issues</id>
</State>
<State>
<id>Internationalization issuesJava</id>
</State>
<State>
<id>J2ME issuesJava</id>
</State>
<State>
<id>JUnit issues</id>
</State>
<State>
<id>JUnit issuesJava</id>
</State>
<State>
<id>Java</id>
</State>
<State>
<id>Java language level issuesJava</id>
</State>
<State>
<id>Java language level migration aidsJava</id>
</State>
<State>
<id>JavaBeans issuesJava</id>
</State>
<State>
<id>JavaFX</id>
</State>
<State>
<id>Javadoc issuesJava</id>
</State>
<State>
<id>Language Injection</id>
</State>
<State>
<id>Logging issuesJava</id>
</State>
<State>
<id>Manifest</id>
</State>
<State>
<id>Memory issuesJava</id>
</State>
<State>
<id>Method metricsJava</id>
</State>
<State>
<id>Modularization issuesJava</id>
</State>
<State>
<id>Naming ConventionsGroovy</id>
</State>
<State>
<id>Naming conventionsJava</id>
</State>
<State>
<id>Numeric issuesJava</id>
</State>
<State>
<id>Packaging issuesJava</id>
</State>
<State>
<id>Performance issuesJava</id>
</State>
<State>
<id>Portability issuesJava</id>
</State>
<State>
<id>Probable bugsGroovy</id>
</State>
<State>
<id>Probable bugsJava</id>
</State>
<State>
<id>Properties Files</id>
</State>
<State>
<id>Properties FilesJava</id>
</State>
<State>
<id>Resource management issuesJava</id>
</State>
<State>
<id>Security issuesJava</id>
</State>
<State>
<id>Serialization issuesJava</id>
</State>
<State>
<id>StyleGroovy</id>
</State>
<State>
<id>TestNG</id>
</State>
<State>
<id>Threading issuesGroovy</id>
</State>
<State>
<id>Threading issuesJava</id>
</State>
<State>
<id>Verbose or redundant code constructsJava</id>
</State>
<State>
<id>Visibility issuesJava</id>
</State>
<State>
<id>toString() issuesJava</id>
</State>
</expanded-state>
</profile-state>
</entry>
</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" 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>

9
.idea/modules.xml generated Executable file
View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/androidDSKY.iml" filepath="$PROJECT_DIR$/androidDSKY.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>
</project>

12
.idea/runConfigurations.xml generated Executable file
View File

@@ -0,0 +1,12 @@
<?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>

1
app/.gitignore vendored Executable file
View File

@@ -0,0 +1 @@
/build

27
app/build.gradle Executable file
View File

@@ -0,0 +1,27 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "rumpold.de.androiddsky"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
}

17
app/proguard-rules.pro vendored Executable file
View File

@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\Users\Adriano\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 *;
#}

View File

@@ -0,0 +1,13 @@
package de.rumpold.androiddsky;
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);
}
}

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.rumpold.androiddsky">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".ui.DSKYActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name"
android:theme="@style/FullscreenTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>

View File

@@ -0,0 +1,260 @@
package de.rumpold.androiddsky;
import android.os.AsyncTask;
import android.util.Log;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import de.rumpold.androiddsky.network.YaAgcClient;
import de.rumpold.androiddsky.ui.DSKYActivity;
/**
* Created by Adriano on 17.05.2016.
*/
public class DSKY {
public static final String TAG = "TAG";
public static final int UPDATE_RATE = 25;
private final DSKYActivity activity;
private final YaAgcClient client;
private String prog;
private String verb;
private String noun;
private char signR1;
private char signR2;
private char signR3;
private String[] register1 = new String[5];
private String[] register2 = new String[5];
private String[] register3 = new String[5];
private boolean compActy;
private boolean uplinkActy;
private boolean noAtt;
private boolean gimbalLock;
private boolean tracker;
private boolean temp;
private boolean vel;
private boolean alt;
private boolean progError;
private boolean keyRel;
private boolean oprErr;
private boolean stby;
private boolean restart;
private final ScheduledThreadPoolExecutor executor;
private final Map<String, Integer> keycodeMap = new HashMap<>();
{
keycodeMap.put("0", 16);
keycodeMap.put("1", 1);
keycodeMap.put("2", 2);
keycodeMap.put("3", 3);
keycodeMap.put("4", 4);
keycodeMap.put("5", 5);
keycodeMap.put("6", 6);
keycodeMap.put("7", 7);
keycodeMap.put("8", 8);
keycodeMap.put("9", 9);
keycodeMap.put("VERB", 17);
keycodeMap.put("RSET", 18);
keycodeMap.put("KEY\nREL", 25);
keycodeMap.put("+", 26);
keycodeMap.put("-", 27);
keycodeMap.put("ENTR", 28);
keycodeMap.put("CLR", 30);
keycodeMap.put("NOUN", 31);
}
public DSKY(DSKYActivity activity) {
this.activity = activity;
this.client = new YaAgcClient(this);
this.executor = new ScheduledThreadPoolExecutor(1);
Arrays.fill(register1, "");
Arrays.fill(register2, "");
Arrays.fill(register3, "");
}
public void connect() {
AsyncTask.execute(new Runnable() {
@Override
public void run() {
try {
client.connect();
} catch (IOException e) {
throw new RuntimeException("Cannot connect to yaAGC", e);
}
}
});
executor.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
activity.updateIndicator(R.id.lbl_gimbalLock, gimbalLock);
activity.updateIndicator(R.id.lbl_noAtt, noAtt);
activity.updateIndicator(R.id.lbl_uplinkActy, uplinkActy);
activity.updateIndicator(R.id.lbl_prog, progError);
activity.updateIndicator(R.id.lbl_tracker, tracker);
activity.updateIndicator(R.id.lbl_oprErr, oprErr);
activity.updateIndicator(R.id.lbl_stby, stby);
activity.updateIndicator(R.id.lbl_keyRel, keyRel);
activity.updateIndicator(R.id.lbl_restart, restart);
activity.updateIndicator(R.id.lbl_compActy, compActy);
activity.updateDisplay(R.id.lbl_progId, prog);
activity.updateDisplay(R.id.lbl_verb, verb);
activity.updateDisplay(R.id.lbl_noun, noun);
activity.updateDisplay(R.id.lbl_R1, concat(register1));
activity.updateDisplay(R.id.lbl_R2, concat(register2));
activity.updateDisplay(R.id.lbl_R3, concat(register3));
activity.updateDisplay(R.id.lbl_sign_R1, String.valueOf(signR1));
activity.updateDisplay(R.id.lbl_sign_R2, String.valueOf(signR2));
activity.updateDisplay(R.id.lbl_sign_R3, String.valueOf(signR3));
}
}, UPDATE_RATE, UPDATE_RATE, TimeUnit.MILLISECONDS);
}
private String concat(String[] array) {
final StringBuffer buffer = new StringBuffer();
for (int i = 0; i < array.length; i++) {
buffer.append(array[i]);
}
return buffer.toString();
}
public void disconnect() {
AsyncTask.execute(new Runnable() {
@Override
public void run() {
try {
client.disconnect();
} catch (IOException e) {
throw new RuntimeException("Cannot connect to yaAGC", e);
}
}
});
executor.shutdownNow();
}
public void setCompActy(boolean compActy) {
this.compActy = compActy;
}
public void setGimbalLock(boolean gimbalLock) {
this.gimbalLock = gimbalLock;
}
public void setKeyRel(boolean keyRel) {
this.keyRel = keyRel;
}
public void setNoAtt(boolean noAtt) {
this.noAtt = noAtt;
}
public void setOprErr(boolean oprErr) {
this.oprErr = oprErr;
}
public void setProgError(boolean progError) {
this.progError = progError;
}
public void setTemp(boolean temp) {
this.temp = temp;
}
public void setAlt(boolean alt) {
this.alt = alt;
}
public void setVel(boolean vel) {
this.vel = vel;
}
public void setTracker(boolean tracker) {
this.tracker = tracker;
}
public void setUplinkActy(boolean uplinkActy) {
this.uplinkActy = uplinkActy;
}
public void setStby(boolean stby) {
this.stby = stby;
}
public void setRestart(boolean restart) {
this.restart = restart;
}
public void setNoun(String noun) {
this.noun = noun;
}
public void setProg(String prog) {
this.prog = prog;
}
public void setVerb(String verb) {
this.verb = verb;
}
public void setRegister1(int index, String digit) {
Log.d(TAG, "setRegister1: " + index + ", " + digit);
this.register1[index] = digit;
}
public void setRegister2(int index, String digit) {
Log.d(TAG, "setRegister2: " + index + ", " + digit);
this.register2[index] = digit;
}
public void setRegister3(int index, String digit) {
Log.d(TAG, "setRegister3: " + index + ", " + digit);
this.register3[index] = digit;
}
public void setSignR1(char signR1) {
this.signR1 = signR1;
}
public void setSignR2(char signR2) {
this.signR2 = signR2;
}
public void setSignR3(char signR3) {
this.signR3 = signR3;
}
public void buttonPressed(final String button) {
Log.d(TAG, "buttonPressed: " + button);
AsyncTask.execute(new Runnable() {
@Override
public void run() {
try {
if ("PRO".equals(button)) {
client.sendProceed();
} else {
final Integer keyCode = keycodeMap.get(button);
client.sendKeyCode(keyCode);
}
} catch (IOException e) {
Log.w(TAG, "buttonPressed: Could not send key press", e);
}
}
});
}
}

View File

@@ -0,0 +1,119 @@
package de.rumpold.androiddsky.network;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/**
* Created by Adriano on 17.05.2016.
*/
public class AgcPacket {
public static final int PACKET_LENGTH = 4;
private final boolean u;
private final boolean t;
private final int ioPort;
private final int dataCode;
private AgcPacket(int dataCode, boolean u, boolean t, int ioPort) {
this.dataCode = dataCode;
this.u = u;
this.t = t;
this.ioPort = ioPort;
}
/**
* The format is quite simple: each data packet consists of 4 bytes,
* arranged in bit-fields as follows (in order of transmission):
* <ioPort/>
* <pre>00utpppp 01pppddd 10dddddd 11dddddd</pre>
*
* @param bytes
*/
public static AgcPacket parseAgcPacket(ByteBuffer bytes) {
try {
bytes.rewind();
/*final StringBuilder sb = new StringBuilder();
for (byte b : bytes.array()) {
sb.append(String.format("%8s", Integer.toBinaryString(((int) b) & 0xff)).replace(' ', '0'));
sb.append(' ');
}
Log.d("AGCPacket", "AgcPacket: " + sb.toString());*/
bytes.order(ByteOrder.BIG_ENDIAN);
if (bytes.remaining() != PACKET_LENGTH) {
// invalid packet length
throw new IllegalArgumentException("packet length");
}
/* PARSE BYTE #1 */
int byteNum = 0;
char c = (char) ((short) bytes.get() & 0xff);
validateByteHeader(c, byteNum);
// Bit 'u':
boolean u = (c & 0b0010_0000) > 0;
boolean t = (c & 0b0001_0000) > 0;
int ioPort = c & 0b0000_1111;
/* PARSE BYTE #2 */
++byteNum;
c = (char) ((short) bytes.get() & 0xff);
validateByteHeader(c, byteNum);
ioPort = (ioPort << 3) | (c & 0b0011_1000) >> 3;
int dataCode = (c & 0b0000_0111);
/* PARSE BYTE #3 */
++byteNum;
c = (char) ((short) bytes.get() & 0xff);
validateByteHeader(c, byteNum);
dataCode = (dataCode << 6) | (c & 0b0011_1111);
/* PARSE BYTE #4 */
++byteNum;
c = (char) ((short) bytes.get() & 0xff);
validateByteHeader(c, byteNum);
dataCode = (dataCode << 6) | (c & 0b0011_1111);
return new AgcPacket(dataCode, u, t, ioPort);
} catch (Exception e) {
return null;
}
}
private static void validateByteHeader(char c, int byteNum) {
if ((c & 0b1100_0000) >> 6 != byteNum) {
// invalid byte header
throw new IllegalArgumentException("packet byte header in byte #" + byteNum);
}
}
public int getDataCode() {
return dataCode;
}
public int getIoPort() {
return ioPort;
}
public boolean t() {
return t;
}
public boolean u() {
return u;
}
@Override
public String toString() {
return "AgcPacket{" +
"dataCode=" + dataCode +
", ioPort=" + Integer.toOctalString(ioPort) +
", u=" + u +
", t=" + t +
'}';
}
}

View File

@@ -0,0 +1,285 @@
package de.rumpold.androiddsky.network;
import android.util.Log;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import de.rumpold.androiddsky.DSKY;
/**
* Created by Adriano on 17.05.2016.
*/
public class YaAgcClient {
public static final int YAAGC_SERVER_PORT = 19698;
private static final String TAG = "YaAGC client";
public static final int KEYBOARD_CHANNEL = 015;
private final DSKY dsky;
private SocketChannel agcChannel;
private Thread handler;
private class DSKYHandler implements Runnable {
@Override
public void run() {
final ByteBuffer buf = ByteBuffer.allocate(4);
while (!Thread.interrupted()) {
try {
buf.rewind();
if (!agcChannel.isConnected()) {
Thread.sleep(500);
continue;
}
agcChannel.read(buf);
buf.rewind();
handleAgcPacket(AgcPacket.parseAgcPacket(buf));
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
}
}
public YaAgcClient(DSKY dsky) {
this.dsky = dsky;
}
public void connect() throws IOException {
agcChannel = SocketChannel.open();
agcChannel.connect(new InetSocketAddress("137.250.170.198", YAAGC_SERVER_PORT));
handler = new Thread(new DSKYHandler(), "DSKY I/O Handler");
handler.start();
}
public void disconnect() throws IOException {
if (handler != null) {
handler.interrupt();
try {
handler.join();
} catch (InterruptedException e) {
// expected
}
}
agcChannel.close();
}
public void sendProceed() throws IOException {
sendChannelOutput(KEYBOARD_CHANNEL, 1 << 13);
}
public void sendKeyCode(int keyCode) throws IOException {
sendChannelOutput(KEYBOARD_CHANNEL, keyCode);
}
protected void sendChannelOutput(int channel, int data) throws IOException {
final byte[] packet = new byte[]{
(byte) (((channel >> 3) & 0b1111) & 0xff),
(byte) ((0b0100_0000 | (channel & 0b111) << 3 | ((data >> 12) & 0b111)) & 0xff),
(byte) ((0b1000_0000 | ((data >> 6) & 0b111_111)) & 0xff),
(byte) ((0b1100_0000 | (data & 0b111_111)) & 0xff)
};
final ByteBuffer buffer = ByteBuffer.wrap(packet);
buffer.rewind();
agcChannel.write(buffer);
}
protected String extractDigit(int digitCode) {
switch (digitCode) {
case 0:
return " ";
case 21:
return "0";
case 3:
return "1";
case 25:
return "2";
case 27:
return "3";
case 15:
return "4";
case 30:
return "5";
case 28:
return "6";
case 19:
return "7";
case 29:
return "8";
case 31:
return "9";
default:
throw new IllegalArgumentException("Invalid TAG digit code: " + digitCode);
}
}
protected void handleAgcPacket(AgcPacket packet) {
if (packet == null) {
return;
}
switch (packet.getIoPort()) {
case 010: {
// TAG 7-segment displays
final int digitIdx = (packet.getDataCode() >> 11) & 0b1111;
final int data = packet.getDataCode() & 0b1_11111_11111;
final int b = (data >> 10) & 0b1;
final int c = (data >> 5) & 0b11111;
final int d = data & 0b11111;
switch (digitIdx) {
case 11: {
// PROG digits
final String prog = extractDigit(c) + extractDigit(d);
dsky.setProg(prog);
Log.d(TAG, "[DSKY PROG] " + prog);
break;
}
case 10: {
// Verb digits
final String verb = extractDigit(c) + extractDigit(d);
dsky.setVerb(verb);
Log.d(TAG, "[DSKY VERB] " + verb);
break;
}
case 9: {
// Noun digits
final String noun = extractDigit(c) + extractDigit(d);
dsky.setNoun(noun);
Log.d(TAG, "[DSKY NOUN] " + noun);
break;
}
case 8: {
// First digit of R1
dsky.setRegister1(0, extractDigit(d));
break;
}
case 7: {
// 2nd & 3rd digit of R1, + sign R1
dsky.setRegister1(1, extractDigit(c));
dsky.setRegister1(2, extractDigit(d));
dsky.setSignR1(b > 0 ? '+' : ' ');
break;
}
case 6: {
// 4th & 5th digit of R1, - sign R1
dsky.setRegister1(3, extractDigit(c));
dsky.setRegister1(4, extractDigit(d));
dsky.setSignR1(b > 0 ? '-' : ' ');
break;
}
case 5: {
// 1st & 2nd digit of R2, + sign R2
dsky.setRegister2(0, extractDigit(c));
dsky.setRegister2(1, extractDigit(d));
dsky.setSignR2(b > 0 ? '+' : ' ');
break;
}
case 4: {
// 3rd & 4th digit of R2, - sign R2
dsky.setRegister2(2, extractDigit(c));
dsky.setRegister2(3, extractDigit(d));
dsky.setSignR2(b > 0 ? '-' : ' ');
break;
}
case 3: {
// 5th digit of R2, 1st digit of R3
dsky.setRegister2(4, extractDigit(c));
dsky.setRegister3(0, extractDigit(d));
break;
}
case 2: {
// 2nd & 3rd digit of R3, + sign R3
dsky.setRegister3(1, extractDigit(c));
dsky.setRegister3(2, extractDigit(d));
dsky.setSignR3(b > 0 ? '+' : ' ');
break;
}
case 1: {
// 4th & 5th digit of R3, - sign R3
dsky.setRegister3(3, extractDigit(c));
dsky.setRegister3(4, extractDigit(d));
dsky.setSignR3(b > 0 ? '-' : ' ');
break;
}
case 12: {
// Indicators
final boolean vel = (data & 0b0_00000_00100) > 0;
final boolean noAtt = (data & 0b0_00000_01000) > 0;
final boolean alt = (data & 0b0_00000_10000) > 0;
final boolean gimbalLock = (data & 0b0_00001_00000) > 0;
final boolean tracker = (data & 0b0_00100_00000) > 0;
final boolean prog = (data & 0b0_01000_00000) > 0;
dsky.setVel(vel);
dsky.setNoAtt(noAtt);
dsky.setAlt(alt);
dsky.setGimbalLock(gimbalLock);
dsky.setTracker(tracker);
dsky.setProgError(prog);
Log.d(TAG, String.format("[DSKY indicators] vel = %s, noAtt = %s, alt = %s, gimbalLock = %s, tracker = %s, prog = %s",
vel, noAtt, alt, gimbalLock, tracker, prog));
break;
}
default:
}
break;
}
case 011: {
// TAG indicator lights
final boolean compActy = (packet.getDataCode() & 0b0000_0010) != 0;
final boolean uplinkActy = (packet.getDataCode() & 0b0000_0100) != 0;
final boolean temp = (packet.getDataCode() & 0b0000_1000) != 0;
dsky.setCompActy(compActy);
dsky.setUplinkActy(uplinkActy);
dsky.setTemp(temp);
Log.d(TAG, String.format("[DSKY indicators] compActy = %s, uplinkActy = %s, temp = %s",
compActy, uplinkActy, temp));
break;
}
default:
}
}
}

View File

@@ -0,0 +1,243 @@
package de.rumpold.androiddsky.ui;
import android.annotation.SuppressLint;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.IdRes;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import de.rumpold.androiddsky.DSKY;
import de.rumpold.androiddsky.R;
/**
* An example full-screen activity that shows and hides the system UI (i.e.
* status bar and navigation/system bar) with user interaction.
*/
public class DSKYActivity extends AppCompatActivity {
/**
* Whether or not the system UI should be auto-hidden after
* {@link #AUTO_HIDE_DELAY_MILLIS} milliseconds.
*/
private static final boolean AUTO_HIDE = true;
/**
* If {@link #AUTO_HIDE} is set, the number of milliseconds to wait after
* user interaction before hiding the system UI.
*/
private static final int AUTO_HIDE_DELAY_MILLIS = 3000;
/**
* Some older devices needs a small delay between UI widget updates
* and a change of the status and navigation bar.
*/
private static final int UI_ANIMATION_DELAY = 300;
private final Handler mHideHandler = new Handler();
private View mContentView;
private final Runnable mHidePart2Runnable = new Runnable() {
@SuppressLint("InlinedApi")
@Override
public void run() {
// Delayed removal of status and navigation bar
// Note that some of these constants are new as of API 16 (Jelly Bean)
// and API 19 (KitKat). It is safe to use them, as they are inlined
// at compile-time and do nothing on earlier devices.
mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
}
};
private View mControlsView;
private final Runnable mShowPart2Runnable = new Runnable() {
@Override
public void run() {
// Delayed display of UI elements
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.show();
}
mControlsView.setVisibility(View.VISIBLE);
}
};
private boolean mVisible;
private final Runnable mHideRunnable = new Runnable() {
@Override
public void run() {
hide();
}
};
private final DSKY dsky = new DSKY(this);
public void updateIndicator(@IdRes final int id, final boolean state) {
mHideHandler.post(new Runnable() {
@Override
public void run() {
TextView indicator = (TextView) findViewById(id);
if (indicator != null) {
if (state) {
final int color;
if ("right".equals(indicator.getTag())) {
color = getResources().getColor(R.color.indicatorRightActive);
} else {
color = getResources().getColor(R.color.indicatorActive);
}
indicator.setBackgroundColor(color);
} else {
indicator.setBackgroundColor(getResources().getColor(R.color.indicatorPassive));
}
}
}
});
}
public void updateDisplay(@IdRes final int id, final String value) {
mHideHandler.post(new Runnable() {
@Override
public void run() {
TextView display = (TextView) findViewById(id);
display.setText(value);
}
});
}
/**
* Touch listener to use for in-layout UI controls to delay hiding the
* system UI. This is to prevent the jarring behavior of controls going away
* while interacting with activity UI.
*/
private final View.OnTouchListener mDelayHideTouchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (AUTO_HIDE) {
delayedHide(AUTO_HIDE_DELAY_MILLIS);
}
return false;
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dsky);
mVisible = true;
mControlsView = findViewById(R.id.controlBar);
mContentView = findViewById(R.id.contentView);
// Set up the user interaction to manually show or hide the system UI.
mContentView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
toggle();
}
});
// Upon interacting with UI controls, delay any scheduled hide()
// operations to prevent the jarring behavior of controls going away
// while interacting with the UI.
View.OnClickListener buttonListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
final Button button = (Button) view;
dsky.buttonPressed(button.getText().toString());
}
};
findViewById(R.id.btn_verb).setOnClickListener(buttonListener);
findViewById(R.id.btn_noun).setOnClickListener(buttonListener);
findViewById(R.id.btn_plus).setOnClickListener(buttonListener);
findViewById(R.id.btn_minus).setOnClickListener(buttonListener);
findViewById(R.id.btn_0).setOnClickListener(buttonListener);
findViewById(R.id.btn_1).setOnClickListener(buttonListener);
findViewById(R.id.btn_2).setOnClickListener(buttonListener);
findViewById(R.id.btn_3).setOnClickListener(buttonListener);
findViewById(R.id.btn_4).setOnClickListener(buttonListener);
findViewById(R.id.btn_5).setOnClickListener(buttonListener);
findViewById(R.id.btn_6).setOnClickListener(buttonListener);
findViewById(R.id.btn_7).setOnClickListener(buttonListener);
findViewById(R.id.btn_8).setOnClickListener(buttonListener);
findViewById(R.id.btn_9).setOnClickListener(buttonListener);
findViewById(R.id.btn_clr).setOnClickListener(buttonListener);
findViewById(R.id.btn_pro).setOnClickListener(buttonListener);
findViewById(R.id.btn_key_rel).setOnClickListener(buttonListener);
findViewById(R.id.btn_entr).setOnClickListener(buttonListener);
findViewById(R.id.btn_rset).setOnClickListener(buttonListener);
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
// Trigger the initial hide() shortly after the activity has been
// created, to briefly hint to the user that UI controls
// are available.
delayedHide(100);
dsky.connect();
}
@Override
protected void onDestroy() {
super.onDestroy();
dsky.disconnect();
}
private void toggle() {
if (mVisible) {
hide();
} else {
show();
}
}
private void hide() {
// Hide UI first
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.hide();
}
mControlsView.setVisibility(View.GONE);
mVisible = false;
// Schedule a runnable to remove the status and navigation bar after a delay
mHideHandler.removeCallbacks(mShowPart2Runnable);
mHideHandler.postDelayed(mHidePart2Runnable, UI_ANIMATION_DELAY);
}
@SuppressLint("InlinedApi")
private void show() {
// Show the system bar
mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
mVisible = true;
// Schedule a runnable to display UI elements after a delay
mHideHandler.removeCallbacks(mHidePart2Runnable);
mHideHandler.postDelayed(mShowPart2Runnable, UI_ANIMATION_DELAY);
}
/**
* Schedules a call to hide() in [delay] milliseconds, canceling any
* previously scheduled calls.
*/
private void delayedHide(int delayMillis) {
mHideHandler.removeCallbacks(mHideRunnable);
mHideHandler.postDelayed(mHideRunnable, delayMillis);
}
}

View File

@@ -0,0 +1,47 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0099cc"
tools:context=".ui.DSKYActivity">
<!-- The primary full-screen view. This can be replaced with whatever view
is needed to present your content, e.g. VideoView, SurfaceView,
TextureView, etc. -->
<!-- This FrameLayout insets its children based on system windows using
android:fitsSystemWindows. -->
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="left|top"
android:id="@+id/controlBar"></LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/material_grey_100">
<include
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="@layout/layout_indicator_lights"
android:layout_gravity="left|top"
android:id="@+id/contentView" />
<include
android:layout_width="449dp"
android:layout_height="wrap_content"
layout="@layout/layout_7seg"
android:layout_gravity="right|top" />
<include
android:layout_width="match_parent"
android:layout_height="282dp"
layout="@layout/layout_keyboard"
android:layout_gravity="center_horizontal|bottom" />
</FrameLayout>
</FrameLayout>

View File

@@ -0,0 +1,212 @@
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:stretchColumns="*">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="16dp">
<TextView
android:id="@+id/lbl_compActy"
style="@style/indicator.passive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="96dp"
android:height="96dp"
android:text="@string/comp_acty"
android:textAppearance="?android:attr/textAppearanceLarge" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PROG"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_gravity="center_horizontal" />
<TextView
android:id="@+id/lbl_progId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="64dp"
android:layout_gravity="center_horizontal"
android:gravity="bottom" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="VERB"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/lbl_verb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="64sp"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NOUN"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_gravity="center_horizontal" />
<TextView
android:id="@+id/lbl_noun"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="64dp"
android:layout_gravity="center_horizontal" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_span="2" >
<TextView
android:id="@+id/lbl_sign_R1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="64sp"
android:layout_gravity="center_horizontal"
android:singleLine="false"
android:phoneNumber="false"
android:layout_span="2" />
<TextView
android:id="@+id/lbl_R1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00000"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="64sp"
android:singleLine="false"
android:phoneNumber="false"
android:layout_span="2" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_span="2">
<TextView
android:id="@+id/lbl_sign_R2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="64sp"
android:layout_gravity="center_horizontal"
android:singleLine="false"
android:phoneNumber="false"
android:layout_span="2" />
<TextView
android:id="@+id/lbl_R2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00000"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="64sp"
android:singleLine="false"
android:phoneNumber="false"
android:layout_span="2" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_span="2" >
<TextView
android:id="@+id/lbl_sign_R3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="64sp"
android:layout_gravity="center_horizontal"
android:singleLine="false"
android:phoneNumber="false"
android:layout_span="2" />
<TextView
android:id="@+id/lbl_R3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00000"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="64sp"
android:singleLine="false"
android:phoneNumber="false"
android:layout_span="2" />
</LinearLayout>
</TableRow>
</TableLayout>

View File

@@ -0,0 +1,128 @@
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="@string/uplink_acty"
android:id="@+id/lbl_uplinkActy"
style="@style/indicator.passive" />
<TextView
style="@style/indicator.passive"
android:text="@string/temp"
android:id="@+id/lbl_temp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:tag="right" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/no_att"
android:id="@+id/lbl_noAtt"
android:layout_column="0"
android:textAlignment="center"
style="@style/indicator.passive"
android:background="#e0e0e0" />
<TextView
style="@style/indicator.passive"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/gimbal_lock"
android:id="@+id/lbl_gimbalLock"
android:layout_column="1"
android:textAlignment="center"
android:background="#e0e0e0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="right" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
style="@style/indicator.passive"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/stby"
android:id="@+id/lbl_stby"
android:layout_column="0"
android:textAlignment="center"
android:background="#e0e0e0" />
<TextView
style="@style/indicator.passive"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/prog"
android:id="@+id/lbl_prog"
android:layout_column="1"
android:textAlignment="center"
android:background="#e0e0e0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="right" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
style="@style/indicator.passive"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/key_rel"
android:id="@+id/lbl_keyRel"
android:layout_column="0"
android:textAlignment="center"
android:background="#e0e0e0" />
<TextView
style="@style/indicator.passive"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/restart"
android:id="@+id/lbl_restart"
android:layout_column="1"
android:textAlignment="center"
android:background="#e0e0e0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="right" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
style="@style/indicator.passive"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/opr_err"
android:id="@+id/lbl_oprErr"
android:layout_column="0"
android:textAlignment="center"
android:background="#e0e0e0" />
<TextView
style="@style/indicator.passive"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/tracker"
android:id="@+id/lbl_tracker"
android:layout_column="1"
android:textAlignment="center"
android:background="#e0e0e0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="right" />
</TableRow>
</TableLayout>

View File

@@ -0,0 +1,189 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical">
<Button
android:text="VERB"
android:id="@+id/btn_verb"
android:elegantTextHeight="false"
style="@style/dsky_button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NOUN"
android:id="@+id/btn_noun"
style="@style/dsky_button" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
android:id="@+id/btn_plus"
style="@style/dsky_button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:id="@+id/btn_minus"
style="@style/dsky_button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:id="@+id/btn_0"
style="@style/dsky_button" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="7"
android:id="@+id/btn_7"
style="@style/dsky_button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4"
android:id="@+id/btn_4"
style="@style/dsky_button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:id="@+id/btn_1"
style="@style/dsky_button" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="8"
android:id="@+id/btn_8"
style="@style/dsky_button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5"
android:id="@+id/btn_5"
style="@style/dsky_button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2"
android:id="@+id/btn_2"
style="@style/dsky_button" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="9"
android:id="@+id/btn_9"
style="@style/dsky_button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6"
android:id="@+id/btn_6"
style="@style/dsky_button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3"
android:id="@+id/btn_3"
style="@style/dsky_button" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CLR"
android:id="@+id/btn_clr"
style="@style/dsky_button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PRO"
android:id="@+id/btn_pro"
style="@style/dsky_button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="KEY\nREL"
android:id="@+id/btn_key_rel"
style="@style/dsky_button" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ENTR"
android:id="@+id/btn_entr"
style="@style/dsky_button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RSET"
android:id="@+id/btn_rset"
style="@style/dsky_button" />
</LinearLayout>
</LinearLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -0,0 +1,12 @@
<resources>
<!-- Declare custom theme attributes that allow changing which styles are
used for button bars depending on the API level.
?android:attr/buttonBarStyle is new as of API 11 so this is
necessary to support previous API levels. -->
<declare-styleable name="ButtonBarContainerTheme">
<attr name="metaButtonBarStyle" format="reference" />
<attr name="metaButtonBarButtonStyle" format="reference" />
</declare-styleable>
</resources>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="indicatorPassive">#e0e0e0</color>
<color name="indicatorActive">#9aff57</color>
<color name="indicatorRightActive">#ffd35c</color>
<color name="black_overlay">#66000000</color>
</resources>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="uplink_acty">UPLINK\nACTY</string>
<string name="no_att">NO ATT</string>
<string name="temp">TEMP</string>
<string name="gimbal_lock">GIMBAL\nLOCK</string>
<string name="stby">STBY</string>
<string name="prog">PROG</string>
<string name="key_rel">KEY REL</string>
<string name="restart">RESTART</string>
<string name="opr_err">OPR ERR</string>
<string name="tracker">TRACKER</string>
<string name="comp_acty">COMP\nACTY</string>
</resources>

View File

@@ -0,0 +1,3 @@
<resources>
<string name="app_name">androidDSKY</string>
</resources>

View File

@@ -0,0 +1,53 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="FullscreenTheme" parent="AppTheme">
<item name="android:actionBarStyle">@style/FullscreenActionBarStyle</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">@null</item>
<item name="metaButtonBarStyle">?android:attr/buttonBarStyle</item>
<item name="metaButtonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
</style>
<style name="FullscreenActionBarStyle" parent="Widget.AppCompat.ActionBar">
<item name="android:background">@color/black_overlay</item>
</style>
<style name="indicator">
<item name="android:textAppearance">?android:attr/textAppearanceLarge</item>
<item name="android:layout_column">0</item>
<item name="android:textAlignment">center</item>
<item name="android:textStyle">bold</item>
<item name="android:width">128dp</item>
<item name="android:height">64dp</item>
<item name="android:gravity">center</item>
<item name="android:textColor">@android:color/black</item>
<item name="android:layout_gravity">center</item>
</style>
<style name="indicator.passive" parent="indicator">
<item name="android:background">@color/indicatorPassive</item>
</style>
<style name="indicator.active" parent="indicator">
<item name="android:background">@color/indicatorActive</item>
</style>
<style name="dsky_button">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:width">96dp</item>
<item name="android:height">96dp</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">18dp</item>
<item name="android:textColor">#ffffff</item>
<item name="android:backgroundTint">#000000</item>
</style>
</resources>

View File

@@ -0,0 +1,15 @@
package de.rumpold.androiddsky;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}

23
build.gradle Executable file
View File

@@ -0,0 +1,23 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

18
gradle.properties Executable file
View File

@@ -0,0 +1,18 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

BIN
gradle/wrapper/gradle-wrapper.jar vendored Executable file

Binary file not shown.

6
gradle/wrapper/gradle-wrapper.properties vendored Executable file
View File

@@ -0,0 +1,6 @@
#Mon Dec 28 10:00:20 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

160
gradlew vendored Executable file
View File

@@ -0,0 +1,160 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

90
gradlew.bat vendored Executable file
View File

@@ -0,0 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

1
settings.gradle Executable file
View File

@@ -0,0 +1 @@
include ':app'