Keep on fixin' shit

This commit is contained in:
Kevin Santo Cappuccio 2023-10-30 21:12:44 -07:00
parent ede51b0219
commit d52ed2eda4
9 changed files with 205 additions and 105 deletions

View File

@ -191,13 +191,43 @@ void resetArduino (void)
sendPath(lastPath, 0);
}
void sendAllPaths(void) // should we sort them by chip? for now, no
{
for (int i = 0; i < numberOfPaths; i++)
{
if (path[i].skip == true)
{
continue;
}
sendPath(i, 1);
if (debugNTCC2)
{
Serial.print("path ");
Serial.print(i);
Serial.print(" \t");
printPathType(i);
Serial.print(" \n\r");
for (int j = 0; j < 4; j++)
{
printChipNumToChar(path[i].chip[j]);
Serial.print(" x[");
Serial.print(j);
Serial.print("]:");
Serial.print(path[i].x[j]);
Serial.print(" y[");
Serial.print(j);
Serial.print("]:");
Serial.print(path[i].y[j]);
Serial.print(" \t ");
}
Serial.print("\n\n\r");
}
}
}
@ -221,6 +251,7 @@ void sendPath(int i, int setOrClear)
if (path[i].y[chip] == -1 || path[i].x[chip] == -1)
{
//Serial.print("!");
continue;
}
@ -244,11 +275,11 @@ void sendPath(int i, int setOrClear)
// delayMicroseconds(50);
delayMicroseconds(30);
delayMicroseconds(60);
pio_sm_put(pio, sm, chAddress);
delayMicroseconds(60);
delayMicroseconds(100);
//}
}
}

View File

@ -193,9 +193,9 @@
#define ADC2_5V 112
#define ADC3_8V 113
#define GPIO_0 114
#define UART_TX 115
#define UART_RX 116
#define RP_GPIO_0 114
#define RP_UART_RX 116
#define RP_UART_TX 117
#define EMPTY_NET 127

View File

@ -761,7 +761,7 @@ void lightUpNet(int netNumber, int node, int onOff, int brightness2, int hueShif
}
}
}
turnOffSkippedNodes();
/* Serial.print("color: ");
Serial.print(color,HEX);
Serial.print(" r: ");
@ -780,6 +780,21 @@ void lightUpNet(int netNumber, int node, int onOff, int brightness2, int hueShif
// showLEDsCore2 = 1;
}
void turnOffSkippedNodes(void)
{
for (int i = 0; i < numberOfPaths; i++)
{
if (path[i].skip == true)
{
leds.setPixelColor(nodesToPixelMap[path[i].node1], 0);
leds.setPixelColor(nodesToPixelMap[path[i].node2], 0);
}
}
}
struct rgbColor pcbColorCorrect(rgbColor colorToShift)
{

View File

@ -123,6 +123,10 @@ rgbColor HsvToRgb(hsvColor hsv);
void applyBrightness (int brightness);
rgbColor unpackRgb(uint32_t color);
void turnOffSkippedNodes();
uint32_t packRgb(uint8_t r, uint8_t g, uint8_t b);
void startupColors(void);
void rainbowBounce(int wait);

View File

@ -113,7 +113,7 @@ struct chipStatus ch[12] = {
{11,'L',
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}, // x status
{-1,-1,-1,-1,-1,-1,-1,-1}, //y status
{CURRENT_SENSE_MINUS, CURRENT_SENSE_PLUS, ADC0_5V, ADC1_5V, ADC2_5V, ADC3_8V, DAC1_8V, DAC0_5V, t1, t30, b1, b30, NANO_A4, NANO_A5, SUPPLY_5V, GND},
{CURRENT_SENSE_MINUS, CURRENT_SENSE_PLUS, ADC0_5V, ADC1_5V, ADC2_5V, ADC3_8V, DAC1_8V, DAC0_5V, t1, t30, b1, b30, NANO_A4, NANO_A5, SUPPLY_5V, RP_GPIO_0},
{CHIP_A,CHIP_B,CHIP_C,CHIP_D,CHIP_E,CHIP_F,CHIP_G,CHIP_H}}
};

View File

@ -112,8 +112,8 @@ const int duplucateSFnodes[26][4] = { // [] [sf chip1, x pin1, sf chip2, x pin
{CHIP_J,13,CHIP_L,3},
{CHIP_J,14,CHIP_L,14},
{CHIP_I,15,CHIP_J,15},
{CHIP_I,15,CHIP_L,15},
{CHIP_J,15,CHIP_L,15},
//{CHIP_I,15,CHIP_L,15},
///{CHIP_J,15,CHIP_L,15},
{CHIP_K,15,CHIP_L,4},
};
@ -137,7 +137,7 @@ struct pathStruct{
enum nodeType nodeType[3];
bool sameChip;
bool Lchip;
bool doubleHop;
bool skip = false;
};

View File

@ -546,6 +546,7 @@ int checkDoNotIntersectsByNet(int netToCheck1, int netToCheck2) // If you're sea
Serial.print(netToCheck1);
if (debugNM)
Serial.print(" due to Do Not Intersect rules, skipping\n\r");
path[newBridgeIndex].skip = true;
path[newBridgeIndex].net = -1;
return 0;
}
@ -879,10 +880,12 @@ int printNodeOrName(int node) // returns number of characters printed (for tabs)
char same[12] = " ";
const char *definesToChar(int defined) // converts the internally used #defined numbers into human readable strings
{
// Serial.print("defined = ");
//Serial.println(defined);
const char *defNanoToChar[26] = {"D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7", "D8", "D9", "D10", "D11", "D12", "D13", "RESET", "AREF", "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7"};
const char *defSpecialToChar[20] = {"GND", "NOT_DEFINED", "NOT_DEFINED", "3V3", "NOT_DEFINED", "5V", "DAC_0", "DAC_1", "I_POS", "I_NEG", "ADC_0" , "ADC_1" , "ADC_2" , "ADC_3"};
const char *defSpecialToChar[20] = {"GND", "NOT_DEFINED", "NOT_DEFINED", "3V3", "NOT_DEFINED", "5V", "DAC_0", "DAC_1", "I_POS", "I_NEG", "ADC_0" , "ADC_1" , "ADC_2" , "ADC_3", "GPIO_0", "NOT_DEFINED", "UART_Rx", "UART_Tx"};
const char *emptyNet[] = {"EMPTY_NET", "?"};
@ -890,8 +893,9 @@ const char *definesToChar(int defined) // converts the internally used #defined
{
return defNanoToChar[defined - 70];
}
else if (defined >= 100 && defined <= ADC3_8V)
else if (defined >= 100 && defined <= RP_UART_TX)
{
return defSpecialToChar[defined - 100];
}
else if (defined == EMPTY_NET)

View File

@ -31,6 +31,7 @@ bool debugNTCC = EEPROM.read(DEBUG_NETTOCHIPCONNECTIONSADDRESS);
bool debugNTCC2 = EEPROM.read(DEBUG_NETTOCHIPCONNECTIONSALTADDRESS);
bool debugNTCC3 = false;
int pathIndex = 0;
void clearAllNTCC(void)
@ -74,6 +75,7 @@ void clearAllNTCC(void)
path[i].altPathNeeded = false;
path[i].Lchip = false;
path[i].sameChip = false;
path[i].skip = false;
for (int j = 0; j < 4; j++)
{
@ -278,7 +280,7 @@ void bridgesToPaths(void)
resolveUncommittedHops();
if (debugNTCC2)
{
delay(10);
// delay(10);
printPathsCompact();
printChipStatus();
@ -298,7 +300,7 @@ void commitPaths(void)
if (debugNTCC == true)
{
Serial.print("path[");
Serial.print("\n\rpath[");
Serial.print(i);
Serial.print("] net: ");
Serial.print(path[i].net);
@ -307,13 +309,14 @@ void commitPaths(void)
printNodeOrName(path[i].node1);
Serial.print(" to ");
printNodeOrName(path[i].node2);
// Serial.print("\n\r");
}
if (path[i].altPathNeeded == true)
{
if (debugNTCC2 == true)
{
Serial.println("\taltPathNeeded flag already set\n\r");
}
// if (debugNTCC2 == true)
// {
// Serial.println("\taltPathNeeded flag already set\n\r");
// }
continue;
}
@ -470,7 +473,7 @@ void commitPaths(void)
if (path[i].chip[0] != CHIP_L && path[i].chip[1] == CHIP_L) // if theyre both chip L we'll deal with it differently
{
// Serial.print("\tBBtoCHIP L ");
// Serial.print("\tBBtoCHIP L ");
int yMapBBc0 = 0; // y 0 is always connected to chip L
int xMapChipL = xMapForNode(path[i].node2, CHIP_L);
@ -564,9 +567,9 @@ void commitPaths(void)
ch[path[i].chip[1]].yStatus[path[i].chip[0]] = path[i].net;
if (debugNTCC2 == true)
if (debugNTCC == true)
{
//delay(10);
// delay(10);
Serial.print(" \tchip[0]: ");
Serial.print(chipNumToChar(path[i].chip[0]));
@ -603,7 +606,7 @@ void commitPaths(void)
if (debugNTCC2)
{
//delay(10);
// delay(10);
Serial.print("\tno direct path, setting altPathNeeded flag (BBtoSF)");
}
break;
@ -668,10 +671,10 @@ void commitPaths(void)
}
// case BBtoNANO:
}
if (debugNTCC2)
{
Serial.println("\n\r");
}
// if (debugNTCC2)
// {
// Serial.println("\n\r");
// }
}
duplicateSFnets();
resolveAltPaths();
@ -736,7 +739,7 @@ void resolveAltPaths(void)
if (path[i].Lchip == true)
{
Serial.print("Lchip");
//Serial.print("Lchip");
if (ch[CHIP_L].yStatus[bb] == -1 || ch[CHIP_L].yStatus[bb] == path[i].net) /////////
{
@ -1418,20 +1421,20 @@ void resolveAltPaths(void)
{
if (debugNTCC2)
{
Serial.println("NANOtoNANO");
Serial.println("NANOtoNANO");
}
int foundHop = 0;
int giveUpOnL = 0;
int swapped = 0;
if (path[i].Lchip == true)
if (path[i].Lchip == true) //TODO check if the same net is connected to another SF chip and use that instead
{
int sfChip1 = path[i].chip[0];
int sfChip2 = path[i].chip[1];
if (((sfChip1 == CHIP_L && sfChip2 >= CHIP_I) || (sfChip2 == CHIP_L && sfChip1 >= CHIP_I)) && sfChip1 != sfChip2)
{
if (debugNTCC2)
if (debugNTCC2)
{
Serial.println("L to Special Function via ADCs");
Serial.println("\n\n\rL to Special Function via ADCs\n\r");
}
int whichIsL = 0;
int whichIsSF = 1;
@ -1445,20 +1448,37 @@ void resolveAltPaths(void)
whichIsL = 1;
whichIsSF = 0;
}
//Serial.println(whichIsL);
// Serial.println(whichIsL);
int whichADC = path[i].chip[whichIsSF] - CHIP_I;
if (debugNTCC2)
if (debugNTCC2)
{
Serial.println(whichADC);
Serial.println("sfChip1: ");
Serial.println(sfChip1);
Serial.println("sfChip2: ");
Serial.println(sfChip2);
Serial.println(whichADC);
Serial.println("sfChip1: ");
Serial.println(sfChip1);
Serial.println("sfChip2: ");
Serial.println(sfChip2);
Serial.println(" ");
}
if (ch[CHIP_L].xStatus[whichADC + 2] != -1 && ch[CHIP_L].xStatus[whichADC + 2] != path[i].net)
{
Serial.print("\n\rCouldn't find a path for ");
printNodeOrName(path[i].node1);
Serial.print(" to ");
printNodeOrName(path[i].node2);
Serial.println(" ");
path[i].skip = true;
path[i].chip[0] = -1;
path[i].chip[1] = -1;
path[i].chip[2] = -1;
path[i].chip[3] = -1;
//numberOfPaths--;
// break;
// continue;
}
path[i].x[whichIsL] = whichADC + 2;
path[i].y[whichIsL] = -2;
@ -1466,31 +1486,35 @@ void resolveAltPaths(void)
if (whichIsSF == 0)
{
path[i].x[whichIsSF] = xMapForNode(ADC0_5V + whichADC, sfChip1);
} else {
//path[i].x[whichIsL] = xMapForNode(ADC0_5V + whichADC, sfChip2);
}
else
{
path[i].x[whichIsSF] = xMapForNode(ADC0_5V + whichADC, sfChip2);
//path[i].x[whichIsL] = xMapForNode(ADC0_5V + whichADC, sfChip1);
}
if (debugNTCC2)
{
if (debugNTCC2)
{
Serial.println(path[i].x[whichIsSF]);
Serial.print("path[i].node1; ");
Serial.println(path[i].node1);
Serial.print("path[i].node2; ");
Serial.println(path[i].node2);
Serial.print("xMapForNode(path[i].node1, sfChip1); ");
Serial.println(xMapForNode(path[i].node1, sfChip1));
Serial.print("xMapForNode(path[i].node2, sfChip2); ");
Serial.println(xMapForNode(path[i].node2, sfChip2));
}
Serial.println(path[i].x[whichIsSF]);
Serial.print("path[i].node1; ");
Serial.println(path[i].node1);
Serial.print("path[i].node2; ");
Serial.println(path[i].node2);
Serial.print("xMapForNode(path[i].node1, sfChip1); ");
Serial.println(xMapForNode(path[i].node1, sfChip1));
Serial.print("xMapForNode(path[i].node2, sfChip2); ");
Serial.println(xMapForNode(path[i].node2, sfChip2));
}
path[i].y[whichIsSF] = -2;
if (whichIsL == 0)
if (whichIsL == 0) //l is the first chip
{
path[i].x[3] = xMapForNode(path[i].node1, sfChip2);
path[i].x[2] = xMapForNode(path[i].node2, sfChip1);
path[i].chip[3] = sfChip1;
path[i].chip[2] = sfChip2;
path[i].x[3] = xMapForNode(path[i].node1, sfChip2);
path[i].chip[2] = sfChip1;
path[i].chip[3] = sfChip2;
path[i].y[2] = -2;
path[i].y[3] = -2;
@ -1501,64 +1525,89 @@ void resolveAltPaths(void)
ch[sfChip2].xStatus[path[i].x[whichIsSF]] = path[i].net;
ch[sfChip2].xStatus[xMapForNode(path[i].node2, sfChip2)] = path[i].net;
ch[sfChip1].xStatus[xMapForNode(path[i].node1, sfChip1)] = path[i].net;
}
else
else // l is the second chip
{
path[i].x[3] = xMapForNode(path[i].node1, sfChip1);
path[i].x[2] = xMapForNode(path[i].node2, sfChip2);
path[i].chip[3] = sfChip1;
path[i].chip[2] = sfChip2;
path[i].x[3] = xMapForNode(path[i].node1, sfChip1);
path[i].x[2] = xMapForNode(path[i].node2, sfChip2);
path[i].y[2] = -2;
path[i].y[3] = -2;
ch[sfChip1].xStatus[path[i].x[whichIsSF]] = path[i].net;
ch[sfChip1].xStatus[xMapForNode(path[i].node1, sfChip1)] = path[i].net;
ch[sfChip2].xStatus[xMapForNode(path[i].node2, sfChip2)] = path[i].net;
ch[sfChip2].xStatus[path[i].x[whichIsL]] = path[i].net;
ch[sfChip2].xStatus[whichADC + 2] = path[i].net;
ch[sfChip1].xStatus[path[i].x[whichIsSF]] = path[i].net;
ch[sfChip1].xStatus[xMapForNode(path[i].node1, sfChip1)] = path[i].net;
ch[sfChip2].xStatus[xMapForNode(path[i].node2, sfChip2)] = path[i].net;
}
//foundPath = 1;
path[i].altPathNeeded = false;
//path[i].sameChip = true;
// path[i].sameChip = true;
//resolveUncommittedHops();
// resolveUncommittedHops();
for (int ySearch = 0; ySearch < 8; ySearch++)
{
if (ch[sfChip1].yStatus[ySearch] == path[i].net || ch[sfChip1].yStatus[ySearch] == -1)
if ( ch[sfChip1].yStatus[ySearch] == -1 || ch[sfChip1].yStatus[ySearch] == path[i].net)
{
ch[sfChip1].yStatus[ySearch] = path[i].net;
if (whichIsL == 0)
{
path[i].y[1] = ySearch;
path[i].y[2] = ySearch;
}
else
{
path[i].y[0] = ySearch;
path[i].y[3] = 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;
break;
}
}
for (int ySearch = 0; ySearch < 8; ySearch++)
{
if (ch[sfChip2].yStatus[ySearch] == path[i].net || ch[sfChip2].yStatus[ySearch] == -1)
if ( ch[sfChip2].yStatus[ySearch] == -1 || ch[sfChip2].yStatus[ySearch] == path[i].net)
{
ch[sfChip2].yStatus[ySearch] = path[i].net;
path[i].y[whichIsSF] = ySearch;
path[i].y[whichIsSF+2] = ySearch;
if (whichIsL == 0)
{
path[i].y[0] = ySearch;
path[i].y[3] = ySearch;
}
else
{
path[i].y[1] = ySearch;
path[i].y[2] = ySearch;
}
// path[i].y[whichIsSF] = ySearch;
// path[i].y[whichIsSF + 2] = ySearch;
break;
}
}
}
else
{
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(bb);
// Serial.println(bb);
// Serial.print("ERROR: ");
//Serial.print("ERROR: ");
if (sfChip1 == CHIP_L && sfChip2 == CHIP_L)
{
@ -1647,8 +1696,9 @@ void resolveAltPaths(void)
if (giveUpOnL == 0)
{
ch[CHIP_L].yStatus[bb] = path[i].net;
path[i].y[2] = 0;
path[i].y[3] = 0;
path[i].y[2] = -1;
path[i].y[3] = -1;
break;
}
else
{
@ -1821,32 +1871,32 @@ void resolveUncommittedHops(void)
if (pathsWithSameXChips[i] == 1 || pathsWithSameYChips[i] == 1)
{
if (debugNTCC2)
if (debugNTCC3)
{
Serial.print(i);
Serial.print("\tsame chips: ");
}
for (int chip = 0; chip < 4; chip++)
{
if (debugNTCC2)
if (debugNTCC3)
{
Serial.print(chipNumToChar(sameChips[0][chip]));
Serial.print(", ");
}
}
if (debugNTCC2)
if (debugNTCC3)
{
Serial.print("\t");
}
for (int chip = 0; chip < 4; chip++)
{
if (debugNTCC2)
if (debugNTCC3)
{
Serial.print(chipNumToChar(sameChips[1][chip]));
Serial.print(", ");
}
}
if (debugNTCC2)
if (debugNTCC3)
{
Serial.println(" ");
}
@ -1907,7 +1957,7 @@ void resolveUncommittedHops(void)
{
continue;
}
if (debugNTCC2)
if (debugNTCC3)
{
Serial.print("freeXidx: ");
Serial.print(freeXidx);
@ -1957,7 +2007,7 @@ void resolveUncommittedHops(void)
otherChipXStatus = ch[otherChip].xStatus[otherChipX];
if (debugNTCC2)
if (debugNTCC3)
{
Serial.print("Checking free X connections on the bounce chip for freeness\n\r");
@ -1997,10 +2047,6 @@ void resolveUncommittedHops(void)
ch[thisChip].xStatus[freeX] = path[i].net;
}
}
if (debugNTCC2)
{
//printChipStatus();
}
}
}
}
@ -2055,11 +2101,6 @@ void resolveUncommittedHops(void)
{
}
}
if (debugNTCC2)
{
// printPathsCompact();
}
}
void swapDuplicateNode(int pathIndex)
@ -2446,6 +2487,7 @@ void assignPathType(int pathIndex)
if ((path[pathIndex].node1 == 1 || path[pathIndex].node1 == 30 || path[pathIndex].node1 == 31 || path[pathIndex].node1 == 60) || path[pathIndex].chip[0] == CHIP_L)
{
// Serial.print("\n\n\rthis should be a bb to sf connection\n\n\n\r ");
path[pathIndex].altPathNeeded = true;
swapNodes(pathIndex);
path[pathIndex].Lchip = true;
@ -2460,7 +2502,7 @@ void assignPathType(int pathIndex)
{
path[pathIndex].nodeType[0] = NANO;
}
else if (path[pathIndex].node1 >= GND && path[pathIndex].node1 <= ADC3_8V)
else if (path[pathIndex].node1 >= GND && path[pathIndex].node1 <= EMPTY_NET)
{
path[pathIndex].nodeType[0] = SF;
}
@ -2468,6 +2510,7 @@ void assignPathType(int pathIndex)
if ((path[pathIndex].node2 == 1 || path[pathIndex].node2 == 30 || path[pathIndex].node2 == 31 || path[pathIndex].node2 == 60) || path[pathIndex].chip[1] == CHIP_L)
{
// Serial.print("\n\n\rthis should be a bb to sf connection 2\n\n\n\r ");
path[pathIndex].altPathNeeded = true;
path[pathIndex].Lchip = true;
path[pathIndex].nodeType[1] = SF;
}
@ -2479,7 +2522,7 @@ void assignPathType(int pathIndex)
{
path[pathIndex].nodeType[1] = NANO;
}
else if (path[pathIndex].node2 >= GND && path[pathIndex].node2 <= ADC3_8V)
else if (path[pathIndex].node2 >= GND && path[pathIndex].node2 <= EMPTY_NET)
{
path[pathIndex].nodeType[1] = SF;
}
@ -2524,7 +2567,7 @@ void assignPathType(int pathIndex)
{
path[pathIndex].pathType = NANOtoNANO;
}
if (debugNTCC)
if (debugNTCC2)
{
Serial.print("Path ");
Serial.print(pathIndex);
@ -2934,11 +2977,11 @@ void printPathArray(void) // this also prints candidates and x y
}
tabs += Serial.println("\n\n\r");
// Serial.print(tabs);
// for (int i = 0; i < 24 - (tabs); i++)
//{
// Serial.print(" ");
// }
Serial.print(tabs);
for (int i = 0; i < 24 - (tabs); i++)
{
Serial.print(" ");
}
tabs = 0;
}
}

View File

@ -157,10 +157,13 @@ menu:
digitalWrite(RESETPIN, HIGH);
clearAllNTCC();
delay(10);
delay(5);
//showLEDsCore2 = 1;
digitalWrite(RESETPIN, LOW);
//delay(5);
//resetArduino();
sendAllPathsCore2 = 1;
timer = millis();
#ifdef FSSTUFF
@ -190,7 +193,7 @@ sendAllPathsCore2 = 1;
}
resetArduino();
break;
case '\n':