NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rc_adjustments.h
Go to the documentation of this file.
1 /*
2  * This file is part of Ninjaflight.
3  *
4  * Ninjaflight is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Ninjaflight is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Ninjaflight. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #pragma once
19 
20 #include "../config/rx.h"
21 #include "../config/rc_adjustments.h"
22 
23 struct rx;
24 
25 #define PID_MIN 0
26 #define PID_MAX 200
27 #define PID_F_MIN 0
28 #define PID_F_MAX 100
29 #define RC_RATE_MIN 0
30 #define RC_RATE_MAX 250
31 #define EXPO_MIN 0
32 #define EXPO_MAX 100
33 
34 typedef enum {
74 
76 
77 #define ADJUSTMENT_FUNCTION_COUNT 39
78 
79 typedef enum {
83 
84 typedef struct adjustmentStepConfig_s {
85  uint8_t step;
87 
88 typedef struct adjustmentSelectConfig_s {
89  uint8_t switchPositions;
91 
92 typedef union adjustmentConfig_u {
96 
97 typedef struct adjustmentConfig_s {
99  uint8_t mode;
102 
103 #define ADJUSTMENT_INDEX_OFFSET 1
104 
105 typedef struct adjustmentState_s {
108  uint32_t timeoutAt;
109  adjustmentRange_t *range;
111 
112 #ifndef MAX_SIMULTANEOUS_ADJUSTMENT_COUNT
113 #define MAX_SIMULTANEOUS_ADJUSTMENT_COUNT 4 // enough for 4 x 3position switches / 4 aux channel
114 #endif
115 
116 struct rc_adj {
119 
121  struct ninja *ninja;
122 
124  struct config *config;
125 };
126 
127 // TODO: remove this include
128 #include "../config/config.h"
129 
130 void rc_adj_init(struct rc_adj *self, struct ninja *ninja, struct config *config);
131 void rc_adj_reset(struct rc_adj *self);
132 void rc_adj_add_range(struct rc_adj *self, adjustmentRange_t *adjustmentRange);
133 void rc_adj_update_states(struct rc_adj *self, adjustmentRange_t *adjustmentRanges);
134 void rc_adj_update(struct rc_adj *self);
135 
struct adjustmentState_s adjustmentState_t
uint8_t adjustmentStateMask
Definition: rc_adjustments.h:117
void rc_adj_update(struct rc_adj *self)
Definition: rc_adjustments.c:269
Definition: rc_adjustments.h:38
Definition: config.h:81
Definition: rc_adjustments.h:61
Definition: rc_adjustments.h:54
Definition: rc_adjustments.h:105
Definition: rc_adjustments.h:52
Definition: rc_adjustments.h:84
Definition: rc_adjustments.h:72
Definition: ninja.h:40
Definition: rc_adjustments.h:97
Definition: rc_adjustments.h:46
Definition: rc_adjustments.h:73
adjustmentState_t adjustmentStates[MAX_SIMULTANEOUS_ADJUSTMENT_COUNT]
Definition: rc_adjustments.h:118
Definition: rc_adjustments.h:55
Definition: rc_adjustments.h:56
Definition: rc_adjustments.h:81
Definition: rc_adjustments.h:41
void rc_adj_init(struct rc_adj *self, struct ninja *ninja, struct config *config)
Definition: rc_adjustments.c:342
void rc_adj_update_states(struct rc_adj *self, adjustmentRange_t *adjustmentRanges)
Definition: rc_adjustments.c:325
Definition: rc_adjustments.h:88
Definition: rc_adjustments.h:35
Definition: rc_adjustments.h:68
uint32_t timeoutAt
Definition: rc_adjustments.h:108
Definition: rc_adjustments.h:60
Definition: rc_adjustments.h:63
adjustmentRange_t adjustmentRanges[MAX_ADJUSTMENT_RANGE_COUNT]
Definition: rc_adjustments.h:29
Definition: rc_adjustments.h:48
struct ninja * ninja
pointer to the ninja object on which we are going to be adjusting things
Definition: rc_adjustments.h:121
Definition: rc_adjustments.h:116
adjustmentSelectConfig_t selectConfig
Definition: rc_adjustments.h:94
void rc_adj_reset(struct rc_adj *self)
Definition: rc_adjustments.c:348
Definition: rc_adjustments.h:37
struct adjustmentStepConfig_s adjustmentStepConfig_t
Definition: rc_adjustments.h:51
Definition: rx.h:97
Definition: rc_adjustments.h:47
Definition: rc_adjustments.h:66
#define MAX_SIMULTANEOUS_ADJUSTMENT_COUNT
Definition: rc_adjustments.h:113
void rc_adj_add_range(struct rc_adj *self, adjustmentRange_t *adjustmentRange)
Definition: rc_adjustments.c:81
Definition: rc_adjustments.h:64
uint8_t mode
Definition: rc_adjustments.h:99
union adjustmentConfig_u adjustmentData_t
Definition: rc_adjustments.h:49
Definition: rc_adjustments.h:45
Definition: rc_adjustments.h:80
adjustmentData_t data
Definition: rc_adjustments.h:100
Definition: rc_adjustments.h:62
Definition: rc_adjustments.h:40
Definition: rc_adjustments.h:65
Definition: rc_adjustments.h:43
adjustmentFunction_e
Definition: rc_adjustments.h:34
Definition: rc_adjustments.h:50
adjustmentMode_e
Definition: rc_adjustments.h:79
struct config * config
modifyable version of the config that is to be adjusted
Definition: rc_adjustments.h:124
Definition: rc_adjustments.h:71
Definition: rc_adjustments.h:36
Definition: rc_adjustments.h:39
Definition: rc_adjustments.h:57
uint8_t step
Definition: rc_adjustments.h:85
adjustmentStepConfig_t stepConfig
Definition: rc_adjustments.h:93
uint8_t adjustmentFunction
Definition: rc_adjustments.h:98
Definition: rc_adjustments.h:92
Definition: rc_adjustments.h:58
Definition: rc_adjustments.h:53
struct adjustmentConfig_s adjustmentConfig_t
Definition: rc_adjustments.h:59
Definition: rc_adjustments.h:67
Definition: rc_adjustments.h:70
Definition: rc_adjustments.h:69
adjustmentConfig_t config
Definition: rc_adjustments.h:107
uint8_t auxChannelIndex
Definition: rc_adjustments.h:106
uint8_t switchPositions
Definition: rc_adjustments.h:89
Definition: rc_adjustments.h:44
adjustmentRange_t * range
Definition: rc_adjustments.h:109
Definition: rc_adjustments.h:42
struct adjustmentSelectConfig_s adjustmentSelectConfig_t