Skip to content

Commit

Permalink
Updated'
Browse files Browse the repository at this point in the history
  • Loading branch information
aswanthabam committed Feb 9, 2023
1 parent 0bd4bdc commit 61d5881
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 4 deletions.
Binary file added app/release/app-release.apk
Binary file not shown.
20 changes: 20 additions & 0 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.avc.robocar",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "app-release.apk"
}
],
"elementType": "File"
}
10 changes: 9 additions & 1 deletion app/src/main/java/com/avc/robocar/Bluetooth.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public BluetoothAdapter getAdapter(){
return ba;
}
public boolean send(String data){
Toast.makeText(activity, "Sending : "+data,Toast.LENGTH_LONG).show();
Toast.makeText(activity, "Sending : "+data,Toast.LENGTH_SHORT).show();
if(!IS_CONNECTED) return false;
try{
socket.getOutputStream().write(data.getBytes());
Expand Down Expand Up @@ -130,6 +130,12 @@ public void onReceive(Context context, Intent intent) {
case BluetoothAdapter.STATE_TURNING_OFF:
if(state_listener != null) state_listener.onTurningOFF();
break;
case BluetoothAdapter.STATE_CONNECTING:
if(state_listener != null) state_listener.onConnecting();
break;
case BluetoothAdapter.STATE_CONNECTED:
if(state_listener != null) state_listener.onConnected();
break;
}
}
}
Expand All @@ -145,6 +151,8 @@ public interface OnStateChangedListener{
void onTurnOFF();
void onTurningON();
void onTurningOFF();
void onConnecting();
void onConnected();
}
@SuppressLint("MissingPermission")
public void connect(final BluetoothDevice device){
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/avc/robocar/DeviceDialog.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package com.avc.robocar;
import android.annotation.SuppressLint;
import android.app.*;
import android.os.*;
import android.support.v7.app.*;
Expand Down Expand Up @@ -43,6 +44,7 @@ protected void onCreate(Bundle savedInstanceState)
public void onSelected(BluetoothDevice device){
blue.pairDevice(device);
blue.connect(device);
dismiss();
}
});
find.setOnClickListener(new View.OnClickListener(){
Expand All @@ -51,6 +53,7 @@ public void onClick(View v){
}
});
blue.setOnDeviceDiscoverListener(new Bluetooth.OnDeviceDiscoveredListener(){
@SuppressLint("MissingPermission")
public void onDiscover(BluetoothDevice device){
devices.add(device);
deviceString.add(device.getName());
Expand Down
12 changes: 11 additions & 1 deletion app/src/main/java/com/avc/robocar/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ public void onTurningOFF(){
textStatus.setText("Turning off bluetooth ...");
setStatus(R.color.orange);
}
public void onConnecting(){
state = -1;
textStatus.setText("Connecting ...");
setStatus(R.color.orange);
}
public void onConnected(){
state = -1;
textStatus.setText("Connected");
setStatus(R.color.green);
}
});

status.setOnClickListener(new View.OnClickListener(){
Expand Down Expand Up @@ -173,7 +183,7 @@ public void itemSelection(int id,MotionEvent event)
}
break;
case R.id.btn_brake:
bluetooth.send("S");
if(action == MotionEvent.ACTION_DOWN) bluetooth.send("S");
// else if(action == MotionEvent.ACTION_UP) bluetooth.send("X");
break;
case R.id.radio_control:
Expand Down
36 changes: 34 additions & 2 deletions app/src/main/java/com/avc/robocar/VoiceControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.*;
import java.util.*;
import android.os.*;
import android.util.ArrayMap;
import android.widget.*;
import android.speech.tts.*;

Expand All @@ -15,8 +16,33 @@ public class VoiceControl
private Intent speechRecognizerIntent;
private TextToSpeech tts;
public static boolean IS_LISTENING = false;
private Map<String,String> dataSet = new ArrayMap<String,String>();
//private CheckBox micButton;
VoiceControl(AppCompatActivity a,Bluetooth b){
dataSet.put("move forward","F");
dataSet.put("forward","F");
dataSet.put("go forward","F");
dataSet.put("go straight","F");
dataSet.put("move backward","B");
dataSet.put("backward","B");
dataSet.put("go backward","B");
dataSet.put("go back","B");
dataSet.put("turn left","L");
dataSet.put("left","L");
dataSet.put("move left","L");
dataSet.put("go left","L");
dataSet.put("turn right","R");
dataSet.put("right","R");
dataSet.put("move right","R");
dataSet.put("go right","R");
dataSet.put("brake","S");
dataSet.put("break","S");
dataSet.put("stop","S");
dataSet.put("stop moving","S");
dataSet.put("obstacle mode","O");
dataSet.put("switch to obstacle mode","O");
dataSet.put("control mode","C");
dataSet.put("switch to control mode","C");
activity = a;
blue = b;
//micButton = btn;
Expand All @@ -37,8 +63,14 @@ public void onInit(int i) {
public void onResults(Bundle bundle) {
ArrayList<String> data = bundle.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
reco.stopListening();
speak(data.get(0));
if(IS_LISTENING)reco.startListening(speechRecognizerIntent);
for(String val : data){
if(dataSet.containsKey(val.toLowerCase())){
blue.send(dataSet.get(val.toLowerCase()));
speak(val,true);
break;
}
}
if(IS_LISTENING) reco.startListening(speechRecognizerIntent);
Toast.makeText(activity,""+data, Toast.LENGTH_SHORT).show();
}
@Override
Expand Down

0 comments on commit 61d5881

Please sign in to comment.