1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 04:45:24 +03:00

Added internal resistance adjustment

This commit is contained in:
DieHertz 2017-09-09 23:17:45 +03:00
parent ab53b178ca
commit 8c4b898128
3 changed files with 6 additions and 2 deletions

View file

@ -63,6 +63,7 @@ PG_RESET_TEMPLATE(cameraControlConfig_t, cameraControlConfig,
.mode = CAMERA_CONTROL_MODE_HARDWARE_PWM,
.refVoltage = 330,
.keyDelayMs = 180,
.internalResistance = 470,
.ioTag = IO_TAG(CAMERA_CONTROL_PIN)
);
@ -158,13 +159,12 @@ void cameraControlProcess(uint32_t currentTimeUs)
}
}
static const int cameraPullUpResistance = 47000;
static const int buttonResistanceValues[] = { 45000, 27000, 15000, 6810, 0 };
static float calculateKeyPressVoltage(const cameraControlKey_e key)
{
const int buttonResistance = buttonResistanceValues[key];
return 1.0e-2f * cameraControlConfig()->refVoltage * buttonResistance / (cameraPullUpResistance + buttonResistance);
return 1.0e-2f * cameraControlConfig()->refVoltage * buttonResistance / (100 * cameraControlConfig()->internalResistance + buttonResistance);
}
#if defined(CAMERA_CONTROL_HARDWARE_PWM_AVAILABLE) || defined(CAMERA_CONTROL_SOFTWARE_PWM_AVAILABLE)