APM:Copter
Classes | Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
ToyMode Class Reference

#include <toy_mode.h>

Collaboration diagram for ToyMode:
[legend]

Classes

struct  load_data
 

Public Member Functions

 ToyMode ()
 
bool enabled (void) const
 
void update (void)
 
int16_t get_throttle_mid (void)
 
void throttle_adjust (float &throttle_control)
 
void handle_message (mavlink_message_t *msg)
 
void load_test_run (void)
 

Static Public Attributes

static const struct AP_Param::GroupInfo var_info []
 

Private Types

enum  toy_action {
  ACTION_NONE = 0, ACTION_TAKE_PHOTO = 1, ACTION_TOGGLE_VIDEO = 2, ACTION_MODE_ACRO = 3,
  ACTION_MODE_ALTHOLD = 4, ACTION_MODE_AUTO = 5, ACTION_MODE_LOITER = 6, ACTION_MODE_RTL = 7,
  ACTION_MODE_CIRCLE = 8, ACTION_MODE_LAND = 9, ACTION_MODE_DRIFT = 10, ACTION_MODE_SPORT = 11,
  ACTION_MODE_AUTOTUNE = 12, ACTION_MODE_POSHOLD = 13, ACTION_MODE_BRAKE = 14, ACTION_MODE_THROW = 15,
  ACTION_MODE_FLIP = 16, ACTION_MODE_STAB = 17, ACTION_DISARM = 18, ACTION_TOGGLE_MODE = 19,
  ACTION_ARM_LAND_RTL = 20, ACTION_TOGGLE_SIMPLE = 21, ACTION_TOGGLE_SSIMPLE = 22, ACTION_LOAD_TEST = 23,
  ACTION_MODE_FLOW = 24
}
 
enum  toy_flags { FLAG_THR_DISARM = 1<<0, FLAG_THR_ARM = 1<<1, FLAG_UPGRADE_LOITER = 1<<2, FLAG_RTL_CANCEL = 1<<3 }
 
enum  blink_patterns {
  BLINK_FULL = 0xFFFF, BLINK_OFF = 0x0000, BLINK_1 = 0xBFFF, BLINK_2 = 0xAFFF,
  BLINK_3 = 0xABFF, BLINK_4 = 0xAAFF, BLINK_6 = 0xAAAF, BLINK_8 = 0xAAAA,
  BLINK_NO_RX = 0x1111, BLINK_SLOW_1 = 0xF0FF, BLINK_VSLOW = 0xF000, BLINK_MED_1 = 0xF0F0
}
 
enum  load_type { LOAD_TYPE_CONSTANT =0, LOAD_TYPE_LOG1 =1, LOAD_TYPE_LOG2 =2 }
 

Private Member Functions

void trim_update (void)
 
void action_arm (void)
 
void blink_update (void)
 
void send_named_int (const char *name, int32_t value)
 
bool set_and_remember_mode (control_mode_t mode, mode_reason_t reason)
 
void thrust_limiting (float *thrust, uint8_t num_motors)
 
void arm_check_compass (void)
 
bool is_v2450_buttons (void) const
 
bool is_f412_buttons (void) const
 

Private Attributes

enum toy_action last_action
 
bool done_first_update
 
AP_Int8 enable
 
AP_Int8 primary_mode [2]
 
AP_Int8 actions [9]
 
AP_Int8 trim_auto
 
AP_Int16 flags
 
struct {
   uint32_t   start_ms
 
   uint16_t   chan [4]
 
trim
 
uint32_t power_counter
 
uint32_t throttle_low_counter
 
uint32_t throttle_high_counter
 
uint16_t last_ch5
 
bool last_left_button
 
uint8_t last_mode_choice
 
int32_t left_press_counter
 
int32_t right_press_counter
 
bool ignore_left_change
 
int16_t throttle_mid = 500
 
uint32_t throttle_arm_ms
 
bool upgrade_to_loiter
 
uint32_t last_action_ms
 
uint32_t reset_turtle_start_ms
 
uint32_t last_video_ms
 
uint16_t red_blink_pattern
 
uint16_t green_blink_pattern
 
uint8_t red_blink_index
 
uint8_t green_blink_index
 
uint16_t red_blink_count
 
uint16_t green_blink_count
 
uint8_t blink_disarm
 
struct {
   AP_Float   volt_min
 
   AP_Float   volt_max
 
   AP_Float   thrust_min
 
   AP_Float   thrust_max
 
filter
 
float filtered_voltage = 4.0
 
uint8_t motor_log_counter
 
control_mode_t last_set_mode = LOITER
 
struct {
   bool   running
 
   uint32_t   row
 
   uint8_t   filter_counter
 
   AP_Float   load_mul
 
   AP_Int8   load_filter
 
   AP_Int8   load_type
 
load_test
 

Static Private Attributes

static const struct load_data load_data1 []
 

Friends

class Copter
 

Detailed Description

Definition at line 8 of file toy_mode.h.

Member Enumeration Documentation

◆ blink_patterns

Enumerator
BLINK_FULL 
BLINK_OFF 
BLINK_1 
BLINK_2 
BLINK_3 
BLINK_4 
BLINK_6 
BLINK_8 
BLINK_NO_RX 
BLINK_SLOW_1 
BLINK_VSLOW 
BLINK_MED_1 

Definition at line 92 of file toy_mode.h.

◆ load_type

enum ToyMode::load_type
private
Enumerator
LOAD_TYPE_CONSTANT 
LOAD_TYPE_LOG1 
LOAD_TYPE_LOG2 

Definition at line 165 of file toy_mode.h.

◆ toy_action

enum ToyMode::toy_action
private
Enumerator
ACTION_NONE 
ACTION_TAKE_PHOTO 
ACTION_TOGGLE_VIDEO 
ACTION_MODE_ACRO 
ACTION_MODE_ALTHOLD 
ACTION_MODE_AUTO 
ACTION_MODE_LOITER 
ACTION_MODE_RTL 
ACTION_MODE_CIRCLE 
ACTION_MODE_LAND 
ACTION_MODE_DRIFT 
ACTION_MODE_SPORT 
ACTION_MODE_AUTOTUNE 
ACTION_MODE_POSHOLD 
ACTION_MODE_BRAKE 
ACTION_MODE_THROW 
ACTION_MODE_FLIP 
ACTION_MODE_STAB 
ACTION_DISARM 
ACTION_TOGGLE_MODE 
ACTION_ARM_LAND_RTL 
ACTION_TOGGLE_SIMPLE 
ACTION_TOGGLE_SSIMPLE 
ACTION_LOAD_TEST 
ACTION_MODE_FLOW 

Definition at line 54 of file toy_mode.h.

◆ toy_flags

enum ToyMode::toy_flags
private
Enumerator
FLAG_THR_DISARM 
FLAG_THR_ARM 
FLAG_UPGRADE_LOITER 
FLAG_RTL_CANCEL 

Definition at line 85 of file toy_mode.h.

Constructor & Destructor Documentation

◆ ToyMode()

ToyMode::ToyMode ( )

Member Function Documentation

◆ action_arm()

void ToyMode::action_arm ( void  )
private

◆ arm_check_compass()

void ToyMode::arm_check_compass ( void  )
private

◆ blink_update()

void ToyMode::blink_update ( void  )
private

◆ enabled()

bool ToyMode::enabled ( void  ) const
inline

Definition at line 14 of file toy_mode.h.

Referenced by Copter::arm_motors_check(), Copter::get_pilot_desired_climb_rate(), and Copter::get_throttle_mid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_throttle_mid()

int16_t ToyMode::get_throttle_mid ( void  )
inline

Definition at line 21 of file toy_mode.h.

Referenced by Copter::get_throttle_mid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_message()

void ToyMode::handle_message ( mavlink_message_t *  msg)

Referenced by get_throttle_mid().

Here is the caller graph for this function:

◆ is_f412_buttons()

bool ToyMode::is_f412_buttons ( void  ) const
inlineprivate

Definition at line 50 of file toy_mode.h.

◆ is_v2450_buttons()

bool ToyMode::is_v2450_buttons ( void  ) const
inlineprivate

Definition at line 47 of file toy_mode.h.

◆ load_test_run()

void ToyMode::load_test_run ( void  )

Referenced by get_throttle_mid().

Here is the caller graph for this function:

◆ send_named_int()

void ToyMode::send_named_int ( const char *  name,
int32_t  value 
)
private

◆ set_and_remember_mode()

bool ToyMode::set_and_remember_mode ( control_mode_t  mode,
mode_reason_t  reason 
)
private

◆ throttle_adjust()

void ToyMode::throttle_adjust ( float &  throttle_control)

Referenced by Copter::get_pilot_desired_climb_rate(), and get_throttle_mid().

Here is the caller graph for this function:

◆ thrust_limiting()

void ToyMode::thrust_limiting ( float *  thrust,
uint8_t  num_motors 
)
private

◆ trim_update()

void ToyMode::trim_update ( void  )
private

◆ update()

void ToyMode::update ( void  )

Referenced by enabled().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ Copter

friend class Copter
friend

Definition at line 11 of file toy_mode.h.

Member Data Documentation

◆ actions

AP_Int8 ToyMode::actions[9]
private

Definition at line 110 of file toy_mode.h.

◆ blink_disarm

uint8_t ToyMode::blink_disarm
private

Definition at line 144 of file toy_mode.h.

◆ chan

uint16_t ToyMode::chan[4]

Definition at line 116 of file toy_mode.h.

◆ done_first_update

bool ToyMode::done_first_update
private

Definition at line 107 of file toy_mode.h.

◆ enable

AP_Int8 ToyMode::enable
private

Definition at line 108 of file toy_mode.h.

Referenced by enabled(), is_f412_buttons(), and is_v2450_buttons().

◆ filter

struct { ... } ToyMode::filter

◆ filter_counter

uint8_t ToyMode::filter_counter

Definition at line 174 of file toy_mode.h.

◆ filtered_voltage

float ToyMode::filtered_voltage = 4.0
private

Definition at line 154 of file toy_mode.h.

◆ flags

AP_Int16 ToyMode::flags
private

Definition at line 112 of file toy_mode.h.

◆ green_blink_count

uint16_t ToyMode::green_blink_count
private

Definition at line 143 of file toy_mode.h.

◆ green_blink_index

uint8_t ToyMode::green_blink_index
private

Definition at line 141 of file toy_mode.h.

◆ green_blink_pattern

uint16_t ToyMode::green_blink_pattern
private

Definition at line 139 of file toy_mode.h.

◆ ignore_left_change

bool ToyMode::ignore_left_change
private

Definition at line 127 of file toy_mode.h.

◆ last_action

enum toy_action ToyMode::last_action
private

Definition at line 82 of file toy_mode.h.

◆ last_action_ms

uint32_t ToyMode::last_action_ms
private

Definition at line 131 of file toy_mode.h.

◆ last_ch5

uint16_t ToyMode::last_ch5
private

Definition at line 122 of file toy_mode.h.

◆ last_left_button

bool ToyMode::last_left_button
private

Definition at line 123 of file toy_mode.h.

◆ last_mode_choice

uint8_t ToyMode::last_mode_choice
private

Definition at line 124 of file toy_mode.h.

◆ last_set_mode

control_mode_t ToyMode::last_set_mode = LOITER
private

Definition at line 159 of file toy_mode.h.

◆ last_video_ms

uint32_t ToyMode::last_video_ms
private

Definition at line 135 of file toy_mode.h.

◆ left_press_counter

int32_t ToyMode::left_press_counter
private

Definition at line 125 of file toy_mode.h.

◆ load_data1

const struct load_data ToyMode::load_data1[]
staticprivate

Definition at line 180 of file toy_mode.h.

◆ load_filter

AP_Int8 ToyMode::load_filter

Definition at line 176 of file toy_mode.h.

◆ load_mul

AP_Float ToyMode::load_mul

Definition at line 175 of file toy_mode.h.

◆ load_test

struct { ... } ToyMode::load_test

◆ load_type

Definition at line 177 of file toy_mode.h.

◆ motor_log_counter

uint8_t ToyMode::motor_log_counter
private

Definition at line 156 of file toy_mode.h.

◆ power_counter

uint32_t ToyMode::power_counter
private

Definition at line 119 of file toy_mode.h.

◆ primary_mode

AP_Int8 ToyMode::primary_mode[2]
private

Definition at line 109 of file toy_mode.h.

◆ red_blink_count

uint16_t ToyMode::red_blink_count
private

Definition at line 142 of file toy_mode.h.

◆ red_blink_index

uint8_t ToyMode::red_blink_index
private

Definition at line 140 of file toy_mode.h.

◆ red_blink_pattern

uint16_t ToyMode::red_blink_pattern
private

Definition at line 138 of file toy_mode.h.

◆ reset_turtle_start_ms

uint32_t ToyMode::reset_turtle_start_ms
private

Definition at line 132 of file toy_mode.h.

◆ right_press_counter

int32_t ToyMode::right_press_counter
private

Definition at line 126 of file toy_mode.h.

◆ row

uint32_t ToyMode::row

Definition at line 173 of file toy_mode.h.

◆ running

bool ToyMode::running

Definition at line 172 of file toy_mode.h.

◆ start_ms

uint32_t ToyMode::start_ms

Definition at line 115 of file toy_mode.h.

◆ throttle_arm_ms

uint32_t ToyMode::throttle_arm_ms
private

Definition at line 129 of file toy_mode.h.

◆ throttle_high_counter

uint32_t ToyMode::throttle_high_counter
private

Definition at line 121 of file toy_mode.h.

◆ throttle_low_counter

uint32_t ToyMode::throttle_low_counter
private

Definition at line 120 of file toy_mode.h.

◆ throttle_mid

int16_t ToyMode::throttle_mid = 500
private

Definition at line 128 of file toy_mode.h.

Referenced by get_throttle_mid().

◆ thrust_max

AP_Float ToyMode::thrust_max

Definition at line 150 of file toy_mode.h.

◆ thrust_min

AP_Float ToyMode::thrust_min

Definition at line 149 of file toy_mode.h.

◆ trim

struct { ... } ToyMode::trim

◆ trim_auto

AP_Int8 ToyMode::trim_auto
private

Definition at line 111 of file toy_mode.h.

◆ upgrade_to_loiter

bool ToyMode::upgrade_to_loiter
private

Definition at line 130 of file toy_mode.h.

◆ var_info

const struct AP_Param::GroupInfo ToyMode::var_info[]
static

Definition at line 33 of file toy_mode.h.

◆ volt_max

AP_Float ToyMode::volt_max

Definition at line 148 of file toy_mode.h.

◆ volt_min

AP_Float ToyMode::volt_min

Definition at line 147 of file toy_mode.h.


The documentation for this class was generated from the following file: