added a super-duper raw xy command and a way to toggle GPIO_0

This commit is contained in:
Kevin Santo Cappuccio 2024-12-01 11:34:12 -08:00
parent c957b0e754
commit 105b5f5aa9
6 changed files with 185 additions and 13 deletions

View File

@ -1 +0,0 @@
{"hostname":"Kevins-MacBook-Pro","username":"kevinsanto"}

View File

@ -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");

View File

@ -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();

View File

@ -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)

View File

@ -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;

View File

@ -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;
@ -857,7 +884,10 @@ skipinput:
break;
case 'r':
if (rotaryEncoderInitialized == 0) {
initRotaryEncoder();
rotaryEncoderInitialized = 1;
}
if (rotaryEncoderMode == 1) {
// unInitRotaryEncoder();