Add "load last net" if connected to a power bank with no USB host

This commit is contained in:
Kevin Santo Cappuccio 2024-01-12 14:23:16 -08:00
parent f9e199d687
commit 43a8d674dc
4 changed files with 399 additions and 320 deletions

View File

@ -84,6 +84,33 @@ void savePreformattedNodeFile(int source)
nodeFile.close();
}
void printNodeFile(void)
{
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.clear();
nodeFileString.read(nodeFile);
nodeFile.close();
Serial.println(nodeFileString);
nodeFileString.clear();
}
void parseWokwiFileToNodeFile(void)
{

View File

@ -29,7 +29,7 @@ void openNodeFile();
void splitStringToFields();
void replaceSFNamesWithDefinedInts();
void printNodeFile(void);
void replaceNanoNamesWithDefinedInts();
void parseStringToBridges();

View File

@ -1578,7 +1578,7 @@ struct rgbColor unpackRgb(uint32_t color)
}
void clearLEDs(void)
{
for (int i = 0; i <= 254; i++)
for (int i = 0; i <= 116; i++)
{ // For each pixel in strip...
leds.setPixelColor(i, 0); // Set pixel's color (in RAM)

View File

@ -94,7 +94,65 @@ void setup()
setDac1_8Vvoltage(1.9);
clearAllNTCC();
delay(4);
while (tud_connected() == 0 && millis() < 500);
if (tud_connected() == 0 )
{
int bootselPressed = 0;
openNodeFile();
getNodesToConnect();
// Serial.print("openNF\n\r");
digitalWrite(RESETPIN, HIGH);
bridgesToPaths();
clearLEDs();
assignNetColors();
sendAllPathsCore2 = 1;
delay(250);
if (BOOTSEL)
{
bootselPressed = 1;
}
while (tud_connected() == 0 )
{
if (BOOTSEL) bootselPressed = 1;
clearLEDs();
showLEDsCore2 = 1;
if (BOOTSEL) bootselPressed = 1;
delay(250);
sendAllPathsCore2 = 1;
if (BOOTSEL) bootselPressed = 1;
delay(250);
if (bootselPressed == 1)
{
unsigned long longPressTimer = millis();
while (BOOTSEL)
{
if (millis() - longPressTimer > 1500)
{
clearAllNTCC();
clearLEDs();
sendAllPathsCore2 = 1;
break;
}
}
digitalWrite(RESETPIN, LOW);
sendAllPathsCore2 = 1;
break;
}
}
}
}
void setup1()
@ -130,7 +188,12 @@ void loop()
menu:
// showMeasurements();
// unsigned long connecttimer = 0;
// // while (tud_connected() == 0)
// // {
// // connecttimer = millis();
// // }
@ -146,8 +209,7 @@ menu:
Serial.print("\tr = reset Arduino\n\r");
Serial.print("\n\n\r");
dontshowmenu:
connectFromArduino = '\0';
dontshowmenu : connectFromArduino = '\0';
while (Serial.available() == 0 && connectFromArduino == '\0')
{
@ -169,8 +231,7 @@ dontshowmenu:
}
// Serial.print(input);
skipinput:
switch (input)
skipinput : switch (input)
{
case 'v':
@ -186,8 +247,6 @@ skipinput:
chooseShownReadings();
// Serial.println(showReadings);
// Serial.write("\033"); //these VT100/ANSI commands work on some terminals and not others so I took it out
// Serial.write("\x1B\x5B");
// Serial.write("1F");//scroll up one line
@ -229,6 +288,10 @@ skipinput:
break;
case '!':
printNodeFile();
break;
case 'w':
if (waveGen() == 1)
@ -392,7 +455,6 @@ skipinput:
break;
case 'u':
Serial.print("\n\r");
Serial.print("enter baud rate\n\r");
@ -404,18 +466,9 @@ skipinput:
Serial.print(baudRate);
Serial.print("\n\r");
setBaudRate(baudRate);
break;
case 'd':
{
debugFlagInit();
@ -647,7 +700,6 @@ void loop1() // core 2 handles the LEDs and the CH446Q8
char ch = USBSer1.read();
Serial1.write(ch);
}
if (Serial1.available())