示例#1
0
/* 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
}
示例#2
0
/* Packs command structure to SerialCommand object */
void SBGC_cmd_servo_out_pack(SBGC_cmd_servo_out_t &p, SerialCommand &cmd) {
	cmd.init(SBGC_CMD_SERVO_OUT);
	#ifdef SBGC_CMD_STRUCT_ALIGNED
		memcpy(cmd.data, &p, sizeof(p));
		cmd.len = sizeof(p);
	#else
		for(uint8_t i=0; i<8; i++) {
			cmd.writeWord(p.servo[i]);
		}
	#endif
}
示例#3
0
/* 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
}
示例#4
0
/* Packs command structure to SerialCommand object */
void SBGC_cmd_control_ext_pack(SBGC_cmd_control_ext_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.writeBuf(p.mode, 3);
		for(uint8_t i=0; i<3; i++) {
			cmd.writeWord(p.data[i].speed);
			cmd.writeWord(p.data[i].angle);
		}
	#endif
}
示例#5
0
/* 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
}
示例#6
0
/* 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
}