use crate::{
byte_converter::*, converting_callback_receiver::ConvertingCallbackReceiver, converting_receiver::ConvertingReceiver, device::*,
ip_connection::GetRequestSender,
};
pub enum SilentStepperBrickFunction {
SetMaxVelocity,
GetMaxVelocity,
GetCurrentVelocity,
SetSpeedRamping,
GetSpeedRamping,
FullBrake,
SetCurrentPosition,
GetCurrentPosition,
SetTargetPosition,
GetTargetPosition,
SetSteps,
GetSteps,
GetRemainingSteps,
SetStepConfiguration,
GetStepConfiguration,
DriveForward,
DriveBackward,
Stop,
GetStackInputVoltage,
GetExternalInputVoltage,
SetMotorCurrent,
GetMotorCurrent,
Enable,
Disable,
IsEnabled,
SetBasicConfiguration,
GetBasicConfiguration,
SetSpreadcycleConfiguration,
GetSpreadcycleConfiguration,
SetStealthConfiguration,
GetStealthConfiguration,
SetCoolstepConfiguration,
GetCoolstepConfiguration,
SetMiscConfiguration,
GetMiscConfiguration,
GetDriverStatus,
SetMinimumVoltage,
GetMinimumVoltage,
SetTimeBase,
GetTimeBase,
GetAllData,
SetAllDataPeriod,
GetAllDataPeriod,
SetSpitfpBaudrateConfig,
GetSpitfpBaudrateConfig,
GetSendTimeoutCount,
SetSpitfpBaudrate,
GetSpitfpBaudrate,
GetSpitfpErrorCount,
EnableStatusLed,
DisableStatusLed,
IsStatusLedEnabled,
GetProtocol1BrickletName,
GetChipTemperature,
Reset,
WriteBrickletPlugin,
ReadBrickletPlugin,
GetIdentity,
CallbackUnderVoltage,
CallbackPositionReached,
CallbackAllData,
CallbackNewState,
}
impl From<SilentStepperBrickFunction> for u8 {
fn from(fun: SilentStepperBrickFunction) -> Self {
match fun {
SilentStepperBrickFunction::SetMaxVelocity => 1,
SilentStepperBrickFunction::GetMaxVelocity => 2,
SilentStepperBrickFunction::GetCurrentVelocity => 3,
SilentStepperBrickFunction::SetSpeedRamping => 4,
SilentStepperBrickFunction::GetSpeedRamping => 5,
SilentStepperBrickFunction::FullBrake => 6,
SilentStepperBrickFunction::SetCurrentPosition => 7,
SilentStepperBrickFunction::GetCurrentPosition => 8,
SilentStepperBrickFunction::SetTargetPosition => 9,
SilentStepperBrickFunction::GetTargetPosition => 10,
SilentStepperBrickFunction::SetSteps => 11,
SilentStepperBrickFunction::GetSteps => 12,
SilentStepperBrickFunction::GetRemainingSteps => 13,
SilentStepperBrickFunction::SetStepConfiguration => 14,
SilentStepperBrickFunction::GetStepConfiguration => 15,
SilentStepperBrickFunction::DriveForward => 16,
SilentStepperBrickFunction::DriveBackward => 17,
SilentStepperBrickFunction::Stop => 18,
SilentStepperBrickFunction::GetStackInputVoltage => 19,
SilentStepperBrickFunction::GetExternalInputVoltage => 20,
SilentStepperBrickFunction::SetMotorCurrent => 22,
SilentStepperBrickFunction::GetMotorCurrent => 23,
SilentStepperBrickFunction::Enable => 24,
SilentStepperBrickFunction::Disable => 25,
SilentStepperBrickFunction::IsEnabled => 26,
SilentStepperBrickFunction::SetBasicConfiguration => 27,
SilentStepperBrickFunction::GetBasicConfiguration => 28,
SilentStepperBrickFunction::SetSpreadcycleConfiguration => 29,
SilentStepperBrickFunction::GetSpreadcycleConfiguration => 30,
SilentStepperBrickFunction::SetStealthConfiguration => 31,
SilentStepperBrickFunction::GetStealthConfiguration => 32,
SilentStepperBrickFunction::SetCoolstepConfiguration => 33,
SilentStepperBrickFunction::GetCoolstepConfiguration => 34,
SilentStepperBrickFunction::SetMiscConfiguration => 35,
SilentStepperBrickFunction::GetMiscConfiguration => 36,
SilentStepperBrickFunction::GetDriverStatus => 37,
SilentStepperBrickFunction::SetMinimumVoltage => 38,
SilentStepperBrickFunction::GetMinimumVoltage => 39,
SilentStepperBrickFunction::SetTimeBase => 42,
SilentStepperBrickFunction::GetTimeBase => 43,
SilentStepperBrickFunction::GetAllData => 44,
SilentStepperBrickFunction::SetAllDataPeriod => 45,
SilentStepperBrickFunction::GetAllDataPeriod => 46,
SilentStepperBrickFunction::SetSpitfpBaudrateConfig => 231,
SilentStepperBrickFunction::GetSpitfpBaudrateConfig => 232,
SilentStepperBrickFunction::GetSendTimeoutCount => 233,
SilentStepperBrickFunction::SetSpitfpBaudrate => 234,
SilentStepperBrickFunction::GetSpitfpBaudrate => 235,
SilentStepperBrickFunction::GetSpitfpErrorCount => 237,
SilentStepperBrickFunction::EnableStatusLed => 238,
SilentStepperBrickFunction::DisableStatusLed => 239,
SilentStepperBrickFunction::IsStatusLedEnabled => 240,
SilentStepperBrickFunction::GetProtocol1BrickletName => 241,
SilentStepperBrickFunction::GetChipTemperature => 242,
SilentStepperBrickFunction::Reset => 243,
SilentStepperBrickFunction::WriteBrickletPlugin => 246,
SilentStepperBrickFunction::ReadBrickletPlugin => 247,
SilentStepperBrickFunction::GetIdentity => 255,
SilentStepperBrickFunction::CallbackUnderVoltage => 40,
SilentStepperBrickFunction::CallbackPositionReached => 41,
SilentStepperBrickFunction::CallbackAllData => 47,
SilentStepperBrickFunction::CallbackNewState => 48,
}
}
}
pub const SILENT_STEPPER_BRICK_STEP_RESOLUTION_1: u8 = 8;
pub const SILENT_STEPPER_BRICK_STEP_RESOLUTION_2: u8 = 7;
pub const SILENT_STEPPER_BRICK_STEP_RESOLUTION_4: u8 = 6;
pub const SILENT_STEPPER_BRICK_STEP_RESOLUTION_8: u8 = 5;
pub const SILENT_STEPPER_BRICK_STEP_RESOLUTION_16: u8 = 4;
pub const SILENT_STEPPER_BRICK_STEP_RESOLUTION_32: u8 = 3;
pub const SILENT_STEPPER_BRICK_STEP_RESOLUTION_64: u8 = 2;
pub const SILENT_STEPPER_BRICK_STEP_RESOLUTION_128: u8 = 1;
pub const SILENT_STEPPER_BRICK_STEP_RESOLUTION_256: u8 = 0;
pub const SILENT_STEPPER_BRICK_CHOPPER_MODE_SPREAD_CYCLE: u8 = 0;
pub const SILENT_STEPPER_BRICK_CHOPPER_MODE_FAST_DECAY: u8 = 1;
pub const SILENT_STEPPER_BRICK_FREEWHEEL_MODE_NORMAL: u8 = 0;
pub const SILENT_STEPPER_BRICK_FREEWHEEL_MODE_FREEWHEELING: u8 = 1;
pub const SILENT_STEPPER_BRICK_FREEWHEEL_MODE_COIL_SHORT_LS: u8 = 2;
pub const SILENT_STEPPER_BRICK_FREEWHEEL_MODE_COIL_SHORT_HS: u8 = 3;
pub const SILENT_STEPPER_BRICK_CURRENT_UP_STEP_INCREMENT_1: u8 = 0;
pub const SILENT_STEPPER_BRICK_CURRENT_UP_STEP_INCREMENT_2: u8 = 1;
pub const SILENT_STEPPER_BRICK_CURRENT_UP_STEP_INCREMENT_4: u8 = 2;
pub const SILENT_STEPPER_BRICK_CURRENT_UP_STEP_INCREMENT_8: u8 = 3;
pub const SILENT_STEPPER_BRICK_CURRENT_DOWN_STEP_DECREMENT_1: u8 = 0;
pub const SILENT_STEPPER_BRICK_CURRENT_DOWN_STEP_DECREMENT_2: u8 = 1;
pub const SILENT_STEPPER_BRICK_CURRENT_DOWN_STEP_DECREMENT_8: u8 = 2;
pub const SILENT_STEPPER_BRICK_CURRENT_DOWN_STEP_DECREMENT_32: u8 = 3;
pub const SILENT_STEPPER_BRICK_MINIMUM_CURRENT_HALF: u8 = 0;
pub const SILENT_STEPPER_BRICK_MINIMUM_CURRENT_QUARTER: u8 = 1;
pub const SILENT_STEPPER_BRICK_STALLGUARD_MODE_STANDARD: u8 = 0;
pub const SILENT_STEPPER_BRICK_STALLGUARD_MODE_FILTERED: u8 = 1;
pub const SILENT_STEPPER_BRICK_OPEN_LOAD_NONE: u8 = 0;
pub const SILENT_STEPPER_BRICK_OPEN_LOAD_PHASE_A: u8 = 1;
pub const SILENT_STEPPER_BRICK_OPEN_LOAD_PHASE_B: u8 = 2;
pub const SILENT_STEPPER_BRICK_OPEN_LOAD_PHASE_AB: u8 = 3;
pub const SILENT_STEPPER_BRICK_SHORT_TO_GROUND_NONE: u8 = 0;
pub const SILENT_STEPPER_BRICK_SHORT_TO_GROUND_PHASE_A: u8 = 1;
pub const SILENT_STEPPER_BRICK_SHORT_TO_GROUND_PHASE_B: u8 = 2;
pub const SILENT_STEPPER_BRICK_SHORT_TO_GROUND_PHASE_AB: u8 = 3;
pub const SILENT_STEPPER_BRICK_OVER_TEMPERATURE_NONE: u8 = 0;
pub const SILENT_STEPPER_BRICK_OVER_TEMPERATURE_WARNING: u8 = 1;
pub const SILENT_STEPPER_BRICK_OVER_TEMPERATURE_LIMIT: u8 = 2;
pub const SILENT_STEPPER_BRICK_STATE_STOP: u8 = 1;
pub const SILENT_STEPPER_BRICK_STATE_ACCELERATION: u8 = 2;
pub const SILENT_STEPPER_BRICK_STATE_RUN: u8 = 3;
pub const SILENT_STEPPER_BRICK_STATE_DEACCELERATION: u8 = 4;
pub const SILENT_STEPPER_BRICK_STATE_DIRECTION_CHANGE_TO_FORWARD: u8 = 5;
pub const SILENT_STEPPER_BRICK_STATE_DIRECTION_CHANGE_TO_BACKWARD: u8 = 6;
pub const SILENT_STEPPER_BRICK_COMMUNICATION_METHOD_NONE: u8 = 0;
pub const SILENT_STEPPER_BRICK_COMMUNICATION_METHOD_USB: u8 = 1;
pub const SILENT_STEPPER_BRICK_COMMUNICATION_METHOD_SPI_STACK: u8 = 2;
pub const SILENT_STEPPER_BRICK_COMMUNICATION_METHOD_CHIBI: u8 = 3;
pub const SILENT_STEPPER_BRICK_COMMUNICATION_METHOD_RS485: u8 = 4;
pub const SILENT_STEPPER_BRICK_COMMUNICATION_METHOD_WIFI: u8 = 5;
pub const SILENT_STEPPER_BRICK_COMMUNICATION_METHOD_ETHERNET: u8 = 6;
pub const SILENT_STEPPER_BRICK_COMMUNICATION_METHOD_WIFI_V2: u8 = 7;
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct SpeedRamping {
pub acceleration: u16,
pub deacceleration: u16,
}
impl FromByteSlice for SpeedRamping {
fn bytes_expected() -> usize { 4 }
fn from_le_byte_slice(bytes: &[u8]) -> SpeedRamping {
SpeedRamping { acceleration: <u16>::from_le_byte_slice(&bytes[0..2]), deacceleration: <u16>::from_le_byte_slice(&bytes[2..4]) }
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct StepConfiguration {
pub step_resolution: u8,
pub interpolation: bool,
}
impl FromByteSlice for StepConfiguration {
fn bytes_expected() -> usize { 2 }
fn from_le_byte_slice(bytes: &[u8]) -> StepConfiguration {
StepConfiguration {
step_resolution: <u8>::from_le_byte_slice(&bytes[0..1]),
interpolation: <bool>::from_le_byte_slice(&bytes[1..2]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct BasicConfiguration {
pub standstill_current: u16,
pub motor_run_current: u16,
pub standstill_delay_time: u16,
pub power_down_time: u16,
pub stealth_threshold: u16,
pub coolstep_threshold: u16,
pub classic_threshold: u16,
pub high_velocity_chopper_mode: bool,
}
impl FromByteSlice for BasicConfiguration {
fn bytes_expected() -> usize { 15 }
fn from_le_byte_slice(bytes: &[u8]) -> BasicConfiguration {
BasicConfiguration {
standstill_current: <u16>::from_le_byte_slice(&bytes[0..2]),
motor_run_current: <u16>::from_le_byte_slice(&bytes[2..4]),
standstill_delay_time: <u16>::from_le_byte_slice(&bytes[4..6]),
power_down_time: <u16>::from_le_byte_slice(&bytes[6..8]),
stealth_threshold: <u16>::from_le_byte_slice(&bytes[8..10]),
coolstep_threshold: <u16>::from_le_byte_slice(&bytes[10..12]),
classic_threshold: <u16>::from_le_byte_slice(&bytes[12..14]),
high_velocity_chopper_mode: <bool>::from_le_byte_slice(&bytes[14..15]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct SpreadcycleConfiguration {
pub slow_decay_duration: u8,
pub enable_random_slow_decay: bool,
pub fast_decay_duration: u8,
pub hysteresis_start_value: u8,
pub hysteresis_end_value: i8,
pub sine_wave_offset: i8,
pub chopper_mode: u8,
pub comparator_blank_time: u8,
pub fast_decay_without_comparator: bool,
}
impl FromByteSlice for SpreadcycleConfiguration {
fn bytes_expected() -> usize { 9 }
fn from_le_byte_slice(bytes: &[u8]) -> SpreadcycleConfiguration {
SpreadcycleConfiguration {
slow_decay_duration: <u8>::from_le_byte_slice(&bytes[0..1]),
enable_random_slow_decay: <bool>::from_le_byte_slice(&bytes[1..2]),
fast_decay_duration: <u8>::from_le_byte_slice(&bytes[2..3]),
hysteresis_start_value: <u8>::from_le_byte_slice(&bytes[3..4]),
hysteresis_end_value: <i8>::from_le_byte_slice(&bytes[4..5]),
sine_wave_offset: <i8>::from_le_byte_slice(&bytes[5..6]),
chopper_mode: <u8>::from_le_byte_slice(&bytes[6..7]),
comparator_blank_time: <u8>::from_le_byte_slice(&bytes[7..8]),
fast_decay_without_comparator: <bool>::from_le_byte_slice(&bytes[8..9]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct StealthConfiguration {
pub enable_stealth: bool,
pub amplitude: u8,
pub gradient: u8,
pub enable_autoscale: bool,
pub force_symmetric: bool,
pub freewheel_mode: u8,
}
impl FromByteSlice for StealthConfiguration {
fn bytes_expected() -> usize { 6 }
fn from_le_byte_slice(bytes: &[u8]) -> StealthConfiguration {
StealthConfiguration {
enable_stealth: <bool>::from_le_byte_slice(&bytes[0..1]),
amplitude: <u8>::from_le_byte_slice(&bytes[1..2]),
gradient: <u8>::from_le_byte_slice(&bytes[2..3]),
enable_autoscale: <bool>::from_le_byte_slice(&bytes[3..4]),
force_symmetric: <bool>::from_le_byte_slice(&bytes[4..5]),
freewheel_mode: <u8>::from_le_byte_slice(&bytes[5..6]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct CoolstepConfiguration {
pub minimum_stallguard_value: u8,
pub maximum_stallguard_value: u8,
pub current_up_step_width: u8,
pub current_down_step_width: u8,
pub minimum_current: u8,
pub stallguard_threshold_value: i8,
pub stallguard_mode: u8,
}
impl FromByteSlice for CoolstepConfiguration {
fn bytes_expected() -> usize { 7 }
fn from_le_byte_slice(bytes: &[u8]) -> CoolstepConfiguration {
CoolstepConfiguration {
minimum_stallguard_value: <u8>::from_le_byte_slice(&bytes[0..1]),
maximum_stallguard_value: <u8>::from_le_byte_slice(&bytes[1..2]),
current_up_step_width: <u8>::from_le_byte_slice(&bytes[2..3]),
current_down_step_width: <u8>::from_le_byte_slice(&bytes[3..4]),
minimum_current: <u8>::from_le_byte_slice(&bytes[4..5]),
stallguard_threshold_value: <i8>::from_le_byte_slice(&bytes[5..6]),
stallguard_mode: <u8>::from_le_byte_slice(&bytes[6..7]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct MiscConfiguration {
pub disable_short_to_ground_protection: bool,
pub synchronize_phase_frequency: u8,
}
impl FromByteSlice for MiscConfiguration {
fn bytes_expected() -> usize { 2 }
fn from_le_byte_slice(bytes: &[u8]) -> MiscConfiguration {
MiscConfiguration {
disable_short_to_ground_protection: <bool>::from_le_byte_slice(&bytes[0..1]),
synchronize_phase_frequency: <u8>::from_le_byte_slice(&bytes[1..2]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct DriverStatus {
pub open_load: u8,
pub short_to_ground: u8,
pub over_temperature: u8,
pub motor_stalled: bool,
pub actual_motor_current: u8,
pub full_step_active: bool,
pub stallguard_result: u8,
pub stealth_voltage_amplitude: u8,
}
impl FromByteSlice for DriverStatus {
fn bytes_expected() -> usize { 8 }
fn from_le_byte_slice(bytes: &[u8]) -> DriverStatus {
DriverStatus {
open_load: <u8>::from_le_byte_slice(&bytes[0..1]),
short_to_ground: <u8>::from_le_byte_slice(&bytes[1..2]),
over_temperature: <u8>::from_le_byte_slice(&bytes[2..3]),
motor_stalled: <bool>::from_le_byte_slice(&bytes[3..4]),
actual_motor_current: <u8>::from_le_byte_slice(&bytes[4..5]),
full_step_active: <bool>::from_le_byte_slice(&bytes[5..6]),
stallguard_result: <u8>::from_le_byte_slice(&bytes[6..7]),
stealth_voltage_amplitude: <u8>::from_le_byte_slice(&bytes[7..8]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct AllData {
pub current_velocity: u16,
pub current_position: i32,
pub remaining_steps: i32,
pub stack_voltage: u16,
pub external_voltage: u16,
pub current_consumption: u16,
}
impl FromByteSlice for AllData {
fn bytes_expected() -> usize { 16 }
fn from_le_byte_slice(bytes: &[u8]) -> AllData {
AllData {
current_velocity: <u16>::from_le_byte_slice(&bytes[0..2]),
current_position: <i32>::from_le_byte_slice(&bytes[2..6]),
remaining_steps: <i32>::from_le_byte_slice(&bytes[6..10]),
stack_voltage: <u16>::from_le_byte_slice(&bytes[10..12]),
external_voltage: <u16>::from_le_byte_slice(&bytes[12..14]),
current_consumption: <u16>::from_le_byte_slice(&bytes[14..16]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct AllDataEvent {
pub current_velocity: u16,
pub current_position: i32,
pub remaining_steps: i32,
pub stack_voltage: u16,
pub external_voltage: u16,
pub current_consumption: u16,
}
impl FromByteSlice for AllDataEvent {
fn bytes_expected() -> usize { 16 }
fn from_le_byte_slice(bytes: &[u8]) -> AllDataEvent {
AllDataEvent {
current_velocity: <u16>::from_le_byte_slice(&bytes[0..2]),
current_position: <i32>::from_le_byte_slice(&bytes[2..6]),
remaining_steps: <i32>::from_le_byte_slice(&bytes[6..10]),
stack_voltage: <u16>::from_le_byte_slice(&bytes[10..12]),
external_voltage: <u16>::from_le_byte_slice(&bytes[12..14]),
current_consumption: <u16>::from_le_byte_slice(&bytes[14..16]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct NewStateEvent {
pub state_new: u8,
pub state_previous: u8,
}
impl FromByteSlice for NewStateEvent {
fn bytes_expected() -> usize { 2 }
fn from_le_byte_slice(bytes: &[u8]) -> NewStateEvent {
NewStateEvent { state_new: <u8>::from_le_byte_slice(&bytes[0..1]), state_previous: <u8>::from_le_byte_slice(&bytes[1..2]) }
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct SpitfpBaudrateConfig {
pub enable_dynamic_baudrate: bool,
pub minimum_dynamic_baudrate: u32,
}
impl FromByteSlice for SpitfpBaudrateConfig {
fn bytes_expected() -> usize { 5 }
fn from_le_byte_slice(bytes: &[u8]) -> SpitfpBaudrateConfig {
SpitfpBaudrateConfig {
enable_dynamic_baudrate: <bool>::from_le_byte_slice(&bytes[0..1]),
minimum_dynamic_baudrate: <u32>::from_le_byte_slice(&bytes[1..5]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct SpitfpErrorCount {
pub error_count_ack_checksum: u32,
pub error_count_message_checksum: u32,
pub error_count_frame: u32,
pub error_count_overflow: u32,
}
impl FromByteSlice for SpitfpErrorCount {
fn bytes_expected() -> usize { 16 }
fn from_le_byte_slice(bytes: &[u8]) -> SpitfpErrorCount {
SpitfpErrorCount {
error_count_ack_checksum: <u32>::from_le_byte_slice(&bytes[0..4]),
error_count_message_checksum: <u32>::from_le_byte_slice(&bytes[4..8]),
error_count_frame: <u32>::from_le_byte_slice(&bytes[8..12]),
error_count_overflow: <u32>::from_le_byte_slice(&bytes[12..16]),
}
}
}
#[derive(Clone)]
pub struct Protocol1BrickletName {
pub protocol_version: u8,
pub firmware_version: [u8; 3],
pub name: String,
}
impl FromByteSlice for Protocol1BrickletName {
fn bytes_expected() -> usize { 44 }
fn from_le_byte_slice(bytes: &[u8]) -> Protocol1BrickletName {
Protocol1BrickletName {
protocol_version: <u8>::from_le_byte_slice(&bytes[0..1]),
firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[1..4]),
name: <String>::from_le_byte_slice(&bytes[4..44]),
}
}
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct Identity {
pub uid: String,
pub connected_uid: String,
pub position: char,
pub hardware_version: [u8; 3],
pub firmware_version: [u8; 3],
pub device_identifier: u16,
}
impl FromByteSlice for Identity {
fn bytes_expected() -> usize { 25 }
fn from_le_byte_slice(bytes: &[u8]) -> Identity {
Identity {
uid: <String>::from_le_byte_slice(&bytes[0..8]),
connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
position: <char>::from_le_byte_slice(&bytes[16..17]),
hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
}
}
}
#[derive(Clone)]
pub struct SilentStepperBrick {
device: Device,
}
impl SilentStepperBrick {
pub const DEVICE_IDENTIFIER: u16 = 19;
pub const DEVICE_DISPLAY_NAME: &'static str = "Silent Stepper Brick";
pub fn new<T: GetRequestSender>(uid: &str, req_sender: T) -> SilentStepperBrick {
let mut result = SilentStepperBrick { device: Device::new([2, 0, 1], uid, req_sender, 0) };
result.device.response_expected[u8::from(SilentStepperBrickFunction::SetMaxVelocity) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetMaxVelocity) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetCurrentVelocity) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::SetSpeedRamping) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetSpeedRamping) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::FullBrake) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::SetCurrentPosition) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetCurrentPosition) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::SetTargetPosition) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetTargetPosition) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::SetSteps) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetSteps) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetRemainingSteps) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::SetStepConfiguration) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetStepConfiguration) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::DriveForward) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::DriveBackward) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::Stop) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetStackInputVoltage) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetExternalInputVoltage) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::SetMotorCurrent) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetMotorCurrent) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::Enable) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::Disable) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::IsEnabled) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::SetBasicConfiguration) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetBasicConfiguration) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::SetSpreadcycleConfiguration) as usize] =
ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetSpreadcycleConfiguration) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::SetStealthConfiguration) as usize] =
ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetStealthConfiguration) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::SetCoolstepConfiguration) as usize] =
ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetCoolstepConfiguration) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::SetMiscConfiguration) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetMiscConfiguration) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetDriverStatus) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::SetMinimumVoltage) as usize] = ResponseExpectedFlag::True;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetMinimumVoltage) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::SetTimeBase) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetTimeBase) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetAllData) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::SetAllDataPeriod) as usize] = ResponseExpectedFlag::True;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetAllDataPeriod) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::SetSpitfpBaudrateConfig) as usize] =
ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetSpitfpBaudrateConfig) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetSendTimeoutCount) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::SetSpitfpBaudrate) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetSpitfpBaudrate) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetSpitfpErrorCount) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::EnableStatusLed) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::DisableStatusLed) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::IsStatusLedEnabled) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetProtocol1BrickletName) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetChipTemperature) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::Reset) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::WriteBrickletPlugin) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(SilentStepperBrickFunction::ReadBrickletPlugin) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(SilentStepperBrickFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
result
}
pub fn get_response_expected(&mut self, fun: SilentStepperBrickFunction) -> Result<bool, GetResponseExpectedError> {
self.device.get_response_expected(u8::from(fun))
}
pub fn set_response_expected(
&mut self,
fun: SilentStepperBrickFunction,
response_expected: bool,
) -> Result<(), SetResponseExpectedError> {
self.device.set_response_expected(u8::from(fun), response_expected)
}
pub fn set_response_expected_all(&mut self, response_expected: bool) { self.device.set_response_expected_all(response_expected) }
pub fn get_api_version(&self) -> [u8; 3] { self.device.api_version }
pub fn get_under_voltage_callback_receiver(&self) -> ConvertingCallbackReceiver<u16> {
self.device.get_callback_receiver(u8::from(SilentStepperBrickFunction::CallbackUnderVoltage))
}
pub fn get_position_reached_callback_receiver(&self) -> ConvertingCallbackReceiver<i32> {
self.device.get_callback_receiver(u8::from(SilentStepperBrickFunction::CallbackPositionReached))
}
pub fn get_all_data_callback_receiver(&self) -> ConvertingCallbackReceiver<AllDataEvent> {
self.device.get_callback_receiver(u8::from(SilentStepperBrickFunction::CallbackAllData))
}
pub fn get_new_state_callback_receiver(&self) -> ConvertingCallbackReceiver<NewStateEvent> {
self.device.get_callback_receiver(u8::from(SilentStepperBrickFunction::CallbackNewState))
}
pub fn set_max_velocity(&self, velocity: u16) -> ConvertingReceiver<()> {
let mut payload = vec![0; 2];
payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(velocity));
self.device.set(u8::from(SilentStepperBrickFunction::SetMaxVelocity), payload)
}
pub fn get_max_velocity(&self) -> ConvertingReceiver<u16> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetMaxVelocity), payload)
}
pub fn get_current_velocity(&self) -> ConvertingReceiver<u16> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetCurrentVelocity), payload)
}
pub fn set_speed_ramping(&self, acceleration: u16, deacceleration: u16) -> ConvertingReceiver<()> {
let mut payload = vec![0; 4];
payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(acceleration));
payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(deacceleration));
self.device.set(u8::from(SilentStepperBrickFunction::SetSpeedRamping), payload)
}
pub fn get_speed_ramping(&self) -> ConvertingReceiver<SpeedRamping> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetSpeedRamping), payload)
}
pub fn full_brake(&self) -> ConvertingReceiver<()> {
let payload = vec![0; 0];
self.device.set(u8::from(SilentStepperBrickFunction::FullBrake), payload)
}
pub fn set_current_position(&self, position: i32) -> ConvertingReceiver<()> {
let mut payload = vec![0; 4];
payload[0..4].copy_from_slice(&<i32>::to_le_byte_vec(position));
self.device.set(u8::from(SilentStepperBrickFunction::SetCurrentPosition), payload)
}
pub fn get_current_position(&self) -> ConvertingReceiver<i32> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetCurrentPosition), payload)
}
pub fn set_target_position(&self, position: i32) -> ConvertingReceiver<()> {
let mut payload = vec![0; 4];
payload[0..4].copy_from_slice(&<i32>::to_le_byte_vec(position));
self.device.set(u8::from(SilentStepperBrickFunction::SetTargetPosition), payload)
}
pub fn get_target_position(&self) -> ConvertingReceiver<i32> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetTargetPosition), payload)
}
pub fn set_steps(&self, steps: i32) -> ConvertingReceiver<()> {
let mut payload = vec![0; 4];
payload[0..4].copy_from_slice(&<i32>::to_le_byte_vec(steps));
self.device.set(u8::from(SilentStepperBrickFunction::SetSteps), payload)
}
pub fn get_steps(&self) -> ConvertingReceiver<i32> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetSteps), payload)
}
pub fn get_remaining_steps(&self) -> ConvertingReceiver<i32> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetRemainingSteps), payload)
}
pub fn set_step_configuration(&self, step_resolution: u8, interpolation: bool) -> ConvertingReceiver<()> {
let mut payload = vec![0; 2];
payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(step_resolution));
payload[1..2].copy_from_slice(&<bool>::to_le_byte_vec(interpolation));
self.device.set(u8::from(SilentStepperBrickFunction::SetStepConfiguration), payload)
}
pub fn get_step_configuration(&self) -> ConvertingReceiver<StepConfiguration> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetStepConfiguration), payload)
}
pub fn drive_forward(&self) -> ConvertingReceiver<()> {
let payload = vec![0; 0];
self.device.set(u8::from(SilentStepperBrickFunction::DriveForward), payload)
}
pub fn drive_backward(&self) -> ConvertingReceiver<()> {
let payload = vec![0; 0];
self.device.set(u8::from(SilentStepperBrickFunction::DriveBackward), payload)
}
pub fn stop(&self) -> ConvertingReceiver<()> {
let payload = vec![0; 0];
self.device.set(u8::from(SilentStepperBrickFunction::Stop), payload)
}
pub fn get_stack_input_voltage(&self) -> ConvertingReceiver<u16> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetStackInputVoltage), payload)
}
pub fn get_external_input_voltage(&self) -> ConvertingReceiver<u16> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetExternalInputVoltage), payload)
}
pub fn set_motor_current(&self, current: u16) -> ConvertingReceiver<()> {
let mut payload = vec![0; 2];
payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(current));
self.device.set(u8::from(SilentStepperBrickFunction::SetMotorCurrent), payload)
}
pub fn get_motor_current(&self) -> ConvertingReceiver<u16> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetMotorCurrent), payload)
}
pub fn enable(&self) -> ConvertingReceiver<()> {
let payload = vec![0; 0];
self.device.set(u8::from(SilentStepperBrickFunction::Enable), payload)
}
pub fn disable(&self) -> ConvertingReceiver<()> {
let payload = vec![0; 0];
self.device.set(u8::from(SilentStepperBrickFunction::Disable), payload)
}
pub fn is_enabled(&self) -> ConvertingReceiver<bool> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::IsEnabled), payload)
}
pub fn set_basic_configuration(
&self,
standstill_current: u16,
motor_run_current: u16,
standstill_delay_time: u16,
power_down_time: u16,
stealth_threshold: u16,
coolstep_threshold: u16,
classic_threshold: u16,
high_velocity_chopper_mode: bool,
) -> ConvertingReceiver<()> {
let mut payload = vec![0; 15];
payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(standstill_current));
payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(motor_run_current));
payload[4..6].copy_from_slice(&<u16>::to_le_byte_vec(standstill_delay_time));
payload[6..8].copy_from_slice(&<u16>::to_le_byte_vec(power_down_time));
payload[8..10].copy_from_slice(&<u16>::to_le_byte_vec(stealth_threshold));
payload[10..12].copy_from_slice(&<u16>::to_le_byte_vec(coolstep_threshold));
payload[12..14].copy_from_slice(&<u16>::to_le_byte_vec(classic_threshold));
payload[14..15].copy_from_slice(&<bool>::to_le_byte_vec(high_velocity_chopper_mode));
self.device.set(u8::from(SilentStepperBrickFunction::SetBasicConfiguration), payload)
}
pub fn get_basic_configuration(&self) -> ConvertingReceiver<BasicConfiguration> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetBasicConfiguration), payload)
}
pub fn set_spreadcycle_configuration(
&self,
slow_decay_duration: u8,
enable_random_slow_decay: bool,
fast_decay_duration: u8,
hysteresis_start_value: u8,
hysteresis_end_value: i8,
sine_wave_offset: i8,
chopper_mode: u8,
comparator_blank_time: u8,
fast_decay_without_comparator: bool,
) -> ConvertingReceiver<()> {
let mut payload = vec![0; 9];
payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(slow_decay_duration));
payload[1..2].copy_from_slice(&<bool>::to_le_byte_vec(enable_random_slow_decay));
payload[2..3].copy_from_slice(&<u8>::to_le_byte_vec(fast_decay_duration));
payload[3..4].copy_from_slice(&<u8>::to_le_byte_vec(hysteresis_start_value));
payload[4..5].copy_from_slice(&<i8>::to_le_byte_vec(hysteresis_end_value));
payload[5..6].copy_from_slice(&<i8>::to_le_byte_vec(sine_wave_offset));
payload[6..7].copy_from_slice(&<u8>::to_le_byte_vec(chopper_mode));
payload[7..8].copy_from_slice(&<u8>::to_le_byte_vec(comparator_blank_time));
payload[8..9].copy_from_slice(&<bool>::to_le_byte_vec(fast_decay_without_comparator));
self.device.set(u8::from(SilentStepperBrickFunction::SetSpreadcycleConfiguration), payload)
}
pub fn get_spreadcycle_configuration(&self) -> ConvertingReceiver<SpreadcycleConfiguration> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetSpreadcycleConfiguration), payload)
}
pub fn set_stealth_configuration(
&self,
enable_stealth: bool,
amplitude: u8,
gradient: u8,
enable_autoscale: bool,
force_symmetric: bool,
freewheel_mode: u8,
) -> ConvertingReceiver<()> {
let mut payload = vec![0; 6];
payload[0..1].copy_from_slice(&<bool>::to_le_byte_vec(enable_stealth));
payload[1..2].copy_from_slice(&<u8>::to_le_byte_vec(amplitude));
payload[2..3].copy_from_slice(&<u8>::to_le_byte_vec(gradient));
payload[3..4].copy_from_slice(&<bool>::to_le_byte_vec(enable_autoscale));
payload[4..5].copy_from_slice(&<bool>::to_le_byte_vec(force_symmetric));
payload[5..6].copy_from_slice(&<u8>::to_le_byte_vec(freewheel_mode));
self.device.set(u8::from(SilentStepperBrickFunction::SetStealthConfiguration), payload)
}
pub fn get_stealth_configuration(&self) -> ConvertingReceiver<StealthConfiguration> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetStealthConfiguration), payload)
}
pub fn set_coolstep_configuration(
&self,
minimum_stallguard_value: u8,
maximum_stallguard_value: u8,
current_up_step_width: u8,
current_down_step_width: u8,
minimum_current: u8,
stallguard_threshold_value: i8,
stallguard_mode: u8,
) -> ConvertingReceiver<()> {
let mut payload = vec![0; 7];
payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(minimum_stallguard_value));
payload[1..2].copy_from_slice(&<u8>::to_le_byte_vec(maximum_stallguard_value));
payload[2..3].copy_from_slice(&<u8>::to_le_byte_vec(current_up_step_width));
payload[3..4].copy_from_slice(&<u8>::to_le_byte_vec(current_down_step_width));
payload[4..5].copy_from_slice(&<u8>::to_le_byte_vec(minimum_current));
payload[5..6].copy_from_slice(&<i8>::to_le_byte_vec(stallguard_threshold_value));
payload[6..7].copy_from_slice(&<u8>::to_le_byte_vec(stallguard_mode));
self.device.set(u8::from(SilentStepperBrickFunction::SetCoolstepConfiguration), payload)
}
pub fn get_coolstep_configuration(&self) -> ConvertingReceiver<CoolstepConfiguration> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetCoolstepConfiguration), payload)
}
pub fn set_misc_configuration(
&self,
disable_short_to_ground_protection: bool,
synchronize_phase_frequency: u8,
) -> ConvertingReceiver<()> {
let mut payload = vec![0; 2];
payload[0..1].copy_from_slice(&<bool>::to_le_byte_vec(disable_short_to_ground_protection));
payload[1..2].copy_from_slice(&<u8>::to_le_byte_vec(synchronize_phase_frequency));
self.device.set(u8::from(SilentStepperBrickFunction::SetMiscConfiguration), payload)
}
pub fn get_misc_configuration(&self) -> ConvertingReceiver<MiscConfiguration> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetMiscConfiguration), payload)
}
pub fn get_driver_status(&self) -> ConvertingReceiver<DriverStatus> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetDriverStatus), payload)
}
pub fn set_minimum_voltage(&self, voltage: u16) -> ConvertingReceiver<()> {
let mut payload = vec![0; 2];
payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(voltage));
self.device.set(u8::from(SilentStepperBrickFunction::SetMinimumVoltage), payload)
}
pub fn get_minimum_voltage(&self) -> ConvertingReceiver<u16> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetMinimumVoltage), payload)
}
pub fn set_time_base(&self, time_base: u32) -> ConvertingReceiver<()> {
let mut payload = vec![0; 4];
payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(time_base));
self.device.set(u8::from(SilentStepperBrickFunction::SetTimeBase), payload)
}
pub fn get_time_base(&self) -> ConvertingReceiver<u32> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetTimeBase), payload)
}
pub fn get_all_data(&self) -> ConvertingReceiver<AllData> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetAllData), payload)
}
pub fn set_all_data_period(&self, period: u32) -> ConvertingReceiver<()> {
let mut payload = vec![0; 4];
payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(period));
self.device.set(u8::from(SilentStepperBrickFunction::SetAllDataPeriod), payload)
}
pub fn get_all_data_period(&self) -> ConvertingReceiver<u32> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetAllDataPeriod), payload)
}
pub fn set_spitfp_baudrate_config(&self, enable_dynamic_baudrate: bool, minimum_dynamic_baudrate: u32) -> ConvertingReceiver<()> {
let mut payload = vec![0; 5];
payload[0..1].copy_from_slice(&<bool>::to_le_byte_vec(enable_dynamic_baudrate));
payload[1..5].copy_from_slice(&<u32>::to_le_byte_vec(minimum_dynamic_baudrate));
self.device.set(u8::from(SilentStepperBrickFunction::SetSpitfpBaudrateConfig), payload)
}
pub fn get_spitfp_baudrate_config(&self) -> ConvertingReceiver<SpitfpBaudrateConfig> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetSpitfpBaudrateConfig), payload)
}
pub fn get_send_timeout_count(&self, communication_method: u8) -> ConvertingReceiver<u32> {
let mut payload = vec![0; 1];
payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(communication_method));
self.device.get(u8::from(SilentStepperBrickFunction::GetSendTimeoutCount), payload)
}
pub fn set_spitfp_baudrate(&self, bricklet_port: char, baudrate: u32) -> ConvertingReceiver<()> {
let mut payload = vec![0; 5];
payload[0..1].copy_from_slice(&<char>::to_le_byte_vec(bricklet_port));
payload[1..5].copy_from_slice(&<u32>::to_le_byte_vec(baudrate));
self.device.set(u8::from(SilentStepperBrickFunction::SetSpitfpBaudrate), payload)
}
pub fn get_spitfp_baudrate(&self, bricklet_port: char) -> ConvertingReceiver<u32> {
let mut payload = vec![0; 1];
payload[0..1].copy_from_slice(&<char>::to_le_byte_vec(bricklet_port));
self.device.get(u8::from(SilentStepperBrickFunction::GetSpitfpBaudrate), payload)
}
pub fn get_spitfp_error_count(&self, bricklet_port: char) -> ConvertingReceiver<SpitfpErrorCount> {
let mut payload = vec![0; 1];
payload[0..1].copy_from_slice(&<char>::to_le_byte_vec(bricklet_port));
self.device.get(u8::from(SilentStepperBrickFunction::GetSpitfpErrorCount), payload)
}
pub fn enable_status_led(&self) -> ConvertingReceiver<()> {
let payload = vec![0; 0];
self.device.set(u8::from(SilentStepperBrickFunction::EnableStatusLed), payload)
}
pub fn disable_status_led(&self) -> ConvertingReceiver<()> {
let payload = vec![0; 0];
self.device.set(u8::from(SilentStepperBrickFunction::DisableStatusLed), payload)
}
pub fn is_status_led_enabled(&self) -> ConvertingReceiver<bool> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::IsStatusLedEnabled), payload)
}
pub fn get_protocol1_bricklet_name(&self, port: char) -> ConvertingReceiver<Protocol1BrickletName> {
let mut payload = vec![0; 1];
payload[0..1].copy_from_slice(&<char>::to_le_byte_vec(port));
self.device.get(u8::from(SilentStepperBrickFunction::GetProtocol1BrickletName), payload)
}
pub fn get_chip_temperature(&self) -> ConvertingReceiver<i16> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetChipTemperature), payload)
}
pub fn reset(&self) -> ConvertingReceiver<()> {
let payload = vec![0; 0];
self.device.set(u8::from(SilentStepperBrickFunction::Reset), payload)
}
pub fn write_bricklet_plugin(&self, port: char, offset: u8, chunk: [u8; 32]) -> ConvertingReceiver<()> {
let mut payload = vec![0; 34];
payload[0..1].copy_from_slice(&<char>::to_le_byte_vec(port));
payload[1..2].copy_from_slice(&<u8>::to_le_byte_vec(offset));
payload[2..34].copy_from_slice(&<[u8; 32]>::to_le_byte_vec(chunk));
self.device.set(u8::from(SilentStepperBrickFunction::WriteBrickletPlugin), payload)
}
pub fn read_bricklet_plugin(&self, port: char, offset: u8) -> ConvertingReceiver<[u8; 32]> {
let mut payload = vec![0; 2];
payload[0..1].copy_from_slice(&<char>::to_le_byte_vec(port));
payload[1..2].copy_from_slice(&<u8>::to_le_byte_vec(offset));
self.device.get(u8::from(SilentStepperBrickFunction::ReadBrickletPlugin), payload)
}
pub fn get_identity(&self) -> ConvertingReceiver<Identity> {
let payload = vec![0; 0];
self.device.get(u8::from(SilentStepperBrickFunction::GetIdentity), payload)
}
}