Skip to content

Commit

Permalink
add led code!
Browse files Browse the repository at this point in the history
  • Loading branch information
Jus973 committed Jan 19, 2025
1 parent d5b7f8e commit 1858927
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 69 deletions.
115 changes: 95 additions & 20 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,96 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"type": "wpilib",
"name": "WPILib Desktop Debug",
"request": "launch",
"desktop": true,
},
{
"type": "wpilib",
"name": "WPILib roboRIO Debug",
"request": "launch",
"desktop": false,
}
]
}
"version": "0.2.0",
"configurations": [

{
"type": "wpilib",
"name": "WPILib Desktop Debug",
"request": "launch",
"desktop": true
},
{
"type": "wpilib",
"name": "WPILib roboRIO Debug",
"request": "launch",
"desktop": true
},
{
"name": "C/C++: gcc build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc build active file",
"miDebuggerPath": "/usr/bin/gdb"
},
{
"name": "C/C++: g++-13 build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++-13 build active file",
"miDebuggerPath": "/usr/bin/gdb"
},
{
"name": "C/C++: g++ build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++ build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
105 changes: 83 additions & 22 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,89 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: clang++.exe build active file",
"command": "C:\\Program Files\\LLVM\\bin\\clang++.exe",
"args": [
"-fcolor-diagnostics",
"-fansi-escape-codes",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
{
"type": "cppbuild",
"label": "C/C++: clang++.exe build active file",
"command": "C:\\Program Files\\LLVM\\bin\\clang++.exe",
"args": [
"-fcolor-diagnostics",
"-fansi-escape-codes",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
},
"problemMatcher": ["$gcc"],
"group": {
"kind": "build",
"isDefault": true
{
"type": "cppbuild",
"label": "C/C++: gcc build active file",
"command": "/usr/bin/gcc",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "Task generated by Debugger."
},
"detail": "Task generated by Debugger."
}
{
"type": "cppbuild",
"label": "C/C++: g++-13 build active file",
"command": "/usr/bin/g++-13",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "Task generated by Debugger."
},
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}

}
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ deploy {
def deployArtifact = deploy.targets.roborio.artifacts.frcCpp

// Set this to true to enable desktop support.
def includeDesktopSupport = false
def includeDesktopSupport = true

// Set to true to run simulation in debug mode
wpi.cpp.debugSimulation = true
Expand Down Expand Up @@ -115,7 +115,7 @@ spotless {
include '**/*.cpp', '**/*.cc', '**/*.h', '**/*.hpp'
exclude '**/build/**', '**/build-*/**'
}
def selectedClangVersion = project.hasProperty('fromCI') ? '18.1.8' : '18.1.8'
def selectedClangVersion = project.hasProperty('fromCI') ? '19.1.7' : '19.1.7'

def styleFile = file('.clang-format')
def styleConfig = styleFile.text.trim()
Expand Down
20 changes: 2 additions & 18 deletions src/y2025/cpp/subsystems/hardware/leds.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,15 @@ void LEDsSubsystem::WriteToHardware(LEDsTarget target) {
}

loops++;
} else if (target.state == kLEDSCOOPLeds) {
} else if (target.state == kLEDSFoundAprilTag) {
for (int i = 0; i < kLength; i++) {
leds_buffer_[i].SetRGB(255, 255, 255);
}
} else if (target.state == kLEDSAmpingLeds) {
for (int i = 0; i < kLength; i++) {
leds_buffer_[i].SetRGB(255, 0, 255);
}
} else if (target.state == kLEDSClimbing) {
for (int i = 0; i < kLength; i++) {
leds_buffer_[i].SetRGB(0, 255, 0);
}
} else if (target.state == kLEDSPreparingShoot) {
if (loops % 20 < 10) {
for (int i = 0; i < kLength; i++) {
leds_buffer_[i].SetRGB(0, 0, 255);
}
} else {
for (int i = 0; i < kLength; i++) {
leds_buffer_[i].SetRGB(0, 0, 0);
}
}
loops++;
loops %= 100;
} else if (target.state == kLEDSReadyToShoot) {
} else if (target.state == kLEDSFoundReef) {
if (loops % 10 < 5) {
for (int i = 0; i < kLength; i++) {
leds_buffer_[i].SetRGB(0, 255, 0);
Expand Down
12 changes: 5 additions & 7 deletions src/y2025/include/subsystems/hardware/leds.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ enum LEDsState {
kLEDSNotReady,
kLEDSZeroing,
kLEDSTeleop,
kLEDSAutonomous,
kLEDSHasPiece,
kLEDSPreparingShoot,
kLEDSReadyToShoot,
kLEDSAutonomous, // auto phase + GPD pickup
kLEDSClimbing,
kLEDSAmpingLeds,
kLEDSCOOPLeds,
kLEDSDisabled,
kLEDSHasPiece,
kLEDSFoundReef, // will start reef placing mechanism
kLEDSFoundAprilTag,
kLEDSDisabled
};

struct LEDsReadings {};
Expand Down

0 comments on commit 1858927

Please sign in to comment.