Add files via upload

This commit is contained in:
Nikita Kogan 2019-06-21 01:19:07 +03:00 committed by GitHub
parent 5b70036f18
commit 8acaec031b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 16 deletions

View File

@ -11,11 +11,14 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
<activity android:name=".JoystickActivity" />
<activity android:name=".JoystickActivity" android:configChanges="orientation|screenSize|keyboardHidden">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.ex4.MainActivity"/>
</activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

View File

@ -50,8 +50,8 @@ public class Joystick extends SurfaceView implements SurfaceHolder.Callback, Vie
{
centerX = getWidth() / 2;
centerY = getHeight() / 2;
baseRadius = Math.min(getWidth(), getHeight()) / 3;
hatRadius = Math.min(getWidth(), getHeight()) / 5;
baseRadius = Math.min(getWidth(), getHeight()) / 4;
hatRadius = Math.min(getWidth(), getHeight()) / 7;
}
//method to be called when Joystick surface is created
@Override
@ -71,7 +71,7 @@ public class Joystick extends SurfaceView implements SurfaceHolder.Callback, Vie
@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder)
{
UserHandler.getInstance().disconnect();
//nothing...
}
/*when Joystick is touched, method will be called and will compute values to be sent as
* arguments to the JoystickCallBack onJoystickMoved even handler*/
@ -112,10 +112,10 @@ public class Joystick extends SurfaceView implements SurfaceHolder.Callback, Vie
{
Canvas drawCanvas = this.getHolder().lockCanvas();
Paint colors = new Paint();
drawCanvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
colors.setARGB(255, 50, 50, 50);
drawCanvas.drawColor(Color.WHITE);
colors.setARGB(175, 50, 50, 50);
drawCanvas.drawCircle(centerX, centerY, baseRadius, colors);
colors.setARGB(255, 0, 0, 255);
colors.setARGB(200, 50, 50, 200);
drawCanvas.drawCircle(x, y, hatRadius, colors);
getHolder().unlockCanvasAndPost(drawCanvas);
}

View File

@ -18,4 +18,10 @@ public class JoystickActivity extends AppCompatActivity implements Joystick.Joys
handler.send_message(true, xPercent); //true is aileron
handler.send_message(false, yPercent); //false is elevator
}
@Override
protected void onDestroy()
{
super.onDestroy();
UserHandler.getInstance().disconnect();
}
}

View File

@ -59,9 +59,7 @@ public class UserHandler
{
synchronized (this)
{
if (message != null) {
writer.print(message);
message = null; }
if (message != null) { writer.printf(message); message = null; }
}
}
sock.close();
@ -101,6 +99,7 @@ public class UserHandler
{
aileron_or_elevator = aileron_path;
}
if (val < 0.99 && val > -0.99) { val *= -1; }
synchronized (this)
{
message = "set " + aileron_or_elevator + " " + Float.toString(val) + " \r\n";

View File

@ -87,17 +87,16 @@
<Button
android:id="@+id/connect_button"
android:layout_width="118dp"
android:layout_height="70dp"
android:layout_height="51dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="4dp"
android:text="@string/connect_str"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.478"
app:layout_constraintHorizontal_bias="0.48"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -84,8 +84,8 @@
<Button
android:id="@+id/connect_button"
android:layout_width="118dp"
android:layout_height="70dp"
android:layout_width="114dp"
android:layout_height="43dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginEnd="16dp"