Added 'ack' to recieving connections from arduino (see examples), Allow you to just read the probe with 'j'

This commit is contained in:
Kevin Santo Cappuccio 2025-02-11 18:21:07 -08:00
parent e8ab545457
commit d8be2e44b5
16 changed files with 3242 additions and 2079 deletions

74
JumperlessNano/.vscode/.clang-format vendored Normal file
View File

@ -0,0 +1,74 @@
---
AlignAfterOpenBracket: Never
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: false
AlignOperands: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
PackConstructorInitializers: Never
BreakBeforeBinaryOperators: All
BreakBeforeBraces: WebKit
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
BreakStringLiterals: true
ConstructorInitializerAllOnOneLineOrOnePerLine: false
Cpp11BracedListStyle: false
DerivePointerAlignment: false
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 3
- Regex: '.\*'
Priority: 1
IndentCaseLabels: true
IndentWrappedFunctionNames: true
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 3
NamespaceIndentation: None
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakBeforeFirstCallParameter: 999050
PenaltyBreakComment: 100
PenaltyBreakFirstLessLess: 0
PenaltyBreakString: 500
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 400
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: false
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp20
AccessModifierOffset: -2
BreakBeforeBraces: BS_WebKit
JavaScriptQuotes: Single
JavaScriptWrapImports: false
UseTab: Always
TabWidth: 2
ConstructorInitializerIndentWidth: 2
TableGenBreakInsideDAGArg: DontBreak
ContinuationIndentWidth: 2
IndentWidth: 2
ColumnLimit: 500
Language: Cpp
...

View File

@ -0,0 +1,134 @@
#define MAX_CONNECTIONS 50
#define EOT '\x04'
#define ACK '\x06'
#define STX '\x02'
#define RDY '\x01'
int connectionsToMake[MAX_CONNECTIONS][2];
int numberOfConnections = 0;
int node1 = 2;
int node2 = 4;
void setup() {
for (int i = 0; i < MAX_CONNECTIONS; i++) {
connectionsToMake[i][0] = -1;
connectionsToMake[i][1] = -1;
}
pinMode(LED_BUILTIN, OUTPUT);
delay(1500);
Serial.begin(115200);
delay(1500);
for (int i = 0; i < 10; i++) {
connectionsToMake[i][0] = node1;
connectionsToMake[i][1] = node2;
numberOfConnections++;
node1 += 6;
node2 += 6;
if (node1 > 60) {
node1 = 1;
}
if (node2 > 60) {
node2 = 4;
}
}
}
int count = 1;
// the transmission order is:
// Arduino (A) - Jumperless (J)
//
// each step waits for the next acknowledgement
// A -> J : STX (\x02)
// A <- J : RDY (\x01)
// A -> J : sends one bridge (trailing comma) 6-9,
// A <- J : ACK (\x06)
// A -> J : sends another bridge (trailing comma) 4-20,
// A <- J : ACK (\x06)
// repeat until all bridges are sent
// A -> J : EOT (\x04)
void loop() {
int acknowledged = 0; //-1 is timed out
char readAck = ' ';
unsigned long timeout = 0;
//delay(1000);
numberOfConnections = 0;
for (int i = 0; i < 10; i++) { //this just makes the connections "march" across the board
connectionsToMake[i][0] = ((node1 + count) % 60) + 1;
connectionsToMake[i][1] = ((node2 + count) % 60) + 1;
numberOfConnections++;
node1 += 6;
node2 += 6;
if (node1 > 60) {
node1 = 1;
}
if (node2 > 60) {
node2 = 4;
}
}
count++;
Serial.write(STX); //ready to send
timeout = millis();
while (acknowledged == 0) { //wait for acknowledgement from Jumperless
readAck = Serial.read();
if (readAck == RDY) {
acknowledged = 1;
}
if (millis() - timeout > 1000) {
acknowledged = -1;
break;
}
}
if (acknowledged == 1) {
acknowledged = 0;
for (int i = 0; i < numberOfConnections; i++) {
digitalWrite(LED_BUILTIN, HIGH);
//delay(30); //doesn't even need this now
Serial.print(connectionsToMake[i][0]);
Serial.print("-");
Serial.print(connectionsToMake[i][1]);
Serial.print(", "); //send one bridge
digitalWrite(LED_BUILTIN, LOW);
timeout = millis();
while (acknowledged == 0) { // wait for acknowledgement
readAck = Serial.read();
if (readAck == ACK) {
acknowledged = 1;
}
if (millis() - timeout > 100) {
acknowledged = -1;
break;
}
}
if (acknowledged == -1) {
break;
}
}
Serial.write(EOT); //send end of transmission
if (count >= 60) { //this is just to make the paths move
count = 3;
}
}
}

View File

@ -0,0 +1,131 @@
#define MAX_CONNECTIONS 50
#define EOT '\x04'
#define ACK '\x06'
#define STX '\x02'
#define RDY '\x01'
int connectionsToMake[MAX_CONNECTIONS][2];
int numberOfConnections = 0;
int node1 = 2;
int node2 = 4;
void setup() {
for (int i = 0; i < MAX_CONNECTIONS; i++) {
connectionsToMake[i][0] = -1;
connectionsToMake[i][1] = -1;
}
pinMode(LED_BUILTIN, OUTPUT);
delay(1500);
Serial.begin(115200);
delay(1500);
for (int i = 0; i < 10; i++) {
connectionsToMake[i][0] = node1;
connectionsToMake[i][1] = node2;
numberOfConnections++;
node1 += 6;
node2 += 6;
if (node1 > 60) {
node1 = 1;
}
if (node2 > 60) {
node2 = 4;
}
}
}
int count = 1;
// the transmission order is:
// Arduino (A) - Jumperless (J)
//
// each step waits for the next acknowledgement
// A -> J : STX (\x02)
// A <- J : RDY (\x01)
// A -> J : sends one bridge (trailing comma) 6-9,
// A <- J : ACK (\x06)
// A -> J : sends another bridge (trailing comma) 4-20,
// A <- J : ACK (\x06)
// repeat until all bridges are sent
// A -> J : EOT (\x04)
void loop() {
int acknowledged = 0; //-1 is timed out
char readAck = ' ';
unsigned long timeout = 0;
delay(500);
numberOfConnections = 0;
for (int i = 0; i < 10; i++) { //this just makes the connections "march" across the board
connectionsToMake[i][0] = ((node1 + count) % 60) + 1;
connectionsToMake[i][1] = ((node2 + count) % 60) + 1;
numberOfConnections++;
node1 += 6;
node2 += 6;
if (node1 > 60) {
node1 = 1;
}
if (node2 > 60) {
node2 = 4;
}
}
count++;
timeout = millis();
Serial.print("f ");
timeout = millis();
while (Serial.available() == 0 && (millis()-timeout< 300))
while (Serial.available() > 0) {
char throwaway = Serial.read();
if (throwaway == "1")//this is just to stop the compiler from optimizing this out
{
continue;
}
}
for (int i = 0; i < numberOfConnections; i++) {
digitalWrite(LED_BUILTIN, HIGH);
//delay(30); //doesn't even need this now
Serial.print(connectionsToMake[i][0]);
Serial.print("-");
Serial.print(connectionsToMake[i][1]);
Serial.print(", "); //send one bridge
digitalWrite(LED_BUILTIN, LOW);
timeout = millis();
while (Serial.available() == 0 && (millis()-timeout < 300))
;
while (Serial.available() > 0) {
char throwaway = Serial.read();
if (throwaway == "1")//this is just to stop the compiler from optimizing this out
{
continue;
}
}
}
Serial.println();
// Serial.write(EOT); //send end of transmission
if (count >= 60) { //this is just to make the paths move
count = 3;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -16,10 +16,12 @@ extern bool debugMM;
extern int loadFileOnStart;
extern volatile int abortWait;
extern int rawConn[4]; //connect/clear, chip, x, y
// #include "RotaryEncoder.h"
int openFileThreadSafe(int openTypeEnum, int slot = 0, int flashOrLocal = 0);
//extern File nodeFile;
void createSlots(int slot = -1, int addRotaryConnections = 0);
@ -30,7 +32,7 @@ void changeWokwiDefinesToJumperless ();
void writeToNodeFile(int slot = 0);
void removeBridgeFromNodeFile(int node1, int node2 = -1, int slot = 0);
void addBridgeToNodeFile(int node1, int node2, int slot = 0);
void savePreformattedNodeFile (int source = 0, int slot = 0, int keepEncoder = 1);
void savePreformattedNodeFile (int source = 0, int slot = 0, int keepEncoder = 1, int ack = 0);
void openNodeFile(int slot = 0);
int parseRaw(int connectOrClear = 1);

View File

@ -6,11 +6,16 @@
extern volatile int sendAllPathsCore2;
extern volatile int showLEDsCore2;
extern volatile int core1busy;
extern volatile int core2busy;
extern volatile int core1request;
#define INPUTBUFFERLENGTH 8000
#define PIOSTUFF 1 //comment these out to remove them
#define EEPROMSTUFF 1
#define FSSTUFF 1
@ -45,6 +50,7 @@ extern volatile int sendAllPathsCore2;
#define MAX_BRIDGES 255
#define MAX_NODES 64
#define MAX_DNI 8 //max number of doNotIntersect rules
#define MAX_DUPLICATE 12
#define LASTCOMMANDADDRESS 1
#define CLEARBEFORECOMMANDADDRESS 4

View File

@ -16,7 +16,7 @@ volatile uint8_t LEDbrightness;
volatile uint8_t LEDbrightnessRail;
volatile uint8_t LEDbrightnessSpecial;
int showLEDsCore2 = 0;
volatile int showLEDsCore2 = 0;
int netNumberC2 = 0;
int onOffC2 = 0;

View File

@ -48,7 +48,7 @@
extern Adafruit_NeoPixel leds;
extern bool debugLEDs;
extern int showLEDsCore2;
//extern volatile int showLEDsCore2;
extern int logoFlash;

View File

@ -24,6 +24,234 @@ enum machineModeInstruction lastReceivedInstruction = unknown;
char machineModeInstructionString[NUMBEROFINSTRUCTIONS][20] = {"unknown", "netlist", "getnetlist", "bridgelist", "getbridgelist", "lightnode", "lightnet", "getmeasurement", "gpio", "uart", "arduinoflash", "setnetcolor", "setnodecolor", "setsupplyswitch", "getsupplyswitch", "getchipstatus", "getunconnectedpaths"};
unsigned long lastNetConfirmTimer = 0;
int restoredNodeFile = 0;
void lastNetConfirm(int forceLastNet) {
// while (tud_connected() == 0 && millis() < 500)
// ;
// if (millis() - lastNetConfirmTimer < 3000 && tud_connected() == 1)
// {
// // Serial.println(lastNetConfirmTimer);
// // lastNetConfirmTimer = millis();
// return;
// }
if (forceLastNet == 1) {
int bootselPressed = 0;
openNodeFile();
getNodesToConnect();
// Serial.print("openNF\n\r");
digitalWrite(RESETPIN, HIGH);
bridgesToPaths();
clearLEDs();
assignNetColors();
sendAllPathsCore2 = 1;
Serial.print("\n\r short press BOOTSEL to restore last netlist\n\r");
Serial.print(" long press to cancel\n\r");
delay(250);
if (BOOTSEL) {
bootselPressed = 1;
}
while (forceLastNet == 1) {
if (BOOTSEL)
bootselPressed = 1;
// clearLEDs();
// leds.show();
leds.clear();
lightUpRail(-1, -1, 1, 28);//supplySwitchPosition);
leds.show();
// showLEDsCore2 = 1;
if (BOOTSEL)
bootselPressed = 1;
delay(250);
// showLEDsCore2 = 2;
sendAllPathsCore2 = 1;
// Serial.print("p\n\r");
if (BOOTSEL)
bootselPressed = 1;
// delay(250);
if (bootselPressed == 1) {
unsigned long longPressTimer = millis();
int fade = 8;
while (BOOTSEL) {
sendAllPathsCore2 = 1;
showLEDsCore2 = 2;
delay(250);
clearLEDs();
// leds.clear();
showLEDsCore2 = 2;
if (fade <= 0) {
clearAllNTCC();
clearLEDs();
startupColors();
// clearNodeFile();
sendAllPathsCore2 = 1;
lastNetConfirmTimer = millis();
restoredNodeFile = 0;
// delay(1000);
Serial.print("\n\r cancelled\n\r");
return;
}
delay(fade * 10);
fade--;
}
digitalWrite(RESETPIN, LOW);
restoredNodeFile = 1;
sendAllPathsCore2 = 1;
Serial.print("\n\r restoring last netlist\n\r");
printNodeFile();
return;
}
delay(250);
}
}
}
unsigned long lastTimeNetlistLoaded = 0;
unsigned long lastTimeCommandRecieved = 0;
void machineMode(void) // read in commands in machine readable format
{
int sequenceNumber = -1;
lastTimeCommandRecieved = millis();
if (millis() - lastTimeCommandRecieved > 100) {
machineModeRespond(sequenceNumber, true);
return;
}
enum machineModeInstruction receivedInstruction =
parseMachineInstructions(&sequenceNumber);
// Serial.print("receivedInstruction: ");
// Serial.print(receivedInstruction);
// Serial.print("\n\r");
switch (receivedInstruction) {
case netlist:
lastTimeNetlistLoaded = millis();
clearAllNTCC();
// writeNodeFileFromInputBuffer();
digitalWrite(RESETPIN, HIGH);
machineNetlistToNetstruct();
populateBridgesFromNodes();
bridgesToPaths();
clearLEDs();
assignNetColors();
// showNets();
digitalWrite(RESETPIN, LOW);
sendAllPathsCore2 = 1;
break;
case getnetlist:
if (millis() - lastTimeNetlistLoaded > 300) {
listNetsMachine();
} else {
machineModeRespond(0, true);
// Serial.print ("too soon bro\n\r");
return;
}
break;
case bridgelist:
clearAllNTCC();
writeNodeFileFromInputBuffer();
openNodeFile();
getNodesToConnect();
// Serial.print("openNF\n\r");
digitalWrite(RESETPIN, HIGH);
bridgesToPaths();
clearLEDs();
assignNetColors();
// Serial.print("bridgesToPaths\n\r");
digitalWrite(RESETPIN, LOW);
// showNets();
sendAllPathsCore2 = 1;
break;
case getbridgelist:
listBridgesMachine();
break;
case lightnode:
lightUpNodesFromInputBuffer();
break;
case lightnet:
lightUpNetsFromInputBuffer();
// lightUpNet();
// assignNetColors();
// showLEDsCore2 = 1;
break;
// case getmeasurement:
// showMeasurements();
// break;
case setsupplyswitch:
// supplySwitchPosition = setSupplySwitch();
// printSupplySwitch(supplySwitchPosition);
machineModeRespond(sequenceNumber, true);
showLEDsCore2 = 1;
break;
case getsupplyswitch:
// if (millis() - lastTimeNetlistLoaded > 100)
//{
//printSupplySwitch(supplySwitchPosition);
// machineModeRespond(sequenceNumber, true);
// }else {
// Serial.print ("\n\rtoo soon bro\n\r");
// machineModeRespond(0, true);
// return;
// }
break;
case getchipstatus:
printChipStatusMachine();
break;
// case gpio:
// break;
case getunconnectedpaths:
getUnconnectedPaths();
break;
case unknown:
machineModeRespond(sequenceNumber, false);
return;
}
machineModeRespond(sequenceNumber, true);
}
enum machineModeInstruction parseMachineInstructions(int *sequenceNumber)
{

View File

@ -36,7 +36,9 @@ void populateBridgesFromNodes(void);
int nodeTokenToInt(char *);
int findReplacement(char *name);
int removeHexPrefix(const char *);
void machineMode(void);
void lastNetConfirm(int forceLastNet);
void populateBridgesFromNodes(void);
void writeNodeFileFromInputBuffer(void);

View File

@ -32,6 +32,11 @@ uint32_t rawColor; //color of the net in hex (for the machine)
char *colorName; //name of the color
bool machine = false; //whether this net was created by the machine or by the user
int duplicatePaths[MAX_DUPLICATE] = {-1, -1, -1, -1,-1, -1, -1, -1,-1,-1}; // if the paths are redundant (for lower resistance) this is the pathNumber of the other one(s)
int numberOfDuplicates = 0; // if the paths are redundant (for lower resistance) this is the number of duplicates
};
extern struct netStruct net[MAX_NETS];
@ -144,6 +149,7 @@ struct pathStruct{
bool Lchip;
bool skip = false;
int duplicate = 0; // the "parent" path if 1, the "child" path if 2, 0 if not a duplicate
};

View File

@ -22,6 +22,12 @@ int numberOfUniqueNets = 0;
int numberOfNets = 0;
int numberOfPaths = 0;
int powerPriority = 1;
int dacPriority = 1;
int powerDuplicates = 0;
int dacDuplicates = 0;
int pathDuplicates = 0;
int pathsWithCandidates[MAX_BRIDGES] = {0};
int pathsWithCandidatesIndex = 0;
@ -744,9 +750,361 @@ void commitPaths(void)
// printChipStatus();
resolveAltPaths();
// duplicateSFnets();
}
int newBridges[MAX_NETS][MAX_DUPLICATE][2] = { 0 };
void fillUnusedPaths(int duplicatePathsOverride, int duplicatePathsPower,
int duplicatePathsDac) {
/// return;
int duplicatePathIndex = 0;
uint8_t nodeCount[MAX_NETS] = { 0 };
uint8_t bridgeCount[MAX_NETS] = { 0 };
for (int i = 0; i < MAX_NETS; i++) {
for (int j = 0; j < MAX_DUPLICATE; j++) {
for (int k = 0; k < 2; k++) {
newBridges[i][j][k] = 0;
}
}
}
for (int n = 0; n < numberOfNets; n++) {
// Serial.print("net[");
// Serial.print(n);
// Serial.print("] \n\rnumber: ");
// Serial.println(net[n].number);
for (int i = 0; i < MAX_NODES; i++) {
if (net[n].nodes[i] == 0) {
break;
}
nodeCount[n]++;
// Serial.print(" \n\rnode: ");
// Serial.println(net[n].nodes[i]);
}
for (int i = 0; i < MAX_BRIDGES; i++) {
if (net[n].bridges[i][0] == 0) {
break;
}
bridgeCount[n]++;
// Serial.print(" \n\rbridges: ");
// Serial.print(net[n].bridges[i][0]);
// Serial.print("-");
// Serial.println(net[n].bridges[i][1]);
}
// Serial.println("\n\r");
}
int duplindex = 0;
// first figure out which paths need duplicates
for (int i = 0; i < numberOfPaths; i++) {
if (bridgeCount[path[i].net] > 0) {
// path[i].duplicate = 1;
// net[path[i].net].duplicatePaths[duplindex] = i;
if (path[i].net <= 3) {
net[path[i].net].numberOfDuplicates = powerDuplicates;
} else if (path[i].net == 4 || path[i].net == 5) {
net[path[i].net].numberOfDuplicates = dacDuplicates;
} else {
net[path[i].net].numberOfDuplicates = pathDuplicates;
}
}
}
// get the nodes in the net and cycle them, so if the bridges are A-B, B-C,
// the duplicate paths will start with A-C
// A-B, B-C -> A-C
// A-B, B-C, C-D -> A-C, A-D, B-D
// A-B, B-C, C-D, D-E -> A-C, A-D, A-E, B-D, B-E,
// A-B, B-C, C-D, D-E, E-F -> A-C, A-D, A-E, A-F, B-D, B-E, B-F, C-E,
// C-F, D-F A-B, B-C, C-D, D-E, E-F, F-G -> A-C, A-D, A-E, A-F, A-G, B-D,
// B-E, B-F, B-G, C-E, C-F, C-G, D-F, D-G, E-G A-B, B-C, C-D, D-E, E-F, F-G,
// G-H -> A-C, A-D, A-E, A-F, A-G, A-H, B-D, B-E, B-F, B-G, B-H, C-E, C-F,
// C-G, C-H, D-F, D-G, D-H, E-G, E-H, F-H
// int bridgeLUT[MAX_DUPLICATE] = {1, 1, 3, 5, 10, 15, 21, 28, 36, 45, 55, 66,
// 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300};
// int16_t tempNodes[MAX_NETS][MAX_NODES] = {0};
for (int i = 1; i < numberOfNets; i++) {
if (net[i].numberOfDuplicates == 0) {
continue;
}
// int16_t tempNodes[MAX_NODES];
// Serial.print("net[");
// Serial.print(i);
// Serial.print("] nodes[");
for (int j = 0; j < nodeCount[i]; j++) {
// tempNodes[j] = net[i].nodes[j];
// Serial.print(tempNodes[j]);
// Serial.print(net[i].nodes[j]);
// Serial.print(", ");
}
// Serial.println("]\t\t");
int targetBridgeCount = net[i].numberOfDuplicates;
int skip = 1;
int unique = 0;
int testCounter0 = 0;
int testCounter1 = 1; // nodeCount[i] / 2;
int testBridge[2] = { -1, -1 };
int bridge0 = 0;
int bridge1 = 1;
for (int j = 0; j <= targetBridgeCount; j++) {
if (nodeCount[i] >= 3) {
for (int l = 0; l < MAX_DUPLICATE; l++) {
if (unique == -1) {
bridge1++;
if (bridge1 >= nodeCount[i]) {
bridge0++;
if (bridge0 >= nodeCount[i]) {
bridge0 = 0;
}
bridge1 = bridge0 + 1;
}
unique = 0;
}
if (net[i].nodes[bridge0] == 0 || net[i].nodes[bridge1] == 0) {
break;
}
if (net[i].nodes[bridge0] == net[i].nodes[bridge1]) {
unique = -1;
continue;
}
if (net[i].nodes[bridge0] == net[i].bridges[l][0] &&
net[i].nodes[bridge1] == net[i].bridges[l][1]) {
unique = -1;
continue;
}
if (net[i].nodes[bridge0] == net[i].bridges[l][1] &&
net[i].nodes[bridge1] == net[i].bridges[l][0]) {
unique = -1;
continue;
}
unique = 1;
// Serial.print(net[i].nodes[bridge0]);
// Serial.print("-");
// Serial.print(net[i].nodes[bridge1]);
// Serial.println("]\t\t");
// Serial.print("net[");
break;
}
}
newBridges[i][j][0] = net[i].nodes[bridge0];
newBridges[i][j][1] = net[i].nodes[bridge1];
net[i].bridges[j][0] = newBridges[i][j][0];
net[i].bridges[j][1] = newBridges[i][j][1];
bridge1++;
if (bridge1 >= nodeCount[i]) {
bridge0++;
if (bridge0 >= nodeCount[i]) {
bridge0 = 0;
}
bridge1 = bridge0 + 1;
}
if (newBridges[i][j][0] == newBridges[i][j][1] ||
newBridges[i][j][0] == 0 || newBridges[i][j][1] == 0) {
// Serial.print("skipping ");
// Serial.println(j);
j--;
continue;
} else {
duplicatePathIndex++;
}
}
}
// int maxxed = 0;
int priorities[MAX_NETS] = { 0 };
int maxp = 0;
for (int j = 0; j < MAX_DUPLICATE; j++) {
for (int i = 0; i < numberOfNets; i++) {
priorities[i] = net[i].priority;
if (i < 6 && net[i].priority > maxp) {
maxp = net[i].priority;
}
}
for (int k = 0; k < maxp; k++) {
for (int i = 0; i < 6; i++) {
// for (int p = 0; p < net[i].priority; p++) {
if (net[i].numberOfDuplicates == 0) {
continue;
}
if (newBridges[i][j][0] >= 110 && newBridges[i][j][0] <= 115 ||
newBridges[i][j][1] >= 110 && newBridges[i][j][1] <= 115) {
continue;
}
if (priorities[i] <= 0) {
continue;
}
if (priorities[i] > 0) {
priorities[i]--;
}
if (newBridges[i][j][0] != 0 || newBridges[i][j][1] != 0) {
path[numberOfPaths].net = i;
path[numberOfPaths].node1 = newBridges[i][j][0];
path[numberOfPaths].node2 = newBridges[i][j][1];
path[numberOfPaths].altPathNeeded = false;
path[numberOfPaths].sameChip = false;
path[numberOfPaths].skip = false;
path[numberOfPaths].duplicate = 1;
numberOfPaths++;
if (numberOfPaths >= MAX_BRIDGES - 1) {
// maxxed = 1;
return;
break;
}
}
// }
// Serial.print("\n\r");
}
}
// for (int i = 0; i < 6; i++) {
// priorities[i] = net[i].priority;
// }
for (int i = 5; i < numberOfNets; i++) {
if (net[i].numberOfDuplicates == 0) {
continue;
}
if (newBridges[i][j][0] >= 110 && newBridges[i][j][0] <= 115 ||
newBridges[i][j][1] >= 110 && newBridges[i][j][1] <= 115) {
continue;
}
if (priorities[i] <= 0) {
continue;
}
if (priorities[i] > 0) {
priorities[i]--;
}
if (newBridges[i][j][0] != 0 && newBridges[i][j][1] != 0) {
///
net[i].bridges[bridgeCount[i]][0] = newBridges[i][j][0];
net[i].bridges[bridgeCount[i]][1] = newBridges[i][j][1];
bridgeCount[i]++; ///!why is this incrementing bridgeCount[0]?
path[numberOfPaths].net = i;
path[numberOfPaths].node1 = newBridges[i][j][0];
path[numberOfPaths].node2 = newBridges[i][j][1];
path[numberOfPaths].altPathNeeded = false;
path[numberOfPaths].sameChip = false;
path[numberOfPaths].skip = false;
path[numberOfPaths].duplicate = 1;
numberOfPaths++;
if (numberOfPaths >= MAX_BRIDGES - 1) {
// maxxed = 1;
return;
break;
}
}
// }
// Serial.print("\n\r");
}
}
// Serial.print("done filling unused paths\n\r");
}
int checkForOverlappingPaths() {
int found = 0;
for (int i = 0; i <= numberOfPaths; i++) {
int fchip[4] = { path[i].chip[0], path[i].chip[1], path[i].chip[2],
path[i].chip[3] };
for (int j = 0; j < numberOfPaths; j++) {
if (i == j) {
continue;
}
if (path[i].net == path[j].net) {
continue;
}
int schip[4] = { path[j].chip[0], path[j].chip[1], path[j].chip[2],
path[j].chip[3] };
for (int f = 0; f < 4; f++) {
for (int s = 0; s < 4; s++) {
if (fchip[f] == schip[s] && fchip[f] != -1) {
if (path[i].x[f] == -1 || path[j].x[s] == -1) {
continue;
}
if (path[i].x[f] == path[j].x[s]) {
// if (debugNTCC3) {
Serial.print("Path ");
Serial.print(i);
Serial.print(" and ");
Serial.print(j);
Serial.print(" overlap at x ");
Serial.print(path[i].x[f]);
Serial.print(" on chip ");
Serial.print(chipNumToChar(fchip[f]));
Serial.print(" nets ");
Serial.print(path[i].net);
Serial.print(" and ");
Serial.println(path[j].net);
// printPathsCompact();
// printChipStatus();
// }
// return 1;
found++;
} else if (path[i].y[f] == path[j].y[s]) {
// if (debugNTCC3) {
Serial.print("Path ");
Serial.print(i);
Serial.print(" and ");
Serial.print(j);
Serial.print(" overlap at y ");
Serial.print(path[i].y[f]);
Serial.print(" on chip ");
Serial.print(chipNumToChar(fchip[f]));
Serial.print(" nets ");
Serial.print(path[i].net);
Serial.print(" and ");
Serial.println(path[j].net);
// printPathsCompact();
// printChipStatus();
// }
// return 1;
found++;
}
}
}
}
}
}
return found;
}
void duplicateSFnets(void)
{
// if (debugNTCC2)

View File

@ -13,6 +13,12 @@ extern int numberOfPaths;
extern bool debugNTCC;
extern bool debugNTCC2;
extern int powerPriority;
extern int dacPriority;
extern int powerDuplicates;
extern int dacDuplicates;
extern int pathDuplicates;
extern int numberOfUnconnectablePaths;
extern int unconnectablePaths[10][2];
@ -21,6 +27,10 @@ void clearAllNTCC(void);
void sortPathsByNet(void);
void bridgesToPaths(void);
int checkForOverlappingPaths(void);
void fillUnusedPaths(int duplicatePathsOverride, int duplicatePathsPower,
int duplicatePathsDac);
void findStartAndEndChips(int node1, int node2, int net);
void couldntFindPath(int forcePrint = 0);

File diff suppressed because it is too large Load Diff

View File

@ -22,11 +22,12 @@ enum measuredState
};
int justReadProbe(void);
int voltageSelect(void);
int longShortPress(int pressLength = 500);
int doubleSingleClick(void);
int selectFromLastFound(void);
int selectFromLastFound(int print = 1);
int checkLastFound(int);
void clearLastFound(void);
int probeMode(int pin = 19, int setOrClear = 1);

File diff suppressed because it is too large Load Diff