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
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;
@ -107,7 +105,6 @@ delayMicroseconds(2);
irq_flags = pio0_hw->irq;
pio_interrupt_clear(pio, PIO0_IRQ_0);
hw_clear_bits(&pio0_hw->irq, irq_flags);
}
void initCH446Q(void)
@ -116,13 +113,10 @@ void initCH446Q(void)
uint dat = 14;
uint clk = 15;
if (MYNAMEISERIC)
{
dat = 18;
clk = 19;
}
uint cs = 7;
@ -174,8 +168,6 @@ if (MYNAMEISERIC)
digitalWrite(RESETPIN, LOW);
}
void resetArduino(void)
{
int lastPath = MAX_BRIDGES - 1;
@ -189,9 +181,6 @@ void resetArduino (void)
sendPath(lastPath, 1);
delay(100);
sendPath(lastPath, 0);
}
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;
}
sendPath(i, 1);
if (debugNTCC2)
if (debugNTCC)
{
Serial.print("path ");
Serial.print(i);
@ -223,13 +212,10 @@ if (debugNTCC2)
Serial.print("]:");
Serial.print(path[i].y[j]);
Serial.print(" \t ");
}
Serial.print("\n\n\r");
}
}
}
void sendPath(int i, int setOrClear)
@ -275,11 +261,11 @@ void sendPath(int i, int setOrClear)
// delayMicroseconds(50);
delayMicroseconds(60);
delayMicroseconds(30);
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
// https://wokwi.com/projects/367384677537829889
void setup()
@ -77,13 +75,10 @@ void setup1()
// delay (4);
initLEDs();
startupColors();
lightUpRail();
showLEDsCore2 = 1;
}
void loop()
@ -147,20 +142,20 @@ menu:
break;
}
case 'a':
{
resetArduino(); // reset works
// uploadArduino(); //this is unwritten
}
// case 'a':
// {
// resetArduino(); // reset works
// // uploadArduino(); //this is unwritten
// }
case 'f':
digitalWrite(RESETPIN, HIGH);
clearAllNTCC();
delay(5);
// delay(1);
// showLEDsCore2 = 1;
digitalWrite(RESETPIN, LOW);
// delay(5);
// resetArduino();
@ -173,7 +168,7 @@ sendAllPathsCore2 = 1;
openNodeFile();
getNodesToConnect();
#endif
digitalWrite(RESETPIN, LOW);
bridgesToPaths();
clearLEDs();
assignNetColors();
@ -192,8 +187,6 @@ sendAllPathsCore2 = 1;
Serial.print("ms");
}
break;
case '\n':
@ -285,7 +278,6 @@ sendAllPathsCore2 = 1;
}
break;
case 'r':
resetArduino();
break;
@ -357,7 +349,6 @@ sendAllPathsCore2 = 1;
}
unsigned long logoFlashTimer = 0;
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)
{
lightUpRail();
}
if (rails > 3)
{
Serial.print("\n\r");
Serial.print(rails);
}
delayMicroseconds(5200);
delayMicroseconds(3200);
leds.show();
delayMicroseconds(9200);
delayMicroseconds(8200);
showLEDsCore2 = 0;
}
if (sendAllPathsCore2 == 1)
{
delayMicroseconds(12200);
delayMicroseconds(6200);
sendAllPaths();
delayMicroseconds(4200);
delayMicroseconds(2200);
showNets();
delayMicroseconds(9200);
sendAllPathsCore2 = 0;
}
if (logoFlash == 2)
{
logoFlashTimer = millis();
logoFlash = 1;
}
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.show();
}
}