Skip to content

Commit

Permalink
Merge pull request #44 from bearbotics2358/LED-fix
Browse files Browse the repository at this point in the history
Fixed the sussy LED code (co written by joseph :3)
  • Loading branch information
44RAV authored Mar 30, 2024
2 parents 529db7f + 0f04ec2 commit 1cfa301
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/main/cpp/LED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void LED::SetWhite() {

void LED::SendWhiteMSG() {
char cmd[10];
strncpy(cmd, "0,0\r\n", 8);
strncpy(cmd, "(0,0)\r\n", 8);
m_pserial->Write(cmd, strlen(cmd));
m_pserial->Flush();

Expand All @@ -186,7 +186,7 @@ void LED::SetMSGIdle(){

void LED::SendIdleMSG() {
char cmd[10];
strncpy(cmd, "1,0\r\n", 8);
strncpy(cmd, "(1,0)\r\n", 8);
m_pserial->Write(cmd, strlen(cmd));
m_pserial->Flush();

Expand All @@ -203,7 +203,7 @@ void LED::SendNoCommsMSG() {

printf("in SetNoComms\n");
char cmd[10];
strncpy(cmd, "2,0\r\n", 8);
strncpy(cmd, "(2,0)\r\n", 8);
printf("about to Write: %s\n", cmd);
ret = m_pserial->Write(cmd, strlen(cmd));
printf("written: %d characters\n", ret);
Expand All @@ -222,7 +222,7 @@ LED_currentCommand = RIO_msgs_enum::NOTE_ON_BOARD;

void LED::SendNoteOnBoardMSG() {
char cmd[10];
strncpy(cmd, "3,0\r\n", 8);
strncpy(cmd, "(3,0)\r\n", 8);
m_pserial->Write(cmd, strlen(cmd));
m_pserial->Flush();

Expand Down Expand Up @@ -253,7 +253,7 @@ LED_currentCommand = RIO_msgs_enum::SHOOTER_READY;

void LED::SendShooterReadyMSG() {
char cmd[10];
strncpy(cmd, "5,0\r\n", 8);
strncpy(cmd, "(5,0)\r\n", 8);
m_pserial->Write(cmd, strlen(cmd));
m_pserial->Flush();

Expand Down
11 changes: 9 additions & 2 deletions src/main/cpp/Robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "misc.h"
#include "Gyro.h"
#include <frc/smartdashboard/SmartDashboard.h>
#include <frc/DriverStation.h>
#include <iostream>
#include <stdio.h>
#include <frc/interfaces/Gyro.h>
Expand Down Expand Up @@ -93,6 +94,8 @@ void Robot::RobotInit() {
// a_LED.SetAngleToNote(0.3);

//a_LED.SetTargetType(LED_STAGE_enum::WHITE);

commsStatus = frc::DriverStation::IsDSAttached();
//InterpolationValues value = {22.5, 3500};
a_NoteHandler.insertToInterpolatingMap(2.546859, {22.5, 4000});
a_NoteHandler.insertToInterpolatingMap(4.212965, {9.5, 4000});
Expand All @@ -105,15 +108,19 @@ void Robot::RobotPeriodic() {
a_NoteHandler.UpdateSensors();


if(a_NoteHandler.beamBroken()){


if(!frc::DriverStation::IsDSAttached()){
a_LED.SetNoComms();
}
else if(a_NoteHandler.beamBroken()){
a_LED.SetNoteOnBoard();
} else {
a_LED.SetMSGIdle();
}

a_NoteHandler.updateDashboard();


// photon::PhotonPipelineResult result = a_camera.GetLatestResult();
// double Note_Offset = LimelightHelpers::getTX("limelight-notes");

Expand Down
4 changes: 4 additions & 0 deletions src/main/include/Robot.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <frc/apriltag/AprilTagFields.h>
#include "LED.h"
#include <Vision.h>
#include <frc/DriverStation.h>

enum class DriveBackState {
Inactive,
Expand Down Expand Up @@ -103,6 +104,9 @@ class Robot : public frc::TimedRobot {
LED a_LED;


bool commsStatus;



double state_time;
double piston_time;
Expand Down

0 comments on commit 1cfa301

Please sign in to comment.