Added probing!!!

This commit is contained in:
Kevin Santo Cappuccio 2024-02-13 21:19:57 -08:00
parent 844b0a0f55
commit 2a274928a9
5 changed files with 453 additions and 185 deletions

View File

@ -249,6 +249,8 @@ void sendXYraw(int chip, int x, int y, int setOrClear)
delayMicroseconds(40); delayMicroseconds(40);
} }
int probeHalfPeriodus = 10;
int readFloatingOrState(int pin, int rowBeingScanned) int readFloatingOrState(int pin, int rowBeingScanned)
{ {
@ -263,21 +265,21 @@ int readFloatingOrState(int pin, int rowBeingScanned)
pinMode(pin, INPUT_PULLUP); pinMode(pin, INPUT_PULLUP);
delayMicroseconds(200); delayMicroseconds(100);
readingPullup = digitalRead(pin); readingPullup = digitalRead(pin);
delayMicroseconds(10); delayMicroseconds(probeHalfPeriodus);
readingPullup2 = digitalRead(pin); readingPullup2 = digitalRead(pin);
delayMicroseconds(5); delayMicroseconds(probeHalfPeriodus / 2);
readingPullup3 = digitalRead(pin); readingPullup3 = digitalRead(pin);
pinMode(pin, INPUT_PULLDOWN); pinMode(pin, INPUT_PULLDOWN);
delayMicroseconds(200); delayMicroseconds(100);
readingPulldown = digitalRead(pin); readingPulldown = digitalRead(pin);
delayMicroseconds(10); delayMicroseconds(probeHalfPeriodus);
readingPulldown2 = digitalRead(pin); readingPulldown2 = digitalRead(pin);
delayMicroseconds(5); delayMicroseconds(probeHalfPeriodus / 2);
readingPulldown3 = digitalRead(pin); readingPulldown3 = digitalRead(pin);
if (readingPullup != readingPullup2 || readingPullup2 != readingPullup3 && rowBeingScanned != -1) if (readingPullup != readingPullup2 || readingPullup2 != readingPullup3 && rowBeingScanned != -1)
@ -286,9 +288,10 @@ int readFloatingOrState(int pin, int rowBeingScanned)
{ {
state = probe; state = probe;
leds.setPixelColor(nodesToPixelMap[rowBeingScanned], 45, 0, 45); // leds.setPixelColor(nodesToPixelMap[rowBeingScanned], rainbowList[rainbowIndex][0], rainbowList[rainbowIndex][1], rainbowList[rainbowIndex][2]);
// Serial.print("probe"); // Serial.print("probe");
leds.show(); //
} }
} }
else else
@ -305,13 +308,13 @@ int readFloatingOrState(int pin, int rowBeingScanned)
else if (readingPullup == 1 && readingPulldown == 1) else if (readingPullup == 1 && readingPulldown == 1)
{ {
// Serial.print("HIGH"); // Serial.print("HIGH");
//leds.setPixelColor(nodesToPixelMap[rowBeingScanned], 45, 0, 0); // leds.setPixelColor(nodesToPixelMap[rowBeingScanned], 45, 0, 0);
state = high; state = high;
} }
else if (readingPullup == 0 && readingPulldown == 0) else if (readingPullup == 0 && readingPulldown == 0)
{ {
// Serial.print("LOW"); // Serial.print("LOW");
//leds.setPixelColor(nodesToPixelMap[rowBeingScanned], 0, 45, 0); // leds.setPixelColor(nodesToPixelMap[rowBeingScanned], 0, 45, 0);
state = low; state = low;
} }
else if (readingPullup == 0 && readingPulldown == 1) else if (readingPullup == 0 && readingPulldown == 1)
@ -321,31 +324,65 @@ int readFloatingOrState(int pin, int rowBeingScanned)
} }
// Serial.print("\n"); // Serial.print("\n");
leds.show(); leds.show();
//delayMicroseconds(100); // delayMicroseconds(100);
return state; return state;
} }
void startProbe(void) void startProbe(int probeSpeed)
{ {
probeHalfPeriodus = 1000000 / probeSpeed / 2;
pinMode(19, OUTPUT); pinMode(19, OUTPUT);
analogWriteFreq(50000); analogWriteFreq(probeSpeed);
analogWrite(19, 128); analogWrite(19, 128);
delayMicroseconds(100); // delayMicroseconds(10);
pinMode(18, INPUT);
} }
int rainbowList[12][3] = {
{45, 35, 8},
{10, 45, 30},
{30, 15, 45},
{8, 27, 45},
{45, 18, 19},
{35, 42, 5},
{02, 45, 35},
{18, 25, 45},
{40, 12, 45},
{10, 32, 45},
{18, 5, 43},
{45, 28, 13}};
int rainbowIndex = 0;
int lastFound[5] = {-1, -1, -1, -1, -1};
int nextIsSupply = 0;
int nextIsGnd = 0;
int justCleared = 1;
int scanRows(int pin, bool clearLastFound) int scanRows(int pin, bool clearLastFound)
{ {
static int lastFound = -1;
int found = -1; int found = -1;
if (clearLastFound) if (clearLastFound)
{ {
lastFound = -1; // for (int i = 0; i < 5; i++)
// {
// lastFound[i] = -1;
// }
rainbowIndex++;
if (rainbowIndex > 11)
{
rainbowIndex = 0;
}
justCleared = 1;
nextIsGnd = 0;
nextIsSupply = 0;
return -1; return -1;
} }
digitalWrite(RESETPIN, HIGH); digitalWrite(RESETPIN, HIGH);
delayMicroseconds(10); delayMicroseconds(10);
digitalWrite(RESETPIN, LOW); digitalWrite(RESETPIN, LOW);
@ -390,30 +427,41 @@ int scanRows(int pin, bool clearLastFound)
// analogRead(ADC0_PIN); // analogRead(ADC0_PIN);
rowBeingScanned = ch[chipScan].yMap[yToScan]; rowBeingScanned = ch[chipScan].yMap[yToScan];
if (readFloatingOrState(pin, rowBeingScanned) == probe && rowBeingScanned != lastFound) if (readFloatingOrState(pin, rowBeingScanned) == probe && rowBeingScanned != lastFound[0])
{ {
found = rowBeingScanned; found = rowBeingScanned;
lastFound = found; if (nextIsSupply)
{
leds.setPixelColor(nodesToPixelMap[rowBeingScanned], 65, 10, 10);
}
else if (nextIsGnd)
{
leds.setPixelColor(nodesToPixelMap[rowBeingScanned], 10, 65, 10);
}
else
{
leds.setPixelColor(nodesToPixelMap[rowBeingScanned], rainbowList[rainbowIndex][0], rainbowList[rainbowIndex][1], rainbowList[rainbowIndex][2]);
}
leds.show();
for (int i = 4; i > 0; i--)
{
lastFound[i] = lastFound[i - 1];
}
lastFound[0] = found;
} }
sendXYraw(chipScan, 0, 0, 0); sendXYraw(chipScan, 0, 0, 0);
sendXYraw(chipScan, 0, yToScan, 0); sendXYraw(chipScan, 0, yToScan, 0);
// if (found != -1) if (found != -1)
// { {
// break; break;
// } }
} }
sendXYraw(CHIP_L, 2, chipScan, 0); sendXYraw(CHIP_L, 2, chipScan, 0);
if (found != -1)
{
return found;
}
} }
int corners[4] = {1, 30, 31, 60}; int corners[4] = {1, 30, 31, 60};
@ -426,39 +474,106 @@ int scanRows(int pin, bool clearLastFound)
// analogRead(ADC0_PIN); // analogRead(ADC0_PIN);
rowBeingScanned = corners[cornerScan]; rowBeingScanned = corners[cornerScan];
if (readFloatingOrState(pin, rowBeingScanned) == probe && rowBeingScanned != lastFound) if (readFloatingOrState(pin, rowBeingScanned) == probe && rowBeingScanned != lastFound[0])
{ {
found = rowBeingScanned; found = rowBeingScanned;
lastFound = found; if (nextIsSupply)
{
leds.setPixelColor(nodesToPixelMap[rowBeingScanned], 65, 10, 10);
}
else if (nextIsGnd)
{
leds.setPixelColor(nodesToPixelMap[rowBeingScanned], 10, 65, 10);
}
else
{
leds.setPixelColor(nodesToPixelMap[rowBeingScanned], rainbowList[rainbowIndex][0], rainbowList[rainbowIndex][1], rainbowList[rainbowIndex][2]);
}
leds.show();
for (int i = 4; i > 0; i--)
{
lastFound[i] = lastFound[i - 1];
}
lastFound[0] = found;
} }
sendXYraw(CHIP_L, cornerScan + 8, 0, 0); sendXYraw(CHIP_L, cornerScan + 8, 0, 0);
// if (found != -1) if (found != -1)
// { {
// break; break;
// } }
} }
sendXYraw(CHIP_L, xMapRead, 0, 0); sendXYraw(CHIP_L, xMapRead, 0, 0);
int gp18read = readFloatingOrState(18, -1);
if (gp18read == probe)
{
return -18;
}
pinMode(19, INPUT); pinMode(19, INPUT);
delayMicroseconds(400); delayMicroseconds(400);
int probeRead = readFloatingOrState(19, -1); int probeRead = readFloatingOrState(19, -1);
if (probeRead == high && ((lastFound[0] != SUPPLY_3V3 )))
{
found = SUPPLY_3V3;
if (justCleared)
{
nextIsSupply = 1;
//justCleared = 0;
}
else
{
leds.setPixelColor(nodesToPixelMap[lastFound[0]], 65, 10, 10);
nextIsSupply = 0;
}
for (int i = 4; i > 0; i--)
{
lastFound[i] = lastFound[i - 1];
}
lastFound[0] = found;
}
else if (probeRead == low && ((lastFound[0] != GND )))
{
found = GND;
if (justCleared)
{
// leds.setPixelColor(nodesToPixelMap[lastFound[0]], 0, 0, 0);
nextIsGnd = 1;
//justCleared = 0;
}
else
{
leds.setPixelColor(nodesToPixelMap[lastFound[0]], 10, 65, 10);
nextIsGnd = 0;
}
for (int i = 4; i > 0; i--)
{
lastFound[i] = lastFound[i - 1];
}
lastFound[0] = found;
}
if (justCleared && found != -1)
{
Serial.print("\n\rjustCleared: ");
Serial.println(justCleared);
Serial.print("nextIsSupply: ");
Serial.println(nextIsSupply);
Serial.print("nextIsGnd: ");
Serial.println(nextIsGnd);
justCleared = 0;
}
if (probeRead == high && lastFound != SUPPLY_3V3)
{
found = SUPPLY_3V3;
lastFound = found;
}
else if (probeRead == low && lastFound != GND)
{
found = GND;
lastFound = found;
}
return found; return found;
//return 0; // return 0;
} }
void sendPath(int i, int setOrClear) void sendPath(int i, int setOrClear)

View File

@ -22,7 +22,7 @@ enum measuredState
void initCH446Q(void); void initCH446Q(void);
void sendXYraw(int chip, int x, int y, int setorclear); void sendXYraw(int chip, int x, int y, int setorclear);
int readFloatingOrState (int pin = 0, int row = 0); int readFloatingOrState (int pin = 0, int row = 0);
void startProbe (void); void startProbe (int probeSpeed = 50000);
int scanRows(int pin = 0, bool clearLastFound = false); int scanRows(int pin = 0, bool clearLastFound = false);
void sendAllPaths(void); // should we sort them by chip? for now, no void sendAllPaths(void); // should we sort them by chip? for now, no
void resetArduino (void); void resetArduino (void);

View File

@ -402,8 +402,79 @@ void changeWokwiDefinesToJumperless(void)
void clearNodeFile(void) void clearNodeFile(void)
{ {
LittleFS.remove("nodeFile.txt"); LittleFS.remove("nodeFile.txt");
nodeFile = LittleFS.open("nodeFile.txt", "w+");
nodeFile.print("!");
nodeFile.close();
} }
void addBridgeToNodeFile(int node1, int node2)
{
nodeFile = LittleFS.open("nodeFile.txt", "r+");
if (!nodeFile)
{
if (debugFP)
Serial.println("Failed to open nodeFile");
return;
}
else
{
if (debugFP)
Serial.println("\n\ropened nodeFile.txt\n\n\rloading bridges from file\n\r");
}
int nodeFileBraceIndex = 0;
while (nodeFile.available())
{
char c = nodeFile.read();
// Serial.print(c);
if (c == '}')
{
break;
} else {
nodeFileBraceIndex++;
}
if (c == '!')
{
nodeFile.seek(0);
nodeFile.print("{\n\r");
nodeFile.print(node1);
nodeFile.print("-");
nodeFile.print(node2);
nodeFile.print(",\n\r}\n\r{\n\r}\n\r");
nodeFile.close();
return;
}
}
//Serial.println(nodeFileBraceIndex);
nodeFile.seek(nodeFileBraceIndex);
nodeFile.print(node1);
nodeFile.print("-");
nodeFile.print(node2);
nodeFile.print(",\n\r}\n\r{\n\r}\n\r");
if (debugFP)
{
Serial.println("wrote to nodeFile.txt");
Serial.println("nodeFile.txt contents:\n\r");
nodeFile.seek(0);
while (nodeFile.available())
{
Serial.write(nodeFile.read());
}
Serial.println("\n\r");
}
nodeFile.close();
}
void writeToNodeFile(void) void writeToNodeFile(void)
{ {

View File

@ -22,7 +22,7 @@ extern bool debugMM;
void parseWokwiFileToNodeFile(); void parseWokwiFileToNodeFile();
void changeWokwiDefinesToJumperless (); void changeWokwiDefinesToJumperless ();
void writeToNodeFile(void); void writeToNodeFile(void);
void addBridgeToNodeFile(int node1, int node2);
void savePreformattedNodeFile (int source = 0); void savePreformattedNodeFile (int source = 0);
void openNodeFile(); void openNodeFile();

View File

@ -1,6 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
#include <Arduino.h> #include <Arduino.h>
#define USE_TINYUSB 1 #define USE_TINYUSB 1
@ -53,7 +52,6 @@ int supplySwitchPosition = 0;
void machineMode(void); void machineMode(void);
void lastNetConfirm(int forceLastNet = 0); void lastNetConfirm(int forceLastNet = 0);
unsigned long lastNetConfirmTimer = 0; unsigned long lastNetConfirmTimer = 0;
// int machineMode = 0; // int machineMode = 0;
@ -77,7 +75,6 @@ void setup()
USBSer1.setStringDescriptor("Jumperless USB Serial"); USBSer1.setStringDescriptor("Jumperless USB Serial");
USBSer1.begin(115200); USBSer1.begin(115200);
#ifdef EEPROMSTUFF #ifdef EEPROMSTUFF
@ -104,9 +101,7 @@ void setup()
clearAllNTCC(); clearAllNTCC();
lastNetConfirm(0); // lastNetConfirm(0);
} }
void setup1() void setup1()
@ -134,8 +129,10 @@ char input;
int serSource = 0; int serSource = 0;
int readInNodesArduino = 0; int readInNodesArduino = 0;
int baudRate = 115200; int baudRate = 115200;
unsigned long probingTimer = 0;
int restoredNodeFile = 0;
const char firmwareVersion[] = "1.2.0"; //// remember to update this const char firmwareVersion[] = "1.3.0"; //// remember to update this
void loop() void loop()
{ {
@ -150,7 +147,7 @@ menu:
// // connecttimer = millis(); // // connecttimer = millis();
// // } // // }
//Serial.print("Updated!\n\r"); // Serial.print("Updated!\n\r");
Serial.print("\n\n\r\t\t\tMenu\n\n\r"); Serial.print("\n\n\r\t\t\tMenu\n\n\r");
Serial.print("\tn = show netlist\n\r"); Serial.print("\tn = show netlist\n\r");
@ -173,13 +170,31 @@ dontshowmenu:
if (showReadings >= 1) if (showReadings >= 1)
{ {
showMeasurements(); showMeasurements();
//Serial.print("\n\n\r"); // Serial.print("\n\n\r");
//showLEDsCore2 = 1; // showLEDsCore2 = 1;
} }
if (BOOTSEL) if (BOOTSEL)
{ {
lastNetConfirm(1); lastNetConfirm(1);
} }
// if (tud_connected() == 0 && millis() > 1000)
// {
// input = 'p';
// //clearNodeFile();
// goto skipinput;
// }
if (millis() % 100 == 0)
{
startProbe();
if (readFloatingOrState(18) == 3)
{
input = 'p';
probingTimer = millis();
// delay(500);
goto skipinput;
}
pinMode(19, INPUT);
}
} }
if (connectFromArduino != '\0') if (connectFromArduino != '\0')
@ -235,43 +250,154 @@ skipinput:
} }
case 'p': case 'p':
{ {
//clearLEDs(); // clearLEDs();
int lastRow[10]; int lastRow[10];
int pokedNumber = 0; int pokedNumber = 0;
Serial.print("Press any key to exit\n\n\r"); Serial.print("Press any key to exit and commit paths (or touch probe to gpio 18)\n\n\r");
while(Serial.available() == 0){ rawOtherColors[1] = 0x3500A8;
int row = scanRows(0); // Serial.print(numberOfNets);
if (row != -1 ) if (numberOfNets == 0)
{ {
clearNodeFile();
}
clearAllNTCC();
openNodeFile();
getNodesToConnect();
delay(10); bridgesToPaths();
lastRow[pokedNumber] = row; // clearLEDs();
pokedNumber++; assignNetColors();
delay(18);
showLEDsCore2 = 1;
delay(28);
int probedNodes[40][2];
int probedNodesIndex = 0;
printNodeOrName(row); int row = 0;
Serial.print("\r\t"); while (Serial.available() == 0)
if (pokedNumber >= 2) {
delayMicroseconds(9700);
row = scanRows(0);
if (row != -1)
{
if (row == -18 && millis() - probingTimer > 800)
{ {
Serial.print("\r \r"); Serial.print("\n\rCommitting paths!\n\r");
printNodeOrName(lastRow[0]); break;
Serial.print(" - ");
printNodeOrName(lastRow[1]);
Serial.print("\n\r");
scanRows(0, true);
delay(18);
pokedNumber = 0;
} }
} else if (row == -18)
delayMicroseconds(1000); {
continue;
}
delay(10);
lastRow[pokedNumber] = row;
probedNodes[probedNodesIndex][pokedNumber] = row;
} pokedNumber++;
pinMode(19, INPUT);
printNodeOrName(row);
Serial.print("\r\t");
if (pokedNumber >= 2)
{
Serial.print("\r \r");
printNodeOrName(probedNodes[probedNodesIndex][0]);
Serial.print(" - ");
printNodeOrName(probedNodes[probedNodesIndex][1]);
Serial.print("\n\r");
Serial.print("\n\r");
for (int i = 0; i < probedNodesIndex; i++)
{
/// Serial.print("\n\r");
if ((probedNodes[i][0] == probedNodes[probedNodesIndex][0] && probedNodes[i][1] == probedNodes[probedNodesIndex][1]) || (probedNodes[i][0] == probedNodes[probedNodesIndex][1] && probedNodes[i][1] == probedNodes[probedNodesIndex][0]))
{
probedNodes[probedNodesIndex][0] = 0;
probedNodes[probedNodesIndex][1] = 0;
leds.setPixelColor(nodesToPixelMap[probedNodes[i][0]], 0);
leds.setPixelColor(nodesToPixelMap[probedNodes[i][1]], 0);
for (int j = i; j < probedNodesIndex; j++)
{
probedNodes[j][0] = probedNodes[j + 1][0];
probedNodes[j][1] = probedNodes[j + 1][1];
}
// probedNodes[i][0] = -1;
// probedNodes[i][1] = -1;
pokedNumber = 0;
showLEDsCore2 = 1;
probedNodesIndex--;
probedNodesIndex--;
break;
}
}
// Serial.print("\n\n\n\r");
// Serial.print("\r \r");
// printNodeOrName(probedNodes[probedNodesIndex][0]);
// Serial.print(" - ");
// printNodeOrName(probedNodes[probedNodesIndex][1]);
// Serial.print("\n\r");
for (int i = probedNodesIndex; i >= 0; i--)
{
// Serial.print (" ");
// Serial.print (i);
Serial.print("\t");
printNodeOrName(probedNodes[i][0]);
Serial.print(" - ");
printNodeOrName(probedNodes[i][1]);
Serial.print("\n\r");
}
Serial.print("\n\n\r");
// delay(18);
pokedNumber = 0;
probedNodesIndex++;
// clearLEDs();
// openNodeFile();
// getNodesToConnect();
// bridgesToPaths();
/// assignNetColors();
delay(8);
// showLEDsCore2 = 1;
// delay(18);
scanRows(0, true);
}
}
}
for (int i = 0; i < probedNodesIndex; i++)
{
addBridgeToNodeFile(probedNodes[i][0], probedNodes[i][1]);
}
clearAllNTCC();
openNodeFile();
getNodesToConnect();
bridgesToPaths();
// clearLEDs();
assignNetColors();
// Serial.print("bridgesToPaths\n\r");
delay(18);
// showNets();
rawOtherColors[1] = 0x550008;
sendAllPathsCore2 = 1;
delay(25);
pinMode(19, INPUT);
delay(300);
break; break;
} }
case 'n': case 'n':
@ -374,47 +500,6 @@ skipinput:
goto menu; goto menu;
break; break;
// case 'p':
// // case '{': //I had this so you could paste a wokwi diagram from the main menu but it kinda makes a mess of other things
// digitalWrite(RESETPIN, HIGH);
// delay(1);
// #ifdef FSSTUFF
// clearNodeFile();
// #endif
// digitalWrite(RESETPIN, LOW);
// clearAllNTCC();
// clearLEDs();
// timer = millis();
// #ifdef FSSTUFF
// parseWokwiFileToNodeFile();
// openNodeFile();
// getNodesToConnect();
// #endif
// Serial.println("\n\n\rnetlist\n\n\r");
// bridgesToPaths();
// assignNetColors();
// #ifdef PIOSTUFF
// sendAllPaths();
// #endif
// if (debugNMtime)
// {
// Serial.print("\n\n\r");
// Serial.print("took ");
// Serial.print(millis() - timer);
// Serial.print("ms");
// }
// break;
case 't': case 't':
#ifdef FSSTUFF #ifdef FSSTUFF
clearNodeFile(); clearNodeFile();
@ -561,21 +646,20 @@ skipinput:
// #include <string> // Include the necessary header file // #include <string> // Include the necessary header file
void lastNetConfirm(int forceLastNet) void lastNetConfirm(int forceLastNet)
{ {
while (tud_connected() == 0 && millis() < 500) // while (tud_connected() == 0 && millis() < 500)
; // ;
if (millis() - lastNetConfirmTimer < 3000 && tud_connected() == 1) // if (millis() - lastNetConfirmTimer < 3000 && tud_connected() == 1)
{ // {
//Serial.println(lastNetConfirmTimer); // // Serial.println(lastNetConfirmTimer);
//lastNetConfirmTimer = millis(); // // lastNetConfirmTimer = millis();
return; // return;
} // }
if (tud_connected() == 0 || forceLastNet == 1) if (forceLastNet == 1)
{ {
int bootselPressed = 0; int bootselPressed = 0;
@ -595,7 +679,7 @@ void lastNetConfirm(int forceLastNet)
bootselPressed = 1; bootselPressed = 1;
} }
while (tud_connected() == 0 || forceLastNet == 1) while (forceLastNet == 1)
{ {
if (BOOTSEL) if (BOOTSEL)
bootselPressed = 1; bootselPressed = 1;
@ -607,7 +691,7 @@ void lastNetConfirm(int forceLastNet)
sendAllPathsCore2 = 1; sendAllPathsCore2 = 1;
if (BOOTSEL) if (BOOTSEL)
bootselPressed = 1; bootselPressed = 1;
//delay(250); // delay(250);
if (bootselPressed == 1) if (bootselPressed == 1)
{ {
@ -616,7 +700,6 @@ void lastNetConfirm(int forceLastNet)
while (BOOTSEL) while (BOOTSEL)
{ {
sendAllPathsCore2 = 1; sendAllPathsCore2 = 1;
delay(250); delay(250);
clearLEDs(); clearLEDs();
@ -627,18 +710,20 @@ void lastNetConfirm(int forceLastNet)
clearAllNTCC(); clearAllNTCC();
clearLEDs(); clearLEDs();
startupColors(); startupColors();
clearNodeFile();
sendAllPathsCore2 = 1; sendAllPathsCore2 = 1;
lastNetConfirmTimer = millis(); lastNetConfirmTimer = millis();
//delay(1000); restoredNodeFile = 0;
// delay(1000);
return; return;
} }
delay(fade * 10); delay(fade * 10);
fade--; fade--;
} }
digitalWrite(RESETPIN, LOW); digitalWrite(RESETPIN, LOW);
restoredNodeFile = 1;
sendAllPathsCore2 = 1; sendAllPathsCore2 = 1;
return; return;
} }
@ -653,23 +738,18 @@ void machineMode(void) // read in commands in machine readable format
{ {
int sequenceNumber = -1; int sequenceNumber = -1;
lastTimeCommandRecieved = millis(); lastTimeCommandRecieved = millis();
if (millis() - lastTimeCommandRecieved > 100) if (millis() - lastTimeCommandRecieved > 100)
{ {
machineModeRespond(sequenceNumber, true); machineModeRespond(sequenceNumber, true);
return; return;
} }
enum machineModeInstruction receivedInstruction = parseMachineInstructions(&sequenceNumber); enum machineModeInstruction receivedInstruction = parseMachineInstructions(&sequenceNumber);
// Serial.print("receivedInstruction: ");
// Serial.print(receivedInstruction);
// Serial.print("\n\r");
// Serial.print("receivedInstruction: ");
// Serial.print(receivedInstruction);
// Serial.print("\n\r");
switch (receivedInstruction) switch (receivedInstruction)
{ {
@ -690,15 +770,17 @@ if (millis() - lastTimeCommandRecieved > 100)
break; break;
case getnetlist: case getnetlist:
if (millis() - lastTimeNetlistLoaded > 300) if (millis() - lastTimeNetlistLoaded > 300)
{ {
listNetsMachine(); listNetsMachine();
} else { }
machineModeRespond(0, true); else
//Serial.print ("too soon bro\n\r"); {
return; machineModeRespond(0, true);
} // Serial.print ("too soon bro\n\r");
return;
}
break; break;
case bridgelist: case bridgelist:
@ -742,24 +824,24 @@ if (millis() - lastTimeCommandRecieved > 100)
case setsupplyswitch: case setsupplyswitch:
supplySwitchPosition = setSupplySwitch(); supplySwitchPosition = setSupplySwitch();
//printSupplySwitch(supplySwitchPosition); // printSupplySwitch(supplySwitchPosition);
machineModeRespond(sequenceNumber, true); machineModeRespond(sequenceNumber, true);
showLEDsCore2 = 1; showLEDsCore2 = 1;
break; break;
case getsupplyswitch: case getsupplyswitch:
//if (millis() - lastTimeNetlistLoaded > 100) // if (millis() - lastTimeNetlistLoaded > 100)
//{ //{
printSupplySwitch(supplySwitchPosition); printSupplySwitch(supplySwitchPosition);
//machineModeRespond(sequenceNumber, true); // machineModeRespond(sequenceNumber, true);
// }else { // }else {
//Serial.print ("\n\rtoo soon bro\n\r"); // Serial.print ("\n\rtoo soon bro\n\r");
// machineModeRespond(0, true); // machineModeRespond(0, true);
// return; // return;
// } // }
break; break;
case getchipstatus: case getchipstatus:
@ -876,8 +958,8 @@ void loop1() // core 2 handles the LEDs and the CH446Q8
{ {
input = 'f'; input = 'f';
//connectFromArduino = 'f'; // connectFromArduino = 'f';
// Serial.print("!!!!"); // Serial.print("!!!!");
} }
else else
{ {