Skip to content

Commit

Permalink
Add thruster enable config, adjust log level in pca9685
Browse files Browse the repository at this point in the history
  • Loading branch information
sfxfs committed Dec 28, 2024
1 parent 2ed0517 commit a4a8e20
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 41 deletions.
2 changes: 1 addition & 1 deletion components/pca9685/pca9685_intf.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,6 @@ void pca9685_interface_debug_print(const char *const fmt, ...)
{
va_list list;
va_start(list, fmt);
esp_log_writev(ESP_LOG_DEBUG, "sub_pca9685", fmt, list);
esp_log_writev(ESP_LOG_INFO, "sub_pca9685", fmt, list);
va_end(list);
}
86 changes: 47 additions & 39 deletions components/protobuf_rpc/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -40,53 +40,61 @@ menu "SUB:ProtoBuf-RPC"
endmenu

menu "Thruster"
config SUB_PROTOBUF_THRUSTER0_PIN
int "Thruster0 pin"
default 25
config SUB_PROTOBUF_THRUSTERS_ENABLE
bool "Enable thrusters"
default y
help
The pin of thruster channel 0.
Enable thrusters.

config SUB_PROTOBUF_THRUSTER1_PIN
int "Thruster1 pin"
default 26
help
The pin of thruster channel 1.
if SUB_PROTOBUF_THRUSTERS_ENABLE
config SUB_PROTOBUF_THRUSTER0_PIN
int "Thruster0 pin"
default 25
help
The pin of thruster channel 0.

config SUB_PROTOBUF_THRUSTER2_PIN
int "Thruster2 pin"
default 27
help
The pin of thruster channel 2.
config SUB_PROTOBUF_THRUSTER1_PIN
int "Thruster1 pin"
default 26
help
The pin of thruster channel 1.

config SUB_PROTOBUF_THRUSTER3_PIN
int "Thruster3 pin"
default 14
help
The pin of thruster channel 3.
config SUB_PROTOBUF_THRUSTER2_PIN
int "Thruster2 pin"
default 27
help
The pin of thruster channel 2.

config SUB_PROTOBUF_THRUSTER4_PIN
int "Thruster4 pin"
default 12
help
The pin of thruster channel 4.
config SUB_PROTOBUF_THRUSTER3_PIN
int "Thruster3 pin"
default 14
help
The pin of thruster channel 3.

config SUB_PROTOBUF_THRUSTER5_PIN
int "Thruster5 pin"
default 13
help
The pin of thruster channel 5.
config SUB_PROTOBUF_THRUSTER4_PIN
int "Thruster4 pin"
default 12
help
The pin of thruster channel 4.

config SUB_PROTOBUF_THRUSTER6_PIN
int "Thruster6 pin"
default 15
help
The pin of thruster channel 6.
config SUB_PROTOBUF_THRUSTER5_PIN
int "Thruster5 pin"
default 13
help
The pin of thruster channel 5.

config SUB_PROTOBUF_THRUSTER7_PIN
int "Thruster7 pin"
default 2
help
The pin of thruster channel 7.
config SUB_PROTOBUF_THRUSTER6_PIN
int "Thruster6 pin"
default 15
help
The pin of thruster channel 6.

config SUB_PROTOBUF_THRUSTER7_PIN
int "Thruster7 pin"
default 2
help
The pin of thruster channel 7.
endif
endmenu

endmenu
9 changes: 8 additions & 1 deletion components/protobuf_rpc/message_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ static const char *TAG = "protobuf_commu_rpc_cmd";
static dshot_handle_t dshot_chan0, dshot_chan1, dshot_chan2, dshot_chan3,
dshot_chan4, dshot_chan5, dshot_chan6, dshot_chan7;

#if CONFIG_SUB_PROTOBUF_THRUSTERS_ENABLE
static int thruster_init(void)
{
int ret = 0;

ret += rmt_dshot_init(&dshot_chan0, CONFIG_SUB_PROTOBUF_THRUSTER0_PIN);
ret += rmt_dshot_init(&dshot_chan1, CONFIG_SUB_PROTOBUF_THRUSTER1_PIN);
ret += rmt_dshot_init(&dshot_chan2, CONFIG_SUB_PROTOBUF_THRUSTER2_PIN);
Expand All @@ -25,7 +27,7 @@ static int thruster_init(void)
ret += rmt_dshot_init(&dshot_chan7, CONFIG_SUB_PROTOBUF_THRUSTER7_PIN);
return ret;
}

#endif
#if CONFIG_SUB_ENABLE_PCA9685
static int pwmDev_init(void)
{
Expand All @@ -39,7 +41,9 @@ static int pwmDev_init(void)
int message_cmd_init(void)
{
int ret = 0;
#if CONFIG_SUB_PROTOBUF_THRUSTERS_ENABLE
ret += thruster_init();
#endif
#if CONFIG_SUB_ENABLE_PCA9685
ret += pwmDev_init();
#endif
Expand All @@ -49,6 +53,9 @@ int message_cmd_init(void)

void message_thruster_cmd(ThrusterCommand *msg)
{
#if !CONFIG_SUB_PROTOBUF_THRUSTERS_ENABLE
return;
#endif
if (msg->has_throttle0)
{
ESP_LOGI(TAG, "dshot_chan0: %ld", msg->throttle0);
Expand Down

0 comments on commit a4a8e20

Please sign in to comment.