mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 21:35:44 +03:00
Some more const qualifiers, and including sonar for configuration list.
This commit is contained in:
parent
c578c9d6bc
commit
6ea3e47f56
4 changed files with 7 additions and 3 deletions
|
@ -63,7 +63,7 @@ void hcsr04_extiHandler(extiCallbackRec_t* cb)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void hcsr04_init(sonarRange_t *sonarRange, sonarConfig_t *sonarConfig)
|
void hcsr04_init(const sonarConfig_t *sonarConfig, sonarRange_t *sonarRange)
|
||||||
{
|
{
|
||||||
sonarRange->maxRangeCm = HCSR04_MAX_RANGE_CM;
|
sonarRange->maxRangeCm = HCSR04_MAX_RANGE_CM;
|
||||||
sonarRange->detectionConeDeciDegrees = HCSR04_DETECTION_CONE_DECIDEGREES;
|
sonarRange->detectionConeDeciDegrees = HCSR04_DETECTION_CONE_DECIDEGREES;
|
||||||
|
|
|
@ -37,6 +37,6 @@ typedef struct sonarRange_s {
|
||||||
#define HCSR04_DETECTION_CONE_DECIDEGREES 300 // recommended cone angle30 degrees, from HC-SR04 spec sheet
|
#define HCSR04_DETECTION_CONE_DECIDEGREES 300 // recommended cone angle30 degrees, from HC-SR04 spec sheet
|
||||||
#define HCSR04_DETECTION_CONE_EXTENDED_DECIDEGREES 450 // in practice 45 degrees seems to work well
|
#define HCSR04_DETECTION_CONE_EXTENDED_DECIDEGREES 450 // in practice 45 degrees seems to work well
|
||||||
|
|
||||||
void hcsr04_init(sonarRange_t *sonarRange, sonarConfig_t *sonarConfig);
|
void hcsr04_init(const sonarConfig_t *sonarConfig, sonarRange_t *sonarRange);
|
||||||
void hcsr04_start_reading(void);
|
void hcsr04_start_reading(void);
|
||||||
int32_t hcsr04_get_distance(void);
|
int32_t hcsr04_get_distance(void);
|
||||||
|
|
|
@ -3691,6 +3691,10 @@ const cliResourceValue_t resourceTable[] = {
|
||||||
{ OWNER_PPMINPUT, &masterConfig.ppmConfig.ioTag, 0 },
|
{ OWNER_PPMINPUT, &masterConfig.ppmConfig.ioTag, 0 },
|
||||||
{ OWNER_PWMINPUT, &masterConfig.pwmConfig.ioTags[0], PWM_INPUT_PORT_COUNT },
|
{ OWNER_PWMINPUT, &masterConfig.pwmConfig.ioTags[0], PWM_INPUT_PORT_COUNT },
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef SONAR
|
||||||
|
{ OWNER_SONAR_TRIGGER, &masterConfig.sonarConfig.triggerTag, 0 },
|
||||||
|
{ OWNER_SONAR_ECHO, &masterConfig.sonarConfig.echoTag, 0 },
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static void cliResource(char *cmdline)
|
static void cliResource(char *cmdline)
|
||||||
|
|
|
@ -54,7 +54,7 @@ void sonarInit(const sonarConfig_t *sonarConfig)
|
||||||
{
|
{
|
||||||
sonarRange_t sonarRange;
|
sonarRange_t sonarRange;
|
||||||
|
|
||||||
hcsr04_init(&sonarRange, sonarConfig);
|
hcsr04_init(sonarConfig, &sonarRange);
|
||||||
|
|
||||||
sensorsSet(SENSOR_SONAR);
|
sensorsSet(SENSOR_SONAR);
|
||||||
sonarMaxRangeCm = sonarRange.maxRangeCm;
|
sonarMaxRangeCm = sonarRange.maxRangeCm;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue