Skip to content

Commit

Permalink
Adjust save mem related things to account for TeamOpenFIRE/OpenFIRE-F…
Browse files Browse the repository at this point in the history
  • Loading branch information
SeongGino authored May 12, 2024
1 parent 70650b2 commit 440d60a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 68 deletions.
11 changes: 8 additions & 3 deletions constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,20 @@ enum boardInputs_e {
btnPump,
rumblePin,
solenoidPin,
tempPin,
rumbleSwitch,
solenoidSwitch,
autofireSwitch,
ledR,
ledG,
ledB,
neoPixel,
camSDA,
camSCL,
periphSDA,
periphSCL,
analogX,
analogY
analogY,
tempPin
};

enum boolTypes_e {
Expand All @@ -67,7 +71,8 @@ enum boolTypes_e {
simplePause,
holdToPause,
commonAnode,
lowButtonsMode
lowButtonsMode,
rumbleFF
};

enum settingsTypes_e {
Expand Down
84 changes: 23 additions & 61 deletions guiwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ QVector<profilesTable_s> profilesTable_orig(4);
// Values: -2 = N/A, -1 = reserved, 0 = available, unused
QMap<uint8_t, int8_t> currentPins;

#define INPUTS_COUNT 25
#define INPUTS_COUNT 29
// Map of what inputs are put where,
// Key = button/output, Value = pin number occupying, if any.
// Value of -1 means unmapped.
Expand Down Expand Up @@ -122,7 +122,7 @@ guiWindow::guiWindow(QWidget *parent)
{
ui->setupUi(this);

#if !defined(Q_OS_MAC) && !defined(Q_OS_WIN)
#ifdef Q_OS_UNIX
if(qEnvironmentVariable("USER") != "root") {
QProcess *externalProg = new QProcess;
QStringList args;
Expand Down Expand Up @@ -294,20 +294,16 @@ void guiWindow::SerialLoad()
if(serialPort.waitForReadyRead(2000)) {
// booleans
QString buffer;
for(uint8_t i = 1; i < sizeof(boolSettings); i++) {
for(uint8_t i = 0; i < sizeof(boolSettings); i++) {
buffer = serialPort.readLine();
buffer = buffer.trimmed();
boolSettings[i] = buffer.toInt();
boolSettings_orig[i] = boolSettings[i];
}
// pins
serialPort.write("Xlp");
serialPort.waitForReadyRead(1000);
buffer = serialPort.readLine();
buffer = buffer.trimmed();
boolSettings[customPins] = buffer.toInt(); // remember to change this BACK, teehee
boolSettings_orig[customPins] = boolSettings[customPins];
if(boolSettings[customPins]) {
serialPort.write("Xlp");
serialPort.waitForReadyRead(1000);
for(uint8_t i = 0; i < INPUTS_COUNT; i++) {
buffer = serialPort.readLine();
inputsMap_orig[i] = buffer.toInt();
Expand All @@ -319,23 +315,6 @@ void guiWindow::SerialLoad()
}
}
inputsMap = inputsMap_orig;
} else {
// TODO: fix this in the firmware.
for(uint8_t i = 0; i < INPUTS_COUNT; i++) {
buffer = serialPort.readLine(); // nomfing
inputsMap[i] = -1;
inputsMap_orig[i] = -1;
if(i == 14) {
serialPort.write(".");
serialPort.waitForReadyRead(1000);
}
}
}
buffer = serialPort.readLine();
buffer = buffer.trimmed();
if(buffer != "-127") {
qDebug() << "Padding bit not detected!";
return;
}
// settings
serialPort.write("Xls");
Expand Down Expand Up @@ -688,19 +667,17 @@ void guiWindow::on_confirmButton_clicked()
ui->confirmButton->setEnabled(false);

QStringList serialQueue;
for(uint8_t i = 1; i < sizeof(boolSettings); i++) {
QString genString = QString("Xm.0.%1.%2").arg(i-1).arg(boolSettings[i]);
for(uint8_t i = 0; i < sizeof(boolSettings); i++) {
QString genString = QString("Xm.0.%1.%2").arg(i).arg(boolSettings[i]);
serialQueue.append(genString);
}

if(boolSettings[customPins]) {
serialQueue.append("Xm.1.0.1");
for(uint8_t i = 0; i < INPUTS_COUNT; i++) {
QString genString = QString("Xm.1.%1.%2").arg(i+1).arg(inputsMap.value(i));
QString genString = QString("Xm.1.%1.%2").arg(i).arg(inputsMap.value(i));
serialQueue.append(genString);
}
} else {
serialQueue.append("Xm.1.0.0");
}

for(uint8_t i = 0; i < sizeof(settingsTable) / 2; i++) {
Expand Down Expand Up @@ -850,12 +827,9 @@ void guiWindow::on_comPortSelector_currentIndexChanged(int index)
for(uint8_t i = 0; i < 30; i++) {
pinBoxes[i]->addItems(valuesNameList);
if(rpipicoLayout[i].pinType == pinDigital) {
pinBoxes[i]->removeItem(25);
pinBoxes[i]->removeItem(24);
// replace "Temp Sensor" with a separator
// then remove the presumably bumped up temp sensor index.
pinBoxes[i]->insertSeparator(16);
pinBoxes[i]->removeItem(17);
pinBoxes[i]->removeItem(tempPin);
pinBoxes[i]->removeItem(analogY);
pinBoxes[i]->removeItem(analogX);
}
}

Expand Down Expand Up @@ -947,12 +921,9 @@ void guiWindow::on_comPortSelector_currentIndexChanged(int index)
for(uint8_t i = 0; i < 30; i++) {
pinBoxes[i]->addItems(valuesNameList);
if(adafruitItsyRP2040Layout[i].pinType == pinDigital) {
pinBoxes[i]->removeItem(25);
pinBoxes[i]->removeItem(24);
// replace "Temp Sensor" with a separator
// then remove the presumably bumped up temp sensor index.
pinBoxes[i]->insertSeparator(16);
pinBoxes[i]->removeItem(17);
pinBoxes[i]->removeItem(tempPin);
pinBoxes[i]->removeItem(analogY);
pinBoxes[i]->removeItem(analogX);
}
}

Expand Down Expand Up @@ -1034,12 +1005,9 @@ void guiWindow::on_comPortSelector_currentIndexChanged(int index)
for(uint8_t i = 0; i < 30; i++) {
pinBoxes[i]->addItems(valuesNameList);
if(adafruitKB2040Layout[i].pinType == pinDigital) {
pinBoxes[i]->removeItem(25);
pinBoxes[i]->removeItem(24);
// replace "Temp Sensor" with a separator
// then remove the presumably bumped up temp sensor index.
pinBoxes[i]->insertSeparator(16);
pinBoxes[i]->removeItem(17);
pinBoxes[i]->removeItem(tempPin);
pinBoxes[i]->removeItem(analogY);
pinBoxes[i]->removeItem(analogX);
}
}

Expand Down Expand Up @@ -1106,12 +1074,9 @@ void guiWindow::on_comPortSelector_currentIndexChanged(int index)
for(uint8_t i = 0; i < 30; i++) {
pinBoxes[i]->addItems(valuesNameList);
if(arduinoNanoRP2040Layout[i].pinType == pinDigital) {
pinBoxes[i]->removeItem(25);
pinBoxes[i]->removeItem(24);
// replace "Temp Sensor" with a separator
// then remove the presumably bumped up temp sensor index.
pinBoxes[i]->insertSeparator(16);
pinBoxes[i]->removeItem(17);
pinBoxes[i]->removeItem(tempPin);
pinBoxes[i]->removeItem(analogY);
pinBoxes[i]->removeItem(analogX);
}
}

Expand Down Expand Up @@ -1188,12 +1153,9 @@ void guiWindow::on_comPortSelector_currentIndexChanged(int index)
for(uint8_t i = 0; i < 30; i++) {
pinBoxes[i]->addItems(valuesNameList);
if(genericLayout[i].pinType == pinDigital) {
pinBoxes[i]->removeItem(25);
pinBoxes[i]->removeItem(24);
// replace "Temp Sensor" with a separator
// then remove the presumably bumped up temp sensor index.
pinBoxes[i]->insertSeparator(16);
pinBoxes[i]->removeItem(17);
pinBoxes[i]->removeItem(tempPin);
pinBoxes[i]->removeItem(analogY);
pinBoxes[i]->removeItem(analogX);
}
}

Expand Down
12 changes: 8 additions & 4 deletions guiwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,20 @@ private slots:
"Pump Action",
"Rumble Signal",
"Solenoid Signal",
"Temp Sensor",
"Rumble Switch",
"Solenoid Switch",
"Autofire Switch",
"RGB LED Red",
"RGB LED Green",
"RGB LED Blue",
"External NeoPixel",
"Camera SDA",
"Camera SCL",
"Peripherals SDA",
"Peripherals SCL",
"Analog Pin X",
"Analog Pin Y"
"Analog Pin Y",
"Temp Sensor"
};

// List of serial port objects that were found in PortsSearch()
Expand All @@ -157,9 +161,9 @@ private slots:
uint8_t settingsDiff;

// Current array of booleans, meant to be used as a bitmask
bool boolSettings[8];
bool boolSettings[9];
// Array of booleans, as loaded from the gun firmware
bool boolSettings_orig[8];
bool boolSettings_orig[9];

// Current table of tunable settings
uint16_t settingsTable[8];
Expand Down

0 comments on commit 440d60a

Please sign in to comment.