#![allow(dead_code)]

#[derive(Debug, Clone)]
pub struct MotorStartup1 {
    pub motor_startup_method: MotorStartupMethod,
    pub align_ramp_rate: AlignRampRate,
    pub align_time: AlignTime,
    pub align_current_threshold: FullCurrentThreshold,
    pub ipd_clock_frequency: IpdClockFrequency,
    pub ipd_current_threshold: IpdCurrentThreshold,
    pub ipd_release_mode: IpdReleaseMode,
    pub ipd_advance_angle: IpdAdvanceAngle,
    pub ipd_repeat: IpdRepeat,
    pub slow_first_cycle_frequency: SlowFirstCycleFrequency,
}

impl Default for MotorStartup1 {
    fn default() -> Self {
        Self {
            motor_startup_method: MotorStartupMethod::Align,
            align_ramp_rate: AlignRampRate::VoltsPerSecond0_1,
            align_time: AlignTime::Millisecond5,
            align_current_threshold: FullCurrentThreshold::NotApplicable,
            ipd_clock_frequency: IpdClockFrequency::Hertz50,
            ipd_current_threshold: IpdCurrentThreshold::NotApplicable,
            ipd_release_mode: IpdReleaseMode::Brake,
            ipd_advance_angle: IpdAdvanceAngle::Degrees0,
            ipd_repeat: IpdRepeat::Once,
            slow_first_cycle_frequency: SlowFirstCycleFrequency::Hertz0_05,
        }
    }
}

#[derive(Debug, Copy, Clone)]
pub enum MotorStartupMethod {
    Align = 0x0,
    DoubleAlign = 0x1,
    Ipd = 0x2,
    SlowFirstCycle = 0x3,
}

#[derive(Debug, Copy, Clone)]
pub enum AlignRampRate {
    VoltsPerSecond0_1 = 0x0,
    VoltsPerSecond0_2 = 0x1,
    VoltsPerSecond0_5 = 0x2,
    VoltsPerSecond1 = 0x3,
    VoltsPerSecond2_5 = 0x4,
    VoltsPerSecond5 = 0x5,
    VoltsPerSecond7_5 = 0x6,
    VoltsPerSecond10 = 0x7,
    VoltsPerSecond25 = 0x8,
    VoltsPerSecond50 = 0x9,
    VoltsPerSecond75 = 0xA,
    VoltsPerSecond100 = 0xB,
    VoltsPerSecond250 = 0xC,
    VoltsPerSecond500 = 0xD,
    VoltsPerSecond750 = 0xE,
    VoltsPerSecond1000 = 0xF,
}

#[derive(Debug, Copy, Clone)]
pub enum AlignTime {
    Millisecond5 = 0x0,
    Millisecond10 = 0x1,
    Millisecond25 = 0x2,
    Millisecond50 = 0x3,
    Millisecond75 = 0x4,
    Millisecond100 = 0x5,
    Millisecond200 = 0x6,
    Millisecond400 = 0x7,
    Millisecond600 = 0x8,
    Millisecond800 = 0x9,
    Second1 = 0xA,
    Second2 = 0xB,
    Second4 = 0xC,
    Second6 = 0xD,
    Second8 = 0xE,
    Second10 = 0xF,
}

#[derive(Debug, Copy, Clone)]
pub enum FullCurrentThreshold {
    NotApplicable = 0x0,
    Volts0_1 = 0x1,
    Volts0_2 = 0x2,
    Volts0_3 = 0x3,
    Volts0_4 = 0x4,
    Volts0_5 = 0x5,
    Volts0_6 = 0x6,
    Volts0_7 = 0x7,
    Volts0_8 = 0x8,
    Volts0_9 = 0x9,
    Volts1_0 = 0xA,
    Volts1_1 = 0xB,
    Volts1_2 = 0xC,
    Volts1_3 = 0xD,
    Volts1_4 = 0xE,
    Volts1_5 = 0xF,
}

#[derive(Debug, Copy, Clone)]
pub enum IpdClockFrequency {
    Hertz50 = 0x0,
    Hertz100 = 0x1,
    Hertz250 = 0x2,
    Hertz500 = 0x3,
    Hertz1000 = 0x4,
    Hertz2000 = 0x5,
    Hertz5000 = 0x6,
    Hertz10000 = 0x7,
}

#[derive(Debug, Copy, Clone)]
pub enum IpdCurrentThreshold {
    NotApplicable = 0x0,
    Volts0_2 = 0x2,
    Volts0_3 = 0x3,
    Volts0_4 = 0x4,
    Volts0_5 = 0x5,
    Volts0_6 = 0x6,
    Volts0_7 = 0x7,
    Volts0_8 = 0x8,
    Volts0_9 = 0x9,
    Volts1_0 = 0xA,
    Volts1_1 = 0xB,
    Volts1_2 = 0xC,
    Volts1_3 = 0xD,
    Volts1_4 = 0xE,
    Volts1_5 = 0xF,
}

#[derive(Debug, Copy, Clone)]
pub enum IpdReleaseMode {
    Brake = 0x0,
    Tristate = 0x1,
}

#[derive(Debug, Copy, Clone)]
pub enum IpdAdvanceAngle {
    Degrees0 = 0x0,
    Degrees30 = 0x1,
    Degrees60 = 0x2,
    Degrees90 = 0x3,
}

#[derive(Debug, Copy, Clone)]
pub enum IpdRepeat {
    Once = 0x0,
    Average2 = 0x1,
    Average3 = 0x2,
    Average4 = 0x3,
}

#[derive(Debug, Copy, Clone)]
pub enum SlowFirstCycleFrequency {
    Hertz0_05 = 0x0,
    Hertz0_1 = 0x1,
    Hertz0_25 = 0x2,
    Hertz0_5 = 0x3,
    Hertz1 = 0x4,
    Hertz2 = 0x5,
    Hertz3 = 0x6,
    Hertz5 = 0x7,
    Hertz10 = 0x8,
    Hertz15 = 0x9,
    Hertz25 = 0xB,
    Hertz50 = 0xC,
    Hertz100 = 0xD,
    Hertz150 = 0xE,
    Hertz200 = 0xF,
}

#[derive(Debug, Clone)]
pub struct MotorStartup2 {
    pub open_loop_current_limit_mode: OpenLoopCurrentLimitMode,
    pub open_loop_duty_cycle: DutyCycle,
    pub open_loop_current_limit: FullCurrentThreshold,
    pub open_loop_acceleration1: OpenLoopAcceleration1,
    pub open_loop_acceleration2: OpenLoopAcceleration2,
    pub open_closed_handoff_threshold: OpenClosedHandoffThreshold,
    pub auto_handoff_enable: bool,
    pub first_cycle_frequency_select: FirstCycleFrequencySelect,
    pub minimum_duty_cycle: MinimumDutyCycle,
}

impl Default for MotorStartup2 {
    fn default() -> Self {
        Self {
            open_loop_current_limit_mode: OpenLoopCurrentLimitMode::OpenLoopCurrentLimit,
            open_loop_duty_cycle: DutyCycle::Percent10,
            open_loop_current_limit: FullCurrentThreshold::NotApplicable,
            open_loop_acceleration1: OpenLoopAcceleration1::HertzPerSecond0_005,
            open_loop_acceleration2: OpenLoopAcceleration2::HertzPerSecondSecond0_005,
            open_closed_handoff_threshold: OpenClosedHandoffThreshold::Hertz1,
            auto_handoff_enable: false,
            first_cycle_frequency_select: FirstCycleFrequencySelect::SlowFirstCycle,
            minimum_duty_cycle: MinimumDutyCycle::Percent1_5,
        }
    }
}

#[derive(Debug, Copy, Clone)]
pub enum OpenLoopCurrentLimitMode {
    OpenLoopCurrentLimit = 0x0,
    CurrentLimit = 0x1,
}

#[derive(Debug, Copy, Clone)]
pub enum DutyCycle {
    Percent10 = 0x0,
    Percent15 = 0x1,
    Percent20 = 0x2,
    Percent25 = 0x3,
    Percent30 = 0x4,
    Percent40 = 0x5,
    Percent50 = 0x6,
    Percent100 = 0x7,
}

#[derive(Debug, Copy, Clone)]
pub enum OpenLoopAcceleration1 {
    HertzPerSecond0_005 = 0x00,
    HertzPerSecond0_01 = 0x01,
    HertzPerSecond0_025 = 0x02,
    HertzPerSecond0_05 = 0x03,
    HertzPerSecond0_1 = 0x04,
    HertzPerSecond0_25 = 0x05,
    HertzPerSecond0_5 = 0x06,
    HertzPerSecond1 = 0x07,
    HertzPerSecond2_5 = 0x08,
    HertzPerSecond5 = 0x09,
    HertzPerSecond7_5 = 0x0A,
    HertzPerSecond10 = 0x0B,
    HertzPerSecond12_5 = 0x0C,
    HertzPerSecond15 = 0x0D,
    HertzPerSecond20 = 0x0E,
    HertzPerSecond30 = 0x0F,
    HertzPerSecond40 = 0x10,
    HertzPerSecond50 = 0x11,
    HertzPerSecond60 = 0x12,
    HertzPerSecond75 = 0x13,
    HertzPerSecond100 = 0x14,
    HertzPerSecond125 = 0x15,
    HertzPerSecond150 = 0x16,
    HertzPerSecond175 = 0x17,
    HertzPerSecond200 = 0x18,
    HertzPerSecond250 = 0x19,
    HertzPerSecond300 = 0x1A,
    HertzPerSecond400 = 0x1B,
    HertzPerSecond500 = 0x1C,
    HertzPerSecond750 = 0x1D,
    HertzPerSecond1000 = 0x1E,
    Unlimited = 0x1F,
}

#[derive(Debug, Copy, Clone)]
pub enum OpenLoopAcceleration2 {
    HertzPerSecondSecond0_005 = 0x00,
    HertzPerSecondSecond0_01 = 0x01,
    HertzPerSecondSecond0_025 = 0x02,
    HertzPerSecondSecond0_05 = 0x03,
    HertzPerSecondSecond0_1 = 0x04,
    HertzPerSecondSecond0_25 = 0x05,
    HertzPerSecondSecond0_5 = 0x06,
    HertzPerSecondSecond1 = 0x07,
    HertzPerSecondSecond2_5 = 0x08,
    HertzPerSecondSecond5 = 0x09,
    HertzPerSecondSecond7_5 = 0x0A,
    HertzPerSecondSecond10 = 0x0B,
    HertzPerSecondSecond12_5 = 0x0C,
    HertzPerSecondSecond15 = 0x0D,
    HertzPerSecondSecond20 = 0x0E,
    HertzPerSecondSecond30 = 0x0F,
    HertzPerSecondSecond40 = 0x10,
    HertzPerSecondSecond50 = 0x11,
    HertzPerSecondSecond60 = 0x12,
    HertzPerSecondSecond75 = 0x13,
    HertzPerSecondSecond100 = 0x14,
    HertzPerSecondSecond125 = 0x15,
    HertzPerSecondSecond150 = 0x16,
    HertzPerSecondSecond175 = 0x17,
    HertzPerSecondSecond200 = 0x18,
    HertzPerSecondSecond250 = 0x19,
    HertzPerSecondSecond300 = 0x1A,
    HertzPerSecondSecond400 = 0x1B,
    HertzPerSecondSecond500 = 0x1C,
    HertzPerSecondSecond750 = 0x1D,
    HertzPerSecondSecond1000 = 0x1E,
    Unlimited = 0x1F,
}

#[derive(Debug, Copy, Clone)]
pub enum OpenClosedHandoffThreshold {
    Hertz1 = 0x00,
    Hertz4 = 0x01,
    Hertz8 = 0x02,
    Hertz12 = 0x03,
    Hertz16 = 0x04,
    Hertz20 = 0x05,
    Hertz24 = 0x06,
    Hertz28 = 0x07,
    Hertz32 = 0x08,
    Hertz36 = 0x09,
    Hertz40 = 0x0A,
    Hertz45 = 0x0B,
    Hertz50 = 0x0C,
    Hertz55 = 0x0D,
    Hertz60 = 0x0E,
    Hertz65 = 0x0F,
    Hertz70 = 0x10,
    Hertz75 = 0x11,
    Hertz80 = 0x12,
    Hertz85 = 0x13,
    Hertz90 = 0x14,
    Hertz100 = 0x15,
    Hertz150 = 0x16,
    Hertz200 = 0x17,
    Hertz250 = 0x18,
    Hertz300 = 0x19,
    Hertz350 = 0x1A,
    Hertz400 = 0x1B,
    Hertz450 = 0x1C,
    Hertz500 = 0x1D,
    Hertz550 = 0x1E,
    Hertz600 = 0x1F,
}

#[derive(Debug, Copy, Clone)]
pub enum EnableDisable {
    Disable = 0x0,
    Enable = 0x1,
}

#[derive(Debug, Copy, Clone)]
pub enum FirstCycleFrequencySelect {
    SlowFirstCycle = 0x0,
    Hertz0 = 0x1,
}

#[derive(Debug, Copy, Clone)]
pub enum MinimumDutyCycle {
    Percent1_5 = 0x0,
    Percent2 = 0x1,
    Percent3 = 0x2,
    Percent4 = 0x3,
    Percent5 = 0x4,
    Percent6 = 0x5,
    Percent7 = 0x6,
    Percent8 = 0x7,
    Percent9 = 0x8,
    Percent10 = 0x9,
    Percent12 = 0xA,
    Percent15 = 0xB,
    Percent17_5 = 0xC,
    Percent20 = 0xD,
    Percent25 = 0xE,
    Percent30 = 0xF,
}
