mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-24 16:55:29 +03:00
New functions: sin, cos, tan and range scaling
This commit is contained in:
parent
7a7fcf346b
commit
9714f05368
3 changed files with 79 additions and 11 deletions
|
@ -63,6 +63,11 @@ IPF can be edited using INAV Configurator user interface, of via CLI
|
|||
| 30 | SET_VTX_BAND | Sets VTX band. Accepted values are `1-5` |
|
||||
| 31 | SET_VTX_CHANNEL | Sets VTX channel. Accepted values are `1-8` |
|
||||
| 32 | SET_OSD_LAYOUT | Sets OSD layout. Accepted values are `0-3` |
|
||||
| 33 | SIN | Computes SIN of `Operand A` value in degrees. Output is multiplied by `Operand B` value. If `Operand B` is `0`, result is multiplied by `500` |
|
||||
| 34 | COS | Computes COS of `Operand A` value in degrees. Output is multiplied by `Operand B` value. If `Operand B` is `0`, result is multiplied by `500` |
|
||||
| 35 | TAN | Computes TAN of `Operand A` value in degrees. Output is multiplied by `Operand B` value. If `Operand B` is `0`, result is multiplied by `500` |
|
||||
| 36 | MAP_INPUT | Scales `Operand A` from [`0` : `Operand B`] to [`0` : `1000`]. Note: input will be constrained and then scaled |
|
||||
| 37 | MAP_OUTPUT | Scales `Operand A` from [`0` : `1000`] to [`0` : `Operand B`]. Note: input will be constrained and then scaled |
|
||||
|
||||
|
||||
### Operands
|
||||
|
@ -173,3 +178,36 @@ Sets Thhrottle output to about `50%` when Logic Condition `0` evaluates as `true
|
|||
|
||||
If Logic Condition `0` evaluates as `true`, motor throttle control is bound to RC channel 7 instead of throttle channel
|
||||
|
||||
### Set VTX channel with a POT
|
||||
|
||||
Set VTX channel with a POT on the radio assigned to RC channel 6
|
||||
|
||||
```
|
||||
logic 0 1 -1 15 1 6 0 1000 0
|
||||
logic 1 1 -1 37 4 0 0 7 0
|
||||
logic 2 1 -1 14 4 1 0 1 0
|
||||
logic 3 1 -1 31 4 2 0 0 0
|
||||
```
|
||||
|
||||
Steps:
|
||||
1. Normalize range `[1000:2000]` to `[0:1000]` by substracting `1000`
|
||||
2. Scale range `[0:1000]` to `[0:7]`
|
||||
3. Increase range by `1` to have the range of `[1:8]`
|
||||
4. Assign LC#2 to VTX channel function
|
||||
|
||||
### Set VTX power with a POT
|
||||
|
||||
Set VTX power with a POT on the radio assigned to RC channel 6. In this example we scale POT to 4 power level `[1:4]`
|
||||
|
||||
```
|
||||
logic 0 1 -1 15 1 6 0 1000 0
|
||||
logic 1 1 -1 37 4 0 0 3 0
|
||||
logic 2 1 -1 14 4 1 0 1 0
|
||||
logic 3 1 -1 25 4 2 0 0 0
|
||||
```
|
||||
|
||||
Steps:
|
||||
1. Normalize range [1000:2000] to [0:1000] by substracting `1000`
|
||||
2. Scale range [0:1000] to [0:3]
|
||||
3. Increase range by `1` to have the range of [1:4]
|
||||
4. Assign LC#2 to VTX power function
|
|
@ -277,6 +277,31 @@ static int logicConditionCompute(
|
|||
return operandB;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case LOGIC_CONDITION_SIN:
|
||||
temporaryValue = (operandB == 0) ? 500 : operandB;
|
||||
return sin_approx(DEGREES_TO_RADIANS(operandA)) * temporaryValue;
|
||||
break;
|
||||
|
||||
case LOGIC_CONDITION_COS:
|
||||
temporaryValue = (operandB == 0) ? 500 : operandB;
|
||||
return cos_approx(DEGREES_TO_RADIANS(operandA)) * temporaryValue;
|
||||
break;
|
||||
break;
|
||||
|
||||
case LOGIC_CONDITION_TAN:
|
||||
temporaryValue = (operandB == 0) ? 500 : operandB;
|
||||
return tan_approx(DEGREES_TO_RADIANS(operandA)) * temporaryValue;
|
||||
break;
|
||||
|
||||
case LOGIC_CONDITION_MAP_INPUT:
|
||||
return scaleRange(constrain(operandA, 0, operandB), 0, operandB, 0, 1000);
|
||||
break;
|
||||
|
||||
case LOGIC_CONDITION_MAP_OUTPUT:
|
||||
return scaleRange(constrain(operandA, 0, 1000), 0, 1000, 0, operandB);
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
|
|
|
@ -62,7 +62,12 @@ typedef enum {
|
|||
LOGIC_CONDITION_SET_VTX_BAND = 30,
|
||||
LOGIC_CONDITION_SET_VTX_CHANNEL = 31,
|
||||
LOGIC_CONDITION_SET_OSD_LAYOUT = 32,
|
||||
LOGIC_CONDITION_LAST = 33,
|
||||
LOGIC_CONDITION_SIN = 33,
|
||||
LOGIC_CONDITION_COS = 34,
|
||||
LOGIC_CONDITION_TAN = 35,
|
||||
LOGIC_CONDITION_MAP_INPUT = 36,
|
||||
LOGIC_CONDITION_MAP_OUTPUT = 37,
|
||||
LOGIC_CONDITION_LAST = 38,
|
||||
} logicOperation_e;
|
||||
|
||||
typedef enum logicOperandType_s {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue