Skip to content

Commit

Permalink
Merge pull request #33 from Robocubs/operator-controls
Browse files Browse the repository at this point in the history
Operator-controls
  • Loading branch information
mpulte authored Feb 2, 2024
2 parents 9ac848d + 2702b9a commit 58190d3
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 6 deletions.
9 changes: 4 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,11 @@ node {
}

npmInstall {
args = System.getenv('CI') ? [] : ['--workspaces']
args = System.getenv('CI') ? [] : [
'--workspaces',
'--include-workspace-root'
]
inputs.files 'package.json', 'package-lock.json'
inputs.dir fileTree('.') {
include 'node_modules/**'
exclude 'node_modules/.cache/**'
}
}

task npmRunLint(type: NpmTask) {
Expand Down
19 changes: 19 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@types/node": "^20.11.10",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.19.1",
"cross-env": "^7.0.3",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/team1701/robot/states/RobotState.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.math.geometry.Translation3d;
import edu.wpi.first.math.kinematics.SwerveModulePosition;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.Timer;
import org.littletonrobotics.junction.AutoLogOutput;

Expand All @@ -36,6 +37,11 @@ public void periodic() {
mDetectedNotes.removeIf(note -> note.lastDetectedTimestamp < timeout);
}

@AutoLogOutput
public double getMatchTime() {
return DriverStation.getMatchTime();
}

@AutoLogOutput
public Pose2d getPose2d() {
return mPoseEstimator.getEstimatedPosition();
Expand Down
3 changes: 2 additions & 1 deletion src/main/ts/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"lint:ci": "eslint .",
"dev": "vite",
"build": "vite build",
"build:deploy": "DASHBOARD_BASE='dashboard' DASHBOARD_OUT_DIR='../../deploy/web/dashboard' vite build",
"build:deploy": "cross-env DASHBOARD_BASE='dashboard' DASHBOARD_OUT_DIR='../../deploy/web/dashboard' vite build",
"watch": "vite build --watch",
"watch:deploy": "cross-env DASHBOARD_BASE='dashboard' DASHBOARD_OUT_DIR='../../deploy/web/dashboard' vite build --watch",
"preview": "vite preview",
"check": "svelte-check --tsconfig ./tsconfig.json"
},
Expand Down
1 change: 1 addition & 0 deletions src/main/ts/dashboard/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './match-timer';
36 changes: 36 additions & 0 deletions src/main/ts/dashboard/src/components/match-timer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//liam is the greatest most bestest president - sorryen
import { LitElement, css, html } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import { ClassInfo, classMap } from 'lit/directives/class-map.js';
import { globalStylesCss } from '../styles/styles';

@customElement('team1701-match-timer')
export class MatchTimer extends LitElement {
@property({ type: Number })
timer = 0;

render() {
const roundedTimer = Math.floor(this.timer);
return html`<div class="flex flex-column align-center justify-center">
<div class="text-white text-6xl border-4 border-solid rounded-lg box-border p-4 ${classMap(this.backgroundColor())}">${roundedTimer}</div>
</div>`;
}

backgroundColor(): ClassInfo {
if (this.timer > 60) {
return { 'bg-green-400': true };
} else if (this.timer > 30) {
return { 'bg-yellow-400': true };
} else {
return { 'bg-red-900': true };
}
}

static styles = [globalStylesCss, css``];
}

declare global {
interface HTMLElementTagNameMap {
'team1701-match-timer': MatchTimer;
}
}
1 change: 1 addition & 0 deletions src/main/ts/dashboard/src/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class Dashboard extends LitElement {
.pose=${this.nt.$pose2d('/AdvantageKit/RealOutputs/RobotState/Pose2d', [])}
></frc-field-robot>
</frc-field>
<team1701-match-timer timer=${this.nt.$value('/AdvantageKit/RealOutputs/RobotState/MatchTime', '0')}></team1701-match-timer>
</div>
`;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/ts/dashboard/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import '@frc-web-components/fwc/components';
import './components';
export * from './dashboard';

0 comments on commit 58190d3

Please sign in to comment.