Probing is it's own file and works on the nano header, fixed routing bugs, keep track of unconnected paths

This commit is contained in:
Kevin Santo Cappuccio 2024-02-16 09:43:37 -08:00
parent 7ad7f2ce57
commit df23c7898a
10 changed files with 1026 additions and 666 deletions

View File

@ -219,6 +219,66 @@ void sendAllPaths(void) // should we sort them by chip? for now, no
} }
} }
void sendPath(int i, int setOrClear)
{
uint32_t chAddress = 0;
int chipToConnect = 0;
int chYdata = 0;
int chXdata = 0;
for (int chip = 0; chip < 4; chip++)
{
if (path[i].chip[chip] != -1)
{
chipSelect = path[i].chip[chip];
chipToConnect = path[i].chip[chip];
if (path[i].y[chip] == -1 || path[i].x[chip] == -1)
{
if (debugNTCC)
Serial.print("!");
continue;
}
sendXYraw(chipToConnect, path[i].x[chip], path[i].y[chip], setOrClear);
// chYdata = path[i].y[chip];
// chXdata = path[i].x[chip];
// chYdata = chYdata << 5;
// chYdata = chYdata & 0b11100000;
// chXdata = chXdata << 1;
// chXdata = chXdata & 0b00011110;
// chAddress = chYdata | chXdata;
// if (setOrClear == 1)
// {
// chAddress = chAddress | 0b00000001; // this last bit determines whether we set or unset the path
// }
// chAddress = chAddress << 24;
// // delayMicroseconds(50);
// delayMicroseconds(20);
// pio_sm_put(pio, sm, chAddress);
// delayMicroseconds(40);
// //}
}
}
}
void sendXYraw(int chip, int x, int y, int setOrClear) void sendXYraw(int chip, int x, int y, int setOrClear)
{ {
uint32_t chAddress = 0; uint32_t chAddress = 0;
@ -249,393 +309,6 @@ void sendXYraw(int chip, int x, int y, int setOrClear)
delayMicroseconds(40); delayMicroseconds(40);
} }
int probeHalfPeriodus = 10;
int readFloatingOrState(int pin, int rowBeingScanned)
{
enum measuredState state = floating;
int readingPullup = 0;
int readingPullup2 = 0;
int readingPullup3 = 0;
int readingPulldown = 0;
int readingPulldown2 = 0;
int readingPulldown3 = 0;
pinMode(pin, INPUT_PULLUP);
delayMicroseconds(100);
readingPullup = digitalRead(pin);
delayMicroseconds(probeHalfPeriodus);
readingPullup2 = digitalRead(pin);
delayMicroseconds(probeHalfPeriodus / 2);
readingPullup3 = digitalRead(pin);
pinMode(pin, INPUT_PULLDOWN);
delayMicroseconds(100);
readingPulldown = digitalRead(pin);
delayMicroseconds(probeHalfPeriodus);
readingPulldown2 = digitalRead(pin);
delayMicroseconds(probeHalfPeriodus / 2);
readingPulldown3 = digitalRead(pin);
if (readingPullup != readingPullup2 || readingPullup2 != readingPullup3 && rowBeingScanned != -1)
{
if (readingPulldown != readingPulldown2 || readingPulldown2 != readingPulldown3)
{
state = probe;
// leds.setPixelColor(nodesToPixelMap[rowBeingScanned], rainbowList[rainbowIndex][0], rainbowList[rainbowIndex][1], rainbowList[rainbowIndex][2]);
// Serial.print("probe");
//
}
}
else
{
// Serial.print(readingPulldown);
// Serial.print("\t");
if (readingPullup == 1 && readingPulldown == 0)
{
// Serial.print("floating");
// leds.setPixelColor(nodesToPixelMap[rowBeingScanned], 0, 0, 3);
state = floating;
}
else if (readingPullup == 1 && readingPulldown == 1)
{
// Serial.print("HIGH");
// leds.setPixelColor(nodesToPixelMap[rowBeingScanned], 45, 0, 0);
state = high;
}
else if (readingPullup == 0 && readingPulldown == 0)
{
// Serial.print("LOW");
// leds.setPixelColor(nodesToPixelMap[rowBeingScanned], 0, 45, 0);
state = low;
}
else if (readingPullup == 0 && readingPulldown == 1)
{
// Serial.print("shorted");
}
}
// Serial.print("\n");
leds.show();
// delayMicroseconds(100);
return state;
}
void startProbe(int probeSpeed)
{
probeHalfPeriodus = 1000000 / probeSpeed / 2;
pinMode(19, OUTPUT);
analogWriteFreq(probeSpeed);
analogWrite(19, 128);
// 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 found = -1;
if (clearLastFound)
{
// for (int i = 0; i < 5; i++)
// {
// lastFound[i] = -1;
// }
rainbowIndex++;
if (rainbowIndex > 11)
{
rainbowIndex = 0;
}
justCleared = 1;
nextIsGnd = 0;
nextIsSupply = 0;
return -1;
}
digitalWrite(RESETPIN, HIGH);
delayMicroseconds(10);
digitalWrite(RESETPIN, LOW);
startProbe();
int chipToConnect = 0;
int rowBeingScanned = 0;
int xMapRead = 15;
if (pin == ADC0_PIN)
{
xMapRead = 2;
}
else if (pin == ADC1_PIN)
{
xMapRead = 3;
}
else if (pin == ADC2_PIN)
{
xMapRead = 4;
}
else if (pin == ADC3_PIN)
{
xMapRead = 5;
}
// Serial.print("xMapRead: ");
// Serial.println(xMapRead);
pinMode(pin, INPUT);
for (int chipScan = CHIP_A; chipScan < 8; chipScan++)
{
sendXYraw(CHIP_L, xMapRead, chipScan, 1);
for (int yToScan = 1; yToScan < 8; yToScan++)
{
sendXYraw(chipScan, 0, 0, 1);
sendXYraw(chipScan, 0, yToScan, 1);
// analogRead(ADC0_PIN);
rowBeingScanned = ch[chipScan].yMap[yToScan];
if (readFloatingOrState(pin, rowBeingScanned) == probe && rowBeingScanned != lastFound[0])
{
found = rowBeingScanned;
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, yToScan, 0);
if (found != -1)
{
break;
}
}
sendXYraw(CHIP_L, 2, chipScan, 0);
}
int corners[4] = {1, 30, 31, 60};
sendXYraw(CHIP_L, xMapRead, 0, 1);
for (int cornerScan = 0; cornerScan < 4; cornerScan++)
{
sendXYraw(CHIP_L, cornerScan + 8, 0, 1);
// analogRead(ADC0_PIN);
rowBeingScanned = corners[cornerScan];
if (readFloatingOrState(pin, rowBeingScanned) == probe && rowBeingScanned != lastFound[0])
{
found = rowBeingScanned;
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);
if (found != -1)
{
break;
}
}
sendXYraw(CHIP_L, xMapRead, 0, 0);
int gp18read = readFloatingOrState(18, -1);
if (gp18read == probe)
{
delayMicroseconds(1000);
if (readFloatingOrState(18, -1) == probe)
{
return -18;
}
}
pinMode(19, INPUT);
delayMicroseconds(900);
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;
}
return found;
// return 0;
}
void sendPath(int i, int setOrClear)
{
uint32_t chAddress = 0;
int chipToConnect = 0;
int chYdata = 0;
int chXdata = 0;
for (int chip = 0; chip < 4; chip++)
{
if (path[i].chip[chip] != -1)
{
chipSelect = path[i].chip[chip];
chipToConnect = path[i].chip[chip];
if (path[i].y[chip] == -1 || path[i].x[chip] == -1)
{
if (debugNTCC)
Serial.print("!");
continue;
}
chYdata = path[i].y[chip];
chXdata = path[i].x[chip];
chYdata = chYdata << 5;
chYdata = chYdata & 0b11100000;
chXdata = chXdata << 1;
chXdata = chXdata & 0b00011110;
chAddress = chYdata | chXdata;
if (setOrClear == 1)
{
chAddress = chAddress | 0b00000001; // this last bit determines whether we set or unset the path
}
chAddress = chAddress << 24;
// delayMicroseconds(50);
delayMicroseconds(20);
pio_sm_put(pio, sm, chAddress);
delayMicroseconds(40);
//}
}
}
}
void createXYarray(void) void createXYarray(void)
{ {
} }

View File

@ -10,20 +10,11 @@ extern int brightnessC2;
extern int hueShiftC2; extern int hueShiftC2;
extern int lightUpNetCore2; extern int lightUpNetCore2;
enum measuredState
{
floating = 0,
high = 1,
low = 2,
probe = 3
};
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);
void startProbe (int probeSpeed = 50000);
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);
void sendPath(int path, int setOrClear = 1); void sendPath(int path, int setOrClear = 1);

View File

@ -3,6 +3,12 @@
#ifndef JUMPERLESSDEFINESRP2040_H #ifndef JUMPERLESSDEFINESRP2040_H
#define JUMPERLESSDEFINESRP2040_H #define JUMPERLESSDEFINESRP2040_H
extern volatile int sendAllPathsCore2;
#define INPUTBUFFERLENGTH 8000 #define INPUTBUFFERLENGTH 8000
#define PIOSTUFF 1 //comment these out to remove them #define PIOSTUFF 1 //comment these out to remove them

View File

@ -22,7 +22,7 @@ ArduinoJson::DynamicJsonDocument machineModeJson(8000);
enum machineModeInstruction lastReceivedInstruction = unknown; enum machineModeInstruction lastReceivedInstruction = unknown;
char machineModeInstructionString[NUMBEROFINSTRUCTIONS][20] = {"unknown", "netlist", "getnetlist", "bridgelist", "getbridgelist", "lightnode", "lightnet", "getmeasurement", "gpio", "uart", "arduinoflash", "setnetcolor", "setnodecolor", "setsupplyswitch", "getsupplyswitch", "getchipstatus"}; char machineModeInstructionString[NUMBEROFINSTRUCTIONS][20] = {"unknown", "netlist", "getnetlist", "bridgelist", "getbridgelist", "lightnode", "lightnet", "getmeasurement", "gpio", "uart", "arduinoflash", "setnetcolor", "setnodecolor", "setsupplyswitch", "getsupplyswitch", "getchipstatus", "getunconnectedpaths"};
enum machineModeInstruction parseMachineInstructions(int *sequenceNumber) enum machineModeInstruction parseMachineInstructions(int *sequenceNumber)
{ {
@ -130,6 +130,31 @@ void machineModeRespond(int sequenceNumber, bool ok)
Serial.println(""); Serial.println("");
} }
void getUnconnectedPaths(void)
{
if (numberOfUnconnectablePaths == 0)
{
Serial.println("::unconnectedpaths-begin");
Serial.println("::unconnectedpaths-end");
return;
}
Serial.println("::unconnectedpaths-begin");
Serial.print("::unconnectedpaths[");
for (int i = 0; i < numberOfUnconnectablePaths; i++)
{
if (i > 0)
{
Serial.print(",");
}
printNodeOrName(unconnectablePaths[i][0]);
Serial.print("-");
printNodeOrName(unconnectablePaths[i][1]);
}
Serial.println("]");
Serial.println("::unconnectedpaths-end");
}
void machineNetlistToNetstruct(void) void machineNetlistToNetstruct(void)
{ {
char names[MAX_NETS][32] = {0}; char names[MAX_NETS][32] = {0};
@ -154,16 +179,16 @@ void machineNetlistToNetstruct(void)
for (int i = 0; i < MAX_NETS; i++) for (int i = 0; i < MAX_NETS; i++)
{ {
int nodesIndex = 0; int nodesIndex = 0;
if (machineModeJson[i].isNull() == true) if (machineModeJson[i].isNull() == true)
{ {
continue; continue;
//break; // break;
} }
netIndex ++; netIndex++;
//netIndex = machineModeJson[i]["index"]; // netIndex = machineModeJson[i]["index"];
strcpy(names[i], machineModeJson[i]["name"]); strcpy(names[i], machineModeJson[i]["name"]);
@ -297,7 +322,7 @@ void populateBridgesFromNodes(void)
if (net[i].nodes[j] == -1 || net[i].nodes[j] == 0) if (net[i].nodes[j] == -1 || net[i].nodes[j] == 0)
{ {
continue; continue;
//break; // break;
} }
if (net[i].nodes[j] == net[i].nodes[0]) if (net[i].nodes[j] == net[i].nodes[0])
@ -730,8 +755,8 @@ void listNetsMachine(void)
if (n->number == 0 || n->nodes[0] == -1) if (n->number == 0 || n->nodes[0] == -1)
{ {
// net not allocated yet // net not allocated yet
continue; //this allows us to delete nets and have jumperlab work continue; // this allows us to delete nets and have jumperlab work
//break; // break;
} }
Serial.print("::net["); Serial.print("::net[");
@ -763,8 +788,6 @@ void listNetsMachine(void)
// COLOR // COLOR
rgbColor color = unpackRgb(scaleUpBrightness(n->rawColor)); rgbColor color = unpackRgb(scaleUpBrightness(n->rawColor));
char buf[8]; char buf[8];
snprintf(buf, 8, "%.2x%.2x%.2x,", color.r, color.g, color.b); snprintf(buf, 8, "%.2x%.2x%.2x,", color.r, color.g, color.b);
@ -810,31 +833,36 @@ void listBridgesMachine(void)
{ {
started = true; started = true;
} }
printNodeOrName(n->bridges[j][0],1); printNodeOrName(n->bridges[j][0], 1);
Serial.print("-"); Serial.print("-");
printNodeOrName(n->bridges[j][1],1); printNodeOrName(n->bridges[j][1], 1);
} }
} }
Serial.println("]"); Serial.println("]");
} }
void printChipStatusMachine() { void printChipStatusMachine()
Serial.println("::chipstatus-begin"); {
for (int i = 0; i < 12; i++) { Serial.println("::chipstatus-begin");
Serial.print("::chipstatus["); for (int i = 0; i < 12; i++)
Serial.print(chipNumToChar(i)); {
Serial.print(","); Serial.print("::chipstatus[");
for (int j = 0; j < 16; j++) { Serial.print(chipNumToChar(i));
Serial.print(ch[i].xStatus[j]);
Serial.print(",");
}
for (int j = 0; j < 8; j++) {
Serial.print(ch[i].yStatus[j]);
if (j != 7) {
Serial.print(","); Serial.print(",");
} for (int j = 0; j < 16; j++)
{
Serial.print(ch[i].xStatus[j]);
Serial.print(",");
}
for (int j = 0; j < 8; j++)
{
Serial.print(ch[i].yStatus[j]);
if (j != 7)
{
Serial.print(",");
}
}
Serial.println("]");
} }
Serial.println("]"); Serial.println("::chipstatus-end");
}
Serial.println("::chipstatus-end");
} }

View File

@ -2,7 +2,7 @@
#ifndef MACHINECOMMANDS_H #ifndef MACHINECOMMANDS_H
#define MACHINECOMMANDS_H #define MACHINECOMMANDS_H
#define NUMBEROFINSTRUCTIONS 17 #define NUMBEROFINSTRUCTIONS 18
enum machineModeInstruction enum machineModeInstruction
{ {
@ -21,7 +21,8 @@ enum machineModeInstruction
setnodecolor, setnodecolor,
setsupplyswitch, setsupplyswitch,
getsupplyswitch, getsupplyswitch,
getchipstatus getchipstatus,
getunconnectedpaths
}; };
extern char inputBuffer[INPUTBUFFERLENGTH]; extern char inputBuffer[INPUTBUFFERLENGTH];
@ -29,6 +30,7 @@ extern char machineModeInstructionString[NUMBEROFINSTRUCTIONS][20];
enum machineModeInstruction parseMachineInstructions(int *sequenceNumber); enum machineModeInstruction parseMachineInstructions(int *sequenceNumber);
void machineModeRespond(int sequenceNumber, bool ok); void machineModeRespond(int sequenceNumber, bool ok);
void getUnconnectedPaths(void);
void machineNetlistToNetstruct(void); void machineNetlistToNetstruct(void);
void populateBridgesFromNodes(void); void populateBridgesFromNodes(void);
int nodeTokenToInt(char *); int nodeTokenToInt(char *);

View File

@ -1,6 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
#include <Arduino.h> #include <Arduino.h>
#include "JumperlessDefinesRP2040.h" #include "JumperlessDefinesRP2040.h"
#include "MatrixStateRP2040.h" #include "MatrixStateRP2040.h"
@ -26,6 +25,20 @@ int numberOfPaths = 0;
int pathsWithCandidates[MAX_BRIDGES] = {0}; int pathsWithCandidates[MAX_BRIDGES] = {0};
int pathsWithCandidatesIndex = 0; int pathsWithCandidatesIndex = 0;
int numberOfUnconnectablePaths = 0;
int unconnectablePaths[10][2] = {
{-1, -1},
{-1, -1},
{-1, -1},
{-1, -1},
{-1, -1},
{-1, -1},
{-1, -1},
{-1, -1},
{-1, -1},
{-1, -1},
};
unsigned long timeToSort = 0; unsigned long timeToSort = 0;
bool debugNTCC = EEPROM.read(DEBUG_NETTOCHIPCONNECTIONSADDRESS); bool debugNTCC = EEPROM.read(DEBUG_NETTOCHIPCONNECTIONSADDRESS);
@ -151,6 +164,12 @@ void clearAllNTCC(void)
ch[i].yStatus[j] = -1; ch[i].yStatus[j] = -1;
} }
} }
for (int i = 0; i < 10; i++)
{
unconnectablePaths[i][0] = -1;
unconnectablePaths[i][1] = -1;
}
numberOfUnconnectablePaths = 0;
} }
void sortPathsByNet(void) // not actually sorting, just copying the bridges and nets back from netStruct so they're both in the same order void sortPathsByNet(void) // not actually sorting, just copying the bridges and nets back from netStruct so they're both in the same order
@ -305,6 +324,8 @@ void bridgesToPaths(void)
resolveChipCandidates(); resolveChipCandidates();
commitPaths(); commitPaths();
resolveUncommittedHops(); resolveUncommittedHops();
couldntFindPath();
if (debugNTCC2) if (debugNTCC2)
{ {
// delay(10); // delay(10);
@ -321,6 +342,7 @@ void commitPaths(void)
for (int i = 0; i < numberOfPaths; i++) for (int i = 0; i < numberOfPaths; i++)
{ {
duplicateSFnets();
// Serial.print(i); // Serial.print(i);
// Serial.print(" \t"); // Serial.print(" \t");
@ -529,13 +551,14 @@ void commitPaths(void)
path[i].y[2] = yMapForNode(path[i].node1, path[i].chip[0]); path[i].y[2] = yMapForNode(path[i].node1, path[i].chip[0]);
path[i].chip[2] = path[i].chip[0]; path[i].chip[2] = path[i].chip[0];
path[i].sameChip = true; // so we know both -2 values need to be the same path[i].sameChip = true; // so we know both -2 values need to be the same
path[i].altPathNeeded = true; path[i].altPathNeeded = true;
// path[i].sameChip = true; //so we know both -2 values need to be the same // path[i].sameChip = true; //so we know both -2 values need to be the same
if (debugNTCC3 == true) if (debugNTCC2 == true)
{ {
Serial.print(" \tchip[0]: "); Serial.print(" \n\r\tchip[0]: ");
Serial.print(chipNumToChar(path[i].chip[0])); Serial.print(chipNumToChar(path[i].chip[0]));
Serial.print(" x[0]: "); Serial.print(" x[0]: ");
@ -553,7 +576,7 @@ void commitPaths(void)
Serial.print(" y[1]: "); Serial.print(" y[1]: ");
Serial.print(path[i].y[1]); Serial.print(path[i].y[1]);
// Serial.println(" "); Serial.println(" ");
} }
// path[i].sameChip = true; // path[i].sameChip = true;
} }
@ -594,11 +617,11 @@ void commitPaths(void)
ch[path[i].chip[1]].yStatus[path[i].chip[0]] = path[i].net; ch[path[i].chip[1]].yStatus[path[i].chip[0]] = path[i].net;
if (debugNTCC == true) if (debugNTCC2 == true)
{ {
// delay(10); // delay(10);
Serial.print(" \tchip[0]: "); Serial.print(" \t\n\rchip[0]: ");
Serial.print(chipNumToChar(path[i].chip[0])); Serial.print(chipNumToChar(path[i].chip[0]));
Serial.print(" x[0]: "); Serial.print(" x[0]: ");
@ -623,7 +646,7 @@ void commitPaths(void)
Serial.print(ch[path[i].chip[1]].xStatus[xMapSFc1]); Serial.print(ch[path[i].chip[1]].xStatus[xMapSFc1]);
Serial.print(" \t "); Serial.print(" \t ");
// Serial.println(" "); Serial.println(" ");
} }
} }
else else
@ -667,7 +690,7 @@ void commitPaths(void)
if (false) if (false)
{ {
Serial.print(" \tchip[0]: "); Serial.print(" \t\n\rchip[0]: ");
Serial.print(chipNumToChar(path[i].chip[0])); Serial.print(chipNumToChar(path[i].chip[0]));
Serial.print(" x[0]: "); Serial.print(" x[0]: ");
@ -733,9 +756,12 @@ void duplicateSFnets(void)
void resolveAltPaths(void) void resolveAltPaths(void)
{ {
int couldFindPath = -1;
for (int i = 0; i <= numberOfPaths; i++) for (int i = 0; i <= numberOfPaths; i++)
{ {
couldFindPath = -1;
int swapped = 0; int swapped = 0;
if (path[i].altPathNeeded == true) if (path[i].altPathNeeded == true)
@ -760,6 +786,7 @@ void resolveAltPaths(void)
if (debugNTCC2) if (debugNTCC2)
{ {
Serial.print("Found Path!\n\r"); Serial.print("Found Path!\n\r");
couldFindPath = i;
} }
break; break;
} }
@ -844,8 +871,10 @@ void resolveAltPaths(void)
} }
foundPath = 1; foundPath = 1;
couldFindPath = i;
if (debugNTCC2) if (debugNTCC2)
{ {
Serial.print("\n\r");
Serial.print(i); Serial.print(i);
Serial.print(" chip[2]: "); Serial.print(" chip[2]: ");
Serial.print(chipNumToChar(path[i].chip[2])); Serial.print(chipNumToChar(path[i].chip[2]));
@ -886,6 +915,7 @@ void resolveAltPaths(void)
// not chip L // not chip L
if (debugNTCC2) if (debugNTCC2)
{ {
Serial.print("\n\r");
Serial.print(" bb: "); Serial.print(" bb: ");
printChipNumToChar(bb); printChipNumToChar(bb);
Serial.print(" \t sfChip: "); Serial.print(" \t sfChip: ");
@ -910,6 +940,7 @@ void resolveAltPaths(void)
int xMapL1c1 = xMapForChipLane1(bb, path[i].chip[0]); int xMapL1c1 = xMapForChipLane1(bb, path[i].chip[0]);
if (debugNTCC2) if (debugNTCC2)
{ {
Serial.print("\n\r");
Serial.print(" bb: "); Serial.print(" bb: ");
printChipNumToChar(bb); printChipNumToChar(bb);
Serial.print(" \t sfChip: "); Serial.print(" \t sfChip: ");
@ -960,7 +991,6 @@ void resolveAltPaths(void)
continue; continue;
} }
path[i].chip[2] = bb;
path[i].altPathNeeded = false; path[i].altPathNeeded = false;
int SFnode = xMapForNode(path[i].node2, path[i].chip[1]); int SFnode = xMapForNode(path[i].node2, path[i].chip[1]);
@ -972,6 +1002,8 @@ void resolveAltPaths(void)
if (freeLane == 0) if (freeLane == 0)
{ {
path[i].chip[2] = bb;
path[i].chip[3] = bb;
ch[path[i].chip[0]].xStatus[xMapL0c0] = path[i].net; ch[path[i].chip[0]].xStatus[xMapL0c0] = path[i].net;
ch[path[i].chip[1]].xStatus[SFnode] = path[i].net; ch[path[i].chip[1]].xStatus[SFnode] = path[i].net;
@ -999,11 +1031,15 @@ void resolveAltPaths(void)
ch[path[i].chip[0]].yStatus[path[i].y[0]] = path[i].net; ch[path[i].chip[0]].yStatus[path[i].y[0]] = path[i].net;
ch[path[i].chip[1]].yStatus[path[i].y[1]] = path[i].net; ch[path[i].chip[1]].yStatus[path[i].y[1]] = path[i].net;
ch[path[i].chip[2]].yStatus[0] = path[i].net;
path[i].sameChip = true; path[i].sameChip = true;
} }
else if (freeLane == 1) else if (freeLane == 1)
{ {
path[i].chip[2] = bb;
path[i].chip[3] = bb;
ch[path[i].chip[0]].xStatus[xMapL1c0] = path[i].net; ch[path[i].chip[0]].xStatus[xMapL1c0] = path[i].net;
ch[path[i].chip[1]].xStatus[SFnode] = path[i].net; ch[path[i].chip[1]].xStatus[SFnode] = path[i].net;
@ -1027,12 +1063,15 @@ void resolveAltPaths(void)
ch[path[i].chip[0]].yStatus[path[i].y[0]] = path[i].net; ch[path[i].chip[0]].yStatus[path[i].y[0]] = path[i].net;
ch[path[i].chip[1]].yStatus[path[i].y[1]] = path[i].net; ch[path[i].chip[1]].yStatus[path[i].y[1]] = path[i].net;
ch[path[i].chip[2]].yStatus[0] = path[i].net;
} }
foundPath = 1; foundPath = 1;
couldFindPath = i;
if (debugNTCC2 == true) if (debugNTCC2 == true)
{ {
Serial.print("\n\r");
Serial.print(i); Serial.print(i);
Serial.print(" \tchip[0]: "); Serial.print(" \tchip[0]: ");
Serial.print(chipNumToChar(path[i].chip[0])); Serial.print(chipNumToChar(path[i].chip[0]));
@ -1193,7 +1232,7 @@ void resolveAltPaths(void)
if (foundPath == 1) if (foundPath == 1)
{ {
couldFindPath = i;
break; break;
} }
int giveUpOnL = 0; int giveUpOnL = 0;
@ -1216,6 +1255,7 @@ void resolveAltPaths(void)
if (debugNTCC3) if (debugNTCC3)
{ {
Serial.print("\n\r");
Serial.print("path: "); Serial.print("path: ");
Serial.print(i); Serial.print(i);
Serial.print("\tindex: "); Serial.print("\tindex: ");
@ -1320,6 +1360,7 @@ void resolveAltPaths(void)
if (debugNTCC2) if (debugNTCC2)
{ {
Serial.print("\n\r");
Serial.print(i); Serial.print(i);
Serial.print(" chip[2]: "); Serial.print(" chip[2]: ");
Serial.print(chipNumToChar(path[i].chip[2])); Serial.print(chipNumToChar(path[i].chip[2]));
@ -1384,6 +1425,7 @@ void resolveAltPaths(void)
if (debugNTCC2) if (debugNTCC2)
{ {
Serial.print("\n\r");
Serial.print(i); Serial.print(i);
Serial.print(" chip[2]: "); Serial.print(" chip[2]: ");
Serial.print(chipNumToChar(path[i].chip[2])); Serial.print(chipNumToChar(path[i].chip[2]));
@ -1446,6 +1488,7 @@ void resolveAltPaths(void)
path[i].sameChip = true; path[i].sameChip = true;
if (debugNTCC2) if (debugNTCC2)
{ {
Serial.print("\n\r");
Serial.print(i); Serial.print(i);
Serial.print(" chip[2]: "); Serial.print(" chip[2]: ");
Serial.print(chipNumToChar(path[i].chip[2])); Serial.print(chipNumToChar(path[i].chip[2]));
@ -1458,6 +1501,7 @@ void resolveAltPaths(void)
Serial.print(" \n\r"); Serial.print(" \n\r");
} }
couldFindPath = i;
break; break;
} }
} }
@ -1507,8 +1551,9 @@ void resolveAltPaths(void)
if (debugNTCC2) if (debugNTCC2)
{ {
Serial.print("\n\r");
Serial.print(i); Serial.print(i);
Serial.print(" chip[2]: "); Serial.print(" chip[2]: ");
Serial.print(chipNumToChar(path[i].chip[2])); Serial.print(chipNumToChar(path[i].chip[2]));
Serial.print(" x[2]: "); Serial.print(" x[2]: ");
@ -1519,11 +1564,13 @@ void resolveAltPaths(void)
Serial.print(" \n\r"); Serial.print(" \n\r");
} }
couldFindPath = i;
break; break;
} }
if (debugNTCC2) if (debugNTCC2)
{ {
Serial.print("\n\r");
Serial.print(i); Serial.print(i);
Serial.print(" chip[2]: "); Serial.print(" chip[2]: ");
Serial.print(chipNumToChar(path[i].chip[2])); Serial.print(chipNumToChar(path[i].chip[2]));
@ -1548,17 +1595,21 @@ void resolveAltPaths(void)
{ {
if (debugNTCC2) if (debugNTCC2)
{ {
Serial.println("NANOtoNANO"); Serial.println(" NANOtoNANO");
} }
int foundHop = 0; int foundHop = 0;
int giveUpOnL = 0; int giveUpOnL = 0;
int swapped = 0; int swapped = 0;
if (path[i].Lchip == true) // TODO check if the same net is connected to another SF chip and use that instead duplicateSFnets();
// if (path[i].Lchip == true) // TODO check if the same net is connected to another SF chip and use that instead
if (false)
{ {
int sfChip1 = path[i].chip[0]; int sfChip1 = path[i].chip[0];
int sfChip2 = path[i].chip[1]; int sfChip2 = path[i].chip[1];
if (((sfChip1 == CHIP_L && sfChip2 >= CHIP_I) || (sfChip2 == CHIP_L && sfChip1 >= CHIP_I)) && sfChip1 != sfChip2) if (((sfChip1 == CHIP_L && sfChip2 >= CHIP_I) || (sfChip2 == CHIP_L && sfChip1 >= CHIP_I)) && sfChip1 != sfChip2)
{ {
if (debugNTCC2) if (debugNTCC2)
{ {
Serial.println("\n\n\rL to Special Function via ADCs\n\r"); Serial.println("\n\n\rL to Special Function via ADCs\n\r");
@ -1594,11 +1645,11 @@ void resolveAltPaths(void)
{ {
if (debugNTCC2) if (debugNTCC2)
{ {
Serial.print("\n\rCouldn't find a path for "); // Serial.print("\n\rCouldn't find a path for ");
printNodeOrName(path[i].node1); // printNodeOrName(path[i].node1);
Serial.print(" to "); // Serial.print(" to ");
printNodeOrName(path[i].node2); // printNodeOrName(path[i].node2);
Serial.println(" \n\n\n\n\n\r"); // Serial.println(" \n\n\n\n\n\r");
} }
// path[i].skip = true; // path[i].skip = true;
// / path[i].chip[0] = -1; // / path[i].chip[0] = -1;
@ -1613,6 +1664,7 @@ void resolveAltPaths(void)
{ {
if (debugNTCC2) if (debugNTCC2)
{ {
Serial.print("\n\r");
Serial.print("hopBB: "); Serial.print("hopBB: ");
Serial.println(hopBB); Serial.println(hopBB);
Serial.print("chip[0]: "); Serial.print("chip[0]: ");
@ -1630,7 +1682,8 @@ void resolveAltPaths(void)
{ {
if (debugNTCC2) if (debugNTCC2)
{ {
Serial.print("found: "); Serial.print("\n\r");
Serial.print("found L hop: ");
Serial.println(hopBB); Serial.println(hopBB);
} }
path[i].chip[2] = hopBB; path[i].chip[2] = hopBB;
@ -1663,6 +1716,7 @@ void resolveAltPaths(void)
if (debugNTCC2) if (debugNTCC2)
{ {
Serial.print("\n\r");
Serial.print("xMapForNode(CHIP_L, "); Serial.print("xMapForNode(CHIP_L, ");
Serial.print(path[i].node1); Serial.print(path[i].node1);
Serial.print("): "); Serial.print("): ");
@ -1679,6 +1733,7 @@ void resolveAltPaths(void)
if (debugNTCC2) if (debugNTCC2)
{ {
Serial.print("\n\r");
Serial.print("xMapForNode(CHIP_L, "); Serial.print("xMapForNode(CHIP_L, ");
Serial.print(path[i].node2); Serial.print(path[i].node2);
Serial.print("): "); Serial.print("): ");
@ -1706,6 +1761,7 @@ void resolveAltPaths(void)
// } // }
// foundHop = 1; // foundHop = 1;
couldFindPath = i;
break; break;
} }
} }
@ -1734,6 +1790,7 @@ void resolveAltPaths(void)
if (debugNTCC2) if (debugNTCC2)
{ {
Serial.print("\n\r");
Serial.println(path[i].x[whichIsSF]); Serial.println(path[i].x[whichIsSF]);
Serial.print("path[i].node1; "); Serial.print("path[i].node1; ");
Serial.println(path[i].node1); Serial.println(path[i].node1);
@ -1802,6 +1859,7 @@ void resolveAltPaths(void)
{ {
if (debugNTCC2) if (debugNTCC2)
{ {
Serial.print("\n\r");
Serial.print("ySearch: "); Serial.print("ySearch: ");
Serial.println(ySearch); Serial.println(ySearch);
Serial.print("sfChip1: "); Serial.print("sfChip1: ");
@ -1831,6 +1889,7 @@ void resolveAltPaths(void)
path[i].y[whichIsL] = ySearch; path[i].y[whichIsL] = ySearch;
path[i].y[whichIsL + 2] = ySearch; path[i].y[whichIsL + 2] = ySearch;
// ch[sfChip2].yStatus[ySearch] = path[i].net; // ch[sfChip2].yStatus[ySearch] = path[i].net;
couldFindPath = i;
break; break;
} }
} }
@ -1861,6 +1920,7 @@ void resolveAltPaths(void)
// path[i].y[whichIsSF] = ySearch; // path[i].y[whichIsSF] = ySearch;
// path[i].y[whichIsSF + 2] = ySearch; // path[i].y[whichIsSF + 2] = ySearch;
couldFindPath = i;
break; break;
} }
} }
@ -1922,16 +1982,22 @@ void resolveAltPaths(void)
ch[bb].xStatus[chip1Lane] = path[i].net; ch[bb].xStatus[chip1Lane] = path[i].net;
ch[bb].yStatus[0] = path[i].net; ch[bb].yStatus[0] = path[i].net;
couldFindPath = i;
} }
} }
} }
} }
else else // if the path is not on the L chip
{ {
giveUpOnL = 0;
for (int bb = 0; bb < 8; bb++) // this is a long winded way to do this but it's at least slightly readable for (int bb = 0; bb < 8; bb++) // this is a long winded way to do this but it's at least slightly readable
{ {
// Serial.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
int sfChip1 = path[i].chip[0]; int sfChip1 = path[i].chip[0];
int sfChip2 = path[i].chip[1]; int sfChip2 = path[i].chip[1];
// Serial.print("path: ");
// Serial.println(i);
int chip1Lane = xMapForNode(sfChip1, bb); int chip1Lane = xMapForNode(sfChip1, bb);
int chip2Lane = xMapForNode(sfChip2, bb); int chip2Lane = xMapForNode(sfChip2, bb);
@ -1959,31 +2025,36 @@ void resolveAltPaths(void)
{ {
if (ch[bb].xStatus[chip2Lane] == path[i].net || ch[bb].xStatus[chip2Lane] == -1) if (ch[bb].xStatus[chip2Lane] == path[i].net || ch[bb].xStatus[chip2Lane] == -1)
{ {
// Serial.print("bb:\t");
// Serial.println(bb);
// printPathsCompact();
// printChipStatus();
if (giveUpOnL == 0) if (giveUpOnL == 1)
{
ch[CHIP_L].yStatus[bb] = path[i].net;
path[i].y[2] = -1;
path[i].y[3] = -1;
break;
}
else
{ {
if (debugNTCC2) if (debugNTCC2)
{ {
Serial.println("Gave up on L"); Serial.println("Gave up on L");
Serial.print("path :");
Serial.println(i);
} }
path[i].y[2] = -2; break;
path[i].y[3] = -2;
path[i].sameChip = true;
} }
path[i].sameChip = true;
ch[bb].xStatus[chip1Lane] = path[i].net; ch[bb].xStatus[chip1Lane] = path[i].net;
ch[bb].xStatus[chip2Lane] = path[i].net; ch[bb].xStatus[chip2Lane] = path[i].net;
path[i].chip[2] = bb; if (path[i].chip[0] != path[i].chip[1])
path[i].x[2] = chip1Lane; {
path[i].x[3] = chip2Lane; path[i].chip[2] = bb;
path[i].y[2] = -2;
path[i].y[3] = -2;
path[i].x[2] = chip1Lane;
path[i].x[3] = chip2Lane;
}
path[i].altPathNeeded = false; path[i].altPathNeeded = false;
@ -1995,6 +2066,7 @@ void resolveAltPaths(void)
if (debugNTCC2) if (debugNTCC2)
{ {
Serial.print("\n\r");
Serial.print(i); Serial.print(i);
Serial.print(" chip[2]: "); Serial.print(" chip[2]: ");
Serial.print(chipNumToChar(path[i].chip[2])); Serial.print(chipNumToChar(path[i].chip[2]));
@ -2008,7 +2080,10 @@ void resolveAltPaths(void)
Serial.print(" \n\r"); Serial.print(" \n\r");
} }
foundHop = 1; foundHop = 1;
// break; couldFindPath = i;
// printPathsCompact();
// printChipStatus();
break;
} }
} }
} }
@ -2027,21 +2102,30 @@ void resolveAltPaths(void)
// Serial.print("xStatus:\t"); // Serial.print("xStatus:\t");
// Serial.println(ch[bb].xStatus[chip2Lane]); // Serial.println(ch[bb].xStatus[chip2Lane]);
// Serial.println(" "); // Serial.println(" ");
// Serial.print("path: ");
// Serial.println(i);
// Serial.print("?????????????????????\n\r");
if ((ch[bb].xStatus[chip1Lane] == path[i].net || ch[bb].xStatus[chip1Lane] == -1) && foundHop == 0) if ((ch[bb].xStatus[chip1Lane] == path[i].net || ch[bb].xStatus[chip1Lane] == -1) && foundHop == 0)
{ {
if (ch[bb].xStatus[chip2Lane] == path[i].net || ch[bb].xStatus[chip2Lane] == -1) if (ch[bb].xStatus[chip2Lane] == path[i].net || ch[bb].xStatus[chip2Lane] == -1)
{ {
// Serial.print("path :");
// Serial.println(i);
// printPathsCompact();
ch[bb].xStatus[chip1Lane] = path[i].net; ch[bb].xStatus[chip1Lane] = path[i].net;
ch[bb].xStatus[chip2Lane] = path[i].net; ch[bb].xStatus[chip2Lane] = path[i].net;
path[i].chip[2] = bb; if (path[i].chip[0] != path[i].chip[1]) // this makes it not try to find a third chip if it doesn't need to
path[i].x[2] = chip1Lane; {
path[i].x[3] = chip2Lane;
path[i].chip[2] = bb;
path[i].x[2] = chip1Lane;
path[i].x[3] = chip2Lane;
path[i].y[2] = -2;
path[i].y[3] = -2;
}
path[i].y[2] = -2;
path[i].y[3] = -2;
path[i].sameChip = true; path[i].sameChip = true;
path[i].altPathNeeded = false; path[i].altPathNeeded = false;
@ -2053,6 +2137,7 @@ void resolveAltPaths(void)
if (debugNTCC2) if (debugNTCC2)
{ {
Serial.print("\n\r");
Serial.print(i); Serial.print(i);
Serial.print(" chip[2]: "); Serial.print(" chip[2]: ");
Serial.print(chipNumToChar(path[i].chip[2])); Serial.print(chipNumToChar(path[i].chip[2]));
@ -2066,10 +2151,15 @@ void resolveAltPaths(void)
Serial.print(" \n\r"); Serial.print(" \n\r");
} }
foundHop = 1; foundHop = 1;
// break; couldFindPath = i;
// printPathsCompact();
// printChipStatus();
break;
} }
} }
} }
// couldntFindPath(i);
} }
} }
@ -2077,12 +2167,61 @@ void resolveAltPaths(void)
} }
} }
} }
// Serial.print("path");
// Serial.print(i);
// resolveUncommittedHops(); // resolveUncommittedHops();
// printPathsCompact(); // printPathsCompact();
// printChipStatus(); // printChipStatus();
} }
void couldntFindPath(int forcePrint)
{
if (debugNTCC2 || forcePrint)
{
Serial.print("\n\r");
}
for (int i = 0; i < numberOfPaths; i++)
{
int foundNegative = 0;
for (int j = 0; j < 4; j++)
{
if (path[i].chip[j] == -1 && j >= 2)
{
continue;
}
if (path[i].x[j] < 0 || path[i].y[j] < 0)
{
foundNegative = 1;
}
}
if (foundNegative == 1)
{
if (debugNTCC2 || forcePrint)
{
Serial.print("\n\rCouldn't find a path for ");
printNodeOrName(path[i].node1);
Serial.print(" to ");
printNodeOrName(path[i].node2);
Serial.print("\n\r");
}
unconnectablePaths[numberOfUnconnectablePaths][0] = path[i].node1;
unconnectablePaths[numberOfUnconnectablePaths][1] = path[i].node2;
numberOfUnconnectablePaths++;
path[i].skip = true;
}
}
if (debugNTCC2 || forcePrint)
{
Serial.print("\n\r");
}
}
void resolveUncommittedHops2(void) void resolveUncommittedHops2(void)
{ {
} }
@ -2113,8 +2252,8 @@ void resolveUncommittedHops(void)
for (int i = 0; i < numberOfPaths; i++) for (int i = 0; i < numberOfPaths; i++)
{ {
//printPathsCompact(); // printPathsCompact();
//printChipStatus(); // printChipStatus();
pathsWithSameXChips[i] = -1; pathsWithSameXChips[i] = -1;
pathsWithSameYChips[i] = -1; pathsWithSameYChips[i] = -1;
int sameChips[2][4] = {//[x,y][chip] int sameChips[2][4] = {//[x,y][chip]
@ -2178,32 +2317,33 @@ void resolveUncommittedHops(void)
if (pathsWithSameXChips[i] == 1 || pathsWithSameYChips[i] == 1) if (pathsWithSameXChips[i] == 1 || pathsWithSameYChips[i] == 1)
{ {
if (debugNTCC3) if (debugNTCC2)
{ {
Serial.print("\n\r");
Serial.print(i); Serial.print(i);
Serial.print("\tsame chips: "); Serial.print("\tsame chips: ");
} }
for (int chip = 0; chip < 4; chip++) for (int chip = 0; chip < 4; chip++)
{ {
if (debugNTCC3) if (debugNTCC2)
{ {
Serial.print(chipNumToChar(sameChips[0][chip])); Serial.print(chipNumToChar(sameChips[0][chip]));
Serial.print(", "); Serial.print(", ");
} }
} }
if (debugNTCC3) if (debugNTCC2)
{ {
Serial.print("\t"); Serial.print("\t");
} }
for (int chip = 0; chip < 4; chip++) for (int chip = 0; chip < 4; chip++)
{ {
if (debugNTCC3) if (debugNTCC2)
{ {
Serial.print(chipNumToChar(sameChips[1][chip])); Serial.print(chipNumToChar(sameChips[1][chip]));
Serial.print(", "); Serial.print(", ");
} }
} }
if (debugNTCC3) if (debugNTCC2)
{ {
Serial.println(" "); Serial.println(" ");
} }
@ -2365,11 +2505,10 @@ void resolveUncommittedHops(void)
{ {
int otherChip = ch[sameChips[0][chip]].xMap[freeXSearchOrder[sameChips[0][chip]][freeXidx]]; int otherChip = ch[sameChips[0][chip]].xMap[freeXSearchOrder[sameChips[0][chip]][freeXidx]];
int thisChip = sameChips[0][chip]; int thisChip = sameChips[0][chip];
// Serial.print("other Chip = "); // Serial.print("other Chip = ");
// Serial.println(chipNumToChar(otherChip)); // Serial.println(chipNumToChar(otherChip));
int otherChipFree = 0; int otherChipFree = 0;
int otherChipX = -1; int otherChipX = -1;
for (int xOtherCheck = 0; xOtherCheck < 16; xOtherCheck++) for (int xOtherCheck = 0; xOtherCheck < 16; xOtherCheck++)
{ {
@ -2411,13 +2550,11 @@ void resolveUncommittedHops(void)
} }
if (otherChipXStatus == -1 || otherChipXStatus == path[i].net) if (otherChipXStatus == -1 || otherChipXStatus == path[i].net)
{ {
freeX = freeXSearchOrder[sameChips[0][chip]][freeXidx]; freeX = freeXSearchOrder[sameChips[0][chip]][freeXidx];
ch[otherChip].xStatus[otherChipX] = path[i].net; ch[otherChip].xStatus[otherChipX] = path[i].net;
break; break;
} }
} }
} }
// if (chip >= 2) // if (chip >= 2)
@ -2431,6 +2568,14 @@ void resolveUncommittedHops(void)
path[i].x[chip] = freeX; path[i].x[chip] = freeX;
ch[sameChips[0][chip]].xStatus[freeX] = path[i].net; ch[sameChips[0][chip]].xStatus[freeX] = path[i].net;
// Serial.print("path: ");
// Serial.print(i);
// Serial.print("\nfreeX: ");
// Serial.print(freeX);
// Serial.print(" status: ");
// Serial.print(ch[sameChips[0][chip]].xStatus[freeX]);
// Serial.println(" ");
//} //}
} }
} }
@ -2506,16 +2651,23 @@ void resolveUncommittedHops(void)
if (sameChips[1][chip] < 8 && freeYsearch != 0) if (sameChips[1][chip] < 8 && freeYsearch != 0)
{ {
// Serial.print("continued chip: ");
// Serial.print(sameChips[1][chip]);
// Serial.print("\tfreeYsearch: ");
// Serial.println(freeYsearch);
continue; continue;
} }
// Serial.print("path: "); // Serial.print("\n\rpath: ");
// Serial.print(i); // Serial.print(i);
// Serial.print("\nfreeYsearch: "); // Serial.print("\n\rchip: ");
// Serial.print(chip);
// Serial.print("\n\rfreeYsearch: ");
// Serial.print(freeYsearch); // Serial.print(freeYsearch);
// Serial.print(" status: "); // Serial.print("\n\rstatus: ");
// Serial.print(ch[sameChips[1][chip]].yStatus[freeYsearch]); // Serial.print(ch[sameChips[1][chip]].yStatus[freeYsearch]);
// Serial.println(" "); // Serial.println(" \n\n\r");
if (ch[sameChips[1][chip]].yStatus[freeYsearch] == -1 || ch[sameChips[1][chip]].yStatus[freeYsearch] == path[i].net) if (ch[sameChips[1][chip]].yStatus[freeYsearch] == -1 || ch[sameChips[1][chip]].yStatus[freeYsearch] == path[i].net)
{ {
@ -2529,17 +2681,33 @@ void resolveUncommittedHops(void)
// Serial.print("\n\n\rfreeY After search : "); // Serial.print("\n\n\rfreeY After search : ");
// Serial.print(freeY); // Serial.print(freeY);
path[i].y[chip] = freeY; if (chip == 2)
{
path[i].y[2] = freeY;
path[i].y[3] = freeY;
ch[sameChips[1][chip]].yStatus[freeY] = path[i].net; ch[sameChips[1][chip]].yStatus[freeY] = path[i].net;
ch[path[i].chip[2]].yStatus[freeY] = path[i].net;
path[i].chip[3] = path[i].chip[2];
}
else
{
path[i].y[chip] = freeY;
ch[sameChips[1][chip]].yStatus[freeY] = path[i].net;
}
ch[path[i].chip[0]].yStatus[freeY] = path[i].net;
ch[path[i].chip[1]].yStatus[freeY] = path[i].net;
// Serial.print("\t "); // Serial.print("\t ");
// Serial.print(path[i].y[y]); // Serial.print(path[i].y[chip]);
// Serial.print("\t "); // Serial.print("\t ");
// Serial.print("sameChips[1][chip]: "); // Serial.print("sameChips[1][chip]: ");
// printChipNumToChar(sameChips[1][chip]); // printChipNumToChar(sameChips[1][chip]);
break; // break;
} }
/// Serial.println(" \r\n"); /// Serial.println(" \r\n");
@ -2596,10 +2764,10 @@ void swapDuplicateNode(int pathIndex)
{ {
if (debugNTCC2) if (debugNTCC2)
{ {
Serial.print("swapping "); Serial.print("swapping ");
printChipNumToChar(path[pathIndex].chip[1]); printChipNumToChar(path[pathIndex].chip[1]);
Serial.print(" with "); Serial.print(" with ");
printChipNumToChar(duplucateSFnodes[i][2]); printChipNumToChar(duplucateSFnodes[i][2]);
} }
path[pathIndex].chip[1] = duplucateSFnodes[i][2]; path[pathIndex].chip[1] = duplucateSFnodes[i][2];
@ -2661,7 +2829,7 @@ void printPathsCompact(void)
Serial.print(" \t"); Serial.print(" \t");
Serial.print(path[i].y[3]); Serial.print(path[i].y[3]);
} }
if (debugNTCC2) if (1)
{ {
if (path[i].chip[3] != -1) if (path[i].chip[3] != -1)
{ {
@ -3062,7 +3230,7 @@ void assignPathType(int pathIndex)
{ {
path[pathIndex].pathType = NANOtoNANO; path[pathIndex].pathType = NANOtoNANO;
} }
if (debugNTCC2) if (debugNTCC)
{ {
Serial.print("Path "); Serial.print("Path ");
Serial.print(pathIndex); Serial.print(pathIndex);

View File

@ -13,6 +13,9 @@ extern int numberOfPaths;
extern bool debugNTCC; extern bool debugNTCC;
extern bool debugNTCC2; extern bool debugNTCC2;
extern int numberOfUnconnectablePaths;
extern int unconnectablePaths[10][2];
void clearAllNTCC(void); void clearAllNTCC(void);
void sortPathsByNet(void); void sortPathsByNet(void);
@ -20,6 +23,8 @@ void bridgesToPaths(void);
void findStartAndEndChips(int node1, int node2, int net); void findStartAndEndChips(int node1, int node2, int net);
void couldntFindPath(int forcePrint = 0);
void resolveChipCandidates(); void resolveChipCandidates();
void printPathArray(); void printPathArray();

View File

@ -0,0 +1,610 @@
#include "CH446Q.h"
#include "MatrixStateRP2040.h"
#include "NetsToChipConnections.h"
#include "LEDs.h"
#include "Peripherals.h"
#include "JumperlessDefinesRP2040.h"
#include "FileParsing.h"
#include "NetManager.h"
#include "Probing.h"
int probeHalfPeriodus = 10;
unsigned long probingTimer = 0;
long probeFrequency = 50000;
int probeMode(int pin)
{
int lastRow[10];
int pokedNumber = 0;
Serial.print("Press any key to exit and commit paths (or touch probe to gpio 18)\n\n\r");
rawOtherColors[1] = 0x3500A8;
// Serial.print(numberOfNets);
if (numberOfNets == 0)
{
clearNodeFile();
}
clearAllNTCC();
openNodeFile();
getNodesToConnect();
bridgesToPaths();
// clearLEDs();
assignNetColors();
delay(18);
showLEDsCore2 = 1;
delay(28);
int probedNodes[40][2];
int probedNodesIndex = 0;
int row = 0;
while (Serial.available() == 0)
{
delayMicroseconds(1700);
row = scanRows(0);
if (row != -1)
{
if (row == -18 && millis() - probingTimer > 500)
{
Serial.print("\n\rCommitting paths!\n\r");
probingTimer = millis();
break;
}
else if (row == -18)
{
continue;
}
delay(10);
lastRow[pokedNumber] = row;
probedNodes[probedNodesIndex][pokedNumber] = row;
pokedNumber++;
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] = 0x550004;
sendAllPathsCore2 = 1;
delay(25);
pinMode(19, INPUT);
delay(300);
return 1;
}
int lastProbeButtonState = 0;
int lastProbeButtonState2 = 0;
int checkProbeButton(void)
{
int buttonState = 0;
int probeButton[3] = {-1, -1, -1};
startProbe();
delayMicroseconds(probeHalfPeriodus * 10);
probeButton[0] = readFloatingOrState(18);
delayMicroseconds(probeHalfPeriodus);
probeButton[1] = readFloatingOrState(18);
delayMicroseconds(probeHalfPeriodus);
probeButton[2] = readFloatingOrState(18);
if (probeButton[0] == probeButton[1] && probeButton[1] == probeButton[2] && probeButton[0] == probeButton[2])
{
if (probeButton[0] == probe)
{
buttonState = 1;
}
else
{
buttonState = 0;
}
}
else
{
// Serial.print("periodus: ");
// Serial.print(probeHalfPeriodus);
// Serial.print("\t");
// Serial.print(probeButton[0]);
// Serial.print("\t");
// Serial.print(probeButton[1]);
// Serial.print("\t");
// Serial.print(probeButton[2]);
// Serial.print("\n\r");
}
// pinMode(19, INPUT);
stopProbe();
return buttonState;
}
int readFloatingOrState(int pin, int rowBeingScanned)
{
enum measuredState state = floating;
int readingPullup = 0;
int readingPullup2 = 0;
int readingPullup3 = 0;
int readingPulldown = 0;
int readingPulldown2 = 0;
int readingPulldown3 = 0;
pinMode(pin, INPUT_PULLUP);
delayMicroseconds(probeHalfPeriodus * 32);
readingPullup = digitalRead(pin);
delayMicroseconds(probeHalfPeriodus * 2);
readingPullup2 = digitalRead(pin);
delayMicroseconds(probeHalfPeriodus);
readingPullup3 = digitalRead(pin);
pinMode(pin, INPUT_PULLDOWN);
delayMicroseconds(probeHalfPeriodus * 32);
readingPulldown = digitalRead(pin);
delayMicroseconds(probeHalfPeriodus * 2);
readingPulldown2 = digitalRead(pin);
delayMicroseconds(probeHalfPeriodus);
readingPulldown3 = digitalRead(pin);
if (readingPullup != readingPullup2 || readingPullup2 != readingPullup3 && rowBeingScanned != -1)
{
if (readingPulldown != readingPulldown2 || readingPulldown2 != readingPulldown3)
{
state = probe;
// leds.setPixelColor(nodesToPixelMap[rowBeingScanned], rainbowList[rainbowIndex][0], rainbowList[rainbowIndex][1], rainbowList[rainbowIndex][2]);
// Serial.print("probe");
//
}
}
else
{
// Serial.print(readingPulldown);
// Serial.print("\t");
if (readingPullup == 1 && readingPulldown == 0)
{
// Serial.print("floating");
// leds.setPixelColor(nodesToPixelMap[rowBeingScanned], 0, 0, 3);
state = floating;
}
else if (readingPullup == 1 && readingPulldown == 1)
{
// Serial.print("HIGH");
// leds.setPixelColor(nodesToPixelMap[rowBeingScanned], 45, 0, 0);
state = high;
}
else if (readingPullup == 0 && readingPulldown == 0)
{
// Serial.print("LOW");
// leds.setPixelColor(nodesToPixelMap[rowBeingScanned], 0, 45, 0);
state = low;
}
else if (readingPullup == 0 && readingPulldown == 1)
{
// Serial.print("shorted");
}
}
// Serial.print("\n");
// showLEDsCore2 = 1;
// leds.show();
// delayMicroseconds(100);
return state;
}
void startProbe(long probeSpeed)
{
probeFrequency = probeSpeed;
probeHalfPeriodus = 1000000 / probeSpeed / 2;
pinMode(19, OUTPUT);
analogWriteFreq(probeSpeed);
analogWrite(19, 128);
// delayMicroseconds(10);
// pinMode(18, INPUT);
}
void stopProbe()
{
pinMode(19, INPUT);
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 found = -1;
if (clearLastFound)
{
rainbowIndex++;
if (rainbowIndex > 11)
{
rainbowIndex = 0;
}
justCleared = 1;
nextIsGnd = 0;
nextIsSupply = 0;
return -1;
}
if (checkProbeButton() == 1)
{
return -18;
}
pin = ADC1_PIN;
digitalWrite(RESETPIN, HIGH);
delayMicroseconds(10);
digitalWrite(RESETPIN, LOW);
startProbe();
int chipToConnect = 0;
int rowBeingScanned = 0;
int xMapRead = 15;
if (pin == ADC0_PIN)
{
xMapRead = 2;
}
else if (pin == ADC1_PIN)
{
xMapRead = 3;
}
else if (pin == ADC2_PIN)
{
xMapRead = 4;
}
else if (pin == ADC3_PIN)
{
xMapRead = 5;
}
// Serial.print("xMapRead: ");
// Serial.println(xMapRead);
pinMode(pin, INPUT);
for (int chipScan = CHIP_A; chipScan < 8; chipScan++) // scan the breadboard (except the corners)
{
sendXYraw(CHIP_L, xMapRead, chipScan, 1);
for (int yToScan = 1; yToScan < 8; yToScan++)
{
sendXYraw(chipScan, 0, 0, 1);
sendXYraw(chipScan, 0, yToScan, 1);
// analogRead(ADC0_PIN);
rowBeingScanned = ch[chipScan].yMap[yToScan];
if (readFloatingOrState(pin, rowBeingScanned) == probe && rowBeingScanned != lastFound[0])
{
found = rowBeingScanned;
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]);
}
showLEDsCore2 = 1;
// 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, yToScan, 0);
if (found != -1)
{
stopProbe();
break;
}
}
sendXYraw(CHIP_L, 2, chipScan, 0);
}
int corners[4] = {1, 30, 31, 60};
sendXYraw(CHIP_L, xMapRead, 0, 1);
for (int cornerScan = 0; cornerScan < 4; cornerScan++)
{
sendXYraw(CHIP_L, cornerScan + 8, 0, 1);
// analogRead(ADC0_PIN);
rowBeingScanned = corners[cornerScan];
if (readFloatingOrState(pin, rowBeingScanned) == probe && rowBeingScanned != lastFound[0])
{
found = rowBeingScanned;
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]);
}
showLEDsCore2 = 1;
// leds.show();
for (int i = 4; i > 0; i--)
{
lastFound[i] = lastFound[i - 1];
}
lastFound[0] = found;
}
sendXYraw(CHIP_L, cornerScan + 8, 0, 0);
if (found != -1)
{
stopProbe();
break;
}
}
sendXYraw(CHIP_L, xMapRead, 0, 0);
for (int chipScan2 = CHIP_I; chipScan2 <= CHIP_J; chipScan2++) // scan the breadboard (except the corners)
{
// Serial.print("pin: ");
// Serial.println(pin);
int pinHeader = ADC0_PIN + (chipScan2 - CHIP_I);
// Serial.print("pinHeader: ");
// Serial.println(pinHeader);
for (int xToScan = 0; xToScan < 12; xToScan++)
{
sendXYraw(chipScan2, xToScan, 0, 1);
sendXYraw(chipScan2, 13, 0, 1);
// analogRead(ADC0_PIN);
rowBeingScanned = ch[chipScan2].xMap[xToScan];
// Serial.print("rowBeingScanned: ");
// Serial.println(rowBeingScanned);
// Serial.print("chipScan2: ");
// Serial.println(chipScan2);
// Serial.print("xToScan: ");
// Serial.println(xToScan);
if (readFloatingOrState(pinHeader, rowBeingScanned) == probe && rowBeingScanned != lastFound[0])
{
Serial.print("rowBeingScanned: ");
Serial.println(rowBeingScanned);
found = rowBeingScanned;
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]);
}
showLEDsCore2 = 1;
// leds.show();
for (int i = 4; i > 0; i--)
{
lastFound[i] = lastFound[i - 1];
}
lastFound[0] = found;
}
sendXYraw(chipScan2, xToScan, 0, 0);
sendXYraw(chipScan2, 13, 0, 0);
if (found != -1)
{
stopProbe();
break;
}
}
}
pinMode(19, INPUT);
delayMicroseconds(900);
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);
showLEDsCore2 = 1;
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);
showLEDsCore2 = 1;
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;
}
stopProbe();
return found;
// return 0;
}

View File

@ -0,0 +1,30 @@
// SPDX-License-Identifier: MIT
#ifndef PROBING_H
#define PROBING_H
extern unsigned long probingTimer;
extern long probeFrequency;
enum measuredState
{
floating = 0,
high = 1,
low = 2,
probe = 3
};
int probeMode(int pin = 19);
int checkProbeButton();
int readFloatingOrState (int pin = 0, int row = 0);
void startProbe (long probeSpeed = 50000);
void stopProbe();
int scanRows(int pin = 0, bool clearLastFound = false);
#endif

View File

@ -30,20 +30,15 @@
#include "MachineCommands.h" #include "MachineCommands.h"
// #include <EEPROM.h> // #include <EEPROM.h>
#ifdef EEPROMSTUFF
#include <EEPROM.h> #include <EEPROM.h>
#endif
#ifdef PIOSTUFF
#include "CH446Q.h" #include "CH446Q.h"
#endif
#include "FileParsing.h" #include "FileParsing.h"
#ifdef FSSTUFF
#include "LittleFS.h" #include "LittleFS.h"
#endif #include "Probing.h"
Adafruit_USBD_CDC USBSer1; Adafruit_USBD_CDC USBSer1;
@ -129,7 +124,7 @@ 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; int restoredNodeFile = 0;
const char firmwareVersion[] = "1.3.1"; //// remember to update this const char firmwareVersion[] = "1.3.1"; //// remember to update this
@ -183,21 +178,16 @@ dontshowmenu:
// //clearNodeFile(); // //clearNodeFile();
// goto skipinput; // goto skipinput;
// } // }
if (millis() % 300 == 0) if (millis() % 100 == 0)
{ {
startProbe(); if (checkProbeButton() == 1)
if (readFloatingOrState(18) == 3)
{ {
delayMicroseconds(1000);
if (readFloatingOrState(18) == 3)
{
input = 'p'; input = 'p';
probingTimer = millis(); probingTimer = millis();
// delay(500);
goto skipinput; goto skipinput;
}
} }
pinMode(19, INPUT);
// pinMode(19, INPUT);
} }
} }
@ -254,165 +244,19 @@ skipinput:
} }
case 'p': case 'p':
{ {
// clearLEDs(); probeMode();
int lastRow[10];
int pokedNumber = 0;
Serial.print("Press any key to exit and commit paths (or touch probe to gpio 18)\n\n\r");
rawOtherColors[1] = 0x3500A8;
// Serial.print(numberOfNets);
if (numberOfNets == 0)
{
clearNodeFile();
}
clearAllNTCC();
openNodeFile();
getNodesToConnect();
bridgesToPaths();
// clearLEDs();
assignNetColors();
delay(18);
showLEDsCore2 = 1;
delay(28);
int probedNodes[40][2];
int probedNodesIndex = 0;
int row = 0;
while (Serial.available() == 0)
{
delayMicroseconds(1700);
row = scanRows(0);
if (row != -1)
{
if (row == -18 && millis() - probingTimer > 500)
{
Serial.print("\n\rCommitting paths!\n\r");
probingTimer = millis();
break;
}
else if (row == -18)
{
continue;
}
delay(10);
lastRow[pokedNumber] = row;
probedNodes[probedNodesIndex][pokedNumber] = row;
pokedNumber++;
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] = 0x350004;
sendAllPathsCore2 = 1;
delay(25);
pinMode(19, INPUT);
delay(300);
break; break;
} }
case 'n': case 'n':
couldntFindPath(1);
Serial.print("\n\n\rnetlist\n\n\r"); Serial.print("\n\n\rnetlist\n\n\r");
listSpecialNets(); listSpecialNets();
listNets(); listNets();
break; break;
case 'b': case 'b':
couldntFindPath(1);
Serial.print("\n\n\rBridge Array\n\r"); Serial.print("\n\n\rBridge Array\n\r");
printBridgeArray(); printBridgeArray();
Serial.print("\n\n\n\rPaths\n\r"); Serial.print("\n\n\n\rPaths\n\r");
@ -855,7 +699,10 @@ void machineMode(void) // read in commands in machine readable format
// case gpio: // case gpio:
// break; // break;
case getunconnectedpaths:
getUnconnectedPaths();
break;
case unknown: case unknown:
machineModeRespond(sequenceNumber, false); machineModeRespond(sequenceNumber, false);
return; return;