From 105b5f5aa97d77f1c3990fe92495065090fc3be7 Mon Sep 17 00:00:00 2001 From: Kevin Santo Cappuccio Date: Sun, 1 Dec 2024 11:34:12 -0800 Subject: [PATCH] added a super-duper raw xy command and a way to toggle GPIO_0 --- .../~JumperlessRev3point1.kicad_sch.lck | 1 - JumperlessNano/src/FileParsing.cpp | 142 +++++++++++++++++- JumperlessNano/src/FileParsing.h | 4 +- JumperlessNano/src/RotaryEncoder.cpp | 3 + JumperlessNano/src/RotaryEncoder.h | 2 + JumperlessNano/src/main.cpp | 46 +++++- 6 files changed, 185 insertions(+), 13 deletions(-) delete mode 100644 Hardware/KiCAD/JumperlessRev3point1/~JumperlessRev3point1.kicad_sch.lck diff --git a/Hardware/KiCAD/JumperlessRev3point1/~JumperlessRev3point1.kicad_sch.lck b/Hardware/KiCAD/JumperlessRev3point1/~JumperlessRev3point1.kicad_sch.lck deleted file mode 100644 index e9336e2..0000000 --- a/Hardware/KiCAD/JumperlessRev3point1/~JumperlessRev3point1.kicad_sch.lck +++ /dev/null @@ -1 +0,0 @@ -{"hostname":"Kevins-MacBook-Pro","username":"kevinsanto"} \ No newline at end of file diff --git a/JumperlessNano/src/FileParsing.cpp b/JumperlessNano/src/FileParsing.cpp index ce2c551..9c9f873 100644 --- a/JumperlessNano/src/FileParsing.cpp +++ b/JumperlessNano/src/FileParsing.cpp @@ -16,10 +16,10 @@ bool debugFP = EEPROM.read(DEBUG_FILEPARSINGADDRESS); bool debugFPtime = EEPROM.read(TIME_FILEPARSINGADDRESS); -createSafeString(nodeFileString, 1200); +createSafeString(nodeFileString, 3000); int numConnsJson = 0; -createSafeString(specialFunctionsString, 800); +createSafeString(specialFunctionsString, 3000); char inputBuffer[INPUTBUFFERLENGTH] = {0}; @@ -38,6 +38,10 @@ unsigned long timeToFP = 0; const char rotaryConnectionString[] = "{AREF-GND,D11-GND,D10-UART_TX,D12-UART_RX,D13-GPIO_0, "; + + + + void createSlots(int slot, int addRotaryConnections) { /// delay(2000); if (slot == -1) { @@ -88,7 +92,7 @@ void createSlots(int slot, int addRotaryConnections) { // } // nodeFileString.printTo(Serial); nodeFile.seek(0); - if (nodeFile.size() <= 10) { + if (nodeFile.size() <= 5) { nodeFile = LittleFS.open("nodeFileSlot" + String(i) + ".txt", "w+"); if (i >= 0) { @@ -127,6 +131,138 @@ void createSlots(int slot, int addRotaryConnections) { nodeFile.close(); } } + + +int rawConn[4]; //connect/clear, chip, x, y +int parseRaw(int connectOrClear) { + // Serial.println("Parsing raw"); + unsigned long humanTime = millis(); + + int shown = 0; + + int connectClear = connectOrClear; + int chip = -1; + int x = -1; + int y = -1; + + + while (Serial.available() == 0) { + if (millis() - humanTime == 300 && shown == 0) { + Serial.print("\th/H [clear/CONNECT], chip [A-L/0-11], X [0-15], Y [0-7]\n\n\r"); + Serial.print("\t\tExample: H,d,13,5\n\r"); + shown = 1; + //break; + } + if (millis() - humanTime == 2000 && shown == 1) { + return 0; + } + } + + // nodeFileString.clear(); + + // nodeFileString.readUntil(Serial,','); + // nodeFileString.trim(); + // Serial.print("\n\rconnectClear: "); + // nodeFileString.printTo(Serial); + + // if (nodeFileString == "h" || nodeFileString == "H") { + // connectClear = 0; + // } else { + // connectClear = 0; + // } + nodeFileString.clear(); + nodeFileString.readUntil(Serial,','); + nodeFileString.clear(); + nodeFileString.readUntil(Serial,','); + nodeFileString.trim(); + nodeFileString.replace(",", ""); + + Serial.print("\n\rchip: "); + nodeFileString.printTo(Serial); + //Serial.print(" -> "); + + nodeFileString.replace("\n", ""); + nodeFileString.replace("\r", ""); + nodeFileString.replace("a", "0"); + nodeFileString.replace("b", "1"); + nodeFileString.replace("c", "2"); + nodeFileString.replace("d", "3"); + nodeFileString.replace("e", "4"); + nodeFileString.replace("f", "5"); + nodeFileString.replace("g", "6"); + nodeFileString.replace("h", "7"); + nodeFileString.replace("i", "8"); + nodeFileString.replace("j", "9"); + nodeFileString.replace("k", "10"); + nodeFileString.replace("l", "11"); + + nodeFileString.replace("A", "0"); + nodeFileString.replace("B", "1"); + nodeFileString.replace("C", "2"); + nodeFileString.replace("D", "3"); + nodeFileString.replace("E", "4"); + nodeFileString.replace("F", "5"); + nodeFileString.replace("G", "6"); + nodeFileString.replace("H", "7"); + nodeFileString.replace("I", "8"); + nodeFileString.replace("J", "9"); + nodeFileString.replace("K", "10"); + nodeFileString.replace("L", "11"); + nodeFileString.replace(",", ""); + + //nodeFileString.printTo(Serial); + +nodeFileString.toInt(chip); + nodeFileString.clear(); + + nodeFileString.readUntil(Serial,','); + nodeFileString.replace(",", ""); + nodeFileString.trim(); + Serial.print("\n\rX: "); + nodeFileString.printTo(Serial); + +nodeFileString.toInt(x); + nodeFileString.clear(); + nodeFileString.readUntil(Serial,','); + nodeFileString.replace(",", ""); + nodeFileString.trim(); + Serial.print("\n\rY: "); + nodeFileString.printTo(Serial); + +nodeFileString.toInt(y); + +Serial.println(); +// Serial.println(chip); +// Serial.println(x); +// Serial.println(y); + + + +if (chip < 0 || chip > 11 || x < 0 || x > 15 || y < 0 || y > 7) +{ + Serial.println("Invalid input"); + return 0; +} + + rawConn[0] = connectClear; + rawConn[1] = chip; + rawConn[2] = x; + rawConn[3] = y; + + return 1; + + + + + + + +} + + + + + void inputNodeFileList(int addRotaryConnections) { // addRotaryConnections = 1; // Serial.println("Paste the nodeFile list here\n\n\r"); diff --git a/JumperlessNano/src/FileParsing.h b/JumperlessNano/src/FileParsing.h index 35f1f41..3d05e6f 100644 --- a/JumperlessNano/src/FileParsing.h +++ b/JumperlessNano/src/FileParsing.h @@ -16,6 +16,8 @@ extern bool debugMM; extern int loadFileOnStart; +extern int rawConn[4]; //connect/clear, chip, x, y + // #include "RotaryEncoder.h" @@ -31,7 +33,7 @@ void addBridgeToNodeFile(int node1, int node2, int slot = 0); void savePreformattedNodeFile (int source = 0, int slot = 0, int keepEncoder = 1); void openNodeFile(int slot = 0); - +int parseRaw(int connectOrClear = 1); void splitStringToFields(); void replaceSFNamesWithDefinedInts(); diff --git a/JumperlessNano/src/RotaryEncoder.cpp b/JumperlessNano/src/RotaryEncoder.cpp index 03469cc..1922d27 100644 --- a/JumperlessNano/src/RotaryEncoder.cpp +++ b/JumperlessNano/src/RotaryEncoder.cpp @@ -29,6 +29,8 @@ volatile int rotaryEncoderMode = 0; volatile int slotPreview = 0; +bool rotaryEncoderInitialized = false; + void initRotaryEncoder(void) { @@ -39,6 +41,7 @@ void initRotaryEncoder(void) offsetEnc = pio_add_program(pioEnc, &quadrature_program); smEnc = pio_claim_unused_sm(pioEnc, true); quadrature_program_init(pioEnc, smEnc, offsetEnc, QUADRATURE_A_PIN, QUADRATURE_B_PIN); + rotaryEncoderInitialized = true; } void unInitRotaryEncoder(void) diff --git a/JumperlessNano/src/RotaryEncoder.h b/JumperlessNano/src/RotaryEncoder.h index 01ca39d..17e14b4 100644 --- a/JumperlessNano/src/RotaryEncoder.h +++ b/JumperlessNano/src/RotaryEncoder.h @@ -7,6 +7,8 @@ extern volatile int rotaryEncoderMode; extern int netSlot; extern volatile int slotChanged; +extern bool rotaryEncoderInitialized; + extern volatile int slotPreview; extern int rotState; extern int encoderIsPressed; diff --git a/JumperlessNano/src/main.cpp b/JumperlessNano/src/main.cpp index b64a0b2..4a0a150 100644 --- a/JumperlessNano/src/main.cpp +++ b/JumperlessNano/src/main.cpp @@ -135,10 +135,11 @@ void setup() { // if (rotaryEncoderMode == 1) // { // rotEncInit = 1; - initRotaryEncoder(); + // initRotaryEncoder(); //} initADC(); - + pinMode(0, OUTPUT); + digitalWrite(0, LOW); // delay(20); // setupAdcUsbStuff(); // I took this out because it was causing a crash on delay(10); @@ -171,7 +172,7 @@ int readInNodesArduino = 0; int restoredNodeFile = 0; -const char firmwareVersion[] = "1.3.19"; //// remember to update this +const char firmwareVersion[] = "1.3.20"; //// remember to update this int firstLoop = 1; volatile int probeActive = 1; @@ -207,12 +208,16 @@ menu: rotaryEncoderMode == 1 ? Serial.print(" ON (z/x to cycle)\n\r") : Serial.print(" off\n\r"); Serial.print("\t\b\bz/x = cycle slots - current slot "); + Serial.print(netSlot); + Serial.print("\n\r"); + Serial.print("\t\b\bq/Q = set GPIO 0 low/HIGH\n\r"); Serial.print("\te = show extra menu options\n\r"); if (showExtraMenu == 1) { Serial.print("\tb = show bridge array\n\r"); + Serial.print("\th = send raw XY paths\n\r"); Serial.print("\tp = probe connections\n\r"); Serial.print("\tw = waveGen\n\r"); Serial.print("\tv = toggle show current/voltage\n\r"); @@ -264,9 +269,9 @@ dontshowmenu: // Serial.print("\n\n\r"); // showLEDsCore2 = 1; } - if (BOOTSEL) { - lastNetConfirm(1); - } + // if (BOOTSEL) { + // //lastNetConfirm(1); + // } if ((millis() % 200) < 5) { if (checkProbeButton() == 1) { @@ -306,6 +311,20 @@ dontshowmenu: // Serial.print(input); skipinput: switch (input) { + case 'H': { + if (parseRaw(1) == 1) { + sendXYraw(rawConn[1], rawConn[2], rawConn[3], 1); + } + break; + } + case 'h': { + + if (parseRaw(0) == 1) { + sendXYraw(rawConn[1], rawConn[2], rawConn[3], 0); + } + + break; + } case '?': { Serial.print("Jumperless firmware version: "); Serial.println(firmwareVersion); @@ -750,6 +769,14 @@ skipinput: break; } + case 'q': { + digitalWrite(0, LOW); + break; + } + case 'Q': { + digitalWrite(0, HIGH); + break; + } case 'f': probeActive = 1; @@ -759,7 +786,7 @@ skipinput: // sendAllPathsCore2 = 1; timer = millis(); - //clearNodeFile(netSlot); + // clearNodeFile(netSlot); digitalWrite(RESETPIN, HIGH); if (connectFromArduino != '\0') { serSource = 1; @@ -857,7 +884,10 @@ skipinput: break; case 'r': - + if (rotaryEncoderInitialized == 0) { + initRotaryEncoder(); + rotaryEncoderInitialized = 1; + } if (rotaryEncoderMode == 1) { // unInitRotaryEncoder();