#include <usb.h>
#include "helicontrol_firmware.h"
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. |
Definition in file helicontrol.h.
#define HC_CHALLENGER_CHANNEL_A 1 |
#define HC_CHALLENGER_CHANNEL_B 2 |
#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 |
#define HC_CHALLENGER_MAX_YAW 3 |
#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 |
#define HC_PICOOZ_CHANNEL_B 1 |
#define HC_PICOOZ_CHANNEL_C 2 |
#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 |
#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 |
#define HC_SAUCER_FORWARD -1 |
#define HC_SAUCER_LEFT -1 |
#define HC_SAUCER_MAX_PITCH 7 |
#define HC_SAUCER_MAX_ROLL 7 |
#define HC_SAUCER_MAX_THROTTLE 15 |
#define HC_SAUCER_MAX_YAW 7 |
#define HC_SAUCER_RIGHT 1 |
#define HC_TANDEMZ_CHANNEL_A 0 |
#define HC_TANDEMZ_CHANNEL_B 1 |
#define HC_TANDEMZ_CHANNEL_C 2 |
#define HC_TANDEMZ_LEFT 1 |
#define HC_TANDEMZ_MAX_PITCH 5 |
#define HC_TANDEMZ_MAX_THROTTLE 15 |
#define HC_TANDEMZ_MAX_TRIM 31 |
#define HC_TANDEMZ_MAX_YAW 30 |
#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 |
#define HC_URANUS_CHANNEL_A 1 |
#define HC_URANUS_CHANNEL_B 2 |
#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 |
#define HC_URANUS_MAX_YAW 3 |
#define HC_URANUS_PITCH_CONT 2 |
#define HC_URANUS_PITCH_FAST 3 |
#define HC_URANUS_PITCH_NONE 0 |
#define HC_URANUS_PITCH_SLOW 1 |
#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.
void HC_Close | ( | usb_dev_handle * | handle | ) |
Close device.
Please call me on exit.
handle | handle of usb device (obtained by 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.
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) |
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.
handle | handle of usb device (obtained by HC_Init())yy | |
repeat | 0/1 enable or disable automatic repetition for the last command |
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().
handle | handle of usb device (obtained by HC_Init()) |
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.
Definition at line 40 of file helicontrol.c.
References handle, and HC_Read_Firmware_Revision().
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
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. |
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.
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 |
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
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 |
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.
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 |
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
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 |
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.
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 |
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.
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 |
Definition at line 210 of file helicontrol.c.
References TIMEOUT_MS.