From b6fd16eb2a3694b0651aeb7057bbf1143ceb89c1 Mon Sep 17 00:00:00 2001 From: jonny_jr9 Date: Wed, 13 Sep 2023 15:38:40 +0200 Subject: [PATCH] Patch V2.1-board-motorctl to work with new common code Changes to outsourced motorctl code made configuration of currently unused board-motorctl from V2.1 incompatible -> patch config --- board_control/sdkconfig | 17 +++++++++++++++++ board_motorctl/main/config.cpp | 16 ++++++++++++++-- board_motorctl/sdkconfig | 17 +++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/board_control/sdkconfig b/board_control/sdkconfig index f7c6b17..6e3dc02 100644 --- a/board_control/sdkconfig +++ b/board_control/sdkconfig @@ -132,6 +132,23 @@ CONFIG_PARTITION_TABLE_OFFSET=0x8000 CONFIG_PARTITION_TABLE_MD5=y # end of Partition Table +# +# SSD1306 Configuration +# +CONFIG_GPIO_RANGE_MAX=33 +CONFIG_I2C_INTERFACE=y +# CONFIG_SPI_INTERFACE is not set +# CONFIG_SSD1306_128x32 is not set +CONFIG_SSD1306_128x64=y +CONFIG_OFFSETX=0 +# CONFIG_FLIP is not set +CONFIG_SCL_GPIO=22 +CONFIG_SDA_GPIO=21 +CONFIG_RESET_GPIO=15 +CONFIG_I2C_PORT_0=y +# CONFIG_I2C_PORT_1 is not set +# end of SSD1306 Configuration + # # Compiler options # diff --git a/board_motorctl/main/config.cpp b/board_motorctl/main/config.cpp index 3d57660..543596e 100644 --- a/board_motorctl/main/config.cpp +++ b/board_motorctl/main/config.cpp @@ -76,10 +76,22 @@ fan_config_t configCooling = { //===== create global objects ===== //================================= //TODO outsource global variables to e.g. global.cpp and only config options here? +single100a motorDriverLeft(configDriverLeft); +single100a motorDriverRight(configDriverRight); +//--- controlledMotor --- +//functions for updating the duty via certain/current driver that can then be passed to controlledMotor +//-> makes it possible to easily use different motor drivers +//note: ignoring warning "capture of variable with non-automatic storage duration", since sabertoothDriver object does not get destroyed anywhere - no lifetime issue +motorSetCommandFunc_t setLeftFunc = [&motorDriverLeft](motorCommand_t cmd) { + motorDriverLeft.set(cmd); +}; +motorSetCommandFunc_t setRightFunc = [&motorDriverRight](motorCommand_t cmd) { + motorDriverRight.set(cmd); +}; //create controlled motor instances (motorctl.hpp) -controlledMotor motorLeft(configDriverLeft, configMotorControlLeft); -controlledMotor motorRight(configDriverRight, configMotorControlRight); +controlledMotor motorLeft(setLeftFunc, configMotorControlLeft); +controlledMotor motorRight(setRightFunc, configMotorControlRight); //create buzzer object on pin 12 with gap between queued events of 100ms buzzer_t buzzer(GPIO_NUM_12, 100); diff --git a/board_motorctl/sdkconfig b/board_motorctl/sdkconfig index c54e196..8eb3f07 100644 --- a/board_motorctl/sdkconfig +++ b/board_motorctl/sdkconfig @@ -132,6 +132,23 @@ CONFIG_PARTITION_TABLE_OFFSET=0x8000 CONFIG_PARTITION_TABLE_MD5=y # end of Partition Table +# +# SSD1306 Configuration +# +CONFIG_GPIO_RANGE_MAX=33 +CONFIG_I2C_INTERFACE=y +# CONFIG_SPI_INTERFACE is not set +# CONFIG_SSD1306_128x32 is not set +CONFIG_SSD1306_128x64=y +CONFIG_OFFSETX=0 +# CONFIG_FLIP is not set +CONFIG_SCL_GPIO=22 +CONFIG_SDA_GPIO=21 +CONFIG_RESET_GPIO=15 +CONFIG_I2C_PORT_0=y +# CONFIG_I2C_PORT_1 is not set +# end of SSD1306 Configuration + # # Compiler options #