Merge branch 'master' of https://git.efi.th-nuernberg.de/gitea/yasarba71520/Line-Following-Robot
4
MobileApp/.idea/deploymentTargetDropDown.xml
generated
@ -7,11 +7,11 @@
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="VIRTUAL_DEVICE_PATH" />
|
||||
<value value="C:\Users\baran\.android\avd\Nexus_5_API_R.avd" />
|
||||
<value value="C:\Users\baran\.android\avd\Pixel_2_API_R.avd" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</targetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2023-01-11T18:53:15.217760700Z" />
|
||||
<timeTargetWasSelectedWithDropDown value="2023-01-12T21:16:30.648959800Z" />
|
||||
</component>
|
||||
</project>
|
2
MobileApp/.idea/misc.xml
generated
@ -5,11 +5,13 @@
|
||||
<map>
|
||||
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/drawable-anydpi/manuell.xml" value="0.1" />
|
||||
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/drawable-v24/ic_launcher_foreground.xml" value="0.1" />
|
||||
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/drawable/ic_baseline_rotate_left_24.xml" value="0.1" />
|
||||
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/drawable/ic_dashboard_black_24dp.xml" value="0.1" />
|
||||
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/drawable/ic_home_black_24dp.xml" value="0.1" />
|
||||
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/drawable/ic_launcher_background.xml" value="0.1" />
|
||||
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/drawable/ic_notifications_black_24dp.xml" value="0.1" />
|
||||
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/drawable/my_btn_toggle.xml" value="0.1" />
|
||||
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/drawable/vorwarts.xml" value="0.1" />
|
||||
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/layout/activity_main.xml" value="0.16666666666666666" />
|
||||
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/layout/fragment_automatik.xml" value="0.3333333333333333" />
|
||||
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/layout/fragment_dashboard.xml" value="0.14666666666666667" />
|
||||
|
BIN
MobileApp/PicturesCircles/back.png
Normal file
After Width: | Height: | Size: 80 KiB |
BIN
MobileApp/PicturesCircles/blank.png
Normal file
After Width: | Height: | Size: 74 KiB |
BIN
MobileApp/PicturesCircles/forward.png
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
MobileApp/PicturesCircles/left.png
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
MobileApp/PicturesCircles/left_back.png
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
MobileApp/PicturesCircles/left_forward.png
Normal file
After Width: | Height: | Size: 81 KiB |
BIN
MobileApp/PicturesCircles/right.png
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
MobileApp/PicturesCircles/right_back.png
Normal file
After Width: | Height: | Size: 81 KiB |
BIN
MobileApp/PicturesCircles/right_forward.png
Normal file
After Width: | Height: | Size: 83 KiB |
@ -7,14 +7,15 @@ import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
|
||||
public class Communication {
|
||||
public boolean sendData(String data) {
|
||||
public boolean sendData(String data, String ip, int port) {
|
||||
try {
|
||||
Socket socket = new Socket("192.168.0.1", 1755);
|
||||
Socket socket = new Socket(ip, port);
|
||||
DataOutputStream DOS = new DataOutputStream(socket.getOutputStream());
|
||||
DOS.writeUTF(data);
|
||||
socket.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return true; //ToDo: change to false to test connection - currently always true is delivered
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.example.lfrmobileapp;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
@ -12,6 +14,8 @@ import androidx.navigation.ui.NavigationUI;
|
||||
|
||||
import com.example.lfrmobileapp.databinding.ActivityMainBinding;
|
||||
|
||||
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private ActivityMainBinding binding;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.example.lfrmobileapp.ui.home;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -14,12 +15,20 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.example.lfrmobileapp.Communication;
|
||||
import com.example.lfrmobileapp.R;
|
||||
import com.example.lfrmobileapp.databinding.FragmentManuellBinding;
|
||||
import com.example.lfrmobileapp.ui.notifications.NotificationsFragment;
|
||||
|
||||
import io.github.controlwear.virtual.joystick.android.JoystickView;
|
||||
|
||||
public class HomeFragment extends Fragment {
|
||||
|
||||
String ipKey = "ipkey";
|
||||
String portKey = "portkey";
|
||||
|
||||
String ipAddress = "192.168.0.1";
|
||||
int port = 8000;
|
||||
|
||||
private FragmentManuellBinding binding;
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
@ -30,6 +39,12 @@ public class HomeFragment extends Fragment {
|
||||
binding = FragmentManuellBinding.inflate(inflater, container, false);
|
||||
View root = binding.getRoot();
|
||||
|
||||
SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedPref.edit();
|
||||
|
||||
ipAddress = sharedPref.getString(ipKey, "");
|
||||
port = sharedPref.getInt(portKey, 0);
|
||||
|
||||
final TextView textView = binding.textHome;
|
||||
homeViewModel.getText().observe(getViewLifecycleOwner(), textView::setText);
|
||||
|
||||
@ -39,7 +54,28 @@ public class HomeFragment extends Fragment {
|
||||
@Override
|
||||
public void onMove(int angle, int strength) {
|
||||
homeViewModel.setText(Integer.toString(angle), Integer.toString(strength));
|
||||
com.sendData("Vanessa stinkt, Baran nicht");
|
||||
if((angle >= 338 || angle < 22) && strength != 0){
|
||||
joystick.setBackgroundResource(R.mipmap.right);
|
||||
}else if((angle >= 22 && angle < 67) && strength != 0){
|
||||
joystick.setBackgroundResource(R.mipmap.right_forward);
|
||||
}else if((angle >=67 && angle < 112) && strength != 0){
|
||||
joystick.setBackgroundResource(R.mipmap.forward);
|
||||
}else if((angle >=112 && angle < 157) && strength != 0){
|
||||
joystick.setBackgroundResource(R.mipmap.left_forward);
|
||||
}else if((angle >=157 && angle < 202) && strength != 0){
|
||||
joystick.setBackgroundResource(R.mipmap.left);
|
||||
}else if((angle >=202 && angle < 247) && strength != 0){
|
||||
joystick.setBackgroundResource(R.mipmap.left_back);
|
||||
}else if((angle >=247 && angle < 292) && strength != 0){
|
||||
joystick.setBackgroundResource(R.mipmap.back);
|
||||
}else if((angle >=292 && angle < 337) && strength != 0){
|
||||
joystick.setBackgroundResource(R.mipmap.right_back);
|
||||
}
|
||||
else{
|
||||
joystick.setBackgroundResource(R.mipmap.blank);
|
||||
}
|
||||
|
||||
com.sendData("Vanessa stinkt, Baran nicht", ipAddress, port);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,19 +1,37 @@
|
||||
package com.example.lfrmobileapp.ui.notifications;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.example.lfrmobileapp.Communication;
|
||||
import com.example.lfrmobileapp.R;
|
||||
import com.example.lfrmobileapp.databinding.FragmentEinstellungenBinding;
|
||||
|
||||
|
||||
public class NotificationsFragment extends Fragment {
|
||||
|
||||
String ipKey = "ipkey";
|
||||
String portKey = "portkey";
|
||||
String connectionFailed = "Verbindung fehlgeschlagen.";
|
||||
String connectionSuccessful = "Verbindung erfolgreich.";
|
||||
|
||||
String ipAddress = "192.168.0.1";
|
||||
int port = 8000;
|
||||
|
||||
int duration = Toast.LENGTH_LONG;
|
||||
|
||||
private FragmentEinstellungenBinding binding;
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
@ -24,6 +42,40 @@ public class NotificationsFragment extends Fragment {
|
||||
binding = FragmentEinstellungenBinding.inflate(inflater, container, false);
|
||||
View root = binding.getRoot();
|
||||
|
||||
Communication com = new Communication();
|
||||
|
||||
SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedPref.edit();
|
||||
|
||||
ipAddress = sharedPref.getString(ipKey, "");
|
||||
binding.ipAdress.setText(ipAddress);
|
||||
port = sharedPref.getInt(portKey, -1);
|
||||
if(port != -1){
|
||||
binding.port.setText(Integer.toString(port));
|
||||
}else{
|
||||
binding.port.setText("");
|
||||
}
|
||||
|
||||
|
||||
final Button button = binding.connect;
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
ipAddress = String.valueOf(binding.ipAdress.getText());
|
||||
port = Integer.parseInt(String.valueOf(binding.port.getText()));
|
||||
if(com.sendData("", ipAddress, port)){
|
||||
editor.putString(ipKey, ipAddress);
|
||||
editor.putInt(portKey, port);
|
||||
editor.apply();
|
||||
Toast toast = Toast.makeText(v.getContext(), connectionSuccessful, duration);
|
||||
toast.show();
|
||||
}else{
|
||||
Toast toast = Toast.makeText(v.getContext(), connectionFailed, duration);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,8 @@
|
||||
<EditText
|
||||
android:id="@+id/ipAdress"
|
||||
android:layout_width="269dp"
|
||||
android:layout_height="38dp"
|
||||
android:layout_marginTop="64dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="60dp"
|
||||
android:hint="IP-Adresse"
|
||||
android:digits="0123456789."
|
||||
android:textColor="#000000"
|
||||
@ -22,8 +22,9 @@
|
||||
<EditText
|
||||
android:id="@+id/port"
|
||||
android:layout_width="269dp"
|
||||
android:layout_height="38dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="120dp"
|
||||
android:ems="10"
|
||||
android:hint="Port"
|
||||
android:digits="0123456789"
|
||||
android:textColor="#000000"
|
||||
@ -31,4 +32,17 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/connect"
|
||||
android:layout_width="269dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="180dp"
|
||||
android:text="Verbinden"
|
||||
android:background="@color/THblue"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"></Button>
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -10,13 +10,13 @@
|
||||
android:id="@+id/joystick"
|
||||
android:layout_width="308dp"
|
||||
android:layout_height="317dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:background="@mipmap/kreis"
|
||||
android:layout_marginTop="68dp"
|
||||
android:background="@mipmap/blank"
|
||||
app:JV_buttonColor="#FFFFFF"
|
||||
app:JV_buttonSizeRatio="11%"
|
||||
app:JV_fixedCenter="false"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.481"
|
||||
app:layout_constraintHorizontal_bias="0.495"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:textAlignment="center"
|
||||
android:textSize="15sp"
|
||||
@ -37,9 +38,9 @@
|
||||
|
||||
<Button
|
||||
android:id="@+id/rotateLeft"
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="140dp"
|
||||
android:layout_marginTop="325dp"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_marginTop="350dp"
|
||||
android:background="@drawable/ic_baseline_rotate_left_24"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.150"
|
||||
@ -48,9 +49,9 @@
|
||||
|
||||
<Button
|
||||
android:id="@+id/rotateRight"
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="140dp"
|
||||
android:layout_marginTop="325dp"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_marginTop="350dp"
|
||||
android:background="@drawable/ic_baseline_rotate_right_24"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.85"
|
||||
|
BIN
MobileApp/app/src/main/res/mipmap-hdpi/back.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
MobileApp/app/src/main/res/mipmap-hdpi/blank.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
MobileApp/app/src/main/res/mipmap-hdpi/forward.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
MobileApp/app/src/main/res/mipmap-hdpi/left.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
MobileApp/app/src/main/res/mipmap-hdpi/left_forward.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
MobileApp/app/src/main/res/mipmap-hdpi/right.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
MobileApp/app/src/main/res/mipmap-hdpi/right_back.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
MobileApp/app/src/main/res/mipmap-hdpi/right_forward.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
MobileApp/app/src/main/res/mipmap-mdpi/back.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
MobileApp/app/src/main/res/mipmap-mdpi/blank.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
MobileApp/app/src/main/res/mipmap-mdpi/forward.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
MobileApp/app/src/main/res/mipmap-mdpi/left.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
MobileApp/app/src/main/res/mipmap-mdpi/left_forward.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
MobileApp/app/src/main/res/mipmap-mdpi/right.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
MobileApp/app/src/main/res/mipmap-mdpi/right_back.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
MobileApp/app/src/main/res/mipmap-mdpi/right_forward.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xhdpi/back.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xhdpi/blank.png
Normal file
After Width: | Height: | Size: 5.5 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xhdpi/forward.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xhdpi/left.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xhdpi/left_back.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xhdpi/left_forward.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xhdpi/right.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xhdpi/right_back.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xhdpi/right_forward.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xxhdpi/back.png
Normal file
After Width: | Height: | Size: 9.4 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xxhdpi/blank.png
Normal file
After Width: | Height: | Size: 9.2 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xxhdpi/forward.png
Normal file
After Width: | Height: | Size: 9.4 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xxhdpi/left.png
Normal file
After Width: | Height: | Size: 9.3 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xxhdpi/left_back.png
Normal file
After Width: | Height: | Size: 9.5 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xxhdpi/left_forward.png
Normal file
After Width: | Height: | Size: 9.4 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xxhdpi/right.png
Normal file
After Width: | Height: | Size: 9.4 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xxhdpi/right_back.png
Normal file
After Width: | Height: | Size: 9.5 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xxhdpi/right_forward.png
Normal file
After Width: | Height: | Size: 9.5 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xxxhdpi/back.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xxxhdpi/blank.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xxxhdpi/forward.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xxxhdpi/left.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xxxhdpi/left_back.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xxxhdpi/left_forward.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xxxhdpi/right.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xxxhdpi/right_back.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
MobileApp/app/src/main/res/mipmap-xxxhdpi/right_forward.png
Normal file
After Width: | Height: | Size: 14 KiB |