NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rc.c File Reference
#include <string.h>
#include "config/config.h"
#include "../common/maths.h"
#include "rc.h"
#include "rx.h"
#include <stdio.h>
Include dependency graph for rc.c:

Macros

#define ROL_LO   (1 << (2 * ROLL))
 
#define ROL_CE   (3 << (2 * ROLL))
 
#define ROL_HI   (2 << (2 * ROLL))
 
#define PIT_LO   (1 << (2 * PITCH))
 
#define PIT_CE   (3 << (2 * PITCH))
 
#define PIT_HI   (2 << (2 * PITCH))
 
#define YAW_LO   (1 << (2 * YAW))
 
#define YAW_CE   (3 << (2 * YAW))
 
#define YAW_HI   (2 << (2 * YAW))
 
#define THR_LO   (1 << (2 * THROTTLE))
 
#define THR_CE   (3 << (2 * THROTTLE))
 
#define THR_HI   (2 << (2 * THROTTLE))
 

Functions

void rc_update (struct rc *self)
 
void rc_init (struct rc *self, struct rx *rx, struct rc_event_listener *evl, const struct config *config)
 
int16_t rc_get_command (struct rc *self, uint8_t axis)
 
rc_key_state_t rc_key_state (struct rc *self, rc_key_t key)
 

Macro Definition Documentation

#define PIT_CE   (3 << (2 * PITCH))
#define PIT_HI   (2 << (2 * PITCH))
#define PIT_LO   (1 << (2 * PITCH))
#define ROL_CE   (3 << (2 * ROLL))
#define ROL_HI   (2 << (2 * ROLL))
#define ROL_LO   (1 << (2 * ROLL))
#define THR_CE   (3 << (2 * THROTTLE))
#define THR_HI   (2 << (2 * THROTTLE))
#define THR_LO   (1 << (2 * THROTTLE))
#define YAW_CE   (3 << (2 * YAW))
#define YAW_HI   (2 << (2 * YAW))
#define YAW_LO   (1 << (2 * YAW))

Function Documentation

int16_t rc_get_command ( struct rc self,
uint8_t  axis 
)

This function is used to get stick commands after exponential curves have been applied to the rx input.

Parameters
axisone of ROLL, PITCH, YAW, THROTTLE
Returns
a value between -500 and 500.

Here is the call graph for this function:

void rc_init ( struct rc self,
struct rx rx,
struct rc_event_listener evl,
const struct config config 
)

Initializes a new rc struct.

Parameters
rxinstance of the underlying rx to read values from.
evlevent listener or NULL

Here is the call graph for this function:

rc_key_state_t rc_key_state ( struct rc rc,
rc_key_t  key 
)
Parameters
keythe key for which to return state
Returns
current state of the key (PRESSED, RELEASED, DISABLED)
void rc_update ( struct rc self)

Runs an iteration of the rc calculations. This function does not call update on the underlying receiver object - user is expected to update the receiver object outside of rc object (and possibly at a different rate). The responsibility of this function is mainly taking care of repeat logic and firing new events for keys that are pressed for a while.

Here is the call graph for this function: