From 8ff2c9ba957447e499b08ccd2dfc545b37867c9c Mon Sep 17 00:00:00 2001 From: mikeller Date: Mon, 18 Sep 2017 20:01:28 +1200 Subject: [PATCH] Renamed 'DSHOT_CMD_BEEPx' to 'DSHOT_CMD_BEACONx', made beacon tone configurable. --- src/main/drivers/pwm_output.h | 10 +++++----- src/main/fc/config.c | 6 ------ src/main/fc/settings.c | 2 +- src/main/io/beeper.c | 9 +++++++-- src/main/io/beeper.h | 2 +- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/main/drivers/pwm_output.h b/src/main/drivers/pwm_output.h index c95590226f..9767a13726 100644 --- a/src/main/drivers/pwm_output.h +++ b/src/main/drivers/pwm_output.h @@ -39,11 +39,11 @@ typedef enum { DSHOT_CMD_MOTOR_STOP = 0, - DSHOT_CMD_BEEP1, - DSHOT_CMD_BEEP2, - DSHOT_CMD_BEEP3, - DSHOT_CMD_BEEP4, - DSHOT_CMD_BEEP5, + DSHOT_CMD_BEACON1, + DSHOT_CMD_BEACON2, + DSHOT_CMD_BEACON3, + DSHOT_CMD_BEACON4, + DSHOT_CMD_BEACON5, DSHOT_CMD_ESC_INFO, // V2 includes settings DSHOT_CMD_SPIN_DIRECTION_1, DSHOT_CMD_SPIN_DIRECTION_2, diff --git a/src/main/fc/config.c b/src/main/fc/config.c index a86d7183b8..c8664976cc 100755 --- a/src/main/fc/config.c +++ b/src/main/fc/config.c @@ -156,12 +156,6 @@ PG_RESET_TEMPLATE(systemConfig_t, systemConfig, ); #endif -#ifdef BEEPER -PG_REGISTER_WITH_RESET_TEMPLATE(beeperConfig_t, beeperConfig, PG_BEEPER_CONFIG, 0); -PG_RESET_TEMPLATE(beeperConfig_t, beeperConfig, - .dshotForward = true -); -#endif #ifdef USE_ADC PG_REGISTER_WITH_RESET_FN(adcConfig_t, adcConfig, PG_ADC_CONFIG, 0); #endif diff --git a/src/main/fc/settings.c b/src/main/fc/settings.c index 9fbdc1073e..25c660b65d 100644 --- a/src/main/fc/settings.c +++ b/src/main/fc/settings.c @@ -467,7 +467,7 @@ const clivalue_t valueTable[] = { // PG_BEEPER_CONFIG #ifdef USE_DSHOT - { "beeper_dshot", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_BEEPER_CONFIG, offsetof(beeperConfig_t, dshotForward) }, + { "beeper_dshot_beacon_tone", VAR_UINT8 | MASTER_VALUE, .config.minmax = {0, DSHOT_CMD_BEACON5 }, PG_BEEPER_CONFIG, offsetof(beeperConfig_t, dshotBeaconTone) }, #endif #endif diff --git a/src/main/io/beeper.c b/src/main/io/beeper.c index 5ce73ff074..9c03769420 100755 --- a/src/main/io/beeper.c +++ b/src/main/io/beeper.c @@ -84,6 +84,11 @@ PG_RESET_TEMPLATE(beeperDevConfig_t, beeperDevConfig, #define BEEPER_COMMAND_STOP 0xFF #ifdef BEEPER +PG_REGISTER_WITH_RESET_TEMPLATE(beeperConfig_t, beeperConfig, PG_BEEPER_CONFIG, 1); +PG_RESET_TEMPLATE(beeperConfig_t, beeperConfig, + .dshotBeaconTone = 0 +); + /* Beeper Sound Sequences: (Square wave generation) * Sequence must end with 0xFF or 0xFE. 0xFE repeats the sequence from * start when 0xFF stops the sound when it's completed. @@ -363,11 +368,11 @@ void beeperUpdate(timeUs_t currentTimeUs) } #ifdef USE_DSHOT - if (!areMotorsRunning() && beeperConfig()->dshotForward && currentBeeperEntry->mode == BEEPER_RX_SET) { + if (!areMotorsRunning() && beeperConfig()->dshotBeaconTone && (beeperConfig()->dshotBeaconTone <= DSHOT_CMD_BEACON5) && currentBeeperEntry->mode == BEEPER_RX_SET) { pwmDisableMotors(); delay(1); - pwmWriteDshotCommand(ALL_MOTORS, getMotorCount(), DSHOT_CMD_BEEP3); + pwmWriteDshotCommand(ALL_MOTORS, getMotorCount(), beeperConfig()->dshotBeaconTone); pwmEnableMotors(); } diff --git a/src/main/io/beeper.h b/src/main/io/beeper.h index b4d8de0211..997539b80e 100644 --- a/src/main/io/beeper.h +++ b/src/main/io/beeper.h @@ -51,7 +51,7 @@ typedef enum { typedef struct beeperConfig_s { uint32_t beeper_off_flags; uint32_t preferred_beeper_off_flags; - bool dshotForward; + uint8_t dshotBeaconTone; } beeperConfig_t; #ifdef BEEPER