From 5ae0c8ea38ab678fe633243ab4fd81f695fe2764 Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Sat, 6 Jun 2026 16:05:06 -0500 Subject: [PATCH 1/2] feat: Update motorgo configuration to allow selection of which motor to use --- main/Kconfig.projbuild | 38 ++++++++++++++++++++++++++------------ main/main.cpp | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 14 deletions(-) diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild index c54c4d2..270e9a3 100644 --- a/main/Kconfig.projbuild +++ b/main/Kconfig.projbuild @@ -1,19 +1,33 @@ menu "Example Configuration" - choice EXAMPLE_HARDWARE - prompt "Hardware" - default EXAMPLE_HARDWARE_MOTORGO_MINI - help - Select the hardware to run this example on. + choice EXAMPLE_HARDWARE + prompt "Hardware" + default EXAMPLE_HARDWARE_MOTORGO_MINI + help + Select the hardware to run this example on. - config EXAMPLE_HARDWARE_MOTORGO_MINI - depends on IDF_TARGET_ESP32S3 - bool "MotorGo Mini" + config EXAMPLE_HARDWARE_MOTORGO_MINI + depends on IDF_TARGET_ESP32S3 + bool "MotorGo Mini" - config EXAMPLE_HARDWARE_TEST_STAND - depends on IDF_TARGET_ESP32S3 - bool "BLDC Motor Test Stand (TinyS3)" + config EXAMPLE_HARDWARE_TEST_STAND + depends on IDF_TARGET_ESP32S3 + bool "BLDC Motor Test Stand (TinyS3)" - endchoice + endchoice + + choice EXAMPLE_BLDC_MOTOR + prompt "Which BLDC motor to control" + default EXAMPLE_BLDC_MOTOR_1 + depends on EXAMPLE_HARDWARE_MOTORGO_MINI + help + Select the BLDC motor to control. This is only used for the MotorGo Mini hardware, which has two motors. + + config EXAMPLE_BLDC_MOTOR_1 + bool "Motor 1" + config EXAMPLE_BLDC_MOTOR_2 + bool "Motor 2" + + endchoice endmenu diff --git a/main/main.cpp b/main/main.cpp index 0978a84..9052b5a 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -19,9 +19,37 @@ extern "C" void app_main(void) { logger.info("Using MotorGo Mini hardware configuration"); // we don't want to init both motors, so we'll pass in auto_init=false auto &motorgo_mini = espp::MotorGoMini::get(); - auto motor1_config = motorgo_mini.default_motor1_config; - motorgo_mini.init_motor_channel_1(motor1_config); + +#if CONFIG_EXAMPLE_BLDC_MOTOR_1 +#pragma message("Using MotorGo Mini Motor 1") + logger.info("Configuring Motor 1"); + auto motor_config = motorgo_mini.default_motor1_config; +#elif CONFIG_EXAMPLE_BLDC_MOTOR_2 + logger.info("Configuring Motor 2"); + auto motor_config = motorgo_mini.default_motor2_config; +#else +#error "No motor selected" +#endif + + // velocity PID config: + motor_config.velocity_pid_config.kp = 0.010f; + motor_config.velocity_pid_config.ki = 0.100f; + motor_config.velocity_pid_config.kd = 0.000f; + // angle PID config: + motor_config.angle_pid_config.kp = 5.000f; + motor_config.angle_pid_config.ki = 1.000f; + motor_config.angle_pid_config.kd = 0.000f; + +#if CONFIG_EXAMPLE_BLDC_MOTOR_1 + motorgo_mini.init_motor_channel_1(motor_config); auto motor = motorgo_mini.motor1(); +#elif CONFIG_EXAMPLE_BLDC_MOTOR_2 + motorgo_mini.init_motor_channel_2(motor_config); + auto motor = motorgo_mini.motor2(); +#else +#error "No motor selected" +#endif + using BldcHaptics = espp::BldcHaptics; #elif CONFIG_EXAMPLE_HARDWARE_TEST_STAND #pragma message("Using TinyS3 Test Stand hardware configuration") From da6bfefb99ac4b4ab3bc5b25849c2f9029feff6b Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Sun, 7 Jun 2026 13:46:38 -0500 Subject: [PATCH 2/2] make logs symmetric --- main/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/main/main.cpp b/main/main.cpp index 9052b5a..d576497 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -25,6 +25,7 @@ extern "C" void app_main(void) { logger.info("Configuring Motor 1"); auto motor_config = motorgo_mini.default_motor1_config; #elif CONFIG_EXAMPLE_BLDC_MOTOR_2 +#pragma message("Using MotorGo Mini Motor 2") logger.info("Configuring Motor 2"); auto motor_config = motorgo_mini.default_motor2_config; #else