use core::f32::consts::SQRT_2;
use super::{MixRow, MixerConfig, TableMixer};
const OCTO_INNER: f32 = SQRT_2 - 1.0;
const QUAD_X: [MixRow; 4] = [
MixRow::motor(0, 1.0, 1.0, -1.0),
MixRow::motor(1, -1.0, 1.0, 1.0),
MixRow::motor(2, 1.0, -1.0, 1.0),
MixRow::motor(3, -1.0, -1.0, -1.0),
];
const QUAD_PLUS: [MixRow; 4] = [
MixRow::motor(0, 0.0, 1.0, -1.0),
MixRow::motor(1, -1.0, 0.0, 1.0),
MixRow::motor(2, 0.0, -1.0, -1.0),
MixRow::motor(3, 1.0, 0.0, 1.0),
];
const HEX_X: [MixRow; 6] = [
MixRow::motor(0, 0.5, 1.0, -1.0),
MixRow::motor(1, -0.5, 1.0, 1.0),
MixRow::motor(2, -1.0, 0.0, -1.0),
MixRow::motor(3, -0.5, -1.0, 1.0),
MixRow::motor(4, 0.5, -1.0, -1.0),
MixRow::motor(5, 1.0, 0.0, 1.0),
];
const HEX_PLUS: [MixRow; 6] = [
MixRow::motor(0, 0.0, 1.0, -1.0),
MixRow::motor(1, -1.0, 0.5, 1.0),
MixRow::motor(2, -1.0, -0.5, -1.0),
MixRow::motor(3, 0.0, -1.0, 1.0),
MixRow::motor(4, 1.0, -0.5, -1.0),
MixRow::motor(5, 1.0, 0.5, 1.0),
];
const OCTO_X: [MixRow; 8] = [
MixRow::motor(0, OCTO_INNER, 1.0, -1.0),
MixRow::motor(1, -OCTO_INNER, 1.0, 1.0),
MixRow::motor(2, -1.0, OCTO_INNER, -1.0),
MixRow::motor(3, -1.0, -OCTO_INNER, 1.0),
MixRow::motor(4, -OCTO_INNER, -1.0, -1.0),
MixRow::motor(5, OCTO_INNER, -1.0, 1.0),
MixRow::motor(6, 1.0, -OCTO_INNER, -1.0),
MixRow::motor(7, 1.0, OCTO_INNER, 1.0),
];
const Y6: [MixRow; 6] = [
MixRow::motor(0, 1.0, 0.5, -1.0),
MixRow::motor(1, -1.0, 0.5, -1.0),
MixRow::motor(2, 0.0, -1.0, -1.0),
MixRow::motor(3, 1.0, 0.5, 1.0),
MixRow::motor(4, -1.0, 0.5, 1.0),
MixRow::motor(5, 0.0, -1.0, 1.0),
];
const X8: [MixRow; 8] = [
MixRow::motor(0, 1.0, 1.0, -1.0),
MixRow::motor(1, -1.0, 1.0, 1.0),
MixRow::motor(2, -1.0, -1.0, -1.0),
MixRow::motor(3, 1.0, -1.0, 1.0),
MixRow::motor(4, 1.0, 1.0, 1.0),
MixRow::motor(5, -1.0, 1.0, -1.0),
MixRow::motor(6, -1.0, -1.0, 1.0),
MixRow::motor(7, 1.0, -1.0, -1.0),
];
const TRI: [MixRow; 4] = [
MixRow::motor(0, 1.0, 0.5, 0.0),
MixRow::motor(1, -1.0, 0.5, 0.0),
MixRow::motor(2, 0.0, -1.0, 0.0),
MixRow::servo(0, 0.0, 0.0, 1.0),
];
const TAILSITTER_2P: [MixRow; 4] = [
MixRow::motor(0, 0.0, 0.0, 1.0),
MixRow::motor(1, 0.0, 0.0, -1.0),
MixRow::servo(0, -1.0, 1.0, 0.0),
MixRow::servo(1, 1.0, 1.0, 0.0),
];
const PLANE: [MixRow; 4] = [
MixRow::motor(0, 0.0, 0.0, 0.0),
MixRow::servo(0, 1.0, 0.0, 0.0),
MixRow::servo(1, 0.0, 1.0, 0.0),
MixRow::servo(2, 0.0, 0.0, 1.0),
];
const QUADPLANE: [MixRow; 8] = [
QUAD_X[0],
QUAD_X[1],
QUAD_X[2],
QUAD_X[3],
MixRow::pusher(4),
PLANE[1],
PLANE[2],
PLANE[3],
];
const QUADPLANE_VTAIL: [MixRow; 8] = [
QUAD_X[0],
QUAD_X[1],
QUAD_X[2],
QUAD_X[3],
MixRow::pusher(4),
PLANE[1],
MixRow::servo(1, 0.0, 1.0, 1.0),
MixRow::servo(2, 0.0, 1.0, -1.0),
];
const BI: [MixRow; 4] = [
MixRow::motor(0, 1.0, 0.0, 0.0),
MixRow::motor(1, -1.0, 0.0, 0.0),
MixRow::servo(0, 0.0, 1.0, -1.0),
MixRow::servo(1, 0.0, 1.0, 1.0),
];
impl TableMixer<4> {
pub fn quad_x() -> Self {
Self::from_valid(QUAD_X, MixerConfig::default())
}
pub fn quad_plus() -> Self {
Self::from_valid(QUAD_PLUS, MixerConfig::default())
}
pub fn tri() -> Self {
Self::from_valid(TRI, MixerConfig::default())
}
pub fn bi() -> Self {
Self::from_valid(BI, MixerConfig::default())
}
pub fn tailsitter_2p() -> Self {
Self::from_valid(TAILSITTER_2P, MixerConfig::default())
}
pub fn plane() -> Self {
Self::from_valid(PLANE, MixerConfig::default())
}
}
impl TableMixer<6> {
pub fn hex_x() -> Self {
Self::from_valid(HEX_X, MixerConfig::default())
}
pub fn hex_plus() -> Self {
Self::from_valid(HEX_PLUS, MixerConfig::default())
}
pub fn y6() -> Self {
Self::from_valid(Y6, MixerConfig::default())
}
}
impl TableMixer<8> {
pub fn octo_x() -> Self {
Self::from_valid(OCTO_X, MixerConfig::default())
}
pub fn x8() -> Self {
Self::from_valid(X8, MixerConfig::default())
}
pub fn quadplane() -> Self {
Self::from_valid(QUADPLANE, MixerConfig::default())
}
pub fn quadplane_vtail() -> Self {
Self::from_valid(QUADPLANE_VTAIL, MixerConfig::default())
}
}