mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 16:55:36 +03:00
Convert motor values at the final stage // Increase resolution
This commit is contained in:
parent
c5054f9e9d
commit
b21877438e
9 changed files with 62 additions and 50 deletions
|
@ -54,15 +54,17 @@ uint8_t getTimerIndex(TIM_TypeDef *timer)
|
|||
return dmaMotorTimerCount-1;
|
||||
}
|
||||
|
||||
void pwmWriteDshot(uint8_t index, uint16_t value)
|
||||
void pwmWriteDshot(uint8_t index, float value)
|
||||
{
|
||||
const uint16_t digitalValue = lrintf(value);
|
||||
|
||||
motorDmaOutput_t * const motor = &dmaMotors[index];
|
||||
|
||||
if (!motor->timerHardware || !motor->timerHardware->dmaRef) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t packet = (value << 1) | (motor->requestTelemetry ? 1 : 0);
|
||||
uint16_t packet = (digitalValue << 1) | (motor->requestTelemetry ? 1 : 0);
|
||||
motor->requestTelemetry = false; // reset telemetry request to make sure it's triggered only once in a row
|
||||
|
||||
// compute checksum
|
||||
|
@ -85,15 +87,17 @@ void pwmWriteDshot(uint8_t index, uint16_t value)
|
|||
DMA_Cmd(motor->timerHardware->dmaRef, ENABLE);
|
||||
}
|
||||
|
||||
void pwmWriteProShot(uint8_t index, uint16_t value)
|
||||
void pwmWriteProShot(uint8_t index, float value)
|
||||
{
|
||||
const uint16_t digitalValue = lrintf(value);
|
||||
|
||||
motorDmaOutput_t * const motor = &dmaMotors[index];
|
||||
|
||||
if (!motor->timerHardware || !motor->timerHardware->dmaRef) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t packet = (value << 1) | (motor->requestTelemetry ? 1 : 0);
|
||||
uint16_t packet = (digitalValue << 1) | (motor->requestTelemetry ? 1 : 0);
|
||||
motor->requestTelemetry = false; // reset telemetry request to make sure it's triggered only once in a row
|
||||
|
||||
// compute checksum
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue