Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {

var versionMajor = 3
var versionMinor = 0
var versionPatch = 7
var versionPatch = 9

android {
namespace = "com.team3663.scouting_app"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ else if (current_X_Absolute < matchBinding.butRightZone.getX())
matchBinding.butPickup.setVisibility(View.INVISIBLE);

// Enable the climb button
matchBinding.butClimb.setEnabled(true);
matchBinding.butClimb.setClickable(true);
matchBinding.butClimb.setEnabled(in_alliance_zone);
matchBinding.butClimb.setClickable(in_alliance_zone);
climb_button_pressed = false;

// Certain actions can't be set from a non-UI thread (like within a TimerTask that runs on a
Expand Down Expand Up @@ -785,6 +785,15 @@ private void setRobotLocation(float in_X, float in_Y) {
starting_X_Absolute = Math.min(Math.max(in_X, matchBinding.FieldTouch.getWidth() * (100.0f - Constants.Match.START_LINE_X) / 100.0f - offset), matchBinding.FieldTouch.getWidth() * (100.0f - Constants.Match.START_LINE_X) / 100.0f + offset);
}

// Ensure we aren't placing a robot where it can't be located - 2026 Season
if ((starting_Y_Absolute > (Constants.Match.HUB_TOP_Y_PERCENT * matchBinding.FieldTouch.getHeight())) && (starting_Y_Absolute < (Constants.Match.HUB_BOTTOM_Y_PERCENT * matchBinding.FieldTouch.getHeight()))) {
if ((blue_alliance && currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_BLUE_ON_LEFT)) ||
(!blue_alliance && currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_RED_ON_LEFT)))
starting_X_Absolute = matchBinding.FieldTouch.getWidth() * Constants.Match.START_LINE_X / 100.0f - offset;
else
starting_X_Absolute = matchBinding.FieldTouch.getWidth() * (100.0f - Constants.Match.START_LINE_X) / 100.0f + offset;
}

// Save off the correct relative values based on the orientation
if (currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_RED_ON_LEFT)) {
starting_X_Relative = starting_X_Absolute;
Expand Down Expand Up @@ -916,11 +925,6 @@ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
private void initZoneButtons() {
// Set up an OnClick listener per button
matchBinding.butLeftZone.setOnClickListener(view -> {
// We'll use the button click to determine if we should allow or disallow shooting / climbing but won't process
// anything else if we're not in Tele mode.
in_alliance_zone = ((currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_RED_ON_LEFT)) && team_alliance.substring(0, 1).equalsIgnoreCase("R")) ||
((currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_BLUE_ON_LEFT)) && team_alliance.substring(0, 1).equalsIgnoreCase("B"));

// If the match hasn't even started yet, just return
if (Globals.CurrentMatchPhase.equals(Constants.Phases.NONE)) return;

Expand All @@ -943,8 +947,6 @@ private void initZoneButtons() {
});

matchBinding.butCenterZone.setOnClickListener(view -> {
in_alliance_zone = false;

// If the match hasn't even started yet, just return
if (Globals.CurrentMatchPhase.equals(Constants.Phases.NONE)) return;

Expand All @@ -968,11 +970,6 @@ private void initZoneButtons() {
});

matchBinding.butRightZone.setOnClickListener(view -> {
// We'll use the button click to determine if we should allow or disallow shooting / climbing but won't process
// anything else if we're not in Tele mode.
in_alliance_zone = ((!currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_RED_ON_LEFT)) || !team_alliance.substring(0, 1).equalsIgnoreCase("R")) &&
((!currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_BLUE_ON_LEFT)) || !team_alliance.substring(0, 1).equalsIgnoreCase("B"));

// If the match hasn't even started yet, just return
if (Globals.CurrentMatchPhase.equals(Constants.Phases.NONE)) return;

Expand All @@ -995,16 +992,48 @@ private void initZoneButtons() {
});

matchBinding.butLeftZone.setOnTouchListener((view, motionEvent) -> {
// only handle DOWN actions
if (motionEvent.getAction() == MotionEvent.ACTION_UP) return false;

// We'll use the button click to determine if we should allow or disallow shooting / climbing but won't process
// anything else if we're not in Tele mode.
in_alliance_zone = ((currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_RED_ON_LEFT)) && team_alliance.substring(0, 1).equalsIgnoreCase("R")) ||
((currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_BLUE_ON_LEFT)) && team_alliance.substring(0, 1).equalsIgnoreCase("B"));

tele_button_position_x = matchBinding.butLeftZone.getX();
tele_button_position_y = matchBinding.butLeftZone.getY();
matchBinding.FieldTouch.dispatchTouchEvent(motionEvent);
return false; });
matchBinding.butCenterZone.setOnTouchListener((view, motionEvent) -> {
// only handle DOWN actions
if (motionEvent.getAction() == MotionEvent.ACTION_UP) return false;

// if the alliance zone is on the LEFT, check the left edge of the robot
in_alliance_zone = false;
if (((currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_RED_ON_LEFT))
&& team_alliance.substring(0, 1).equalsIgnoreCase("R"))
|| ((currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_BLUE_ON_LEFT))
&& team_alliance.substring(0, 1).equalsIgnoreCase("B"))) {
if (motionEvent.getX() <= (matchBinding.textRobot.getWidth() / 2f))
in_alliance_zone = true;
// otherwise the alliance zone is on the RIGHT, check the right edge of the robot
} else
if (motionEvent.getX() >= (matchBinding.butCenterZone.getWidth() - matchBinding.textRobot.getWidth() / 2f))
in_alliance_zone = true;

tele_button_position_x = matchBinding.butCenterZone.getX();
tele_button_position_y = matchBinding.butCenterZone.getY();
matchBinding.FieldTouch.dispatchTouchEvent(motionEvent);
return false; });
matchBinding.butRightZone.setOnTouchListener((view, motionEvent) -> {
// only handle DOWN actions
if (motionEvent.getAction() == MotionEvent.ACTION_UP) return false;

// We'll use the button click to determine if we should allow or disallow shooting / climbing but won't process
// anything else if we're not in Tele mode.
in_alliance_zone = ((!currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_RED_ON_LEFT)) || !team_alliance.substring(0, 1).equalsIgnoreCase("R")) &&
((!currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_BLUE_ON_LEFT)) || !team_alliance.substring(0, 1).equalsIgnoreCase("B"));

tele_button_position_x = matchBinding.butRightZone.getX();
tele_button_position_y = matchBinding.butRightZone.getY();
matchBinding.FieldTouch.dispatchTouchEvent(motionEvent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public static class Match {
public static float START_LINE_X = 24.17f;
public static final int TRANSITION_EVENT_DNE = -1;
public static final int SEEKBAR_MAX = 60;
public static final float HUB_TOP_Y_PERCENT = 129f / 337f;
public static final float HUB_BOTTOM_Y_PERCENT = 208f / 337f;
}

public static class Data {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/match_tally.xml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
android:text="@string/button_climb"
android:textSize="22sp"
android:layout_gravity="center_vertical"
android:backgroundTint="@color/light_blue"
android:backgroundTint="@color/dark_green"
app:cornerRadius="20dp"/>

<TextView
Expand All @@ -198,7 +198,7 @@
android:text="@string/button_pickup"
android:textSize="22sp"
android:layout_gravity="center_vertical"
android:backgroundTint="@color/light_blue"
android:backgroundTint="@color/dark_yellow"
app:cornerRadius="20dp"/>
</LinearLayout>

Expand Down