Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operator-controls #33

Merged
merged 4 commits into from
Feb 2, 2024
Merged
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
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';
Loading