1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-18 22:05:17 +03:00

First cut of code that passed the unit tests for mod activations,

however it uses / operations and doesn't handle the case where the
channel value is on the boundary between two ranges.
This commit is contained in:
Dominic Clifton 2014-10-12 18:15:44 +01:00
parent c0fd0c1f33
commit 2369a63df0
5 changed files with 117 additions and 52 deletions

View file

@ -47,6 +47,7 @@ typedef enum {
extern uint32_t rcModeActivationMask;
#define IS_RC_MODE_ACTIVE(modeId) ((1 << modeId) & rcModeActivationMask)
#define ACTIVATE_RC_MODE(modeId) (rcModeActivationMask |= (1 << modeId))
typedef enum rc_alias {
ROLL = 0,
@ -90,7 +91,7 @@ typedef enum {
#define MODE_STEP_TO_CHANNEL_VALUE(step) (900 + 25 * step)
#define CHANNEL_VALUE_TO_STEP(channelValue) (constrain(channelValue, 900, 2100) - 900 / 25)
#define CHANNEL_VALUE_TO_STEP(channelValue) ((constrain(channelValue, 900, 2100) - 900) / 25)
typedef struct modeActivationCondition_s {
boxId_e modeId;
@ -98,7 +99,7 @@ typedef struct modeActivationCondition_s {
// steps are 25 apart
// a value of 0 corresponds to a channel value of 900 or less
// a value of 47 corresponds to a channel value of 2100 or more
// a value of 48 corresponds to a channel value of 2100 or more
// 48 steps between 900 and 1200
uint8_t rangeStartStep;
uint8_t rangeEndStep;