fixin bullshit

This commit is contained in:
Kevin Santo Cappuccio 2023-07-05 13:02:54 -07:00
parent b8f58bc7ff
commit d874b49848
5 changed files with 90 additions and 74 deletions

View File

@ -60,7 +60,7 @@ justChecked = 0
reading = 0 reading = 0
def check_presence(correct_port, interval=.25): def check_presence(correct_port, interval=.15):
global ser global ser
global justreconnected global justreconnected
global serialconnected global serialconnected
@ -112,62 +112,22 @@ def check_presence(correct_port, interval=.25):
import threading import threading
port_controller = threading.Thread(target=check_presence, args=(portName, .25,), daemon=True) port_controller = threading.Thread(target=check_presence, args=(portName, .15,), daemon=True)
#port_controller.daemon(True) #port_controller.daemon(True)
port_controller.start() port_controller.start()
def waitForReconnect():
global ser
global justChecked
global serialconnected
serialconnected = 0
portNotFound = 1
while (portNotFound == 1):
portFound = 0
for port in serial.tools.list_ports.comports():
if portName in port.device:
portFound = 1
#print (port.device)
if portFound >= 1:
ser = serial.Serial(portName, 115200, timeout= None)
justChecked = 1
serialconnected = 1
time.sleep(0.05)
justChecked = 0
portNotFound = 0
else:
justreconnected = 1
justChecked = 0
serialconnected = 0
ser.close()
portNotFound = 1
time.sleep(.05)
#555 project
#https://wokwi.com/projects/369024970682423297 #https://wokwi.com/projects/369024970682423297
#the website URL #the website URL
url_link = "https://wokwi.com/projects/369024970682423297" #url_link = "https://wokwi.com/projects/369024970682423297"
#url_link = input('\n\n\rPaste the link to you Wokwi project here:\n\n\r') url_link = input('\n\n\rPaste the link to you Wokwi project here:\n\n\r')
while True: while True:
@ -239,7 +199,7 @@ def serialTermIn():
except: except:
portNotFound = 1 portNotFound = 1
print("!!!!!!") print("Disconnected")
while (portNotFound == 1): while (portNotFound == 1):
portFound = 0 portFound = 0
@ -365,9 +325,14 @@ while True:
#ser = serial.Serial(portName, 460800, timeout=0.050) #ser = serial.Serial(portName, 460800, timeout=0.050)
while (justreconnected == 1): while (justreconnected == 1):
time.sleep(.001) time.sleep(.01)
if serialconnected == 1: lastDiagram = '-1'
if (serialconnected == 1):
print ('Reconnected')
break break
else:
justreconnected = 0
if (serialconnected == 1): if (serialconnected == 1):
@ -414,10 +379,10 @@ while True:
if (justreconnected == 1): #if (justreconnected == 1):
print ('Reconnected')
lastDiagram = '-1'
#print (lastDiagram) #print (lastDiagram)
#time.sleep(1.8) #time.sleep(1.8)
@ -573,14 +538,14 @@ while True:
ser.write(p.encode()) ser.write(p.encode())
except: except:
#continue continue
waitForReconnect() #waitForReconnect()
ser.write('f'.encode()) #ser.write('f'.encode())
time.sleep(0.05) #time.sleep(0.05)
ser.write(p.encode()) #ser.write(p.encode())
#print (p) #print (p)

View File

@ -681,7 +681,9 @@ debugNMtime = EEPROM.read(TIME_NETMANAGERADDRESS);
debugNTCC = EEPROM.read(DEBUG_NETTOCHIPCONNECTIONSADDRESS); debugNTCC = EEPROM.read(DEBUG_NETTOCHIPCONNECTIONSADDRESS);
debugNTCC2 = EEPROM.read(DEBUG_NETTOCHIPCONNECTIONSALTADDRESS); debugNTCC2 = EEPROM.read(DEBUG_NETTOCHIPCONNECTIONSALTADDRESS);
//debugLEDs = EEPROM.read(DEBUG_LEDSADDRESS); debugLEDs = EEPROM.read(DEBUG_LEDSADDRESS);
#else #else
debugFP = 1; debugFP = 1;
@ -696,6 +698,33 @@ debugNTCC2 = EEPROM.read(DEBUG_NETTOCHIPCONNECTIONSALTADDRESS);
// debugLEDs = 1; // debugLEDs = 1;
#endif #endif
if (debugFP != 0 && debugFP != 1)
EEPROM.write(DEBUG_FILEPARSINGADDRESS, 1);
if (debugFPtime != 0 && debugFPtime != 1)
EEPROM.write(TIME_FILEPARSINGADDRESS, 1);
if (debugNM != 0 && debugNM != 1)
EEPROM.write(DEBUG_NETMANAGERADDRESS, 1);
if (debugNMtime != 0 && debugNMtime != 1)
EEPROM.write(TIME_NETMANAGERADDRESS, 1);
if (debugNTCC != 0 && debugNTCC != 1)
EEPROM.write(DEBUG_NETTOCHIPCONNECTIONSADDRESS, 1);
if (debugNTCC2 != 0 && debugNTCC2 != 1)
EEPROM.write(DEBUG_NETTOCHIPCONNECTIONSALTADDRESS, 1);
if (debugLEDs != 0 && debugLEDs != 1)
EEPROM.write(DEBUG_LEDSADDRESS, 1);
EEPROM.commit();
delay(5);
} }
void debugFlagSet(int flag) void debugFlagSet(int flag)
@ -870,9 +899,9 @@ void debugFlagSet(int flag)
break; break;
} }
} }
delay(2); delay(4);
EEPROM.commit(); EEPROM.commit();
delay(5); delay(8);
return; return;
} }

View File

@ -2,6 +2,7 @@
#include <Adafruit_NeoPixel.h> #include <Adafruit_NeoPixel.h>
#include "NetsToChipConnections.h" #include "NetsToChipConnections.h"
#include "MatrixStateRP2040.h" #include "MatrixStateRP2040.h"
#include "fileParsing.h"
@ -18,7 +19,9 @@ int showLEDsCore2 = 0;
#ifdef EEPROMSTUFF #ifdef EEPROMSTUFF
#include <EEPROM.h> #include <EEPROM.h>
bool debugLEDs = EEPROM.read(DEBUG_LEDSADDRESS); bool debugLEDs = 1; //EEPROM.read(DEBUG_LEDSADDRESS);
#else #else
bool debugLEDs = 1; bool debugLEDs = 1;
#endif #endif
@ -44,9 +47,22 @@ int showLEDsCore2 = 0;
void initLEDs(void) void initLEDs(void)
{ {
debugLEDs = EEPROM.read(DEBUG_LEDSADDRESS);
if (debugLEDs != 0 && debugLEDs != 1)
{
debugLEDs = 1;
}
EEPROM.write(DEBUG_LEDSADDRESS, debugLEDs);
EEPROM.commit();
delay(80);
pinMode(LED_PIN, OUTPUT); pinMode(LED_PIN, OUTPUT);
delay(2);
leds.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) leds.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
delay(2);
showLEDsCore2 = 1; // Turn OFF all pixels ASAP showLEDsCore2 = 1; // Turn OFF all pixels ASAP
delay(4);
leds.setBrightness(BRIGHTNESS); leds.setBrightness(BRIGHTNESS);
} }
@ -119,6 +135,7 @@ if (debugLEDs)
Serial.print(numberOfNets); Serial.print(numberOfNets);
Serial.print("\n\rassigning net colors\n\r"); Serial.print("\n\rassigning net colors\n\r");
Serial.print("\n\rNet\t\tR\tG\tB\t\tH\tS\tV"); Serial.print("\n\rNet\t\tR\tG\tB\t\tH\tS\tV");
delay(3);
} }
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
@ -142,6 +159,7 @@ if (debugLEDs)
Serial.print(netHsv.s); Serial.print(netHsv.s);
Serial.print("\t"); Serial.print("\t");
Serial.print(netHsv.v); Serial.print(netHsv.v);
delay(3);
} }
} }
@ -258,7 +276,7 @@ if (debugLEDs)
Serial.print(saturation); Serial.print(saturation);
Serial.print("\t"); Serial.print("\t");
Serial.print(brightness); Serial.print(brightness);
delay(3);
} }
} }
} }

View File

@ -1798,7 +1798,7 @@ void swapDuplicateNode(int pathIndex)
void printPathsCompact(void) void printPathsCompact(void)
{ {
Serial.println("\n\rpath\tnet\tnode1\ttype\tchip0\tx0\ty0\tnode2\ttype\tchip1\tx1\ty1\taltPath\tsameChp\tpthType\t\tchipL\tchip2\tx2\ty2\tx3\ty3\tchip3\tx4\ty4\tx5\ty5\n\r"); Serial.println("\n\rpath\tnet\tnode1\ttype\tchip0\tx0\ty0\tnode2\ttype\tchip1\tx1\ty1\taltPath\tsameChp\tpathType\t\tchipL\tchip2\tx2\ty2\tx3\ty3\n\r");
for (int i = 0; i < numberOfPaths; i++) for (int i = 0; i < numberOfPaths; i++)
{ {
Serial.print(i); Serial.print(i);
@ -1862,7 +1862,7 @@ void printPathsCompact(void)
Serial.println(" "); Serial.println(" ");
} }
Serial.println("\n\rpath\tnet\tnode1\ttype\tchip0\tx0\ty0\tnode2\ttype\tchip1\tx1\ty1\taltPath\tsameChp\tpthType\t\tchipL\tchip2\tx2\ty2\tx3\ty3\tchip3\tx4\ty4\tx5\ty5\n\r"); Serial.println("\n\rpath\tnet\tnode1\ttype\tchip0\tx0\ty0\tnode2\ttype\tchip1\tx1\ty1\taltPath\tsameChp\tpathType\t\tchipL\tchip2\tx2\ty2\tx3\ty3\n\r");
} }
void printChipStatus(void) void printChipStatus(void)

View File

@ -43,7 +43,7 @@ void setup()
// //
// initArduino(); // initArduino();
debugFlagInit(); //debugFlagInit();
#ifdef EEPROMSTUFF #ifdef EEPROMSTUFF
EEPROM.begin(256); EEPROM.begin(256);
@ -72,7 +72,7 @@ setDac0_5V(0.0);
void setup1() void setup1()
{ {
//delay(100);
initLEDs(); initLEDs();
lightUpRail(-1, 1, 220); lightUpRail(-1, 1, 220);
@ -103,10 +103,10 @@ menu:
Serial.print("\tn = show netlist\n\r"); Serial.print("\tn = show netlist\n\r");
Serial.print("\tb = show bridge array\n\r"); Serial.print("\tb = show bridge array\n\r");
Serial.print("\tw = waveGen\n\r"); Serial.print("\tw = waveGen\n\r");
Serial.print("\tm = measure current/voltage\n\r"); //Serial.print("\tm = measure current/voltage\n\r");
Serial.print("\tf = load formatted nodeFile\n\r"); Serial.print("\tf = load formatted nodeFile\n\r");
Serial.print("\tu = upload new Wokwi diagram\n\r"); Serial.print("\tp = paste new Wokwi diagram\n\r");
Serial.print("\tt = reset and load nodeFile.txt\n\r"); //Serial.print("\tt = reset and load nodeFile.txt\n\r");
Serial.print("\td = toggle debug flags\n\r"); Serial.print("\td = toggle debug flags\n\r");
Serial.print("\tr = reset\n\r"); Serial.print("\tr = reset\n\r");
Serial.print("\n\r"); Serial.print("\n\r");
@ -178,14 +178,16 @@ menu:
sendAllPaths(); sendAllPaths();
#endif #endif
if (debugNMtime)
{
Serial.print("\n\n\r"); Serial.print("\n\n\r");
Serial.print("took "); Serial.print("took ");
Serial.print(millis() - timer); Serial.print(millis() - timer);
Serial.print("ms"); Serial.print("ms");
}
break; break;
case 'u': case 'p':
// case '{': // case '{':
@ -222,11 +224,13 @@ menu:
sendAllPaths(); sendAllPaths();
#endif #endif
if (debugNMtime)
{
Serial.print("\n\n\r"); Serial.print("\n\n\r");
Serial.print("took "); Serial.print("took ");
Serial.print(millis() - timer); Serial.print(millis() - timer);
Serial.print("ms"); Serial.print("ms");
}
break; break;
case 't': case 't':
@ -275,8 +279,8 @@ menu:
digitalWrite(RESETPIN, LOW); digitalWrite(RESETPIN, LOW);
clearAllNTCC(); clearAllNTCC();
leds.clear(); leds.clear();
leds.show(); //leds.show();
showLEDsCore2 = 1;
// AIRCR_Register = 0x5FA0004; // this just hardware resets the rp2040, it would be too much of a pain in the ass to reinitialize everything // AIRCR_Register = 0x5FA0004; // this just hardware resets the rp2040, it would be too much of a pain in the ass to reinitialize everything
break; break;
@ -384,7 +388,7 @@ void loop1()
if (showLEDsCore2 == 1) if (showLEDsCore2 == 1)
{ {
leds.show(); leds.show();
delayMicroseconds(900); delayMicroseconds(1200);
showLEDsCore2 = 0; showLEDsCore2 = 0;
} }