From 41b71f5b292b1733800eb77128f9fd7a32c49794 Mon Sep 17 00:00:00 2001 From: joshua-8 Date: Wed, 25 Sep 2024 00:24:04 -0700 Subject: [PATCH] workign on start pulse for esp32 --- gbg_program/_Save_Recall.ino | 4 +++- gbg_program/gbg_program.ino | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/gbg_program/_Save_Recall.ino b/gbg_program/_Save_Recall.ino index d179e72..33e8662 100644 --- a/gbg_program/_Save_Recall.ino +++ b/gbg_program/_Save_Recall.ino @@ -163,6 +163,7 @@ void settingsSerial() { leftMotorController.writeMicroseconds(LEFT_MOTOR_CENTER); leftMotorController.detach(); LEFT_MOTOR_CONTROLLER_PIN = atoi(v); + delay(10); leftMotorController.attach(LEFT_MOTOR_CONTROLLER_PIN); leftMotorController.writeMicroseconds(LEFT_MOTOR_CENTER); rightMotorController.attach(RIGHT_MOTOR_CONTROLLER_PIN); @@ -174,6 +175,7 @@ void settingsSerial() { rightMotorController.writeMicroseconds(RIGHT_MOTOR_CENTER); rightMotorController.detach(); RIGHT_MOTOR_CONTROLLER_PIN = atoi(v); + delay(10); rightMotorController.attach(RIGHT_MOTOR_CONTROLLER_PIN); rightMotorController.writeMicroseconds(RIGHT_MOTOR_CENTER); leftMotorController.attach(LEFT_MOTOR_CONTROLLER_PIN); @@ -192,7 +194,7 @@ void settingsSerial() { RIGHT_MOTOR_PULSE = atoi(v); sprintf(resultBuf, "%d", RIGHT_MOTOR_PULSE); } else if (strcmp(k, "START_MOTOR_PULSE_TIME") == 0) { - START_MOTOR_PULSE_TIME = max(atoi(v), 0); + START_MOTOR_PULSE_TIME = constrain(atoi(v), 0, 1000); sprintf(resultBuf, "%d", START_MOTOR_PULSE_TIME); } else if (strcmp(k, "ENABLE_STARTUP_PULSE") == 0) { ENABLE_STARTUP_PULSE = atoi(v); diff --git a/gbg_program/gbg_program.ino b/gbg_program/gbg_program.ino index b4d6a36..4f9a367 100644 --- a/gbg_program/gbg_program.ino +++ b/gbg_program/gbg_program.ino @@ -453,6 +453,7 @@ void loop() if (startupPulse && joyOK && delayedStartDone) { startupPulse = false; if (movementAllowed) { // don't pulse if the website says don't move + delay(10); leftMotorController.writeMicroseconds(LEFT_MOTOR_CENTER + LEFT_MOTOR_PULSE * (LEFT_MOTOR_SLOW > 0 ? 1 : -1)); rightMotorController.writeMicroseconds(RIGHT_MOTOR_CENTER + RIGHT_MOTOR_PULSE * (RIGHT_MOTOR_SLOW > 0 ? 1 : -1)); }