/* Packs command structure to SerialCommand object */ void SBGC_cmd_trigger_pack(SBGC_cmd_trigger_t &p, SerialCommand &cmd) { cmd.init(SBGC_CMD_TRIGGER_PIN); #ifdef SBGC_CMD_STRUCT_ALIGNED memcpy(cmd.data, &p, sizeof(p)); cmd.len = sizeof(p); #else cmd.writeByte(p.pin); cmd.writeByte(p.state); #endif }
/* Packs command structure to SerialCommand object */ void SBGC_cmd_set_adj_vars_pack(SBGC_cmd_set_adj_vars_var_t vars[], uint8_t vars_num, SerialCommand &cmd) { cmd.init(SBGC_CMD_SET_ADJ_VARS_VAL); cmd.writeByte(vars_num); // number of variables #ifdef SBGC_CMD_STRUCT_ALIGNED cmd.writeBuf(vars, sizeof(SBGC_cmd_set_adj_vars_var_t)*vars_num); #else for(uint8_t i=0; i<vars_num; i++) { cmd.writeByte(vars[i].id); cmd.writeLong(vars[i].val); } #endif }
/* Packs command structure to SerialCommand object */ void SBGC_cmd_api_virt_ch_control_pack(SBGC_cmd_api_virt_ch_control_t &p, SerialCommand &cmd) { cmd.init(SBGC_CMD_API_VIRT_CH_CONTROL); #ifdef SBGC_CMD_STRUCT_ALIGNED memcpy(cmd.data, &p, sizeof(p)); cmd.len = sizeof(p); #else for(uint8_t i=0; i<SBGC_API_VIRT_NUM_CHANNELS; i++) { cmd.writeByte(p.data[i]); } #endif }
/* Packs command structure to SerialCommand object */ void SBGC_cmd_control_pack(SBGC_cmd_control_t &p, SerialCommand &cmd) { cmd.init(SBGC_CMD_CONTROL); #ifdef SBGC_CMD_STRUCT_ALIGNED memcpy(cmd.data, &p, sizeof(p)); cmd.len = sizeof(p); #else cmd.writeByte(p.mode); cmd.writeWord(p.speedROLL); cmd.writeWord(p.angleROLL); cmd.writeWord(p.speedPITCH); cmd.writeWord(p.anglePITCH); cmd.writeWord(p.speedYAW); cmd.writeWord(p.angleYAW); #endif }