started pathfinding logic

This commit is contained in:
Kevin Santo Cappuccio 2023-05-31 16:00:30 -07:00
parent 95da735079
commit 9f8499d4b0
15 changed files with 1873 additions and 585 deletions

View File

@ -8,8 +8,10 @@
"vector": "cpp",
"string_view": "cpp",
"initializer_list": "cpp",
"ranges": "cpp"
"ranges": "cpp",
"cstring": "cpp"
},
"cortex-debug.registerUseNaturalFormat": false
"cortex-debug.registerUseNaturalFormat": false,
"C_Cpp.errorSquiggles": "disabled"
}

View File

@ -1,22 +1,32 @@
bridges
{
1-2,
3-4,
5-6,
7-8,
30-4,
50-60,
17-38,
9-10,
11-12,
12-13,
2-3,
10-11,
16-12,
D13-D1,
D0-1,
A1-5,
D13-A7,
AREF-A1,
20-33,
10-41,
D10-D11,
D11-D12,
1-11,
0-7,
D2-33,
D9,18,
D5-44,
A2-33,
}
special functions
special functions //these are connected first so DNIs will be applied to all the nets
{
1-GND,
19-GND,
11-SUPPLY_5V,
D10-SUPPLY_3V3,
6-I_P,
I_P-I_N,
}

View File

@ -17,5 +17,5 @@ board_build.filesystem_size = 0.5m
[env:pico]
board = pico
lib_deps =
bblanchon/ArduinoJson@^6.21.2
bblanchon/StreamUtils@^1.7.3
powerbroker2/SafeString@^4.1.27
adafruit/Adafruit NeoPixel@^1.11.0

View File

@ -0,0 +1,257 @@
#include "FileParsing.h"
#include <Arduino.h>
#include "LittleFS.h"
#include "MatrixStateRP2040.h"
#include "SafeString.h"
#include "NetManager.h"
static bool debugFP;
static bool debugFPtime;
createSafeString(nodeFileString, 1200);
createSafeString(bridgeString, 800);
createSafeString(specialFunctionsString, 400);
File nodeFile;
unsigned long timeToFP = 0;
void openNodeFile()
{
timeToFP = millis();
if(DEBUG_FILEPARSING == 1) debugFP = true; //yeah we're using runtime debug flags so it can be toggled from commands
else debugFP = false;
if(TIME_FILEPARSING == 1) debugFPtime = true;
else debugFPtime = false;
nodeFile = LittleFS.open("nodeFile.txt", "r");
if (!nodeFile)
{
if(debugFP)Serial.println("Failed to open nodeFile");
return;
}
else
{
if(debugFP)Serial.println("\n\ropened nodeFile.txt\n\n\rloading bridges from file\n\r");
}
nodeFileString.read(nodeFile);
nodeFile.close();
splitStringToFields();
// parseStringToBridges();
}
void splitStringToFields()
{
int openBraceIndex = 0;
int closeBraceIndex = 0;
if(debugFP)Serial.println("\n\rraw input file\n\r");
if(debugFP)Serial.println(nodeFileString);
if(debugFP)Serial.println("\n\rsplitting and cleaning up string\n\r");
if(debugFP)Serial.println("_");
openBraceIndex = nodeFileString.indexOf("{");
closeBraceIndex = nodeFileString.indexOf("}");
nodeFileString.substring(bridgeString ,openBraceIndex + 1, closeBraceIndex);
bridgeString.trim();
if(debugFP)Serial.println(bridgeString);
if(debugFP)Serial.println("^\n\r");
nodeFileString.remove(0, closeBraceIndex + 1);
nodeFileString.trim();
openBraceIndex = nodeFileString.indexOf("{");
closeBraceIndex = nodeFileString.indexOf("}");
nodeFileString.substring(specialFunctionsString, openBraceIndex + 1, closeBraceIndex);
specialFunctionsString.trim();
if(debugFP)Serial.println("_");
if(debugFP)Serial.println(specialFunctionsString);
if(debugFP)Serial.println("^\n\r");
replaceSFNamesWithDefinedInts();
}
void replaceSFNamesWithDefinedInts(void)
{
if(debugFP)Serial.println("replacing special function names with defined ints\n\r");
specialFunctionsString.replace("GND", "100");
specialFunctionsString.replace("SUPPLY_5V", "105");
specialFunctionsString.replace("SUPPLY_3V3", "103");
specialFunctionsString.replace("DAC0_5V", "106");
specialFunctionsString.replace("DAC1_8V", "107");
specialFunctionsString.replace("I_N", "109");
specialFunctionsString.replace("I_P", "108");
specialFunctionsString.replace("EMPTY_NET", "127");
if(debugFP)Serial.println(specialFunctionsString);
if(debugFP)Serial.println("\n\n\r");
replaceNanoNamesWithDefinedInts();
}
void replaceNanoNamesWithDefinedInts(void)//for dome reason Arduino's String wasn't replacing like 1 or 2 of the names, so I'm using SafeString now and it works
{
if(debugFP)Serial.println("replacing special function names with defined ints\n\r");
char nanoName[5];
itoa(NANO_D10, nanoName, 10);
specialFunctionsString.replace("D10", nanoName);
bridgeString.replace("D10", nanoName);
itoa(NANO_D11, nanoName, 10);
specialFunctionsString.replace("D11", nanoName);
bridgeString.replace("D11", nanoName);
itoa(NANO_D12, nanoName, 10);
specialFunctionsString.replace("D12", nanoName);
bridgeString.replace("D12", nanoName);
itoa(NANO_D13, nanoName, 10);
specialFunctionsString.replace("D13", nanoName);
bridgeString.replace("D13", nanoName);
itoa(NANO_D0, nanoName, 10);
specialFunctionsString.replace("D0", nanoName);
bridgeString.replace("D0", nanoName);
itoa(NANO_D1, nanoName, 10);
specialFunctionsString.replace("D1", nanoName);
bridgeString.replace("D1", nanoName);
itoa(NANO_D2, nanoName, 10);
specialFunctionsString.replace("D2", nanoName);
bridgeString.replace("D2", nanoName);
itoa(NANO_D3, nanoName, 10);
specialFunctionsString.replace("D3", nanoName);
bridgeString.replace("D3", nanoName);
itoa(NANO_D4, nanoName, 10);
specialFunctionsString.replace("D4", nanoName);
bridgeString.replace("D4", nanoName);
itoa(NANO_D5, nanoName, 10);
specialFunctionsString.replace("D5", nanoName);
bridgeString.replace("D5", nanoName);
itoa(NANO_D6, nanoName, 10);
specialFunctionsString.replace("D6", nanoName);
bridgeString.replace("D6", nanoName);
itoa(NANO_D7, nanoName, 10);
specialFunctionsString.replace("D7", nanoName);
bridgeString.replace("D7", nanoName);
itoa(NANO_D8, nanoName, 10);
specialFunctionsString.replace("D8", nanoName);
bridgeString.replace("D8", nanoName);
itoa(NANO_D9, nanoName, 10);
specialFunctionsString.replace("D9", nanoName);
bridgeString.replace("D9", nanoName);
itoa(NANO_RESET, nanoName, 10);
specialFunctionsString.replace("RESET", nanoName);
bridgeString.replace("RESET", nanoName);
itoa(NANO_AREF, nanoName, 10);
specialFunctionsString.replace("AREF", nanoName);
bridgeString.replace("AREF", nanoName);
itoa(NANO_A0, nanoName, 10);
specialFunctionsString.replace("A0", nanoName);
bridgeString.replace("A0", nanoName);
itoa(NANO_A1, nanoName, 10);
specialFunctionsString.replace("A1", nanoName);
bridgeString.replace("A1", nanoName);
itoa(NANO_A2, nanoName, 10);
specialFunctionsString.replace("A2", nanoName);
bridgeString.replace("A2", nanoName);
itoa(NANO_A3, nanoName, 10);
specialFunctionsString.replace("A3", nanoName);
bridgeString.replace("A3", nanoName);
itoa(NANO_A4, nanoName, 10);
specialFunctionsString.replace("A4", nanoName);
bridgeString.replace("A4", nanoName);
itoa(NANO_A5, nanoName, 10);
specialFunctionsString.replace("A5", nanoName);
bridgeString.replace("A5", nanoName);
itoa(NANO_A6, nanoName, 10);
specialFunctionsString.replace("A6", nanoName);
bridgeString.replace("A6", nanoName);
itoa(NANO_A7, nanoName, 10);
specialFunctionsString.replace("A7", nanoName);
bridgeString.replace("A7", nanoName);
if(debugFP)Serial.println(bridgeString);
if(debugFP)Serial.println(specialFunctionsString);
if(debugFP)Serial.println("\n\n\r");
parseStringToBridges();
}
void parseStringToBridges(void)
{
int bridgeStringLength = bridgeString.length() - 1;
int specialFunctionsStringLength = specialFunctionsString.length() - 1;
int readLength = 0;
int readTotal = specialFunctionsStringLength;
newBridgeLength = 0;
newBridgeIndex = 0;
if(debugFP)Serial.println("parsing bridges into array\n\r");
for (int i = 0; i <= specialFunctionsStringLength; i += readLength)
{
sscanf(specialFunctionsString.c_str(), "%i-%i,\n\r%n", &path[newBridgeIndex].node1, &path[newBridgeIndex].node2, &readLength);
specialFunctionsString.remove(0, readLength);
readTotal -= readLength;
// if(debugFP)Serial.print(newBridge[newBridgeIndex][0]);
// if(debugFP)Serial.print("-");
// if(debugFP)Serial.println(newBridge[newBridgeIndex][1]);
newBridgeLength++;
newBridgeIndex++;
// delay(500);
}
readTotal = bridgeStringLength;
for (int i = 0; i <= bridgeStringLength; i += readLength)
{
sscanf(bridgeString.c_str(), "%i-%i,\n\r%n", &path[newBridgeIndex].node1, &path[newBridgeIndex].node2, &readLength);
bridgeString.remove(0, readLength);
readTotal -= readLength;
// if(debugFP)Serial.print(newBridge[newBridgeIndex][0]);
// if(debugFP)Serial.print("-");
// if(debugFP)Serial.println(newBridge[newBridgeIndex][1]);
newBridgeLength++;
newBridgeIndex++;
// delay(500);
}
newBridgeIndex = 0;
if(debugFP) for (int i = 0; i < newBridgeLength; i++)
{
Serial.print("[");
Serial.print(path[newBridgeIndex].node1);
Serial.print("-");
Serial.print(path[newBridgeIndex].node2);
Serial.print("],");
newBridgeIndex++;
}
if(debugFP)Serial.print("\n\rbridge pairs = ");
if(debugFP)Serial.println(newBridgeLength);
nodeFileString.clear();
// if(debugFP)Serial.println(nodeFileString);
timeToFP = millis() - timeToFP;
if(debugFP)Serial.print("\n\rtook ");
if(debugFPtime)Serial.print(timeToFP);
if(debugFPtime)Serial.println("ms to open and parse file\n\r");
}

View File

@ -0,0 +1,20 @@
#ifndef FILEPARSING_H
#define FILEPARSING_H
//this just opens the file, takes out all the bullshit, and then populates the newBridge array
void openNodeFile();
void splitStringToFields();
void replaceSFNamesWithDefinedInts();
void replaceNanoNamesWithDefinedInts();
void parseStringToBridges();
#endif

View File

@ -1,5 +1,10 @@
#define DEBUG_FILEPARSING 1
#define TIME_FILEPARSING 1
#define DEBUG_NETMANAGER 1
#define TIME_NETMANAGER 1
#define MAX_NETS 64
#define MAX_BRIDGES 255
#define MAX_NODES 64
@ -54,7 +59,10 @@
#define ADC2_5V 28
#define ADC3_8V 29
#define T_RAIL_POS 31
#define T_RAIL_NEG 0
#define B_RAIL_POS 63
#define B_RAIL_NEG 32
#define t1 1

View File

@ -0,0 +1,46 @@
#include "LEDs.h"
#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel leds(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
void initLEDs(void)
{
leds.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
leds.show(); // Turn OFF all pixels ASAP
leds.setBrightness(BRIGHTNESS);
}
void colorWipe(uint32_t color, int wait) {
for(int i=0; i<leds.numPixels(); i++) { // For each pixel in strip...
leds.setPixelColor(i, color); // Set pixel's color (in RAM)
leds.show(); // Update strip to match
delay(wait); // Pause for a moment
}
}
void rainbowy(int saturation, int brightness, int wait) {
for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) {
// strip.rainbow() can take a single argument (first pixel hue) or
// optionally a few extras: number of rainbow repetitions (default 1),
// saturation and value (brightness) (both 0-255, similar to the
// ColorHSV() function, default 255), and a true/false flag for whether
// to apply gamma correction to provide 'truer' colors (default true).
leds.rainbow(firstPixelHue, 1, saturation, 220, true);
// Above line is equivalent to:
// strip.rainbow(firstPixelHue, 1, 255, 255, true);
leds.show(); // Update strip with new contents
delay(wait); // Pause for a moment
}
}

39
JumperlessNano/src/LEDs.h Normal file
View File

@ -0,0 +1,39 @@
#ifndef LEDS_H
#define LEDS_H
#include <Arduino.h>
#include "JumperlessDefinesRP2040.h"
#include "Adafruit_NeoPixel.h"
#define LED_PIN 25
#define LED_COUNT 80
#define BRIGHTNESS 50
extern Adafruit_NeoPixel leds;
const int bbPixelToNodesMap[62] = { 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,
32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61};
const int railsToPixelMap[4][5] = {{71,74,75,78,79},//top positive rail
{72,73,76,77,80},//top negative rail
{70,67,66,63,62},//bottom positive rail
{69,68,65,64,61}};//bottom negative rail
const int pixelsToRails[20] = {B_RAIL_NEG, B_RAIL_POS, B_RAIL_POS, B_RAIL_NEG, B_RAIL_NEG, B_RAIL_POS, B_RAIL_POS, B_RAIL_NEG, B_RAIL_NEG, B_RAIL_POS,
T_RAIL_POS, T_RAIL_NEG, T_RAIL_NEG, T_RAIL_POS, T_RAIL_POS, T_RAIL_NEG, T_RAIL_NEG, T_RAIL_POS, T_RAIL_POS, T_RAIL_NEG};
void initLEDs(void);
void colorWipe(uint32_t color, int wait);
void rainbowy(int ,int, int wait);
#endif

View File

@ -17,8 +17,6 @@ struct netStruct net[MAX_NETS] = { //these are the special function nets that wi
{ 5 ,"DAC 1\t" ,{DAC1_8V} ,{{}} ,DAC1_8V ,{} ,{GND,SUPPLY_5V,SUPPLY_3V3,DAC0_5V} , 1},
{ 6 ,"I Sense +" ,{CURRENT_SENSE_PLUS} ,{{}} ,CURRENT_SENSE_PLUS ,{} ,{CURRENT_SENSE_MINUS} , 2},
{ 7 ,"I Sense -" ,{CURRENT_SENSE_MINUS} ,{{}} ,CURRENT_SENSE_MINUS ,{} ,{CURRENT_SENSE_PLUS} , 2},
//{ 8 ,"Net 8" ,{4,2,9,30,40,22,3} ,{{}} ,-1 ,{} ,{} , 0},
//{ 9 ,"Net 9" ,{5,7,33,23,21,8,14} ,{{}} ,-1 ,{} ,{} , 0},
};
char *netNameConstants[MAX_NETS] = {(char*)"Net 0",(char*)"Net 1",(char*)"Net 2",(char*)"Net 3",(char*)"Net 4",(char*)"Net 5",(char*)"Net 6",(char*)"Net 7",(char*)"Net 8",(char*)"Net 9",(char*)"Net 10",(char*)"Net 11",(char*)"Net 12",(char*)"Net 13",(char*)"Net 14",(char*)"Net 15",(char*)"Net 16",(char*)"Net 17",(char*)"Net 18",(char*)"Net 19",(char*)"Net 20",(char*)"Net 21",(char*)"Net 22",(char*)"Net 23",(char*)"Net 24",(char*)"Net 25",(char*)"Net 26",(char*)"Net 27",(char*)"Net 28",(char*)"Net 29",(char*)"Net 30",(char*)"Net 31",(char*)"Net 32",(char*)"Net 33",(char*)"Net 34",(char*)"Net 35",(char*)"Net 36",(char*)"Net 37",(char*)"Net 38",(char*)"Net 39",(char*)"Net 40",(char*)"Net 41",(char*)"Net 42",(char*)"Net 43",(char*)"Net 44",(char*)"Net 45",(char*)"Net 46",(char*)"Net 47",(char*)"Net 48",(char*)"Net 49",(char*)"Net 50",(char*)"Net 51",(char*)"Net 52",(char*)"Net 53",(char*)"Net 54",(char*)"Net 55",(char*)"Net 56",(char*)"Net 57",(char*)"Net 58",(char*)"Net 59",(char*)"Net 60",(char*)"Net 61",(char*)"Net 62"};//,{"Net 63",(char*)"Net 64",(char*)"Net 65",(char*)"Net 66",(char*)"Net 67",(char*)"Net 68",(char*)"Net 69",(char*)"Net 70",(char*)"Net 71",(char*)"Net 72",(char*)"Net 73",(char*)"Net 74",(char*)"Net 75",(char*)"Net 76",(char*)"Net 77",(char*)"Net 78",(char*)"Net 79",(char*)"Net 80",(char*)"Net 81",(char*)"Net 82",(char*)"Net 83",(char*)"Net 84",(char*)"Net 85",(char*)"Net 86",(char*)"Net 87",(char*)"Net 88",(char*)"Net 89",(char*)"Net 90",(char*)"Net 91",(char*)"Net 92",(char*)"Net 93",(char*)"Net 94",(char*)"Net 95",(char*)"Net 96",(char*)"Net 97",(char*)"Net 98",(char*)"Net 99",(char*)"Net 100",(char*)"Net 101",(char*)"Net 102",(char*)"Net 103",(char*)"Net 104",(char*)"Net 105",(char*)"Net 106",(char*)"Net 107",(char*)"Net 108",(char*)"Net 109",(char*)"Net 110",(char*)"Net 111",(char*)"Net 112",(char*)"Net 113",(char*)"Net 114",(char*)"Net 115",(char*)"Net 116",(char*)"Net 117",(char*)"Net 118",(char*)"Net 119",(char*)"Net 120",(char*)"Net 121",(char*)"Net 122",(char*)"Net 123",(char*)"Net 124",(char*)"Net 125",(char*)"Net 126",(char*)"Net 127"}};
@ -100,34 +98,43 @@ struct chipStatus ch[12] = {
enum nanoPinsToIndex { NANO_PIN_D0 , NANO_PIN_D1 , NANO_PIN_D2 , NANO_PIN_D3 , NANO_PIN_D4 , NANO_PIN_D5 , NANO_PIN_D6 , NANO_PIN_D7 , NANO_PIN_D8 , NANO_PIN_D9 , NANO_PIN_D10 , NANO_PIN_D11 , NANO_PIN_D12 , NANO_PIN_D13 , NANO_PIN_RST , NANO_PIN_REF , NANO_PIN_A0 , NANO_PIN_A1 , NANO_PIN_A2 , NANO_PIN_A3 , NANO_PIN_A4 , NANO_PIN_A5 , NANO_PIN_A6 , NANO_PIN_A7 };
extern struct nanoStatus nano;
char same[12];
const char* definesToChar (int defined) //converts the internally used #defined numbers into human readable strings
{
struct nanoStatus nano = { //there's only one of these so ill declare and initalize together unlike above
//all these arrays should line up (both by index and visually) so one index will give you all this data
itoa(defined,same,10);
const char *defNanoToChar[26] = {"NANO_D0", "NANO_D1", "NANO_D2", "NANO_D3", "NANO_D4", "NANO_D5", "NANO_D6", "NANO_D7", "NANO_D8", "NANO_D9", "NANO_D10", "NANO_D11", "NANO_D12", "NANO_D13", "NANO_RESET", "NANO_AREF", "NANO_A0", "NANO_A1", "NANO_A2", "NANO_A3", "NANO_A4", "NANO_A5", "NANO_A6", "NANO_A7"};
const char *defSpecialToChar[12] = {"GND","NOT_DEFINED","NOT_DEFINED","3V3","NOT_DEFINED","5V","DAC_0","DAC_1","I_POS","I_NEG"};
const char *emptyNet[] = {"EMPTY_NET", "?"};
// | | | | | | | | | | | | | | | | | | | | | | | | |
{ " D0", " D1", " D2", " D3", " D4", " D5", " D6", " D7", " D8", " D9", "D10", "D11", "D12", "D13", "RST", "REF", " A0", " A1", " A2", " A3", " A4", " A5", " A6", " A7"},// String with readable name //padded to 3 chars (space comes before chars)
// | | | | | | | | | | | | | | | | | | | | | | | | |
{ NANO_D0, NANO_D1, NANO_D2, NANO_D3, NANO_D4, NANO_D5, NANO_D6, NANO_D7, NANO_D8, NANO_D9, NANO_D10, NANO_D11, NANO_D12, NANO_D13, NANO_RESET, NANO_AREF, NANO_A0, NANO_A1, NANO_A2, NANO_A3, NANO_A4, NANO_A5, NANO_A6, NANO_A7},//Array index to internal arbitrary #defined number
// | | | | | | | | | | | | | | | | | | | | | | | | |
{ 1 , 1 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 1 , 1 , 1 , 2 , 2 , 2 , 2 , 2 , 2 , 1 , 1 },//Whether this pin has 1 or 2 connections to special function chips (OR maybe have it be a map like i = 2 j = 3 k = 4 l = 5 if there's 2 it's the product of them ij = 6 ik = 8 il = 10 jk = 12 jl = 15 kl = 20 we're trading minuscule amounts of CPU for RAM)
// | | | | | | | | | | | | | | | | | | | | | | | | |
{ CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J },//Since there's no overlapping connections between Chip I and J, this holds which of those 2 chips has a connection at that index, if numConns is 1, you only need to check this one
{ -1 , -1 , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , -1 , -1 , -1 , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_L , CHIP_L , -1 , -1 },//Since there's no overlapping connections between Chip K and L, this holds which of those 2 chips has a connection at that index, -1 for no connection
// | | | | | | | | | | | | | | | | | | | | | | | | |
{ -1 , 1 , -1 , 3 , -1 , 5 , -1 , 7 , -1 , 9 , -1 , 8 , -1 , 10 , 11 , -1 , 0 , -1 , 2 , -1 , 4 , -1 , 6 , -1 },//holds which X pin is connected to the index on Chip I, -1 for none
{ -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 },//-1 for not connected to that chip, 0 for available, >0 means it's connected and the netNumber is stored here
// | | | | | | | | | | | | | | | | | | | | | | | | |
{ 0 , -1 , 2 , -1 , 4 , -1 , 6 , -1 , 8 , -1 , 9 , -1 , 10 , -1 , -1 , 11 , -1 , 1 , -1 , 3 , -1 , 5 , -1 , 7 },//holds which X pin is connected to the index on Chip J, -1 for none
{ 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 },//-1 for not connected to that chip, 0 for available, >0 means it's connected and the netNumber is stored here
// | | | | | | | | | | | | | | | | | | | | | | | | |
{ -1 , -1 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , -1 , -1 , -1 , 0 , 1 , 2 , 3 , -1 , -1 , -1 , -1 },//holds which X pin is connected to the index on Chip K, -1 for none
{ -1 , -1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , -1 , -1 , -1 , 0 , 0 , 0 , 0 , -1 , -1 , -1 , -1 },//-1 for not connected to that chip, 0 for available, >0 means it's connected and the netNumber is stored here
// | | | | | | | | | | | | | | | | | | | | | | | | |
{ -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , 12 , 13 , -1 , -1 },//holds which X pin is connected to the index on Chip L, -1 for none
{ -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , 0 , 0 , -1 , -1 },//-1 for not connected to that chip, 0 for available, >0 means it's connected and the netNumber is stored here
if (defined >= 70 && defined <= 93)
{
return defNanoToChar[defined-70];
} else if (defined >= 100 && defined <= 110)
{
return defSpecialToChar[defined-100];
} else if (defined == EMPTY_NET)
{
return emptyNet[0];
}else {
//itoa(defined,same,10);
return " ";
}
// mapIJKL[] will tell you whethher there's a connection from that nano pin to the corresponding special function chip
// xMapIJKL[] will tell you the X pin that it's connected to on that sf chip
// xStatusIJKL[] says whether that x pin is being used (this should be the same as mt[8-10].xMap[] if theyre all stacked on top of each other)
// I haven't decided whether to make this just a flag, or store that signal's destination
{NANO_D0, NANO_D1, NANO_D2, NANO_D3, NANO_D4, NANO_D5, NANO_D6, NANO_D7, NANO_D8, NANO_D9, NANO_D10, NANO_D11, NANO_D12, NANO_D13, NANO_RESET, NANO_AREF, NANO_A0, NANO_A1, NANO_A2, NANO_A3, NANO_A4, NANO_A5, NANO_A6, NANO_A7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,GND,101,102,SUPPLY_3V3,104,SUPPLY_5V,DAC0_5V,DAC1_8V,CURRENT_SENSE_PLUS,CURRENT_SENSE_MINUS}
};
struct pathStruct path[MAX_BRIDGES]; // node1, node2, net, chip[3], x[3], y[3]
}
/*
struct nanoStatus nanoConnections = { //there's only one of these so ill declare and initalize together unlike above

View File

@ -2,16 +2,9 @@
#define MATRIXSTATE_H
#include <Arduino.h>
#include "JumperlessDefinesRP2040.h"
/*
int netIndex = 8; //either search for the next available empty net or keep an index?
int8_t bridges[MAX_BRIDGES][3];//{{netNumber,node1,node2}, ...} //should bridges be stored inside or outside the net structs?
*/
struct netStruct{
uint8_t number; //nets are uint8_t, nodes are int8_t
@ -35,90 +28,79 @@ uint8_t priority = 0; //priority = 1 means it will move connections to take the
extern struct netStruct net[MAX_NETS];
//thanks Copilot for not making me type all this out
//this needs to be here so the pointers have somewhere to point to when we name nets
extern char *netNameConstants[MAX_NETS];
struct chipStatus{
int chipNumber;
char chipChar;
int8_t xStatus[16]; //store the bb row or nano conn this is eventually connected to so they can be stacked if conns are redundant
int8_t yStatus[8]; //store the row/nano it's connected to
const int8_t xMap[16];
const int8_t yMap[8];
};
extern struct chipStatus ch[12];
struct nanoStatus { //there's only one of these so ill declare and initalize together unlike above
//all these arrays should line up (both by index and visually) so one index will give you all this data
// | | | | | | | | | | | | | | | | | | | | | | | | |
const char *pinNames[24]= { " D0", " D1", " D2", " D3", " D4", " D5", " D6", " D7", " D8", " D9", "D10", "D11", "D12", "D13", "RST", "REF", " A0", " A1", " A2", " A3", " A4", " A5", " A6", " A7"};// String with readable name //padded to 3 chars (space comes before chars)
// | | | | | | | | | | | | | | | | | | | | | | | | |
const int8_t pinMap[24] = { NANO_D0, NANO_D1, NANO_D2, NANO_D3, NANO_D4, NANO_D5, NANO_D6, NANO_D7, NANO_D8, NANO_D9, NANO_D10, NANO_D11, NANO_D12, NANO_D13, NANO_RESET, NANO_AREF, NANO_A0, NANO_A1, NANO_A2, NANO_A3, NANO_A4, NANO_A5, NANO_A6, NANO_A7};//Array index to internal arbitrary #defined number
// | | | | | | | | | | | | | | | | | | | | | | | | |
const int8_t numConns[24]= { 1 , 1 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 1 , 1 , 2 , 2 , 2 , 2 , 2 , 2 , 1 , 1 };//Whether this pin has 1 or 2 connections to special function chips (OR maybe have it be a map like i = 2 j = 3 k = 4 l = 5 if there's 2 it's the product of them ij = 6 ik = 8 il = 10 jk = 12 jl = 15 kl = 20 we're trading minuscule amounts of CPU for RAM)
// | | | | | | | | | | | | | | | | | | | | | | | | |
const int8_t mapIJ[24] = { CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J };//Since there's no overlapping connections between Chip I and J, this holds which of those 2 chips has a connection at that index, if numConns is 1, you only need to check this one
const int8_t mapKL[24] = { -1 , -1 , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , -1 , -1 , -1 , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_L , CHIP_L , -1 , -1 };//Since there's no overlapping connections between Chip K and L, this holds which of those 2 chips has a connection at that index, -1 for no connection
// | | | | | | | | | | | | | | | | | | | | | | | | |
const int8_t xMapI[24] = { -1 , 1 , -1 , 3 , -1 , 5 , -1 , 7 , -1 , 9 , -1 , 8 , -1 , 10 , 11 , -1 , 0 , -1 , 2 , -1 , 4 , -1 , 6 , -1 };//holds which X pin is connected to the index on Chip I, -1 for none
int8_t xStatusI[24] = { -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 };//-1 for not connected to that chip, 0 for available, >0 means it's connected and the netNumber is stored here
// | | | | | | | | | | | | | | | | | | | | | | | | |
const int8_t xMapJ[24] = { 0 , -1 , 2 , -1 , 4 , -1 , 6 , -1 , 8 , -1 , 9 , -1 , 10 , -1 , -1 , 11 , -1 , 1 , -1 , 3 , -1 , 5 , -1 , 7 };//holds which X pin is connected to the index on Chip J, -1 for none
int8_t xStatusJ[24] = { 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 };//-1 for not connected to that chip, 0 for available, >0 means it's connected and the netNumber is stored here
// | | | | | | | | | | | | | | | | | | | | | | | | |
const int8_t xMapK[24] = { -1 , -1 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , -1 , -1 , -1 , 0 , 1 , 2 , 3 , -1 , -1 , -1 , -1 };//holds which X pin is connected to the index on Chip K, -1 for none
int8_t xStatusK[24] = { -1 , -1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , -1 , -1 , -1 , 0 , 0 , 0 , 0 , -1 , -1 , -1 , -1 };//-1 for not connected to that chip, 0 for available, >0 means it's connected and the netNumber is stored here
// | | | | | | | | | | | | | | | | | | | | | | | | |
const int8_t xMapL[24] = { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , 12 , 13 , -1 , -1 };//holds which X pin is connected to the index on Chip L, -1 for none
int8_t xStatusL[24] = { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , 0 , 0 , -1 , -1 };//-1 for not connected to that chip, 0 for available, >0 means it's connected and the netNumber is stored here
// | | | | | | | | | | | | | | | | | | | | | | | | |
const char *pinNames[24];//= { " D0", " D1", " D2", " D3", " D4", " D5", " D6", " D7", " D8", " D9", "D10", "D11", "D12", "D13", "RST", "REF", " A0", " A1", " A2", " A3", " A4", " A5", " A6", " A7"};// String with readable name //padded to 3 chars (space comes before chars)
// | | | | | | | | | | | | | | | | | | | | | | | | |
const int8_t pinMap[24];// = { NANO_D0, NANO_D1, NANO_D2, NANO_D3, NANO_D4, NANO_D5, NANO_D6, NANO_D7, NANO_D8, NANO_D9, NANO_D10, NANO_D11, NANO_D12, NANO_D13, NANO_RESET, NANO_AREF, NANO_A0, NANO_A1, NANO_A2, NANO_A3, NANO_A4, NANO_A5, NANO_A6, NANO_A7};//Array index to internal arbitrary #defined number
// | | | | | | | | | | | | | | | | | | | | | | | | |
const int8_t numConns[24];//= { 1 , 1 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 1 , 1 , 2 , 2 , 2 , 2 , 2 , 2 , 1 , 1 };//Whether this pin has 1 or 2 connections to special function chips (OR maybe have it be a map like i = 2 j = 3 k = 4 l = 5 if there's 2 it's the product of them ij = 6 ik = 8 il = 10 jk = 12 jl = 15 kl = 20 we're trading minuscule amounts of CPU for RAM)
// | | | | | | | | | | | | | | | | | | | | | | | | |
const int8_t mapIJ[24];// = { CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J };//Since there's no overlapping connections between Chip I and J, this holds which of those 2 chips has a connection at that index, if numConns is 1, you only need to check this one
const int8_t mapKL[24];// = { -1 , -1 , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , -1 , -1 , -1 , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_L , CHIP_L , -1 , -1 };//Since there's no overlapping connections between Chip K and L, this holds which of those 2 chips has a connection at that index, -1 for no connection
// | | | | | | | | | | | | | | | | | | | | | | | | |
const int8_t xMapI[24];// = { -1 , 1 , -1 , 3 , -1 , 5 , -1 , 7 , -1 , 9 , -1 , 8 , -1 , 10 , 11 , -1 , 0 , -1 , 2 , -1 , 4 , -1 , 6 , -1 };//holds which X pin is connected to the index on Chip I, -1 for none
int8_t xStatusI[24];// = { -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 };//-1 for not connected to that chip, 0 for available, >0 means it's connected and the netNumber is stored here
// | | | | | | | | | | | | | | | | | | | | | | | | |
const int8_t xMapJ[24];// = { 0 , -1 , 2 , -1 , 4 , -1 , 6 , -1 , 8 , -1 , 9 , -1 , 10 , -1 , -1 , 11 , -1 , 1 , -1 , 3 , -1 , 5 , -1 , 7 };//holds which X pin is connected to the index on Chip J, -1 for none
int8_t xStatusJ[24];// = { 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 };//-1 for not connected to that chip, 0 for available, >0 means it's connected and the netNumber is stored here
// | | | | | | | | | | | | | | | | | | | | | | | | |
const int8_t xMapK[24];// = { -1 , -1 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , -1 , -1 , -1 , 0 , 1 , 2 , 3 , -1 , -1 , -1 , -1 };//holds which X pin is connected to the index on Chip K, -1 for none
int8_t xStatusK[24];// = { -1 , -1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , -1 , -1 , -1 , 0 , 0 , 0 , 0 , -1 , -1 , -1 , -1 };//-1 for not connected to that chip, 0 for available, >0 means it's connected and the netNumber is stored here
// | | | | | | | | | | | | | | | | | | | | | | | | |
const int8_t xMapL[24];// = { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , 12 , 13 , -1 , -1 };//holds which X pin is connected to the index on Chip L, -1 for none
int8_t xStatusL[24];// = { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , 0 , 0 , -1 , -1 };//-1 for not connected to that chip, 0 for available, >0 means it's connected and the netNumber is stored here
// mapIJKL[] will tell you whethher there's a connection from that nano pin to the corresponding special function chip
// xMapIJKL[] will tell you the X pin that it's connected to on that sf chip
// xStatusIJKL[] says whether that x pin is being used (this should be the same as mt[8-10].xMap[] if theyre all stacked on top of each other)
// I haven't decided whether to make this just a flag, or store that signal's destination
const int8_t reversePinMap[110] = {NANO_D0, NANO_D1, NANO_D2, NANO_D3, NANO_D4, NANO_D5, NANO_D6, NANO_D7, NANO_D8, NANO_D9, NANO_D10, NANO_D11, NANO_D12, NANO_D13, NANO_RESET, NANO_AREF, NANO_A0, NANO_A1, NANO_A2, NANO_A3, NANO_A4, NANO_A5, NANO_A6, NANO_A7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,GND,101,102,SUPPLY_3V3,104,SUPPLY_5V,DAC0_5V,DAC1_8V,CURRENT_SENSE_PLUS,CURRENT_SENSE_MINUS};
const int8_t reversePinMap[110];// = {NANO_D0, NANO_D1, NANO_D2, NANO_D3, NANO_D4, NANO_D5, NANO_D6, NANO_D7, NANO_D8, NANO_D9, NANO_D10, NANO_D11, NANO_D12, NANO_D13, NANO_RESET, NANO_AREF, NANO_A0, NANO_A1, NANO_A2, NANO_A3, NANO_A4, NANO_A5, NANO_A6, NANO_A7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,GND,101,102,SUPPLY_3V3,104,SUPPLY_5V,DAC0_5V,DAC1_8V,CURRENT_SENSE_PLUS,CURRENT_SENSE_MINUS};
};
extern struct nanoStatus nano;
//see the comments at the end for a more nicely formatted version that's not in struct initalizers
struct xy8_t {
uint8_t x : 4;
uint8_t y : 4;
};
struct pathStruct{
int8_t node1 = 0; //these are the rows or nano header pins to connect
int8_t node2 = 0;
int pathNumber = 0; // this is just a number to refer to the path by
int node1; //these are the rows or nano header pins to connect
int node2;
int net;
uint8_t firstChip = 0xff;
uint8_t firstXY = 0b11101111;
//int8_t firstY = -1;
uint8_t secondChip = 0xff;
uint8_t secondXY = 0b00000000;
//int8_t secondY = -1;
int redundantConnection = 0; // if the paths are redundant (for lower resistance) this is the pathNumber of the other one(s)
int chip[3];
int x[3];
int y[3];
int candidates[3][3];
};
const char* definesToChar (int defined);
extern struct pathStruct path[MAX_BRIDGES]; //this is the array of paths
/*
uint8_t connectionsMatrix[85][85];

File diff suppressed because it is too large Load Diff

View File

@ -6,15 +6,14 @@
#include "JumperlessDefinesRP2040.h"
//#include "MatrixStateRP2040.h"
extern int newBridge[MAX_BRIDGES][3]; // node1, node2, net
extern int newBridgeLength;
extern int newBridgeIndex;
void writeJSONtoFile();
void openNodeFile();
void splitStringToFields();
void replaceSFNamesWithDefinedInts();
void parseStringToBridges();
int printNodeOrName(int node);
void getNodesToConnect(); //read in the nodes you'd like to connect
@ -39,7 +38,7 @@ int checkDoNotIntersectsByNet(int,int); //make sure none of the nodes on the net
int checkDoNotIntersectsByNode(int,int); //make sure none of the nodes on the net violate doNotIntersect rules, exit and warn
void combineNets(); //combine those 2 nets into a single net, probably call addNodesToNet and deleteNet and just expand the lower numbered one. Should we shift nets down? or just reuse the newly emply space for the next net
void combineNets(int,int); //combine those 2 nets into a single net, probably call addNodesToNet and deleteNet and just expand the lower numbered one. Should we shift nets down? or just reuse the newly emply space for the next net
void deleteNet(int); //make sure to check special function nets and clear connections to it
@ -49,6 +48,12 @@ void deleteBridge();
void deleteNode(); //disconnects everything connected to that one node
const char* definesToChar (int defined);
void printBridgeArray();
void checkIfNodesAreABridge(); //if both of those nodes make up a memberBridge[][] pair. if not, warn and exit
void deleteBridgeAndShift(); //shift the remaining bridges over so they're left justified and we don't need to search the entire memberBridges[] every time

View File

@ -0,0 +1,793 @@
#include <Arduino.h>
#include "JumperlessDefinesRP2040.h"
#include "MatrixStateRP2040.h"
#include "NetManager.h"
#include "NetsToChipConnections.h"
//don't try to understand this, it's still a mess
int startEndChip[2] = {-1, -1};
int bothNodes[2] = {-1, -1};
int endChip;
int chipCandidates[2][4] = {{-1, -1, -1, -1}, {-1, -1, -1, -1}}; // nano and sf nodes have multiple possible chips they could be connected to, so we need to store them all and check them all
int chipsLeastToMostCrowded[12] = {0,1,2,3,4,5,6,7,8,9,10,11}; //this will be sorted from most to least crowded, and will be used to determine which chip to use for each node
int sfChipsLeastToMostCrowded[4] = {8,9,10,11}; //this will be sorted from most to least crowded, and will be used to determine which chip to use for each node
int bbToSfLanes[8][4] = {{0}}; // [Chip A - H][CHIP I-K] 0 = free 1 = used
int numberOfUniqueNets = 0;
int numberOfNets = 0;
int numberOfPaths = 0;
unsigned long timeToSort = 0;
bool debugNTCC = false;
void sortPathsByNet(void) // not actually sorting, just copying the bridges and nets back from netStruct so they're both in the same order
{
timeToSort = micros();
printBridgeArray();
for (int i = 0; i < MAX_BRIDGES; i++)
{
if (net[i].number == 0)
{
numberOfNets = i;
break;
}
}
for (int i = 0; i < MAX_BRIDGES; i++)
{
if (path[i].node1 == 0 && path[i].node2 == 0)
{
numberOfPaths = i;
break;
}
}
// printPathArray();
Serial.print("number of nets: ");
Serial.println(numberOfNets);
int pathIndex = 0;
for (int j = 1; j <= numberOfPaths; j++)
{
for (int k = 0; k < MAX_BRIDGES; k++)
{
if (net[j].bridges[k][0] == 0)
{
break;
}
else
{
path[pathIndex].net = net[j].number;
path[pathIndex].node1 = net[j].bridges[k][0];
path[pathIndex].node2 = net[j].bridges[k][1];
if (path[pathIndex].net == path[pathIndex - 1].net)
{
}
else
{
numberOfUniqueNets++;
}
// Serial.print("path[");
// Serial.print(pathIndex);
// Serial.print("] net: ");
// Serial.println(path[pathIndex].net);
pathIndex++;
}
}
}
newBridgeLength = pathIndex;
numberOfPaths = pathIndex;
Serial.print("number unique of nets: ");
Serial.println(numberOfUniqueNets);
Serial.print("pathIndex: ");
Serial.println(pathIndex);
Serial.print("numberOfPaths: ");
Serial.println(numberOfPaths);
clearChipsOnPathToNegOne(); // clear chips and all trailing paths to -1{if there are bridges that weren't made due to DNI rules, there will be fewer paths now because they were skipped}
printBridgeArray();
Serial.println("\n\r");
timeToSort = micros() - timeToSort;
Serial.print("time to sort: ");
Serial.print(timeToSort);
Serial.println("us\n\r");
}
void bridgesToPaths(void)
{
sortPathsByNet();
for (int i = 0; i < numberOfPaths; i++)
{
Serial.print("path[");
Serial.print(i);
Serial.print("]\n\rnodes [");
Serial.print(path[i].node1);
Serial.print("-");
Serial.print(path[i].node2);
Serial.println("]\n\r");
findStartAndEndChips(path[i].node1, path[i].node2, i);
Serial.print("\n\rstart chip: ");
Serial.println(chipNumToChar(startEndChip[0]));
Serial.print("end chip: ");
Serial.println(chipNumToChar(startEndChip[1]));
Serial.println("\n\n\n\r");
}
printPathArray();
sortAllChipsLeastToMostCrowded();
resolveChipCandidates();
}
void findStartAndEndChips(int node1, int node2, int pathIdx)
{
bothNodes[0] = node1;
bothNodes[1] = node2;
startEndChip[0] = -1;
startEndChip[1] = -1;
Serial.print("finding chips for nodes: ");
Serial.print(definesToChar(node1));
Serial.print("-");
Serial.println(definesToChar(node2));
for (int twice = 0; twice < 2; twice++) // first run gets node1 and start chip, second is node2 and end
{
Serial.print("\n\rnode: ");
Serial.println(twice + 1);
Serial.println(" ");
int candidatesFound = 0;
switch (bothNodes[twice]) // not checking availability, just finding the chip
{
case 1:
case 30:
case 32:
case 61:
{
startEndChip[twice] = CHIP_L;
Serial.print("sf chip: ");
Serial.println(chipNumToChar(startEndChip[twice]));
path[pathIdx].chip[twice] = startEndChip[twice];
break;
}
case 2 ... 29: // on the breadboard
case 33 ... 60:
{
for (int i = 0; i < 8; i++)
{
for (int j = 1; j < 8; j++) // start at 1 so we dont confuse CHIP_L for a node
{
if (ch[i].yMap[j] == bothNodes[twice])
{
startEndChip[twice] = i;
Serial.print("bb chip: ");
Serial.println(chipNumToChar(startEndChip[twice]));
path[pathIdx].chip[twice] = startEndChip[twice];
break;
}
}
}
break;
}
case NANO_D0 ... NANO_A7: // on the nano
{
int nanoIndex = defToNano(bothNodes[twice]);
if (nano.numConns[nanoIndex] == 1)
{
startEndChip[twice] = nano.mapIJ[nanoIndex];
Serial.print("nano chip: ");
Serial.println(chipNumToChar(startEndChip[twice]));
path[pathIdx].chip[twice] = startEndChip[twice];
}
else
{
chipCandidates[twice][0] = nano.mapIJ[nanoIndex];
path[pathIdx].candidates[twice][0] = chipCandidates[twice][0];
candidatesFound++;
chipCandidates[twice][1] = nano.mapKL[nanoIndex];
path[pathIdx].candidates[twice][1] = chipCandidates[twice][1];
candidatesFound++;
Serial.print("nano candidate chips: ");
Serial.print(chipNumToChar(chipCandidates[twice][0]));
Serial.print(" ");
Serial.println(chipNumToChar(chipCandidates[twice][1]));
}
break;
}
case GND ... CURRENT_SENSE_MINUS:
{
Serial.print("special function candidate chips: ");
for (int i = 8; i < 12; i++)
{
for (int j = 0; j < 16; j++)
{
if (ch[i].xMap[j] == bothNodes[twice])
{
chipCandidates[twice][candidatesFound] = i;
path[pathIdx].candidates[twice][candidatesFound] = chipCandidates[twice][candidatesFound];
candidatesFound++;
Serial.print(chipNumToChar(i));
Serial.print(" ");
}
}
}
Serial.println(" ");
break;
}
}
//Serial.print("\n\r");
}
if (startEndChip[0] == -1 || startEndChip[1] == -1)
{
}
else
{
}
}
void resolveChipCandidates(void)
{
int nodesToResolve[2] = {0,0}; // {node1,node2} 0 = already found, 1 = needs resolving
for (int pathIndex = 0; pathIndex < numberOfPaths; pathIndex++)
{
nodesToResolve[0] = 0;
nodesToResolve[1] = 0;
if (path[pathIndex].chip[0] == -1)
{
nodesToResolve[0] = 1;
}
else
{
nodesToResolve[0] = 0;
}
if (path[pathIndex].chip[1] == -1)
{
nodesToResolve[1] = 1;
}
else
{
nodesToResolve[1] = 0;
}
for (int nodeOneOrTwo = 0; nodeOneOrTwo < 2; nodeOneOrTwo++)
{
if(nodesToResolve[nodeOneOrTwo] == 1)
{
path[pathIndex].chip[nodeOneOrTwo] = moreAvailableChip(path[pathIndex].candidates[nodeOneOrTwo][0], path[pathIndex].candidates[nodeOneOrTwo][1]);
Serial.print("path[");
Serial.print(pathIndex);
Serial.print("] chip from ");
Serial.print(chipNumToChar(path[pathIndex].chip[(1+nodeOneOrTwo)%2]));
Serial.print(" to chip ");
Serial.print(chipNumToChar(path[pathIndex].chip[nodeOneOrTwo]));
Serial.print(" chosen\n\n\r");
}
}
}
}
void bbToSfConnections (void)
{
for (int i = 0 ; i < numberOfPaths; i++)
{
if (path[i].chip[0] > 7 && path[i].chip[1] <= 7 && path[i].chip[1] >= 0)
{
bbToSfLanes[path[i].chip[1]][path[i].chip[0] - 8] ++; //why is this happening every loop
Serial.print (i);
Serial.print (" ");
Serial.print (chipNumToChar((path[i].chip[1])));
Serial.print ("-");
Serial.println (chipNumToChar((path[i].chip[0])));
} else if (path[i].chip[1] > 7 && path[i].chip[0] <= 7 && path[i].chip[0] >= 0)
bbToSfLanes[path[i].chip[0]][path[i].chip[1] - 8] ++;
Serial.print (i);
Serial.print (" ");
Serial.print (chipNumToChar((path[i].chip[0])));
Serial.print ("-");
Serial.println (chipNumToChar((path[i].chip[1])));
}
for (int i = 0; i < 8; i++)
{
Serial.print(chipNumToChar(i));
Serial.print(": ");
for (int j = 0; j < 4; j++)
{
Serial.print(chipNumToChar(j + 8));
Serial.print(bbToSfLanes[i][j]);
Serial.print(" ");
}
Serial.println("\n\r");
}
}
int moreAvailableChip (int chip1 , int chip2)
{
int chipChosen = -1;
sortAllChipsLeastToMostCrowded();
for (int i = 0; i < 12; i++)
{
if (chipsLeastToMostCrowded[i] == chip1 || chipsLeastToMostCrowded[i] == chip2)
{
chipChosen = chipsLeastToMostCrowded[i];
break;
}
}
return chipChosen;
}
void sortSFchipsLeastToMostCrowded(void)
{
int numberOfConnectionsPerSFchip[4] = {0,0,0,0};
for (int i = 0; i < numberOfPaths; i++)
{
for (int j = 0; j < 2; j++)
{
if (path[i].chip[j] > 7)
{
numberOfConnectionsPerSFchip[path[i].chip[j] - 8]++;
}
}
}
for (int i = 0; i < 4; i++)
{
Serial.print("sf connections: ");
Serial.print (chipNumToChar(i + 8));
Serial.print(numberOfConnectionsPerSFchip[i]);
Serial.print("\n\r");
}
}
void sortAllChipsLeastToMostCrowded(void)
{
debugNTCC = false;
int numberOfConnectionsPerChip[12] = {0,0,0,0,0,0,0,0,0,0,0,0}; //this will be used to determine which chip is most crowded
for (int i = 0; i < 12; i++)
{
chipsLeastToMostCrowded[i] = i;
}
Serial.println("\n\r");
for (int i = 0; i < numberOfPaths; i++)
{
for (int j = 0; j < 2; j++)
{
if (path[i].chip[j] != -1)
{
numberOfConnectionsPerChip[path[i].chip[j]]++;
}
}
}
if (debugNTCC)
{
for (int i = 0; i < 12; i++)
{
Serial.print(chipNumToChar(i));
Serial.print(": ");
Serial.println(numberOfConnectionsPerChip[i]);
}
Serial.println("\n\r");
}
int temp = 0;
for (int i = 0; i < 12; i++)
{
for (int j = 0; j < 11; j++)
{
if (numberOfConnectionsPerChip[j] > numberOfConnectionsPerChip[j + 1])
{
temp = numberOfConnectionsPerChip[j];
//chipsLeastToMostCrowded[j] = chipsLeastToMostCrowded[j + 1];
numberOfConnectionsPerChip[j] = numberOfConnectionsPerChip[j + 1];
numberOfConnectionsPerChip[j + 1] = temp;
temp = chipsLeastToMostCrowded[j];
chipsLeastToMostCrowded[j] = chipsLeastToMostCrowded[j + 1];
chipsLeastToMostCrowded[j + 1] = temp;
}
}
}
for (int i = 0; i < 12; i++)
{
if (chipsLeastToMostCrowded[i] > 7)
{
sfChipsLeastToMostCrowded[i - 8] = chipsLeastToMostCrowded[i];
}
if (debugNTCC)
{
Serial.print(chipNumToChar(chipsLeastToMostCrowded[i]));
Serial.print(": ");
Serial.println(numberOfConnectionsPerChip[i]);
}
}
if (debugNTCC)
{
for (int i = 0; i < 4; i++)
{
Serial.print("\n\n\r");
Serial.print(chipNumToChar(sfChipsLeastToMostCrowded[i]));
Serial.print(": ");
Serial.print("\n\n\r");
}
}
debugNTCC = true;
bbToSfConnections();
}
void printPathArray(void) // this also prints candidates and x y
{
// Serial.print("\n\n\r");
// Serial.print("newBridgeIndex = ");
// Serial.println(newBridgeIndex);
Serial.print("\n\r");
int tabs = 0;
int lineCount = 0;
for (int i = 0; i < newBridgeLength; i++)
{
tabs += Serial.print(i);
Serial.print(" ");
if (i < 10)
{
tabs += Serial.print(" ");
}
if (i < 100)
{
tabs += Serial.print(" ");
}
tabs += Serial.print("[");
tabs += printNodeOrName(path[i].node1);
tabs += Serial.print("-");
tabs += printNodeOrName(path[i].node2);
tabs += Serial.print("]\tNet ");
tabs += printNodeOrName(path[i].net);
tabs += Serial.println(" ");
tabs += Serial.print("\n\rnode1 chip: ");
tabs += printChipNumToChar(path[i].chip[0]);
tabs += Serial.print("\n\rnode2 chip: ");
tabs += printChipNumToChar(path[i].chip[1]);
tabs += Serial.print("\n\n\rnode1 candidates: ");
for (int j = 0; j < 3; j++)
{
printChipNumToChar(path[i].candidates[0][j]);
tabs += Serial.print(" ");
}
tabs += Serial.print("\n\rnode2 candidates: ");
for (int j = 0; j < 3; j++)
{
printChipNumToChar(path[i].candidates[1][j]);
tabs += Serial.print(" ");
}
tabs += Serial.println("\n\n\r");
// Serial.print(tabs);
// for (int i = 0; i < 24 - (tabs); i++)
//{
// Serial.print(" ");
// }
tabs = 0;
}
}
int defToNano(int nanoIndex)
{
return nanoIndex - NANO_D0;
}
char chipNumToChar(int chipNumber)
{
return chipNumber + 'A';
}
int printChipNumToChar(int chipNumber)
{
if (chipNumber == -1)
{
return Serial.print(" ");
}
else
{
return Serial.print((char)(chipNumber + 'A'));
}
}
void clearChipsOnPathToNegOne(void)
{
for (int i = 0; i < MAX_BRIDGES; i++)
{
if (i > numberOfPaths)
{
path[i].node1 = -1; // i know i can just do {-1,-1,-1} but
path[i].node2 = -1;
path[i].net = -1;
}
for (int c = 0; c < 3; c++)
{
path[i].chip[c] = -1;
path[i].x[c] = -1;
path[i].y[c] = -1;
path[i].candidates[c][0] = -1;
path[i].candidates[c][1] = -1;
path[i].candidates[c][2] = -1; //CEEEEEEEE!!!!!! i had this set to 3 and it was clearing everything, but no im not using rust
}
}
}
/*
So the nets are all made, now we need to figure out which chip connections need to be made to make that phycically happen
start with the special function nets, they're the highest priority
maybe its simpler to make an array of every possible connection
start at net 1 and go up
find start and end chip
bb chips
sf chips
nano chips
things that store x and y valuse for paths
chipStatus.xStatus[]
chipStatus.yStatus[]
nanoStatus.xStatusIJKL[]
struct nanoStatus { //there's only one of these so ill declare and initalize together unlike above
//all these arrays should line up (both by index and visually) so one index will give you all this data
// | | | | | | | | | | | | | | | | | | | | | | | | |
const char *pinNames[24]= { " D0", " D1", " D2", " D3", " D4", " D5", " D6", " D7", " D8", " D9", "D10", "D11", "D12", "D13", "RST", "REF", " A0", " A1", " A2", " A3", " A4", " A5", " A6", " A7"};// String with readable name //padded to 3 chars (space comes before chars)
// | | | | | | | | | | | | | | | | | | | | | | | | |
const int8_t pinMap[24] = { NANO_D0, NANO_D1, NANO_D2, NANO_D3, NANO_D4, NANO_D5, NANO_D6, NANO_D7, NANO_D8, NANO_D9, NANO_D10, NANO_D11, NANO_D12, NANO_D13, NANO_RESET, NANO_AREF, NANO_A0, NANO_A1, NANO_A2, NANO_A3, NANO_A4, NANO_A5, NANO_A6, NANO_A7};//Array index to internal arbitrary #defined number
// | | | | | | | | | | | | | | | | | | | | | | | | |
const int8_t numConns[24]= { 1 , 1 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 1 , 1 , 2 , 2 , 2 , 2 , 2 , 2 , 1 , 1 };//Whether this pin has 1 or 2 connections to special function chips (OR maybe have it be a map like i = 2 j = 3 k = 4 l = 5 if there's 2 it's the product of them ij = 6 ik = 8 il = 10 jk = 12 jl = 15 kl = 20 we're trading minuscule amounts of CPU for RAM)
// | | | | | | | | | | | | | | | | | | | | | | | | |
const int8_t mapIJ[24] = { CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J , CHIP_I , CHIP_J };//Since there's no overlapping connections between Chip I and J, this holds which of those 2 chips has a connection at that index, if numConns is 1, you only need to check this one
const int8_t mapKL[24] = { -1 , -1 , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_K , -1 , -1 , -1 , CHIP_K , CHIP_K , CHIP_K , CHIP_K , CHIP_L , CHIP_L , -1 , -1 };//Since there's no overlapping connections between Chip K and L, this holds which of those 2 chips has a connection at that index, -1 for no connection
// | | | | | | | | | | | | | | | | | | | | | | | | |
const int8_t xMapI[24] = { -1 , 1 , -1 , 3 , -1 , 5 , -1 , 7 , -1 , 9 , -1 , 8 , -1 , 10 , 11 , -1 , 0 , -1 , 2 , -1 , 4 , -1 , 6 , -1 };//holds which X pin is connected to the index on Chip I, -1 for none
int8_t xStatusI[24] = { -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 };//-1 for not connected to that chip, 0 for available, >0 means it's connected and the netNumber is stored here
// | | | | | | | | | | | | | | | | | | | | | | | | |
const int8_t xMapJ[24] = { 0 , -1 , 2 , -1 , 4 , -1 , 6 , -1 , 8 , -1 , 9 , -1 , 10 , -1 , -1 , 11 , -1 , 1 , -1 , 3 , -1 , 5 , -1 , 7 };//holds which X pin is connected to the index on Chip J, -1 for none
int8_t xStatusJ[24] = { 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 , -1 , 0 };//-1 for not connected to that chip, 0 for available, >0 means it's connected and the netNumber is stored here
// | | | | | | | | | | | | | | | | | | | | | | | | |
const int8_t xMapK[24] = { -1 , -1 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , -1 , -1 , -1 , 0 , 1 , 2 , 3 , -1 , -1 , -1 , -1 };//holds which X pin is connected to the index on Chip K, -1 for none
int8_t xStatusK[24] = { -1 , -1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , -1 , -1 , -1 , 0 , 0 , 0 , 0 , -1 , -1 , -1 , -1 };//-1 for not connected to that chip, 0 for available, >0 means it's connected and the netNumber is stored here
// | | | | | | | | | | | | | | | | | | | | | | | | |
const int8_t xMapL[24] = { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , 12 , 13 , -1 , -1 };//holds which X pin is connected to the index on Chip L, -1 for none
int8_t xStatusL[24] = { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , 0 , 0 , -1 , -1 };//-1 for not connected to that chip, 0 for available, >0 means it's connected and the netNumber is stored here
// mapIJKL[] will tell you whethher there's a connection from that nano pin to the corresponding special function chip
// xMapIJKL[] will tell you the X pin that it's connected to on that sf chip
// xStatusIJKL[] says whether that x pin is being used (this should be the same as mt[8-10].xMap[] if theyre all stacked on top of each other)
// I haven't decided whether to make this just a flag, or store that signal's destination
const int8_t reversePinMap[110] = {NANO_D0, NANO_D1, NANO_D2, NANO_D3, NANO_D4, NANO_D5, NANO_D6, NANO_D7, NANO_D8, NANO_D9, NANO_D10, NANO_D11, NANO_D12, NANO_D13, NANO_RESET, NANO_AREF, NANO_A0, NANO_A1, NANO_A2, NANO_A3, NANO_A4, NANO_A5, NANO_A6, NANO_A7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,GND,101,102,SUPPLY_3V3,104,SUPPLY_5V,DAC0_5V,DAC1_8V,CURRENT_SENSE_PLUS,CURRENT_SENSE_MINUS};
};
struct netStruct net[MAX_NETS] = { //these are the special function nets that will always be made
//netNumber, ,netName ,memberNodes[] ,memberBridges[][2] ,specialFunction ,intsctNet[] ,doNotIntersectNodes[] ,priority
{ 127 ,"Empty Net" ,{EMPTY_NET} ,{{}} ,EMPTY_NET ,{} ,{EMPTY_NET,EMPTY_NET,EMPTY_NET,EMPTY_NET,EMPTY_NET,EMPTY_NET,EMPTY_NET} , 0},
{ 1 ,"GND\t" ,{GND} ,{{}} ,GND ,{} ,{SUPPLY_3V3,SUPPLY_5V,DAC0_5V,DAC1_8V} , 1},
{ 2 ,"+5V\t" ,{SUPPLY_5V} ,{{}} ,SUPPLY_5V ,{} ,{GND,SUPPLY_3V3,DAC0_5V,DAC1_8V} , 1},
{ 3 ,"+3.3V\t" ,{SUPPLY_3V3} ,{{}} ,SUPPLY_3V3 ,{} ,{GND,SUPPLY_5V,DAC0_5V,DAC1_8V} , 1},
{ 4 ,"DAC 0\t" ,{DAC0_5V} ,{{}} ,DAC0_5V ,{} ,{GND,SUPPLY_5V,SUPPLY_3V3,DAC1_8V} , 1},
{ 5 ,"DAC 1\t" ,{DAC1_8V} ,{{}} ,DAC1_8V ,{} ,{GND,SUPPLY_5V,SUPPLY_3V3,DAC0_5V} , 1},
{ 6 ,"I Sense +" ,{CURRENT_SENSE_PLUS} ,{{}} ,CURRENT_SENSE_PLUS ,{} ,{CURRENT_SENSE_MINUS} , 2},
{ 7 ,"I Sense -" ,{CURRENT_SENSE_MINUS} ,{{}} ,CURRENT_SENSE_MINUS ,{} ,{CURRENT_SENSE_PLUS} , 2},
};
Index Name Number Nodes Bridges Do Not Intersects
0 Empty Net 127 EMPTY_NET {0-0} EMPTY_NET
1 GND 1 GND,1,2,D0,3,4 {1-GND,1-2,D0-1,2-3,3-4} 3V3,5V,DAC_0,DAC_1
2 +5V 2 5V,11,12,10,9 {11-5V,11-12,10-11,9-10} GND,3V3,DAC_0,DAC_1
3 +3.3V 3 3V3,D10,D11,D12 {D10-3V3,D10-D11,D11-D12} GND,5V,DAC_0,DAC_1
4 DAC 0 4 DAC_0 {0-0} GND,5V,3V3,DAC_1
5 DAC 1 5 DAC_1 {0-0} GND,5V,3V3,DAC_0
6 I Sense + 6 I_POS,6,5,A1,AREF {6-I_POS,5-6,A1-5,AREF-A1} I_NEG
7 I Sense - 7 I_NEG {0-0} I_POS
Index Name Number Nodes Bridges Do Not Intersects
8 Net 8 8 7,8 {7-8} 0
9 Net 9 9 D13,D1,A7 {D13-D1,D13-A7} 0
struct chipStatus{
int chipNumber;
char chipChar;
int8_t xStatus[16]; //store the bb row or nano conn this is eventually connected to so they can be stacked if conns are redundant
int8_t yStatus[8]; //store the row/nano it's connected to
const int8_t xMap[16];
const int8_t yMap[8];
};
struct chipStatus ch[12] = {
{0,'A',
{-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
{CHIP_I, CHIP_J, CHIP_B, CHIP_B, CHIP_C, CHIP_C, CHIP_D, CHIP_D, CHIP_E, CHIP_K, CHIP_F, CHIP_F, CHIP_G, CHIP_G, CHIP_H, CHIP_H},//X MAP constant
{CHIP_L, t2,t3, t4, t5, t6, t7, t8}}, // Y MAP constant
{1,'B',
{-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
{CHIP_A, CHIP_A, CHIP_I, CHIP_J, CHIP_C, CHIP_C, CHIP_D, CHIP_D, CHIP_E, CHIP_E, CHIP_F, CHIP_K, CHIP_G, CHIP_G, CHIP_H, CHIP_H},
{CHIP_L, t9,t10,t11,t12,t13,t14,t15}},
{2,'C',
{-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
{CHIP_A, CHIP_A, CHIP_B, CHIP_B, CHIP_I, CHIP_J, CHIP_D, CHIP_D, CHIP_E, CHIP_E, CHIP_F, CHIP_F, CHIP_G, CHIP_K, CHIP_H, CHIP_H},
{CHIP_L, t16,t17,t18,t19,t20,t21,t22}},
{3,'D',
{-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
{CHIP_A, CHIP_A, CHIP_B, CHIP_B, CHIP_C, CHIP_C, CHIP_I, CHIP_J, CHIP_E, CHIP_E, CHIP_F, CHIP_F, CHIP_G, CHIP_G, CHIP_H, CHIP_K},
{CHIP_L, t23,t24,t25,t26,t27,t28,t29}},
{4,'E',
{-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
{CHIP_A, CHIP_K, CHIP_B, CHIP_B, CHIP_C, CHIP_C, CHIP_D, CHIP_D, CHIP_I, CHIP_J, CHIP_F, CHIP_F, CHIP_G, CHIP_G, CHIP_H, CHIP_H},
{CHIP_L, b2, b3, b4, b5, b6, b7, b8}},
{5,'F',
{-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
{CHIP_A, CHIP_A, CHIP_B, CHIP_K, CHIP_C, CHIP_C, CHIP_D, CHIP_D, CHIP_E, CHIP_E, CHIP_I, CHIP_J, CHIP_G, CHIP_G, CHIP_H, CHIP_H},
{CHIP_L, b9, b10,b11,b12,b13,b14,b15}},
{6,'G',
{-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
{CHIP_A, CHIP_A, CHIP_B, CHIP_B, CHIP_C, CHIP_K, CHIP_D, CHIP_D, CHIP_E, CHIP_E, CHIP_F, CHIP_F, CHIP_I, CHIP_J, CHIP_H, CHIP_H},
{CHIP_L, b16,b17,b18,b19,b20,b21,b22}},
{7,'H',
{-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
{CHIP_A, CHIP_A, CHIP_B, CHIP_B, CHIP_C, CHIP_C, CHIP_D, CHIP_K, CHIP_E, CHIP_E, CHIP_F, CHIP_F, CHIP_G, CHIP_G, CHIP_I, CHIP_J},
{CHIP_L, b23,b24,b25,b26,b27,b28,b29}},
{8,'I',
{-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
{NANO_A0, NANO_D1, NANO_A2, NANO_D3, NANO_A4, NANO_D5, NANO_A6, NANO_D7, NANO_D11, NANO_D9, NANO_D13, NANO_RESET, DAC0_5V, ADC0_5V, SUPPLY_3V3, GND},
{CHIP_A,CHIP_B,CHIP_C,CHIP_D,CHIP_E,CHIP_F,CHIP_G,CHIP_H}},
{9,'J',
{-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
{NANO_D0, NANO_A1, NANO_D2, NANO_A3, NANO_D4, NANO_A5, NANO_D6, NANO_A7, NANO_D8, NANO_D10, NANO_D12, NANO_AREF, DAC1_8V, ADC1_5V, SUPPLY_5V, GND},
{CHIP_A,CHIP_B,CHIP_C,CHIP_D,CHIP_E,CHIP_F,CHIP_G,CHIP_H}},
{10,'K',
{-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
{NANO_A0, NANO_A1, NANO_A2, NANO_A3, NANO_A4, NANO_A5, NANO_A6, NANO_A7, NANO_D2, NANO_D3, NANO_D4, NANO_D5, NANO_D6, NANO_D7, NANO_D8, NANO_D9},
{CHIP_A,CHIP_B,CHIP_C,CHIP_D,CHIP_E,CHIP_F,CHIP_G,CHIP_H}},
{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},
{CHIP_A,CHIP_B,CHIP_C,CHIP_D,CHIP_E,CHIP_F,CHIP_G,CHIP_H}}
};
enum nanoPinsToIndex { NANO_PIN_D0 , NANO_PIN_D1 , NANO_PIN_D2 , NANO_PIN_D3 , NANO_PIN_D4 , NANO_PIN_D5 , NANO_PIN_D6 , NANO_PIN_D7 , NANO_PIN_D8 , NANO_PIN_D9 , NANO_PIN_D10 , NANO_PIN_D11 , NANO_PIN_D12 , NANO_PIN_D13 , NANO_PIN_RST , NANO_PIN_REF , NANO_PIN_A0 , NANO_PIN_A1 , NANO_PIN_A2 , NANO_PIN_A3 , NANO_PIN_A4 , NANO_PIN_A5 , NANO_PIN_A6 , NANO_PIN_A7 };
extern struct nanoStatus nano;
struct pathStruct{
int node1; //these are the rows or nano header pins to connect
int node2;
int net;
int chip[3];
int x[3];
int y[3];
int candidates[3][3];
};
*/

View File

@ -0,0 +1,56 @@
#ifndef NETTOCHIPCONNECTIONS_H
#define NETTOCHIPCONNECTIONS_H
void sortPathsByNet(void);
void bridgesToPaths(void);
void findStartAndEndChips(int node1, int node2, int net);
void resolveChipCandidates();
void printPathArray();
int defToNano(int nanoIndex);
void bbToSfConnections(void);
char chipNumToChar(int);
int printChipNumToChar(int);
void clearChipsOnPathToNegOne(void);
void sortAllChipsLeastToMostCrowded(void);
void sortSFchipsMostToLeastCrowded(void);
int moreAvailableChip (int chip1 , int chip2);
#endif

View File

@ -3,7 +3,9 @@
#include "NetManager.h"
#include "MatrixStateRP2040.h"
#include "LittleFS.h"
#include "FileParsing.h"
#include "NetsToChipConnections.h"
#include "LEDs.h"
//nanoStatus nano;
@ -15,29 +17,38 @@ const char* definesToChar (int); //i really need to find a way to not need to fo
void setup() {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT_12MA);
pinMode(25, OUTPUT);
LittleFS.begin();
delay(3000);
openNodeFile();
initLEDs();
}
void loop() {
digitalWrite(LED_BUILTIN,HIGH);
delay(100);
digitalWrite(LED_BUILTIN,LOW);
//digitalWrite(LED_BUILTIN,HIGH);
//delay(100);
//digitalWrite(LED_BUILTIN,LOW);
delay(800);
rainbowy(180 ,55 , 20); // Red
//delay(800);
getNodesToConnect();
delay(800);
//delay(800);
Serial.println("\n\n\rfinal netlist\n\n\r");
listSpecialNets();
listNets();
//printBridgeArray();
bridgesToPaths();
while(1);
Serial.println("\n\r");
//Serial.println("\n\r");
//writeJSONtoFile();