helicontrol.h File Reference

API documentation of libhelicontrol, PLEASE READ ME! More...

#include <usb.h>
#include "helicontrol_firmware.h"

Include dependency graph for helicontrol.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

Picooz
#define HC_PICOOZ_LEFT   -1
 use HC_PICOOZ_LEFT*step for yaw and just HC_PICOOZ_LEFT for trim
#define HC_PICOOZ_RIGHT   1
 use HC_PICOOZ_RIGHT*step for yaw and just HC_PICOOZ_RIGHT for trim
#define HC_PICOOZ_MAX_THROTTLE   14
 maximum throttle value (helicontrol firmware will accept 15 as valid input, but actually send 14, for consistency with other models)
#define HC_PICOOZ_MAX_YAW   3
 maximum absolute yaw value
#define HC_PICOOZ_CHANNEL_A   0
 channel A
#define HC_PICOOZ_CHANNEL_B   1
 channel B
#define HC_PICOOZ_CHANNEL_C   2
 channel C
Challenger
#define HC_CHALLENGER_LEFT   -1
 use HC_CHALLENGER_LEFT*step for yaw and just HC_CHALLENGER_LEFT for trim
#define HC_CHALLENGER_RIGHT   1
 use HC_CHALLENGER_RIGHT*step for yaw and just HC_CHALLENGER_RIGHT for trim
#define HC_CHALLENGER_MAX_THROTTLE   15
 maximum throttle value
#define HC_CHALLENGER_MAX_YAW   3
 maximum absolute yaw value
#define HC_CHALLENGER_CHANNEL_A   1
 channel A
#define HC_CHALLENGER_CHANNEL_B   2
 channel B
Uranus
#define HC_URANUS_LEFT   -1
 use HC_URANUS_LEFT*step for yaw and just HC_URANUS_LEFT for trim
#define HC_URANUS_RIGHT   1
 use HC_URANUS_RIGHT*step for yaw and just HC_URANUS_RIGHT for trim
#define HC_URANUS_MAX_THROTTLE   15
 maximum throttle value
#define HC_URANUS_MAX_YAW   3
 maximum absolute yaw value
#define HC_URANUS_CHANNEL_A   1
 channel A
#define HC_URANUS_CHANNEL_B   2
 channel B
#define HC_URANUS_PITCH_NONE   0
 send normal pitch
#define HC_URANUS_PITCH_SLOW   1
 send slow pitch boost
#define HC_URANUS_PITCH_FAST   3
 send fast pitch boost
#define HC_URANUS_PITCH_CONT   2
 send continous pitch boost
TandemZ
#define HC_TANDEMZ_LEFT   1
 use HC_TANDEMZ_LEFT*step
#define HC_TANDEMZ_RIGHT   -1
 use HC_TANDEMZ_RIGHT*step
#define HC_TANDEMZ_MAX_THROTTLE   15
 maximum throttle value
#define HC_TANDEMZ_MAX_TRIM   31
 maximum pitch trim value
#define HC_TANDEMZ_MAX_PITCH   5
 maximum pitch value
#define HC_TANDEMZ_MAX_YAW   30
 maximum absolute yaw value
#define HC_TANDEMZ_CHANNEL_A   0
 channel A
#define HC_TANDEMZ_CHANNEL_B   1
 channel B
#define HC_TANDEMZ_CHANNEL_C   2
 channel C
#define HC_TANDEMZ_PITCH_CENTER   2
 center position for pitch (0.
Flying Saucer
#define HC_SAUCER_LEFT   -1
 use HC_SAUCER_LEFT*step for yaw or roll
#define HC_SAUCER_RIGHT   1
 use HC_SAUCER_RIGHT*step for yaw or roll
#define HC_SAUCER_FORWARD   -1
 use HC_SAUCER_FORWARD*step for pitch
#define HC_SAUCER_BACKWARD   1
 use HC_SAUCER_BACKWARD*step for pitch
#define HC_SAUCER_MAX_THROTTLE   15
 maximum throttle value
#define HC_SAUCER_MAX_PITCH   7
 maximum absolute pitch value
#define HC_SAUCER_MAX_YAW   7
 maximum absolute yaw value
#define HC_SAUCER_MAX_ROLL   7
 maximum absolute roll value

Functions

struct usb_dev_handle * HC_Init (void)
 try to open helicontrol usb device.
int HC_Read_Firmware_Revision (usb_dev_handle *handle, char *fwstring, size_t maxlen)
 read firmware revision from device
int HC_Read_Firmware_Build_Date (usb_dev_handle *handle, char *datestring, size_t maxlen)
void HC_Read_Lib_Build_Date (char *datestring, size_t maxlen)
int HC_CMD_Repeat (usb_dev_handle *handle, char repeat)
 switch continious sending.
int HC_CMD_Interval (usb_dev_handle *handle, int interval_ms)
 specifies rate at which commands are sent.
int HC_CMD_Stop (usb_dev_handle *handle)
 stop sending.
int HC_Send_Picooz (usb_dev_handle *handle, char channel, char throttle, char yaw, char trim)
 PicooZ.
int HC_Send_Challenger (usb_dev_handle *handle, char channel, char throttle, char yaw, char trim, char fire)
 Challanger.
int HC_Send_Uranus (usb_dev_handle *handle, char channel, char throttle, char yaw, char pitch, char trim, char light)
 Uranus.
int HC_Send_Tandemz (usb_dev_handle *handle, char channel, char throttle, char yaw, char pitch, char pitch_trim, char light)
 TandemZ.
int HC_Send_Ibird (usb_dev_handle *handle, char channel, char throttle, char yaw, char unknown, char checksum)
 i-Bird checksum algorithm is undetermined, but helicontrol firmware supports bit encoding for iBird, so checksum could be calculated/brute forced by host application
int HC_Send_Saucer (usb_dev_handle *handle, char throttle, char yaw, char pitch, char roll)
 saucer
void HC_Close (usb_dev_handle *handle)
 Close device.


Detailed Description

API documentation of libhelicontrol, PLEASE READ ME!

Definition in file helicontrol.h.


Define Documentation

#define HC_CHALLENGER_CHANNEL_A   1

channel A

Definition at line 70 of file helicontrol.h.

#define HC_CHALLENGER_CHANNEL_B   2

channel B

Definition at line 72 of file helicontrol.h.

#define HC_CHALLENGER_LEFT   -1

use HC_CHALLENGER_LEFT*step for yaw and just HC_CHALLENGER_LEFT for trim

Definition at line 62 of file helicontrol.h.

#define HC_CHALLENGER_MAX_THROTTLE   15

maximum throttle value

Definition at line 66 of file helicontrol.h.

#define HC_CHALLENGER_MAX_YAW   3

maximum absolute yaw value

Definition at line 68 of file helicontrol.h.

#define HC_CHALLENGER_RIGHT   1

use HC_CHALLENGER_RIGHT*step for yaw and just HC_CHALLENGER_RIGHT for trim

Definition at line 64 of file helicontrol.h.

#define HC_PICOOZ_CHANNEL_A   0

channel A

Definition at line 52 of file helicontrol.h.

#define HC_PICOOZ_CHANNEL_B   1

channel B

Definition at line 54 of file helicontrol.h.

#define HC_PICOOZ_CHANNEL_C   2

channel C

Definition at line 56 of file helicontrol.h.

#define HC_PICOOZ_LEFT   -1

use HC_PICOOZ_LEFT*step for yaw and just HC_PICOOZ_LEFT for trim

Definition at line 44 of file helicontrol.h.

#define HC_PICOOZ_MAX_THROTTLE   14

maximum throttle value (helicontrol firmware will accept 15 as valid input, but actually send 14, for consistency with other models)

Definition at line 48 of file helicontrol.h.

#define HC_PICOOZ_MAX_YAW   3

maximum absolute yaw value

Definition at line 50 of file helicontrol.h.

#define HC_PICOOZ_RIGHT   1

use HC_PICOOZ_RIGHT*step for yaw and just HC_PICOOZ_RIGHT for trim

Definition at line 46 of file helicontrol.h.

#define HC_SAUCER_BACKWARD   1

use HC_SAUCER_BACKWARD*step for pitch

Definition at line 132 of file helicontrol.h.

#define HC_SAUCER_FORWARD   -1

use HC_SAUCER_FORWARD*step for pitch

Definition at line 130 of file helicontrol.h.

#define HC_SAUCER_LEFT   -1

use HC_SAUCER_LEFT*step for yaw or roll

Definition at line 126 of file helicontrol.h.

#define HC_SAUCER_MAX_PITCH   7

maximum absolute pitch value

Definition at line 136 of file helicontrol.h.

#define HC_SAUCER_MAX_ROLL   7

maximum absolute roll value

Definition at line 140 of file helicontrol.h.

#define HC_SAUCER_MAX_THROTTLE   15

maximum throttle value

Definition at line 134 of file helicontrol.h.

#define HC_SAUCER_MAX_YAW   7

maximum absolute yaw value

Definition at line 138 of file helicontrol.h.

#define HC_SAUCER_RIGHT   1

use HC_SAUCER_RIGHT*step for yaw or roll

Definition at line 128 of file helicontrol.h.

#define HC_TANDEMZ_CHANNEL_A   0

channel A

Definition at line 114 of file helicontrol.h.

#define HC_TANDEMZ_CHANNEL_B   1

channel B

Definition at line 116 of file helicontrol.h.

#define HC_TANDEMZ_CHANNEL_C   2

channel C

Definition at line 118 of file helicontrol.h.

#define HC_TANDEMZ_LEFT   1

use HC_TANDEMZ_LEFT*step

Definition at line 102 of file helicontrol.h.

#define HC_TANDEMZ_MAX_PITCH   5

maximum pitch value

Definition at line 110 of file helicontrol.h.

#define HC_TANDEMZ_MAX_THROTTLE   15

maximum throttle value

Definition at line 106 of file helicontrol.h.

#define HC_TANDEMZ_MAX_TRIM   31

maximum pitch trim value

Definition at line 108 of file helicontrol.h.

#define HC_TANDEMZ_MAX_YAW   30

maximum absolute yaw value

Definition at line 112 of file helicontrol.h.

#define HC_TANDEMZ_PITCH_CENTER   2

center position for pitch (0.

.1 are backwards, 3..5 forwards)

Definition at line 120 of file helicontrol.h.

#define HC_TANDEMZ_RIGHT   -1

use HC_TANDEMZ_RIGHT*step

Definition at line 104 of file helicontrol.h.

#define HC_URANUS_CHANNEL_A   1

channel A

Definition at line 86 of file helicontrol.h.

#define HC_URANUS_CHANNEL_B   2

channel B

Definition at line 88 of file helicontrol.h.

#define HC_URANUS_LEFT   -1

use HC_URANUS_LEFT*step for yaw and just HC_URANUS_LEFT for trim

Definition at line 78 of file helicontrol.h.

#define HC_URANUS_MAX_THROTTLE   15

maximum throttle value

Definition at line 82 of file helicontrol.h.

#define HC_URANUS_MAX_YAW   3

maximum absolute yaw value

Definition at line 84 of file helicontrol.h.

#define HC_URANUS_PITCH_CONT   2

send continous pitch boost

Definition at line 96 of file helicontrol.h.

#define HC_URANUS_PITCH_FAST   3

send fast pitch boost

Definition at line 94 of file helicontrol.h.

#define HC_URANUS_PITCH_NONE   0

send normal pitch

Definition at line 90 of file helicontrol.h.

#define HC_URANUS_PITCH_SLOW   1

send slow pitch boost

Definition at line 92 of file helicontrol.h.

#define HC_URANUS_RIGHT   1

use HC_URANUS_RIGHT*step for yaw and just HC_URANUS_RIGHT for trim

Definition at line 80 of file helicontrol.h.


Function Documentation

void HC_Close ( usb_dev_handle *  handle  ) 

Close device.

Please call me on exit.

Parameters:
handle handle of usb device (obtained by HC_Init())
See also:
HC_Init()

Definition at line 264 of file helicontrol.c.

int HC_CMD_Interval ( usb_dev_handle *  handle,
int  interval_ms 
)

specifies rate at which commands are sent.

See also:
HC_CMD_Repeat() which is used to enable continious sending.
Parameters:
handle handle of usb device (obtained by HC_Init())
interval_ms interval in ms between end of a frame and start of the next one. If 0 the interval will be reset to its default value (200ms)
Returns:
number of bytes written/read or < 0 on error. See libusb/usb_control_msg() documentation.
See also:
HC_CMD_Repeat

Definition at line 173 of file helicontrol.c.

References TIMEOUT_MS.

int HC_CMD_Repeat ( usb_dev_handle *  handle,
char  repeat 
)

switch continious sending.

Note that all helis will stop after 300ms without command.

Parameters:
handle handle of usb device (obtained by HC_Init())yy
repeat 0/1 enable or disable automatic repetition for the last command
Returns:
number of bytes written/read or < 0 on error. See libusb/usb_control_msg() documentation.
See also:
HC_CMD_Interval

Definition at line 167 of file helicontrol.c.

References TIMEOUT_MS.

int HC_CMD_Stop ( usb_dev_handle *  handle  ) 

stop sending.

Note that it is better to set throttle to 0 for an emergency stop of the heli. Otherwise stop will occur approx. 300ms after calling HC_CMD_Stop().

Parameters:
handle handle of usb device (obtained by HC_Init())
Returns:
number of bytes written/read or < 0 on error. See libusb/usb_control_msg() documentation.

Definition at line 179 of file helicontrol.c.

References TIMEOUT_MS.

struct usb_dev_handle* HC_Init ( void   )  [read]

try to open helicontrol usb device.

If more than one is connected, returns handle to first device which has not been opened.

Returns:
ptr to usb device handle, if one is found. NULL on error.
See also:
HC_Close

Definition at line 40 of file helicontrol.c.

References handle, and HC_Read_Firmware_Revision().

Here is the call graph for this function:

int HC_Read_Firmware_Build_Date ( usb_dev_handle *  handle,
char *  datestring,
size_t  maxlen 
)

Definition at line 139 of file helicontrol.c.

int HC_Read_Firmware_Revision ( usb_dev_handle *  handle,
char *  fwstring,
size_t  maxlen 
)

read firmware revision from device

Parameters:
handle handle of usb device (obtained by HC_Init())
fwstring pointer to memory where revision string will be stored to (null-terminated).
maxlen maximum length of string, including tailing null.
Returns:
something < 0 on error.

Definition at line 118 of file helicontrol.c.

void HC_Read_Lib_Build_Date ( char *  datestring,
size_t  maxlen 
)

Definition at line 160 of file helicontrol.c.

int HC_Send_Challenger ( usb_dev_handle *  handle,
char  channel,
char  throttle,
char  yaw,
char  trim,
char  fire 
)

Challanger.

Parameters:
handle handle of usb device (obtained by HC_Init())
channel channel, 0..2 for A..C, see down side of heli
throttle throttle, 0..15
trim yaw trim, 1 = right, 0 = normal, -1 = left (trim value is stored in helicopter and only increased, when the trim bits are different from the previous frame)
yaw yaw, 1..3 left, 0 center, -1..-3 right
fire 0/1, triggers "fire" LED in helicopter when set to 1
Returns:

Definition at line 197 of file helicontrol.c.

References TIMEOUT_MS.

int HC_Send_Ibird ( usb_dev_handle *  handle,
char  channel,
char  throttle,
char  yaw,
char  unknown,
char  checksum 
)

i-Bird checksum algorithm is undetermined, but helicontrol firmware supports bit encoding for iBird, so checksum could be calculated/brute forced by host application

Parameters:
handle handle of usb device (obtained by HC_Init())
channel channel, 2 bits
throttle throttle, 0..15
yaw yaw, 3 bits
unknown 5 bits, unknown purpose
checksum 5 bit checksum, algorithm undetermined
Returns:
number of bytes written/read or < 0 on error. See libusb/usb_control_msg() documentation.

Definition at line 239 of file helicontrol.c.

References TIMEOUT_MS.

int HC_Send_Picooz ( usb_dev_handle *  handle,
char  channel,
char  throttle,
char  yaw,
char  trim 
)

PicooZ.

Parameters:
handle handle of usb device (obtained by HC_Init())
channel channel, 0..2 for A..C, see down side of heli
throttle throttle, 0..15
trim yaw trim, 1 = right, 0 = normal, -1 = left (trim value is stored in helicopter and only increased, when the trim bits are different from the previous frame)
yaw yaw, 1..3 left, 0 center, -1..-3 right
Returns:
number of bytes written/read or < 0 on error. See libusb/usb_control_msg() documentation.

Definition at line 185 of file helicontrol.c.

References TIMEOUT_MS.

int HC_Send_Saucer ( usb_dev_handle *  handle,
char  throttle,
char  yaw,
char  pitch,
char  roll 
)

saucer

Parameters:
handle handle of usb device (obtained by HC_Init)
roll roll, -7..7, negative = left, positive = right
pitch pitch, -7..7, negative = forward, positive = backward
throttle throttle, 0..15
yaw yaw, -7..7, negative = left, positive = right
Returns:
number of bytes written/read or < 0 on error. See libusb/usb_control_msg() documentation.

Definition at line 252 of file helicontrol.c.

References TIMEOUT_MS.

int HC_Send_Tandemz ( usb_dev_handle *  handle,
char  channel,
char  throttle,
char  yaw,
char  pitch,
char  pitch_trim,
char  light 
)

TandemZ.

Parameters:
handle handle of usb device (obtained by HC_Init())
channel channel, 0..2 for A..C, see down side of heli
light 0/1, turns on light when 1
throttle throttle, 0..15
pitch 0..1 = backwards, 2 = neutral/hover, 3..5 = forward
pitch_trim 0..31, 0 = max. forward, 31 = max. backwards
yaw 0..31, 0 = full left, 31 = full forward, center depends on helicopter (the original rc adds yaw trim to this value), steps 3-5, 19-22 and 27-29 are not valid, the helicontrol firmware will map those values to the nearest valid step
Returns:
number of bytes written/read or < 0 on error. See libusb/usb_control_msg() documentation.

Definition at line 224 of file helicontrol.c.

References TIMEOUT_MS.

int HC_Send_Uranus ( usb_dev_handle *  handle,
char  channel,
char  throttle,
char  yaw,
char  pitch,
char  trim,
char  light 
)

Uranus.

Parameters:
handle handle of usb device (obtained by HC_Init())
channel channel, 0..2 for A..C, see down side of heli
throttle throttle, 0..15
trim yaw trim, 1 = right, 0 = normal, -1 = left (trim value is stored in helicopter and only increased, when the trim bits are different from the previous frame)
yaw yaw, 1..3 left, 0 center, -1..-3 right
pitch 0..2, 0 = neutral/hover, 1 = slow boost, 2 = fast boost, 3 = continuous boost
light 0/1, turns on light when 1
Returns:
number of bytes written/read or < 0 on error. See libusb/usb_control_msg() documentation.

Definition at line 210 of file helicontrol.c.

References TIMEOUT_MS.


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