Skip to content

Commit

Permalink
New Wokwi Bridge app
Browse files Browse the repository at this point in the history
  • Loading branch information
Architeuthis-Flux committed May 31, 2024
1 parent 52a8308 commit 94572ac
Show file tree
Hide file tree
Showing 1,152 changed files with 47,963 additions and 430 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"hostname":"Kevins-MBP","username":"kevinsanto"}
Binary file not shown.
48 changes: 48 additions & 0 deletions JumperlessNano/src/CH446Q.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,56 @@ void sendAllPaths(void) // should we sort them by chip? for now, no
}
}

uint8_t restoreConnections[12][16][2]; // [chip][index][pairs 0=x, 1=y]




int clearAllConnectionsOnChip(int chip, int clearOrRestore)
{

int numCleared = 0;
uint8_t netCleared = 0;

if (clearOrRestore == 0)
{
for (int x = 0; x < 16; x++)
{
if (ch[chip].xStatus[x] != -1)
{
netCleared = ch[chip].xStatus[x];

for (int y = 0; y < 8; y++)
{
if (ch[chip].yStatus[y] == netCleared)
{

restoreConnections[chip][numCleared][0] = x;
restoreConnections[chip][numCleared][1] = y;
numCleared++;
Serial.print("chip ");
Serial.print(chip);
Serial.print(" x:");
Serial.print(x);
Serial.print(" y:");
Serial.print(y);
Serial.print(" net:");
Serial.print(netCleared);
Serial.print("\n\r");
sendXYraw(chip, x, y, 0);
}
}
}
}
} else {
for (int i = 0; i < numCleared; i++)
{
sendXYraw(chip, restoreConnections[chip][i][0], restoreConnections[chip][i][1], 1);
}
}
return numCleared;

}

void sendPath(int i, int setOrClear)
{
Expand Down
1 change: 1 addition & 0 deletions JumperlessNano/src/CH446Q.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extern int lightUpNetCore2;

void initCH446Q(void);
void sendXYraw(int chip, int x, int y, int setorclear);
int clearAllConnectionsOnChip(int chip, int clearOrRestore);//returns number of connections cleared

void sendAllPaths(void); // should we sort them by chip? for now, no
void resetArduino (void);
Expand Down
98 changes: 62 additions & 36 deletions JumperlessNano/src/FileParsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ File nodeFileBuffer;

unsigned long timeToFP = 0;

const char rotaryConnectionString[] = "{ AREF-GND, D11-GND, D10-UART_TX, D12-UART_RX, D13-GPIO_0, ";
const char rotaryConnectionString[] = "{AREF-GND,D11-GND,D10-UART_TX,D12-UART_RX,D13-GPIO_0, ";

void createSlots(int slot, int addRotaryConnections)
{
Expand All @@ -55,8 +55,8 @@ void createSlots(int slot, int addRotaryConnections)
// {
// //nodeFile.write(' ');
// index++;
// } else

// } else
// length++;
// }
// }
Expand All @@ -78,11 +78,7 @@ void createSlots(int slot, int addRotaryConnections)
// Serial.write(nodeFile.read());
// }


// nodeFile.close();




nodeFile = LittleFS.open("nodeFileSlot" + String(i) + ".txt", "w");
if (i >= 0)
Expand All @@ -92,11 +88,11 @@ void createSlots(int slot, int addRotaryConnections)
// nodeFile.print("{ AREF-D8, D8-ADC0, ADC0-GPIO_0, D11-GND, D10-ADC2, ADC2-UART_TX, D12-ADC1, ADC1-UART_RX, D13-GND, ");
if (addRotaryConnections > 0)
{
nodeFile.print("{ AREF-GND, D11-GND, D10-UART_TX, D12-UART_RX, D13-GPIO_0, ");
nodeFile.print("{AREF-GND,D11-GND,D10-UART_TX,D12-UART_RX,D13-GPIO_0,");
nodeFile.print(i * 4 + 1);
nodeFile.print("-");
nodeFile.print(i * 4 + 2);
nodeFile.print(", }");
nodeFile.print(",}");
}
else
{
Expand All @@ -113,7 +109,7 @@ void createSlots(int slot, int addRotaryConnections)
// nodeFile.print("{ D12-D7, D7-ADC0, ADC0-UART_RX, D11-GND, D10-ADC2, ADC2-UART_TX, AREF-ADC1, ADC1-GPIO_0, D13-GND, ");
if (addRotaryConnections > 0)
{
nodeFile.print("{ AREF-GND, D11-GND, D10-UART_TX, D12-UART_RX, D13-GPIO_0, } ");
nodeFile.print("{AREF-GND,D11-GND,D10-UART_TX,D12-UART_RX,D13-GPIO_0,} ");
// nodeFile.print(slot * 4 + 1);
// nodeFile.print("-");
// nodeFile.print(slot * 4 + 2);
Expand All @@ -122,22 +118,51 @@ void createSlots(int slot, int addRotaryConnections)
nodeFile.close();
}
}
void inputNodeFileList(void)
void inputNodeFileList(int addRotaryConnections)
{
Serial.println("Paste the nodeFile list here");
// addRotaryConnections = 1;
// Serial.println("Paste the nodeFile list here\n\n\r");

unsigned long humanTime = millis();

int shown = 0;
while (Serial.available() == 0)
{
if (millis() - humanTime == 400 && shown == 0)
{
Serial.println("Paste the nodeFile list here\n\n\r");
shown = 1;
}
}
nodeFileString.clear();

// if (addRotaryConnections > 0)
// {
// for (int i = 0; i < 59 ; i++)
// {
// nodeFileString.write(rotaryConnectionString[i]);
// Serial.print(rotaryConnectionString[i]);
// }
// }
int startInsertion = 0;
while (Serial.available() > 0)
{
nodeFileString.write(Serial.read());
uint8_t c = Serial.read();
if (c == '{' && addRotaryConnections > 0)
{
// startInsertion = 1;
for (int i = 0; i < 53; i++)
{
nodeFileString.write(rotaryConnectionString[i]);
// Serial.print(rotaryConnectionString[i]);
}
continue;
}
nodeFileString.write(c);
delayMicroseconds(100);
}
// nodeFileString.read(Serial);
// Serial.println("nodeFileString");
// Serial.println(nodeFileString);
// Serial.println(nodeFileString);
int lastTokenIndex = 0;
int tokenFound = 0;
uint8_t lastReads[8] = {' ', ' ', ' ', ' '};
Expand Down Expand Up @@ -165,10 +190,11 @@ void inputNodeFileList(void)
// nodeFileBuffer.seek(nodeFileBuffer.size());
// nodeFileBuffer.print("fuck \n\r");
nodeFileBuffer.seek(0);
// while (nodeFileBuffer.available())
// {
// Serial.write(nodeFileBuffer.read());
// }
// Serial.println(" \n\n\n\r");
// while (nodeFileBuffer.available())
// {
// Serial.write(nodeFileBuffer.read());
// }

for (int i = 0; i < NUM_SLOTS; i++) // this just searches for how many slots are in the pasted list
{
Expand Down Expand Up @@ -215,15 +241,8 @@ void inputNodeFileList(void)
}
index++;
}

// Serial.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
// nodeFile.close();
}

Serial.print("\n\rFirst slot found: ");
Serial.println(firstSlotNumber, HEX);

Serial.println("Number of slots found: " + String(numberOfSlotsFound));
index = 0;
int lastSlotNumber = firstSlotNumber + numberOfSlotsFound - 1;

Expand All @@ -232,7 +251,7 @@ void inputNodeFileList(void)

if (i >= firstSlotNumber && i <= lastSlotNumber)
{
Serial.println(i);
// Serial.println(i);
nodeFile = LittleFS.open("nodeFileSlot" + String(i) + ".txt", "w");
}

Expand Down Expand Up @@ -270,31 +289,38 @@ void inputNodeFileList(void)
if (i >= firstSlotNumber && i <= lastSlotNumber)
{
nodeFile.seek(0);
printNodeFile(i);

// Serial.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
nodeFile.close();
}
}
// uint8_t trash = Serial.read();
// Serial.write(trash);
// delay(10);

for (int i = 0; i < NUM_SLOTS; i++)
{
// printNodeFile(i);
}
// while(Serial.available() > 0)
// {
// trash = Serial.read();
// //Serial.write(trash);
// delay(1);
// }

// for (int i = 0; i < NUM_SLOTS; i++)
// {
// // printNodeFile(i);
// }
}

void savePreformattedNodeFile(int source, int slot, int keepEncoder)
{

nodeFile = LittleFS.open("nodeFileSlot" + String(slot) + ".txt", "w+");
Serial.println("Slot " + String(slot));
// Serial.println("Slot " + String(slot));

// Serial.println(nodeFile);

if (keepEncoder == 1)
{
// nodeFile.print("{ D12-D7, D7-ADC0, ADC0-UART_RX, D11-GND, D10-ADC2, ADC2-UART_TX, AREF-ADC1, ADC1-GPIO_0, D13-GND, ");
nodeFile.print("{ AREF-GND, D11-GND, D10-UART_TX, D12-UART_RX, D13-GPIO_0, ");
nodeFile.print("{AREF-GND,D11-GND,D10-UART_TX,D12-UART_RX,D13-GPIO_0, ");
// Serial.println(" keeping encoder");
}

Expand Down
2 changes: 1 addition & 1 deletion JumperlessNano/src/FileParsing.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extern bool debugMM;

//extern File nodeFile;
void createSlots(int slot = -1, int addRotaryConnections = 0);
void inputNodeFileList(void);
void inputNodeFileList(int addRotaryConnections = 0);
//this just opens the file, takes out all the bullshit, and then populates the newBridge array
void parseWokwiFileToNodeFile();
void changeWokwiDefinesToJumperless ();
Expand Down
4 changes: 3 additions & 1 deletion JumperlessNano/src/LEDs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ void showSavedColors(int slot)
// }
// Serial.print("\rNo saved colors for slot ");
// Serial.print(slot);
///pauseCore2 = 1;
clearAllNTCC();
openNodeFile(slot);
getNodesToConnect();
Expand All @@ -572,8 +573,9 @@ void showSavedColors(int slot)
// leds.clear();

assignNetColors();
//pauseCore2 = 0;
showNets();
lightUpRail();
//lightUpRail();
// delayMicroseconds(100);
// saveRawColors(slot);
}
Expand Down
2 changes: 2 additions & 0 deletions JumperlessNano/src/LEDs.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
extern volatile uint8_t LEDbrightness;
extern volatile uint8_t LEDbrightnessSpecial;

extern volatile uint8_t pauseCore2;

extern Adafruit_NeoPixel leds;
extern bool debugLEDs;

Expand Down
Loading

0 comments on commit 94572ac

Please sign in to comment.