From 791d67b4ee785b644578044ff8395ef966029f91 Mon Sep 17 00:00:00 2001 From: timecop Date: Mon, 26 Mar 2012 16:53:40 +0000 Subject: [PATCH] added separate yaw deadband from issue #6 after fixing some stuff. config version bumped again. git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@132 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61 --- src/cli.c | 1 + src/config.c | 3 ++- src/mw.c | 26 +++++++++++++++++--------- src/mw.h | 3 ++- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/cli.c b/src/cli.c index 31a4703d7..05cba35e9 100644 --- a/src/cli.c +++ b/src/cli.c @@ -83,6 +83,7 @@ typedef struct { const clivalue_t valueTable[] = { { "deadband", VAR_UINT8, &cfg.deadband, 0, 32 }, + { "yawdeadband", VAR_UINT8, &cfg.yawdeadband, 0, 100 }, { "midrc", VAR_UINT16, &cfg.midrc, 1200, 1700 }, { "minthrottle", VAR_UINT16, &cfg.minthrottle, 0, 2000 }, { "maxthrottle", VAR_UINT16, &cfg.maxthrottle, 0, 2000 }, diff --git a/src/config.c b/src/config.c index b9f2c14e2..64720afc3 100755 --- a/src/config.c +++ b/src/config.c @@ -9,7 +9,7 @@ config_t cfg; const char rcChannelLetters[] = "AERT1234"; static uint32_t enabledSensors = 0; -static uint8_t checkNewConf = 7; +static uint8_t checkNewConf = 8; void parseRcChannels(const char *input) { @@ -123,6 +123,7 @@ void checkFirstTime(bool reset) // Radio/ESC parseRcChannels("AETR1234"); cfg.deadband = 0; + cfg.yawdeadband = 0; cfg.spektrum_hires = 0; cfg.midrc = 1500; cfg.mincheck = 1100; diff --git a/src/mw.c b/src/mw.c index e54f8e63d..d1103ef3f 100755 --- a/src/mw.c +++ b/src/mw.c @@ -120,19 +120,27 @@ void annexCode(void) for (axis = 0; axis < 3; axis++) { uint16_t tmp = min(abs(rcData[axis] - cfg.midrc), 500); - if (cfg.deadband > 0) { - if (tmp > cfg.deadband) { - tmp -= cfg.deadband; - } else { - tmp = 0; + if (axis != 2) { // ROLL & PITCH + uint16_t tmp2; + if (cfg.deadband) { + if (tmp > cfg.deadband) { + tmp -= cfg.deadband; + } else { + tmp = 0; + } } - } - if (axis != 2) { //ROLL & PITCH - uint16_t tmp2 = tmp / 100; + tmp2 = tmp / 100; rcCommand[axis] = lookupRX[tmp2] + (tmp - tmp2 * 100) * (lookupRX[tmp2 + 1] - lookupRX[tmp2]) / 100; prop1 = 100 - (uint16_t) cfg.rollPitchRate * tmp / 500; prop1 = (uint16_t)prop1 * prop2 / 100; - } else { //YAW + } else { // YAW + if (cfg.yawdeadband) { + if (tmp > cfg.yawdeadband) { + tmp -= cfg.yawdeadband; + } else { + tmp = 0; + } + } rcCommand[axis] = tmp; prop1 = 100 - (uint16_t)cfg.yawRate * tmp / 500; } diff --git a/src/mw.h b/src/mw.h index 5b2cb132b..d753c48c5 100755 --- a/src/mw.h +++ b/src/mw.h @@ -157,7 +157,8 @@ typedef struct config_t { // Radio/ESC-related configuration uint8_t rcmap[8]; // mapping of radio channels to internal RPYTA+ order - uint8_t deadband; // introduce a deadband around the stick center. Must be greater than zero + uint8_t deadband; // introduce a deadband around the stick center for pitch and roll axis. Must be greater than zero. + uint8_t yawdeadband; // introduce a deadband around the stick center for yaw axis. Must be greater than zero. uint8_t spektrum_hires; // spektrum high-resolution y/n (1024/2048bit) uint16_t midrc; // Some radios have not a neutral point centered on 1500. can be changed here uint16_t mincheck; // minimum rc end