helidemo_sdl.c File Reference

This is a simple demo which shows how to work with libhelicontrol. More...

#include <stdio.h>
#include <stdint.h>
#include <getopt.h>
#include <errno.h>
#include <unistd.h>
#include <SDL/SDL.h>
#include <helicontrol.h>

Include dependency graph for helidemo_sdl.c:

Go to the source code of this file.

Defines

#define bound(min, num, max)   ((num) >= (min) ? ((num) < (max) ? (num) : (max)) : (min))
#define JOYSTICK   0
#define JOYSTICK_THROTTLE_MAX   -32768
#define JOYSTICK_YAW_MAX   -32768
#define JOYSTICK_PITCH_MAX   -32768
#define JOYSTICK_ROLL_MAX   32768
#define JOYSTICK_AXIS_SAUCER_ROLL   2
#define JOYSTICK_AXIS_SAUCER_YAW   0
#define JOYSTICK_AXIS_THROTTLE   1
#define JOYSTICK_AXIS_YAW   2
#define JOYSTICK_AXIS_PITCH   3
#define JOYSTICK_BUTTON_TRIM_L   6
#define JOYSTICK_BUTTON_TRIM_R   7
#define JOYSTICK_BUTTON_FIRE1   4
#define JOYSTICK_BUTTON_FIRE2   5
#define JOYSTICK_BUTTON_PITCH1   4
#define JOYSTICK_BUTTON_PITCH2   5
#define INTERVAL   25000
#define MODE_NORMAL   0
#define MODE_JOYSTICK   1
#define MODE_STOP   2

Functions

static void usage (void)
static void send_frame (char protocol, char channel, char throttle, char trim, char yaw, char pitch, char special)
int main (int argc, char **argv)

Variables

static struct option long_options []
struct usb_dev_handle * handle


Detailed Description

This is a simple demo which shows how to work with libhelicontrol.

It implements a simple remote control, similar to helictrl.cc in ../tools but with joystick support (SDL, not available on win32/vs2008).

Definition in file helidemo_sdl.c.


Define Documentation

#define bound ( min,
num,
max   )     ((num) >= (min) ? ((num) < (max) ? (num) : (max)) : (min))

Examples:
helictrl.cc, helidemo_sdl.c, and helidemo_simple.c.

Definition at line 44 of file helidemo_sdl.c.

Referenced by send_frame().

#define INTERVAL   25000

Examples:
helidemo_sdl.c.

Definition at line 63 of file helidemo_sdl.c.

Referenced by main().

#define JOYSTICK   0

Examples:
helidemo_sdl.c.

Definition at line 46 of file helidemo_sdl.c.

Referenced by main().

#define JOYSTICK_AXIS_PITCH   3

Examples:
helidemo_sdl.c.

Definition at line 55 of file helidemo_sdl.c.

Referenced by main().

#define JOYSTICK_AXIS_SAUCER_ROLL   2

Examples:
helidemo_sdl.c.

Definition at line 51 of file helidemo_sdl.c.

Referenced by main().

#define JOYSTICK_AXIS_SAUCER_YAW   0

Examples:
helidemo_sdl.c.

Definition at line 52 of file helidemo_sdl.c.

Referenced by main().

#define JOYSTICK_AXIS_THROTTLE   1

Examples:
helidemo_sdl.c.

Definition at line 53 of file helidemo_sdl.c.

Referenced by main().

#define JOYSTICK_AXIS_YAW   2

Examples:
helidemo_sdl.c.

Definition at line 54 of file helidemo_sdl.c.

Referenced by main().

#define JOYSTICK_BUTTON_FIRE1   4

Examples:
helidemo_sdl.c.

Definition at line 58 of file helidemo_sdl.c.

Referenced by main().

#define JOYSTICK_BUTTON_FIRE2   5

Examples:
helidemo_sdl.c.

Definition at line 59 of file helidemo_sdl.c.

Referenced by main().

#define JOYSTICK_BUTTON_PITCH1   4

Examples:
helidemo_sdl.c.

Definition at line 60 of file helidemo_sdl.c.

Referenced by main().

#define JOYSTICK_BUTTON_PITCH2   5

Examples:
helidemo_sdl.c.

Definition at line 61 of file helidemo_sdl.c.

Referenced by main().

#define JOYSTICK_BUTTON_TRIM_L   6

Examples:
helidemo_sdl.c.

Definition at line 56 of file helidemo_sdl.c.

Referenced by main().

#define JOYSTICK_BUTTON_TRIM_R   7

Examples:
helidemo_sdl.c.

Definition at line 57 of file helidemo_sdl.c.

Referenced by main().

#define JOYSTICK_PITCH_MAX   -32768

Examples:
helidemo_sdl.c.

Definition at line 49 of file helidemo_sdl.c.

Referenced by main().

#define JOYSTICK_ROLL_MAX   32768

Examples:
helidemo_sdl.c.

Definition at line 50 of file helidemo_sdl.c.

Referenced by main().

#define JOYSTICK_THROTTLE_MAX   -32768

Examples:
helidemo_sdl.c.

Definition at line 47 of file helidemo_sdl.c.

Referenced by main().

#define JOYSTICK_YAW_MAX   -32768

Examples:
helidemo_sdl.c.

Definition at line 48 of file helidemo_sdl.c.

Referenced by main().

#define MODE_JOYSTICK   1

Examples:
helidemo_sdl.c.

Definition at line 66 of file helidemo_sdl.c.

Referenced by main().

#define MODE_NORMAL   0

Examples:
helictrl.cc, and helidemo_sdl.c.

Definition at line 65 of file helidemo_sdl.c.

Referenced by main().

#define MODE_STOP   2

Examples:
helictrl.cc, and helidemo_sdl.c.

Definition at line 67 of file helidemo_sdl.c.

Referenced by main().


Function Documentation

int main ( int  argc,
char **  argv 
)

Examples:
helictrl.cc, helidemo_sdl.c, and helidemo_simple.c.

Definition at line 131 of file helidemo_sdl.c.

References handle, HC_Close(), HC_CMD_Repeat(), HC_CMD_Stop(), HC_Init(), INTERVAL, JOYSTICK, JOYSTICK_AXIS_PITCH, JOYSTICK_AXIS_SAUCER_ROLL, JOYSTICK_AXIS_SAUCER_YAW, JOYSTICK_AXIS_THROTTLE, JOYSTICK_AXIS_YAW, JOYSTICK_BUTTON_FIRE1, JOYSTICK_BUTTON_FIRE2, JOYSTICK_BUTTON_PITCH1, JOYSTICK_BUTTON_PITCH2, JOYSTICK_BUTTON_TRIM_L, JOYSTICK_BUTTON_TRIM_R, JOYSTICK_PITCH_MAX, JOYSTICK_ROLL_MAX, JOYSTICK_THROTTLE_MAX, JOYSTICK_YAW_MAX, long_options, MODE_JOYSTICK, MODE_NORMAL, MODE_STOP, send_frame(), and usage().

Here is the call graph for this function:

static void send_frame ( char  protocol,
char  channel,
char  throttle,
char  trim,
char  yaw,
char  pitch,
char  special 
) [static]

Examples:
helictrl.cc, helidemo_sdl.c, and helidemo_simple.c.

Definition at line 102 of file helidemo_sdl.c.

References bound, handle, HC_Send_Challenger(), HC_Send_Picooz(), HC_Send_Saucer(), HC_Send_Tandemz(), and HC_Send_Uranus().

Referenced by main().

Here is the call graph for this function:

static void usage ( void   )  [static]

Examples:
helidemo_sdl.c.

Definition at line 85 of file helidemo_sdl.c.

Referenced by main().


Variable Documentation

struct usb_dev_handle* handle

Examples:
helictrl.cc, helidemo_sdl.c, and helidemo_simple.c.

Definition at line 100 of file helidemo_sdl.c.

Referenced by HC_Init(), main(), and send_frame().

struct option long_options[] [static]

Initial value:

{
    {"protocol",        required_argument,      0, 'p'},
    {"channel",         required_argument,      0, 'c'},
    {"throttle",        required_argument,      0, 't'},
    {"trim",            required_argument,      0, 'm'},
    {"yaw",                     required_argument,      0, 'y'},
    {"fire",            required_argument,      0, 'f'},
    {"pitch",           required_argument,      0, 'i'},
    {"roll",            required_argument,      0, 'r'},
    {"stop",            no_argument,            0, 's'},
    {"joystick",        no_argument,            0, 'j'},
    {"help",            no_argument,            0, 'h'},
    {0, 0, 0, 0}
}
Examples:
helidemo_sdl.c.

Definition at line 69 of file helidemo_sdl.c.

Referenced by main().


Generated on Thu Dec 18 00:02:53 2008 for libhelicontrol by  doxygen 1.5.3