Add recording capability to simple controller.

This commit is contained in:
Piv
2020-04-22 22:22:08 +09:30
parent 54770d7675
commit 807921b58f
3 changed files with 60 additions and 2 deletions

View File

@@ -1,6 +1,8 @@
package org.vato.carcontroller;
import com.google.protobuf.Empty;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -68,4 +70,15 @@ public class PiLoader implements Runnable {
}
}
}
public void saveRecording() {
// Ideally don't want to use a blocking stub here, android may complain.
Empty done = stub.saveRecordedData(SaveRequest.newBuilder().setFile("Test").build());
}
public void record(boolean record) {
// Ideally don't want to use a blocking stub here, android may complain.
Empty done = stub.record(RecordingReqeust.newBuilder().setRecord(record).build());
}
}

View File

@@ -2,15 +2,19 @@ package org.vato.carcontroller;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.SeekBar;
import android.widget.Switch;
import androidx.appcompat.app.AppCompatActivity;
import androidx.preference.PreferenceManager;
public class SimpleController extends AppCompatActivity implements SeekBar.OnSeekBarChangeListener {
SeekBar steeringSlider;
SeekBar throttleSlider;
private SeekBar steeringSlider;
private SeekBar throttleSlider;
private Switch recordSwitch;
private static PiLoader grpcController;
@Override
@@ -26,6 +30,8 @@ public class SimpleController extends AppCompatActivity implements SeekBar.OnSee
if (throttleSlider != null) {
throttleSlider.setOnSeekBarChangeListener(this);
}
recordSwitch = findViewById(R.id.recordSwitch);
}
@Override
@@ -83,4 +89,12 @@ public class SimpleController extends AppCompatActivity implements SeekBar.OnSee
steeringSlider.setProgress(50);
throttleSlider.setProgress(50);
}
public void saveRecording(View view) {
grpcController.saveRecording();
}
public void record(View view) {
grpcController.record(recordSwitch.isSelected());
}
}

View File

@@ -28,4 +28,35 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Switch
android:id="@+id/recordSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:text="Switch"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView3" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:text="TextView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Recording" />
<Button
android:id="@+id/saveButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginEnd="16dp"
android:text="Save"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>