#include "../firmware/com_def.h"
#include "helicontrol.h"
#include "helicontrol_firmware.h"
#include "frame.h"
#include <string.h>
#include <stdio.h>
Go to the source code of this file.
Defines | |
#define | TIMEOUT_MS 2000 |
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. |
.. Sorry, I am Q&D and don't come with helpful comments in the code :-(
Definition in file helicontrol.c.
#define TIMEOUT_MS 2000 |
Definition at line 38 of file helicontrol.c.
Referenced by HC_CMD_Interval(), HC_CMD_Repeat(), HC_CMD_Stop(), HC_Send_Challenger(), HC_Send_Ibird(), HC_Send_Picooz(), HC_Send_Saucer(), HC_Send_Tandemz(), and HC_Send_Uranus().
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.
Referenced by main().
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.
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.
Referenced by main().
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.
Referenced by main().
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.
Referenced by main().
int HC_Read_Firmware_Build_Date | ( | usb_dev_handle * | handle, | |
char * | datestring, | |||
size_t | maxlen | |||
) |
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 | |||
) |
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.
Referenced by send_frame().
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.
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.
Referenced by send_frame().
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.
Referenced by send_frame().
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.
Referenced by send_frame().
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.
Referenced by send_frame().