Adjusting timing and delays to make things feel a bit snappier

This commit is contained in:
Kevin Santo Cappuccio 2023-11-15 18:08:19 -08:00
parent d52ed2eda4
commit fb41f849f8
2 changed files with 86 additions and 118 deletions

View File

@ -13,8 +13,6 @@
#define MYNAMEISERIC 0 // on the board I sent to eric, the data and clock lines are bodged to GPIO 18 and 19. To allow for using hardware SPI #define MYNAMEISERIC 0 // on the board I sent to eric, the data and clock lines are bodged to GPIO 18 and 19. To allow for using hardware SPI
int chipToPinArray[12] = {CS_A, CS_B, CS_C, CS_D, CS_E, CS_F, CS_G, CS_H, CS_I, CS_J, CS_K, CS_L}; int chipToPinArray[12] = {CS_A, CS_B, CS_C, CS_D, CS_E, CS_F, CS_G, CS_H, CS_I, CS_J, CS_K, CS_L};
PIO pio = pio0; PIO pio = pio0;
@ -107,7 +105,6 @@ delayMicroseconds(2);
irq_flags = pio0_hw->irq; irq_flags = pio0_hw->irq;
pio_interrupt_clear(pio, PIO0_IRQ_0); pio_interrupt_clear(pio, PIO0_IRQ_0);
hw_clear_bits(&pio0_hw->irq, irq_flags); hw_clear_bits(&pio0_hw->irq, irq_flags);
} }
void initCH446Q(void) void initCH446Q(void)
@ -116,13 +113,10 @@ void initCH446Q(void)
uint dat = 14; uint dat = 14;
uint clk = 15; uint clk = 15;
if (MYNAMEISERIC) if (MYNAMEISERIC)
{ {
dat = 18; dat = 18;
clk = 19; clk = 19;
} }
uint cs = 7; uint cs = 7;
@ -174,8 +168,6 @@ if (MYNAMEISERIC)
digitalWrite(RESETPIN, LOW); digitalWrite(RESETPIN, LOW);
} }
void resetArduino(void) void resetArduino(void)
{ {
int lastPath = MAX_BRIDGES - 1; int lastPath = MAX_BRIDGES - 1;
@ -189,9 +181,6 @@ void resetArduino (void)
sendPath(lastPath, 1); sendPath(lastPath, 1);
delay(100); delay(100);
sendPath(lastPath, 0); sendPath(lastPath, 0);
} }
void sendAllPaths(void) // should we sort them by chip? for now, no void sendAllPaths(void) // should we sort them by chip? for now, no
{ {
@ -204,7 +193,7 @@ void sendAllPaths(void) // should we sort them by chip? for now, no
continue; continue;
} }
sendPath(i, 1); sendPath(i, 1);
if (debugNTCC2) if (debugNTCC)
{ {
Serial.print("path "); Serial.print("path ");
Serial.print(i); Serial.print(i);
@ -223,13 +212,10 @@ if (debugNTCC2)
Serial.print("]:"); Serial.print("]:");
Serial.print(path[i].y[j]); Serial.print(path[i].y[j]);
Serial.print(" \t "); Serial.print(" \t ");
} }
Serial.print("\n\n\r"); Serial.print("\n\n\r");
} }
} }
} }
void sendPath(int i, int setOrClear) void sendPath(int i, int setOrClear)
@ -275,11 +261,11 @@ void sendPath(int i, int setOrClear)
// delayMicroseconds(50); // delayMicroseconds(50);
delayMicroseconds(60); delayMicroseconds(30);
pio_sm_put(pio, sm, chAddress); pio_sm_put(pio, sm, chAddress);
delayMicroseconds(100); delayMicroseconds(60);
//} //}
} }
} }

View File

@ -31,8 +31,6 @@
volatile int sendAllPathsCore2 = 0; // this signals the core 2 to send all the paths to the CH446Q volatile int sendAllPathsCore2 = 0; // this signals the core 2 to send all the paths to the CH446Q
// https://wokwi.com/projects/367384677537829889 // https://wokwi.com/projects/367384677537829889
void setup() void setup()
@ -77,13 +75,10 @@ void setup1()
// delay (4); // delay (4);
initLEDs(); initLEDs();
startupColors(); startupColors();
lightUpRail(); lightUpRail();
showLEDsCore2 = 1; showLEDsCore2 = 1;
} }
void loop() void loop()
@ -147,20 +142,20 @@ menu:
break; break;
} }
case 'a': // case 'a':
{ // {
resetArduino(); // reset works // resetArduino(); // reset works
// uploadArduino(); //this is unwritten // // uploadArduino(); //this is unwritten
} // }
case 'f': case 'f':
digitalWrite(RESETPIN, HIGH); digitalWrite(RESETPIN, HIGH);
clearAllNTCC(); clearAllNTCC();
delay(5); // delay(1);
// showLEDsCore2 = 1; // showLEDsCore2 = 1;
digitalWrite(RESETPIN, LOW);
// delay(5); // delay(5);
// resetArduino(); // resetArduino();
@ -173,7 +168,7 @@ sendAllPathsCore2 = 1;
openNodeFile(); openNodeFile();
getNodesToConnect(); getNodesToConnect();
#endif #endif
digitalWrite(RESETPIN, LOW);
bridgesToPaths(); bridgesToPaths();
clearLEDs(); clearLEDs();
assignNetColors(); assignNetColors();
@ -192,8 +187,6 @@ sendAllPathsCore2 = 1;
Serial.print("ms"); Serial.print("ms");
} }
break; break;
case '\n': case '\n':
@ -285,7 +278,6 @@ sendAllPathsCore2 = 1;
} }
break; break;
case 'r': case 'r':
resetArduino(); resetArduino();
break; break;
@ -357,7 +349,6 @@ sendAllPathsCore2 = 1;
} }
unsigned long logoFlashTimer = 0; unsigned long logoFlashTimer = 0;
void loop1() // core 2 handles the LEDs and the CH446Q8 void loop1() // core 2 handles the LEDs and the CH446Q8
{ {
@ -370,38 +361,33 @@ void loop1() // core 2 handles the LEDs and the CH446Q8
if (rails == 1) if (rails == 1)
{ {
lightUpRail(); lightUpRail();
} }
if (rails > 3) if (rails > 3)
{ {
Serial.print("\n\r"); Serial.print("\n\r");
Serial.print(rails); Serial.print(rails);
} }
delayMicroseconds(5200); delayMicroseconds(3200);
leds.show(); leds.show();
delayMicroseconds(9200); delayMicroseconds(8200);
showLEDsCore2 = 0; showLEDsCore2 = 0;
} }
if (sendAllPathsCore2 == 1) if (sendAllPathsCore2 == 1)
{ {
delayMicroseconds(12200); delayMicroseconds(6200);
sendAllPaths(); sendAllPaths();
delayMicroseconds(4200); delayMicroseconds(2200);
showNets(); showNets();
delayMicroseconds(9200); delayMicroseconds(9200);
sendAllPathsCore2 = 0; sendAllPathsCore2 = 0;
} }
if (logoFlash == 2) if (logoFlash == 2)
{ {
logoFlashTimer = millis(); logoFlashTimer = millis();
logoFlash = 1; logoFlash = 1;
} }
if (logoFlash == 1 && logoFlashTimer != 0 && millis() - logoFlashTimer > 600) if (logoFlash == 1 && logoFlashTimer != 0 && millis() - logoFlashTimer > 600)
@ -412,8 +398,4 @@ void loop1() // core 2 handles the LEDs and the CH446Q8
leds.setPixelColor(110, 0x550008); leds.setPixelColor(110, 0x550008);
leds.show(); leds.show();
} }
} }