Skip to content

Commit

Permalink
changed variable names.
Browse files Browse the repository at this point in the history
  • Loading branch information
VG-Fish committed Feb 4, 2025
1 parent ee00932 commit ec03750
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 15 deletions.
79 changes: 78 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,83 @@
},
"C_Cpp.default.configurationProvider": "vscode-wpilib",
"files.associations": {
"*.inc": "cpp"
"*.inc": "cpp",
"array": "cpp",
"any": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"cfenv": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"expected": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"regex": "cpp",
"source_location": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"ranges": "cpp",
"semaphore": "cpp",
"span": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cinttypes": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"valarray": "cpp",
"variant": "cpp"
}
}
20 changes: 10 additions & 10 deletions src/main/cpp/subsystems/LED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ void LED::Init() {
m_pserial->SetReadBufferSize(0);
m_pserial->SetWriteBufferMode(frc::SerialPort::kFlushOnAccess);

rx_index = 0;
m_rxIndex = 0;
for(int i = 0; i < BUFF_SIZE; i++) {
rx_buff[i] = 0;
m_rxBuff[i] = 0;
}
//SetTargetType(LED_STAGE_enum::WHITE);
}
Expand All @@ -66,33 +66,33 @@ void LED::Update() {
// printf("LED: in Update, attempting to receive\n");

while (m_pserial->GetBytesReceived() > 0) {
m_pserial->Read(&rx_buff[rx_index], 1);
m_pserial->Read(&m_rxBuff[m_rxIndex], 1);

if((rx_buff[rx_index] == '\r') || (rx_buff[rx_index] == '\n')) {
if((m_rxBuff[m_rxIndex] == '\r') || (m_rxBuff[m_rxIndex] == '\n')) {

// process report
if(rx_index == 0) {
if(m_rxIndex == 0) {
// no report
continue;
}

// terminate the report string
rx_buff[rx_index] = 0;
m_rxBuff[m_rxIndex] = 0;

// print the report:
printf("RX: %s\n", rx_buff);
printf("RX: %s\n", m_rxBuff);
m_pserial->Flush();

ProcessReport();

// printf("LED report: rx_buff\n");

// reset for next report
rx_index = 0;
m_rxIndex = 0;
} else {
// have not received end of report yet
if(rx_index < BUFF_SIZE - 1) {
rx_index++;
if(m_rxIndex < BUFF_SIZE - 1) {
m_rxIndex++;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/include/subsystems/LED.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef H_LED
#define H_LED

#include "Constants.h" //yay i can use CONE and CUBE
#include "Constants.h"
#include <frc/SerialPort.h>

#define BUFF_SIZE 256
Expand Down Expand Up @@ -51,9 +51,9 @@ class LED : public frc2::SubsystemBase {
std::array<std::function<void()>, ArduinoConstants::NUMBER_OF_LED_STATES> m_LEDArray;

frc::SerialPort* m_pserial;
char rx_buff[BUFF_SIZE];
int rx_index = 0;
float valAngle = 0;
char m_rxBuff[BUFF_SIZE];
int m_rxIndex = 0;
float m_valAngle = 0;
//LED_STAGE_enum target_type = LED_STAGE_enum::WHITE;
ArduinoConstants::RIO_MESSAGES LED_prevCommand = ArduinoConstants::RIO_MESSAGES::MSG_IDLE;
ArduinoConstants::RIO_MESSAGES LED_currentCommand = ArduinoConstants::RIO_MESSAGES::MSG_IDLE;
Expand Down

0 comments on commit ec03750

Please sign in to comment.