pub struct PoKeysDevice {Show 22 fields
pub info: DeviceInfo,
pub device_data: DeviceData,
pub network_device_data: Option<NetworkDeviceInfo>,
pub model: Option<DeviceModel>,
pub pins: Vec<PinData>,
pub encoders: Vec<EncoderData>,
pub pwm: PwmData,
pub matrix_keyboard: MatrixKeyboard,
pub matrix_led: Vec<MatrixLed>,
pub lcd: LcdData,
pub pulse_engine_v2: PulseEngineV2,
pub easy_sensors: Vec<EasySensor>,
pub rtc: RealTimeClock,
pub fast_encoders_configuration: u8,
pub fast_encoders_options: u8,
pub ultra_fast_encoder_configuration: u8,
pub ultra_fast_encoder_options: u8,
pub ultra_fast_encoder_filter: u32,
pub po_ext_bus_data: Vec<u8>,
pub i2c_config: I2cConfig,
pub i2c_metrics: I2cMetrics,
pub validation_level: ValidationLevel,
/* private fields */
}Expand description
Main PoKeys device structure
Fields§
§info: DeviceInfo§device_data: DeviceData§network_device_data: Option<NetworkDeviceInfo>§model: Option<DeviceModel>§pins: Vec<PinData>§encoders: Vec<EncoderData>§pwm: PwmData§matrix_keyboard: MatrixKeyboard§matrix_led: Vec<MatrixLed>§lcd: LcdData§pulse_engine_v2: PulseEngineV2§easy_sensors: Vec<EasySensor>§rtc: RealTimeClock§fast_encoders_configuration: u8§fast_encoders_options: u8§ultra_fast_encoder_configuration: u8§ultra_fast_encoder_options: u8§ultra_fast_encoder_filter: u32§po_ext_bus_data: Vec<u8>§i2c_config: I2cConfig§i2c_metrics: I2cMetrics§validation_level: ValidationLevelImplementations§
Source§impl PoKeysDevice
impl PoKeysDevice
Sourcepub fn get_device_data(&mut self) -> Result<()>
pub fn get_device_data(&mut self) -> Result<()>
Get device information from the connected device
Sourcepub fn is_pin_capability_supported(&self, pin: u32, capability: &str) -> bool
pub fn is_pin_capability_supported(&self, pin: u32, capability: &str) -> bool
Sourcepub fn get_pin_capabilities(&self, pin: u32) -> Vec<String>
pub fn get_pin_capabilities(&self, pin: u32) -> Vec<String>
Sourcepub fn save_configuration(&mut self) -> Result<()>
pub fn save_configuration(&mut self) -> Result<()>
Save current configuration to device
Sourcepub fn get_system_load(&mut self) -> Result<u8>
pub fn get_system_load(&mut self) -> Result<u8>
Get the device’s current system load as a percentage (0–100).
Sends the “Get system load status” command (0x05) defined in the
PoKeys protocol specification. The device replies with the current
CPU/system load in byte 3 of the response.
Sourcepub fn set_device_name(&mut self, name: &str) -> Result<()>
pub fn set_device_name(&mut self, name: &str) -> Result<()>
Set the device name (up to 20 bytes for the long device name).
Sends protocol command 0x06 with “write long device name” flags set.
After the write succeeds, save_configuration
is called to persist the value to non-volatile storage — 0x06 alone
does not auto-save.
§Side effect
The request packet includes fields for the joystick device name (spec bytes 19–34) and the product-ID offset (byte 35) that this implementation always sends as zero. If the target device was using those fields, they will be cleared as a side effect of this call.
Sourcepub fn clear_configuration(&mut self) -> Result<()>
pub fn clear_configuration(&mut self) -> Result<()>
Reset device configuration to defaults (protocol command 0x52
“Disable lock and reset configuration”). Requires the magic bytes
0xAA, 0x55 to match the spec and the upstream PoKeysLib behaviour.
Sourcepub fn reboot_device(&mut self) -> Result<()>
pub fn reboot_device(&mut self) -> Result<()>
Reboot the device (command 0xF3).
Sends the “Reboot system” command defined in the PoKeys protocol specification. The device may reboot before a response reaches the host; transfer-level failures caused by the interrupted response are treated as success, as the request was already delivered.
After a successful reboot the active connection is effectively invalidated — callers should re-enumerate and reconnect before issuing further commands.
Sourcepub fn custom_request(
&mut self,
request_type: u8,
param1: u8,
param2: u8,
param3: u8,
param4: u8,
) -> Result<[u8; 68]>
pub fn custom_request( &mut self, request_type: u8, param1: u8, param2: u8, param3: u8, param4: u8, ) -> Result<[u8; 68]>
Send custom request to device
Sourcepub fn set_ethernet_retry_count_and_timeout(
&mut self,
send_retries: u32,
read_retries: u32,
timeout_ms: u32,
)
pub fn set_ethernet_retry_count_and_timeout( &mut self, send_retries: u32, read_retries: u32, timeout_ms: u32, )
Set ethernet retry count and timeout
Sourcepub fn get_connection_type(&self) -> DeviceConnectionType
pub fn get_connection_type(&self) -> DeviceConnectionType
Get connection type
Sourcepub fn set_i2c_config(&mut self, config: I2cConfig)
pub fn set_i2c_config(&mut self, config: I2cConfig)
Set I2C configuration
Sourcepub fn get_i2c_config(&self) -> &I2cConfig
pub fn get_i2c_config(&self) -> &I2cConfig
Get I2C configuration
Sourcepub fn set_validation_level(&mut self, level: ValidationLevel)
pub fn set_validation_level(&mut self, level: ValidationLevel)
Set validation level
Sourcepub fn get_i2c_metrics(&self) -> &I2cMetrics
pub fn get_i2c_metrics(&self) -> &I2cMetrics
Get I2C metrics
Sourcepub fn reset_i2c_metrics(&mut self)
pub fn reset_i2c_metrics(&mut self)
Reset I2C metrics
Sourcepub fn health_check(&mut self) -> HealthStatus
pub fn health_check(&mut self) -> HealthStatus
Perform device health check
Sourcepub fn check_pin_capability(&self, pin: u32, capability: PinCapability) -> bool
pub fn check_pin_capability(&self, pin: u32, capability: PinCapability) -> bool
Check if device supports a specific capability
Sourcepub fn get_network_configuration(
&mut self,
timeout_ms: u32,
) -> Result<(Option<NetworkDeviceSummary>, NetworkDeviceInfo)>
pub fn get_network_configuration( &mut self, timeout_ms: u32, ) -> Result<(Option<NetworkDeviceSummary>, NetworkDeviceInfo)>
Get complete network configuration including discovery info
Sourcepub fn set_network_configuration(
&mut self,
config: &NetworkDeviceInfo,
) -> Result<()>
pub fn set_network_configuration( &mut self, config: &NetworkDeviceInfo, ) -> Result<()>
Set network configuration on the device.
Sends command 0xE0 with option 10, which writes and saves the
configuration to non-volatile storage in one operation — no separate
save_configuration call is needed.
§Field mapping
NetworkDeviceInfo field | Protocol byte (doc) | Notes |
|---|---|---|
dhcp | 9 | 0 = fixed IP, 1 = DHCP |
ip_address_setup | 10–13 | Applied when dhcp == 0 |
tcp_timeout (ms) | 18–19 | Stored in units of 100 ms |
gateway_ip | 20–23 | Applied when non-zero |
subnet_mask | 24–27 | Applied when non-zero |
additional_network_options | 29 | Upper nibble forced to 0xA |
ip_address_current is read-only (assigned by DHCP) and is ignored here.
pub fn send_request( &mut self, request_type: u8, param1: u8, param2: u8, param3: u8, param4: u8, ) -> Result<[u8; 68]>
Sourcepub fn send_request_with_data(
&mut self,
request_type: u8,
param1: u8,
param2: u8,
param3: u8,
param4: u8,
data: &[u8],
) -> Result<[u8; 68]>
pub fn send_request_with_data( &mut self, request_type: u8, param1: u8, param2: u8, param3: u8, param4: u8, data: &[u8], ) -> Result<[u8; 68]>
Send request with data payload
Sourcepub fn read_device_data(&mut self) -> Result<()>
pub fn read_device_data(&mut self) -> Result<()>
Read comprehensive device data using command 0x00 This provides accurate device information including proper firmware version and device type
Sourcepub fn configure_led_matrix(
&mut self,
config: &MatrixLedProtocolConfig,
) -> Result<()>
pub fn configure_led_matrix( &mut self, config: &MatrixLedProtocolConfig, ) -> Result<()>
Command 0xD5: Get/Set Matrix LED Configuration
Sourcepub fn read_led_matrix_config(&mut self) -> Result<MatrixLedProtocolConfig>
pub fn read_led_matrix_config(&mut self) -> Result<MatrixLedProtocolConfig>
Read Matrix LED Configuration
Sourcepub fn update_led_matrix(
&mut self,
matrix_id: u8,
action: MatrixAction,
row: u8,
column: u8,
data: &[u8],
) -> Result<()>
pub fn update_led_matrix( &mut self, matrix_id: u8, action: MatrixAction, row: u8, column: u8, data: &[u8], ) -> Result<()>
Command 0xD6: Update Matrix Display
Sourcepub fn configure_matrix_keyboard(
&mut self,
width: u8,
height: u8,
column_pins: &[u8],
row_pins: &[u8],
) -> Result<()>
pub fn configure_matrix_keyboard( &mut self, width: u8, height: u8, column_pins: &[u8], row_pins: &[u8], ) -> Result<()>
Command 0xCA: Configure Matrix Keyboard
Configures a matrix keyboard using the official PoKeys protocol. Uses command 0xCA with option 16 for configuration.
§Arguments
width- Number of columns (1-8)height- Number of rows (1-16)column_pins- Pin numbers for columns (1-based)row_pins- Pin numbers for rows (1-based)
§Protocol Details
- Pins are converted to 0-based indexing for the device
- Matrix uses 8-column internal layout regardless of configured width
- Supports extended row pins for matrices with height > 8
Sourcepub fn read_matrix_keyboard(&mut self) -> Result<()>
pub fn read_matrix_keyboard(&mut self) -> Result<()>
Command 0xCA: Read Matrix Keyboard State
Reads the current state of all keys in the matrix keyboard. Uses command 0xCA with option 20 to read the 16x8 matrix status.
§Protocol Details
- Returns 16 bytes representing the full 16x8 matrix
- Each byte represents 8 keys in a row (bit 0 = column 0, bit 7 = column 7)
- Key indexing: row * 8 + column (e.g., key at row 1, col 2 = index 10)
- Updates the internal key_values array with current state
Sourcepub fn configure_led_matrices(
&mut self,
configs: &[LedMatrixConfig],
) -> Result<()>
pub fn configure_led_matrices( &mut self, configs: &[LedMatrixConfig], ) -> Result<()>
Configure multiple LED matrices with device model validation
This method validates all configurations against the device model first, then applies the configurations and reserves the necessary pins.
§Arguments
configs- Array of LED matrix configurations
§Returns
Result<()>- Ok if all configurations were applied successfully
Sourcepub fn configure_servo(&mut self, config: ServoConfig) -> Result<()>
pub fn configure_servo(&mut self, config: ServoConfig) -> Result<()>
Configure and control a servo motor
Sourcepub fn set_servo_angle(
&mut self,
config: &ServoConfig,
angle: f32,
) -> Result<()>
pub fn set_servo_angle( &mut self, config: &ServoConfig, angle: f32, ) -> Result<()>
Set servo angle (for position servos)
Sourcepub fn set_servo_speed(
&mut self,
config: &ServoConfig,
speed: f32,
) -> Result<()>
pub fn set_servo_speed( &mut self, config: &ServoConfig, speed: f32, ) -> Result<()>
Set servo speed (for speed servos)
Sourcepub fn stop_servo(&mut self, config: &ServoConfig) -> Result<()>
pub fn stop_servo(&mut self, config: &ServoConfig) -> Result<()>
Stop servo (for speed servos)
Source§impl PoKeysDevice
impl PoKeysDevice
Sourcepub fn configure_encoder(
&mut self,
encoder_id: u8,
channel_a_pin: u8,
channel_b_pin: u8,
options: EncoderOptions,
) -> Result<()>
pub fn configure_encoder( &mut self, encoder_id: u8, channel_a_pin: u8, channel_b_pin: u8, options: EncoderOptions, ) -> Result<()>
Configure encoder with pins and options Protocol: 0x11 - Individual encoder settings (per protocol spec)
Sourcepub fn read_encoder_settings(&mut self, encoder_id: u8) -> Result<EncoderData>
pub fn read_encoder_settings(&mut self, encoder_id: u8) -> Result<EncoderData>
Read encoder settings using protocol 0x16
Sourcepub fn enable_encoder(&mut self, encoder_id: u8, enable: bool) -> Result<()>
pub fn enable_encoder(&mut self, encoder_id: u8, enable: bool) -> Result<()>
Enable or disable encoder
Sourcepub fn set_encoder_sampling(
&mut self,
encoder_id: u8,
sampling_4x: bool,
sampling_2x: bool,
) -> Result<()>
pub fn set_encoder_sampling( &mut self, encoder_id: u8, sampling_4x: bool, sampling_2x: bool, ) -> Result<()>
Set encoder sampling mode (4x or 2x)
Sourcepub fn configure_encoder_key_mapping_a(
&mut self,
encoder_id: u8,
key_code: u8,
key_modifier: u8,
) -> Result<()>
pub fn configure_encoder_key_mapping_a( &mut self, encoder_id: u8, key_code: u8, key_modifier: u8, ) -> Result<()>
Configure encoder key mapping for direction A Protocol: 0x12 - Encoder key mapping for direction A
Sourcepub fn configure_encoder_key_mapping_b(
&mut self,
encoder_id: u8,
key_code: u8,
key_modifier: u8,
) -> Result<()>
pub fn configure_encoder_key_mapping_b( &mut self, encoder_id: u8, key_code: u8, key_modifier: u8, ) -> Result<()>
Configure encoder key mapping for direction B Protocol: 0x13 - Encoder key mapping for direction B
Sourcepub fn read_encoder_key_mapping_a(&mut self, encoder_id: u8) -> Result<(u8, u8)>
pub fn read_encoder_key_mapping_a(&mut self, encoder_id: u8) -> Result<(u8, u8)>
Read encoder key mapping for direction A Protocol: 0x17 - Read encoder key mapping for direction A
Sourcepub fn read_encoder_key_mapping_b(&mut self, encoder_id: u8) -> Result<(u8, u8)>
pub fn read_encoder_key_mapping_b(&mut self, encoder_id: u8) -> Result<(u8, u8)>
Read encoder key mapping for direction B Protocol: 0x18 - Read encoder key mapping for direction B
Sourcepub fn read_encoder_raw_value(&mut self, encoder_id: u8) -> Result<i32>
pub fn read_encoder_raw_value(&mut self, encoder_id: u8) -> Result<i32>
Read encoder RAW value Protocol: 0x19 - Read encoder RAW value
Sourcepub fn reset_encoder_raw_value(&mut self, encoder_id: u8) -> Result<()>
pub fn reset_encoder_raw_value(&mut self, encoder_id: u8) -> Result<()>
Reset encoder RAW value to zero Protocol: 0x1A - Reset encoder RAW value
Sourcepub fn get_encoder_value(&mut self, encoder_id: u8) -> Result<i32>
pub fn get_encoder_value(&mut self, encoder_id: u8) -> Result<i32>
Get encoder value (convenience method)
Sourcepub fn reset_encoder(&mut self, encoder_id: u8) -> Result<()>
pub fn reset_encoder(&mut self, encoder_id: u8) -> Result<()>
Reset encoder value (convenience method)
Sourcepub fn read_encoder_long_values(&mut self, group: u8) -> Result<Vec<i32>>
pub fn read_encoder_long_values(&mut self, group: u8) -> Result<Vec<i32>>
Get encoder long RAW values (bulk operation) Protocol: 0xCD - Get encoder long RAW values option: 0 = encoders 1-13, 1 = encoders 14-26
Sourcepub fn set_encoder_long_values(
&mut self,
group: u8,
values: &[i32],
) -> Result<()>
pub fn set_encoder_long_values( &mut self, group: u8, values: &[i32], ) -> Result<()>
Set encoder long RAW values (bulk operation) Protocol: 0xCD - Set encoder long RAW values option: 10 = encoders 1-13, 11 = encoders 14-26
Sourcepub fn read_all_encoder_values(&mut self) -> Result<Vec<i32>>
pub fn read_all_encoder_values(&mut self) -> Result<Vec<i32>>
Read all encoder values using bulk operations (more efficient)
Sourcepub fn configure_encoder_options_bulk(
&mut self,
options: &[u8],
) -> Result<Vec<u8>>
pub fn configure_encoder_options_bulk( &mut self, options: &[u8], ) -> Result<Vec<u8>>
Configure encoder options (bulk operation) Protocol: 0xC4 - Encoder option
Sourcepub fn read_encoder_options_bulk(&mut self) -> Result<Vec<u8>>
pub fn read_encoder_options_bulk(&mut self) -> Result<Vec<u8>>
Read encoder options (bulk operation) Protocol: 0xC4 - Encoder option
Sourcepub fn configure_fast_encoders(
&mut self,
config: FastEncoderConfiguration,
options: FastEncoderOptions,
) -> Result<()>
pub fn configure_fast_encoders( &mut self, config: FastEncoderConfiguration, options: FastEncoderOptions, ) -> Result<()>
Configure the fast encoders via protocol command 0xCE.
0xCE uses two bytes: the configuration selector (which pin
configuration / enable state to use) and the options byte
(per-encoder direction invert + 4x-sampling control). They are passed
as typed values so callers don’t have to know the bit layout.
Per PoKeysLib C reference (PoKeysLibEncoders.c:154):
req[2] = FastEncodersConfiguration, req[3] = FastEncodersOptions.
Sourcepub fn read_fast_encoder_values(&mut self) -> Result<[i32; 3]>
pub fn read_fast_encoder_values(&mut self) -> Result<[i32; 3]>
Read fast encoder values
Sourcepub fn configure_ultra_fast_encoder(
&mut self,
enable: bool,
options: UltraFastEncoderOptions,
reset_on_index: bool,
filter_delay: u32,
) -> Result<()>
pub fn configure_ultra_fast_encoder( &mut self, enable: bool, options: UltraFastEncoderOptions, reset_on_index: bool, filter_delay: u32, ) -> Result<()>
Configure the ultra-fast encoder via protocol command 0x1C
(PoKeys56E and later).
The ultra-fast encoder uses fixed pins: Pin 8 (Phase A), Pin 12 (Phase B), Pin 13 (Index).
Bit layout of the options byte matches PoKeysLib C reference
(ePK_UltraFastEncoderOptions): bit 0 = invert direction, bit 1 = signal
mode, bit 2 = enable 4x sampling. See UltraFastEncoderOptions.
Sourcepub fn read_ultra_fast_encoder_config(
&mut self,
) -> Result<(bool, UltraFastEncoderOptions, u32)>
pub fn read_ultra_fast_encoder_config( &mut self, ) -> Result<(bool, UltraFastEncoderOptions, u32)>
Read the ultra-fast encoder’s current configuration.
Protocol: 0x1C with param1 = 0xFF to request a read. Returns the
enable flag, decoded UltraFastEncoderOptions, and the filter delay
(u32 LE at response bytes 8..12).
Sourcepub fn read_ultra_fast_encoder_value(&mut self) -> Result<i32>
pub fn read_ultra_fast_encoder_value(&mut self) -> Result<i32>
Read ultra-fast encoder value
Sourcepub fn set_ultra_fast_encoder_value(&mut self, value: i32) -> Result<()>
pub fn set_ultra_fast_encoder_value(&mut self, value: i32) -> Result<()>
Set ultra-fast encoder value
Sourcepub fn configure_encoder_with_keys(
&mut self,
encoder_id: u8,
channel_a_pin: u8,
channel_b_pin: u8,
sampling_4x: bool,
sampling_2x: bool,
dir_a_key_code: u8,
dir_a_key_modifier: u8,
dir_b_key_code: u8,
dir_b_key_modifier: u8,
) -> Result<()>
pub fn configure_encoder_with_keys( &mut self, encoder_id: u8, channel_a_pin: u8, channel_b_pin: u8, sampling_4x: bool, sampling_2x: bool, dir_a_key_code: u8, dir_a_key_modifier: u8, dir_b_key_code: u8, dir_b_key_modifier: u8, ) -> Result<()>
Configure encoder with keyboard mapping (convenience method)
Sourcepub fn get_encoder_sampling_mode(&self, encoder_id: u8) -> Result<String>
pub fn get_encoder_sampling_mode(&self, encoder_id: u8) -> Result<String>
Get encoder sampling mode as string (for debugging/display)
Sourcepub fn is_encoder_4x_sampling(&self, encoder_id: u8) -> Result<bool>
pub fn is_encoder_4x_sampling(&self, encoder_id: u8) -> Result<bool>
Check if encoder is configured for 4x sampling
Sourcepub fn is_encoder_2x_sampling(&self, encoder_id: u8) -> Result<bool>
pub fn is_encoder_2x_sampling(&self, encoder_id: u8) -> Result<bool>
Check if encoder is configured for 2x sampling
Sourcepub fn get_enabled_encoders(&self) -> Vec<u8> ⓘ
pub fn get_enabled_encoders(&self) -> Vec<u8> ⓘ
Get all enabled encoders
Source§impl PoKeysDevice
impl PoKeysDevice
Sourcepub fn set_pin_function(
&mut self,
pin: u32,
pin_function: PinFunction,
) -> Result<(u32, PinFunction)>
pub fn set_pin_function( &mut self, pin: u32, pin_function: PinFunction, ) -> Result<(u32, PinFunction)>
Set a pin’s function (non-inverted polarity).
Thin wrapper over Self::set_pin_function_with_invert with
inverted = false; byte-identical on the wire to the pre-invert
behaviour for every existing caller.
Sourcepub fn set_pin_function_with_invert(
&mut self,
pin: u32,
pin_function: PinFunction,
inverted: bool,
) -> Result<(u32, PinFunction)>
pub fn set_pin_function_with_invert( &mut self, pin: u32, pin_function: PinFunction, inverted: bool, ) -> Result<(u32, PinFunction)>
Set a pin’s function with an optional hardware invert flag.
When inverted == true, bit 7 (0x80) of protocol byte 4 is set,
producing a combined wire byte such as 0x82 for inverted
DigitalInput. The firmware then reports/drives the logical
complement of the electrical state at no CPU cost to the caller.
Pin functions that honor the invert bit:
Pin functions that ignore the invert bit (firmware silently drops it):
PinFunction::AnalogInput,PinFunction::AnalogOutputPinFunction::DigitalCounterPinFunction::PinRestricted,PinFunction::Reserved
For functions that ignore the flag, this method logs a warning via the
log crate and still sends the byte as requested. Use
Self::get_pin_invert to read the invert state back from the cache.
Sourcepub fn get_pin_function(&self, pin: u32) -> Result<PinFunction>
pub fn get_pin_function(&self, pin: u32) -> Result<PinFunction>
Get pin function (base function only; the invert bit is ignored).
To read the invert flag, use Self::get_pin_invert.
Sourcepub fn get_pin_invert(&self, pin: u32) -> Result<bool>
pub fn get_pin_invert(&self, pin: u32) -> Result<bool>
Return whether bit 7 (the hardware invert flag) is set on the pin’s cached configuration byte.
Reflects the most recently written or read-back wire byte; call
Self::read_all_pin_functions first if you want the device’s
current state rather than the local cache.
Sourcepub fn get_digital_input(&mut self, pin: u32) -> Result<bool>
pub fn get_digital_input(&mut self, pin: u32) -> Result<bool>
Read digital input
Sourcepub fn get_analog_input(&mut self, pin: u32) -> Result<u32>
pub fn get_analog_input(&mut self, pin: u32) -> Result<u32>
Read analog input
Sourcepub fn get_digital_counter(&mut self, pin: u32) -> Result<u32>
pub fn get_digital_counter(&mut self, pin: u32) -> Result<u32>
Read digital counter value
Sourcepub fn reset_all_digital_counters(&mut self) -> Result<()>
pub fn reset_all_digital_counters(&mut self) -> Result<()>
Reset all digital counter values (protocol command 0x1D).
The PoKeys protocol does not support per-pin counter resets — 0x1D
clears all digital counters at once.
Sourcepub fn get_digital_inputs(&mut self) -> Result<()>
pub fn get_digital_inputs(&mut self) -> Result<()>
Read all digital inputs.
Uses two protocol commands:
0x31“Block inputs reading” — pins 1–32 packed into response bytes 3–6 (0-based 2–5)0x32“Block inputs reading – part 2” — pins 33–55 packed into response bytes 3–5 (0-based 2–4)
Sourcepub fn write_digital_outputs(&mut self) -> Result<()>
pub fn write_digital_outputs(&mut self) -> Result<()>
Write all digital outputs
Sourcepub fn read_analog_inputs(&mut self) -> Result<()>
pub fn read_analog_inputs(&mut self) -> Result<()>
Read all analog inputs
Sourcepub fn write_analog_outputs(&mut self) -> Result<()>
pub fn write_analog_outputs(&mut self) -> Result<()>
Write analog outputs for every pin currently configured as an analog output.
Sends one “Analog outputs settings” request (0x41) per pin, carrying the pin’s
analog_value as a 10-bit DAC value (0–1023). Values larger than 10 bits are
clamped by masking. The pin ID sent to the device is the 0-based pin code
per the protocol spec (pin 43 → pin code 42).
Sourcepub fn read_digital_counters(&mut self) -> Result<()>
pub fn read_digital_counters(&mut self) -> Result<()>
Read digital counter values via protocol command 0xD8.
The request carries up to 13 pin IDs at spec bytes 9–21 (0-based 8–20) identifying which counters to return. The response packs thirteen 32-bit LE counter values at spec bytes 9–60 (0-based 8–59).
Sourcepub fn read_all_pin_functions(&mut self) -> Result<[PinFunction; 55]>
pub fn read_all_pin_functions(&mut self) -> Result<[PinFunction; 55]>
Read all pin functions at once using extended mode (0xC0) This is much more efficient than reading pins individually Performance improvement: 55x fewer commands
Sourcepub fn read_all_pin_settings_raw(&mut self) -> Result<[u8; 55]>
pub fn read_all_pin_settings_raw(&mut self) -> Result<[u8; 55]>
Read all 55 pin-setting bytes verbatim, including the invert bit
(0x80) when set. Unlike Self::read_all_pin_functions, this
preserves the full protocol byte so callers can reason about
hardware-level polarity inversion.
Also refreshes the local pin cache with the returned bytes.
Sourcepub fn set_all_pin_settings_raw(&mut self, raw: &[u8; 55]) -> Result<()>
pub fn set_all_pin_settings_raw(&mut self, raw: &[u8; 55]) -> Result<()>
Send all 55 pin-setting bytes verbatim using the bulk 0xC0 command.
Callers compose each byte themselves — e.g.
(PinFunction::DigitalInput as u8) | 0x80 for an inverted digital
input.
The local pin cache is updated to match the bytes sent.
Sourcepub fn set_all_pin_functions(
&mut self,
functions: &[PinFunction; 55],
) -> Result<()>
pub fn set_all_pin_functions( &mut self, functions: &[PinFunction; 55], ) -> Result<()>
Set all pin functions at once using extended mode (0xC0) This is much more efficient than setting pins individually Performance improvement: 55x fewer commands — the 55-byte function array is sent in a single request instead of one request per pin.
Sourcepub fn get_device_status(&mut self) -> Result<()>
pub fn get_device_status(&mut self) -> Result<()>
Read combined device status (digital inputs, analog inputs, and encoder values)
in a single round-trip using protocol command 0xCC
(“Get device status (IO, analog, encoders)”).
Updates self.pins[*].digital_value_get, self.pins[*].analog_value (for up to 5
analog-input pins), and self.encoders[*].encoder_value (up to 25 channels).
Matrix keyboard rows and ultra-fast encoder data from the response are not applied here — use the dedicated methods for those when needed.
Source§impl PoKeysDevice
impl PoKeysDevice
Sourcepub fn configure_lcd(
&mut self,
rows: u8,
columns: u8,
mode: LcdMode,
) -> Result<()>
pub fn configure_lcd( &mut self, rows: u8, columns: u8, mode: LcdMode, ) -> Result<()>
Configure LCD display
Sourcepub fn enable_lcd(&mut self, enable: bool) -> Result<()>
pub fn enable_lcd(&mut self, enable: bool) -> Result<()>
Enable or disable LCD
Sourcepub fn lcd_read_line(&self, line: usize) -> Result<String>
pub fn lcd_read_line(&self, line: usize) -> Result<String>
Read text from LCD line
Sourcepub fn lcd_clear_line(&mut self, line: usize) -> Result<()>
pub fn lcd_clear_line(&mut self, line: usize) -> Result<()>
Clear LCD line
Sourcepub fn lcd_clear_all(&mut self) -> Result<()>
pub fn lcd_clear_all(&mut self) -> Result<()>
Clear entire LCD display
Sourcepub fn lcd_write_at(
&mut self,
line: usize,
column: usize,
text: &str,
) -> Result<()>
pub fn lcd_write_at( &mut self, line: usize, column: usize, text: &str, ) -> Result<()>
Write text at specific position
Sourcepub fn lcd_set_custom_character(
&mut self,
char_index: usize,
pattern: &[u8; 8],
) -> Result<()>
pub fn lcd_set_custom_character( &mut self, char_index: usize, pattern: &[u8; 8], ) -> Result<()>
Set custom character pattern
Sourcepub fn lcd_update(&mut self) -> Result<()>
pub fn lcd_update(&mut self) -> Result<()>
Update LCD display (refresh all changed lines)
Source§impl PoKeysDevice
impl PoKeysDevice
Sourcepub fn configure_matrix_led(
&mut self,
led_index: usize,
rows: u8,
columns: u8,
) -> Result<()>
pub fn configure_matrix_led( &mut self, led_index: usize, rows: u8, columns: u8, ) -> Result<()>
Configure matrix LED display
Sourcepub fn update_matrix_led(&mut self, led_index: usize) -> Result<()>
pub fn update_matrix_led(&mut self, led_index: usize) -> Result<()>
Update matrix LED display
Sourcepub fn set_matrix_led(
&mut self,
led_index: usize,
row: usize,
col: usize,
state: bool,
) -> Result<()>
pub fn set_matrix_led( &mut self, led_index: usize, row: usize, col: usize, state: bool, ) -> Result<()>
Set individual LED in matrix
Sourcepub fn get_matrix_led(
&self,
led_index: usize,
row: usize,
col: usize,
) -> Result<bool>
pub fn get_matrix_led( &self, led_index: usize, row: usize, col: usize, ) -> Result<bool>
Get individual LED state in matrix
Sourcepub fn clear_matrix_led(&mut self, led_index: usize) -> Result<()>
pub fn clear_matrix_led(&mut self, led_index: usize) -> Result<()>
Clear all LEDs in matrix
Sourcepub fn set_all_matrix_led(&mut self, led_index: usize) -> Result<()>
pub fn set_all_matrix_led(&mut self, led_index: usize) -> Result<()>
Set all LEDs in matrix
Source§impl PoKeysDevice
impl PoKeysDevice
Sourcepub fn read_oem_parameter(&mut self, index: u8) -> Result<Option<i32>>
pub fn read_oem_parameter(&mut self, index: u8) -> Result<Option<i32>>
Read a single OEM parameter from non-volatile storage.
Returns None if the parameter slot has never been written (the device
clears the corresponding status bit on a factory reset).
§Errors
Returns PoKeysError::Parameter when index > OEM_PARAMETER_MAX_INDEX,
or a communication error if the exchange fails.
Sourcepub fn write_oem_parameter(&mut self, index: u8, value: i32) -> Result<()>
pub fn write_oem_parameter(&mut self, index: u8, value: i32) -> Result<()>
Write a single OEM parameter to non-volatile storage.
§Errors
Returns PoKeysError::Parameter when index > OEM_PARAMETER_MAX_INDEX,
or a communication error if the exchange fails.
Sourcepub fn get_location(&mut self) -> Result<Option<i32>>
pub fn get_location(&mut self) -> Result<Option<i32>>
Read the device location from OEM parameter storage.
The location is persisted at OEM parameter index LOCATION_PARAMETER_INDEX.
Returns None if the location has never been set.
Sourcepub fn set_location(&mut self, location: i32) -> Result<()>
pub fn set_location(&mut self, location: i32) -> Result<()>
Write the device location to OEM parameter storage.
The location is a user-defined integer stored in the device’s non-volatile
OEM parameter slot at index LOCATION_PARAMETER_INDEX.
Sourcepub fn clear_location(&mut self) -> Result<()>
pub fn clear_location(&mut self) -> Result<()>
Clear the device location from OEM parameter storage.
After this call get_location will return None.
Sourcepub fn clear_oem_parameter(&mut self, index: u8) -> Result<()>
pub fn clear_oem_parameter(&mut self, index: u8) -> Result<()>
Clear a single OEM parameter, marking it as unset in non-volatile storage.
After clearing, read_oem_parameter returns None
for this index until a new value is written.
§Errors
Returns PoKeysError::Parameter when index > OEM_PARAMETER_MAX_INDEX,
or a communication error if the exchange fails.
Source§impl PoKeysDevice
CAN protocol implementation
impl PoKeysDevice
CAN protocol implementation
Sourcepub fn can_configure(&mut self, baud_rate: u32, mode: u8) -> Result<()>
pub fn can_configure(&mut self, baud_rate: u32, mode: u8) -> Result<()>
Configure CAN interface
Sourcepub fn can_send(&mut self, message: &CanMessage) -> Result<()>
pub fn can_send(&mut self, message: &CanMessage) -> Result<()>
Send CAN message
Sourcepub fn can_receive(&mut self) -> Result<Option<CanMessage>>
pub fn can_receive(&mut self) -> Result<Option<CanMessage>>
Receive CAN message
Source§impl PoKeysDevice
I2C protocol implementation
impl PoKeysDevice
I2C protocol implementation
Sourcepub fn i2c_init(&mut self) -> Result<()>
pub fn i2c_init(&mut self) -> Result<()>
Initialize I2C bus with default settings
This initializes the I2C bus. Note: I2C bus is always activated on PoKeys devices.
Sourcepub fn i2c_configure(&mut self, _speed_khz: u16, _options: u8) -> Result<()>
pub fn i2c_configure(&mut self, _speed_khz: u16, _options: u8) -> Result<()>
Configure I2C bus with specific settings
§Arguments
speed_khz- I2C bus speed in kHz (typically 100 or 400)options- Additional I2C configuration options
Sourcepub fn i2c_write_register(
&mut self,
address: u8,
register: u8,
data: &[u8],
) -> Result<I2cStatus>
pub fn i2c_write_register( &mut self, address: u8, register: u8, data: &[u8], ) -> Result<I2cStatus>
Write to I2C device register
This is a convenience method for writing to a specific register in an I2C device.
§Arguments
address- 7-bit I2C device addressregister- Register addressdata- Data to write to the register
Sourcepub fn i2c_read_register(
&mut self,
address: u8,
register: u8,
length: u8,
) -> Result<(I2cStatus, Vec<u8>)>
pub fn i2c_read_register( &mut self, address: u8, register: u8, length: u8, ) -> Result<(I2cStatus, Vec<u8>)>
Read from I2C device register
This is a convenience method for reading from a specific register in an I2C device.
§Arguments
address- 7-bit I2C device addressregister- Register addresslength- Number of bytes to read
Sourcepub fn i2c_scan(&mut self) -> Result<Vec<u8>>
pub fn i2c_scan(&mut self) -> Result<Vec<u8>>
Scan I2C bus for devices
This method scans the I2C bus for responding devices.
§Returns
Vector of addresses that responded to the scan
Sourcepub fn i2c_write_with_retry(
&mut self,
address: u8,
data: &[u8],
config: &RetryConfig,
) -> Result<I2cStatus>
pub fn i2c_write_with_retry( &mut self, address: u8, data: &[u8], config: &RetryConfig, ) -> Result<I2cStatus>
Sourcepub fn i2c_get_status(&mut self) -> Result<I2cStatus>
pub fn i2c_get_status(&mut self) -> Result<I2cStatus>
Check I2C bus status
This method checks the current status of the I2C bus.
Source§impl PoKeysDevice
1-Wire protocol implementation
impl PoKeysDevice
1-Wire protocol implementation
Sourcepub fn onewire_init(&mut self) -> Result<()>
pub fn onewire_init(&mut self) -> Result<()>
Initialize 1-Wire bus
Sourcepub fn onewire_reset(&mut self) -> Result<bool>
pub fn onewire_reset(&mut self) -> Result<bool>
Reset 1-Wire bus
Sourcepub fn onewire_write_byte(&mut self, data: u8) -> Result<()>
pub fn onewire_write_byte(&mut self, data: u8) -> Result<()>
Write byte to 1-Wire bus
Sourcepub fn onewire_read_byte(&mut self) -> Result<u8>
pub fn onewire_read_byte(&mut self) -> Result<u8>
Read byte from 1-Wire bus
Source§impl PoKeysDevice
SPI protocol implementation
impl PoKeysDevice
SPI protocol implementation
Sourcepub fn spi_configure(&mut self, prescaler: u8, frame_format: u8) -> Result<()>
pub fn spi_configure(&mut self, prescaler: u8, frame_format: u8) -> Result<()>
Configure SPI interface
§Arguments
prescaler- SPI clock prescaler value (affects SPI clock speed)frame_format- SPI frame format configuration
This matches the C library function: PK_SPIConfigure(device, prescaler, frameFormat)
Sourcepub fn spi_write(&mut self, buffer: &[u8], pin_cs: u8) -> Result<()>
pub fn spi_write(&mut self, buffer: &[u8], pin_cs: u8) -> Result<()>
Write data to SPI bus
§Arguments
buffer- Data buffer to write (maximum 55 bytes)pin_cs- Chip select pin number
This matches the C library function: PK_SPIWrite(device, buffer, length, pinCS)
Source§impl PoKeysDevice
UART protocol implementation
impl PoKeysDevice
UART protocol implementation
Source§impl PoKeysDevice
uSPIBridge protocol implementation
impl PoKeysDevice
uSPIBridge protocol implementation
Sourcepub fn uspibridge_write_command(
&mut self,
slave_address: u8,
command: USPIBridgeCommand,
device_id: u8,
data: &[u8],
) -> Result<I2cStatus>
pub fn uspibridge_write_command( &mut self, slave_address: u8, command: USPIBridgeCommand, device_id: u8, data: &[u8], ) -> Result<I2cStatus>
Sourcepub fn uspibridge_set_segment_mapping(
&mut self,
slave_address: u8,
device_id: u8,
mapping: &[u8; 8],
) -> Result<I2cStatus>
pub fn uspibridge_set_segment_mapping( &mut self, slave_address: u8, device_id: u8, mapping: &[u8; 8], ) -> Result<I2cStatus>
Sourcepub fn uspibridge_set_segment_mapping_type(
&mut self,
slave_address: u8,
device_id: u8,
mapping_type: SegmentMappingType,
) -> Result<I2cStatus>
pub fn uspibridge_set_segment_mapping_type( &mut self, slave_address: u8, device_id: u8, mapping_type: SegmentMappingType, ) -> Result<I2cStatus>
Sourcepub fn uspibridge_get_segment_mapping(
&mut self,
slave_address: u8,
device_id: u8,
) -> Result<(I2cStatus, Option<[u8; 8]>)>
pub fn uspibridge_get_segment_mapping( &mut self, slave_address: u8, device_id: u8, ) -> Result<(I2cStatus, Option<[u8; 8]>)>
Sourcepub fn uspibridge_test_segment_mapping(
&mut self,
slave_address: u8,
device_id: u8,
test_pattern: u8,
) -> Result<I2cStatus>
pub fn uspibridge_test_segment_mapping( &mut self, slave_address: u8, device_id: u8, test_pattern: u8, ) -> Result<I2cStatus>
Test segment mapping with a specific pattern
This command displays a test pattern on the specified device to verify that the segment mapping is working correctly.
§Arguments
slave_address- I2C slave address of the uSPIBridge devicedevice_id- Target MAX7219 device ID (0-based)test_pattern- 8-bit pattern to display for testing
§Returns
I2C operation status
Sourcepub fn uspibridge_display_text(
&mut self,
slave_address: u8,
device_id: u8,
text: &str,
) -> Result<I2cStatus>
pub fn uspibridge_display_text( &mut self, slave_address: u8, device_id: u8, text: &str, ) -> Result<I2cStatus>
Sourcepub fn uspibridge_display_number(
&mut self,
slave_address: u8,
device_id: u8,
number: u32,
) -> Result<I2cStatus>
pub fn uspibridge_display_number( &mut self, slave_address: u8, device_id: u8, number: u32, ) -> Result<I2cStatus>
Sourcepub fn uspibridge_set_character(
&mut self,
slave_address: u8,
device_id: u8,
position: u8,
character: u8,
) -> Result<I2cStatus>
pub fn uspibridge_set_character( &mut self, slave_address: u8, device_id: u8, position: u8, character: u8, ) -> Result<I2cStatus>
Sourcepub fn uspibridge_set_pattern(
&mut self,
slave_address: u8,
device_id: u8,
position: u8,
pattern: u8,
) -> Result<I2cStatus>
pub fn uspibridge_set_pattern( &mut self, slave_address: u8, device_id: u8, position: u8, pattern: u8, ) -> Result<I2cStatus>
Sourcepub fn uspibridge_set_decimal(
&mut self,
slave_address: u8,
device_id: u8,
position: u8,
state: bool,
) -> Result<I2cStatus>
pub fn uspibridge_set_decimal( &mut self, slave_address: u8, device_id: u8, position: u8, state: bool, ) -> Result<I2cStatus>
Sourcepub fn uspibridge_set_brightness(
&mut self,
slave_address: u8,
device_id: u8,
brightness: u8,
) -> Result<I2cStatus>
pub fn uspibridge_set_brightness( &mut self, slave_address: u8, device_id: u8, brightness: u8, ) -> Result<I2cStatus>
Sourcepub fn uspibridge_clear_device(
&mut self,
slave_address: u8,
device_id: u8,
) -> Result<I2cStatus>
pub fn uspibridge_clear_device( &mut self, slave_address: u8, device_id: u8, ) -> Result<I2cStatus>
Sourcepub fn uspibridge_virtual_text(
&mut self,
slave_address: u8,
virtual_id: u8,
text: &str,
) -> Result<I2cStatus>
pub fn uspibridge_virtual_text( &mut self, slave_address: u8, virtual_id: u8, text: &str, ) -> Result<I2cStatus>
Sourcepub fn uspibridge_create_virtual_device(
&mut self,
slave_address: u8,
virtual_id: u8,
physical_devices: &[u8],
) -> Result<I2cStatus>
pub fn uspibridge_create_virtual_device( &mut self, slave_address: u8, virtual_id: u8, physical_devices: &[u8], ) -> Result<I2cStatus>
Sourcepub fn uspibridge_delete_virtual_device(
&mut self,
slave_address: u8,
virtual_id: u8,
) -> Result<I2cStatus>
pub fn uspibridge_delete_virtual_device( &mut self, slave_address: u8, virtual_id: u8, ) -> Result<I2cStatus>
Sourcepub fn uspibridge_list_virtual_devices(
&mut self,
slave_address: u8,
) -> Result<(I2cStatus, Option<Vec<u8>>)>
pub fn uspibridge_list_virtual_devices( &mut self, slave_address: u8, ) -> Result<(I2cStatus, Option<Vec<u8>>)>
Sourcepub fn uspibridge_virtual_brightness(
&mut self,
slave_address: u8,
virtual_id: u8,
brightness: u8,
) -> Result<I2cStatus>
pub fn uspibridge_virtual_brightness( &mut self, slave_address: u8, virtual_id: u8, brightness: u8, ) -> Result<I2cStatus>
Sourcepub fn uspibridge_virtual_scroll(
&mut self,
slave_address: u8,
virtual_id: u8,
text: &str,
speed_ms: u16,
direction_left: bool,
) -> Result<I2cStatus>
pub fn uspibridge_virtual_scroll( &mut self, slave_address: u8, virtual_id: u8, text: &str, speed_ms: u16, direction_left: bool, ) -> Result<I2cStatus>
Start scrolling effect on a virtual display
§Arguments
slave_address- I2C slave address of the uSPIBridge devicevirtual_id- Virtual display ID (0-based)text- Text to scrollspeed_ms- Scroll speed in millisecondsdirection_left- True for left scroll, false for right scroll
§Returns
I2C operation status
Sourcepub fn uspibridge_virtual_flash(
&mut self,
slave_address: u8,
virtual_id: u8,
text: &str,
interval_ms: u16,
) -> Result<I2cStatus>
pub fn uspibridge_virtual_flash( &mut self, slave_address: u8, virtual_id: u8, text: &str, interval_ms: u16, ) -> Result<I2cStatus>
Sourcepub fn uspibridge_virtual_stop(
&mut self,
slave_address: u8,
virtual_id: u8,
) -> Result<I2cStatus>
pub fn uspibridge_virtual_stop( &mut self, slave_address: u8, virtual_id: u8, ) -> Result<I2cStatus>
Sourcepub fn uspibridge_virtual_clear(
&mut self,
slave_address: u8,
virtual_id: u8,
) -> Result<I2cStatus>
pub fn uspibridge_virtual_clear( &mut self, slave_address: u8, virtual_id: u8, ) -> Result<I2cStatus>
Sourcepub fn uspibridge_system_reset(
&mut self,
slave_address: u8,
) -> Result<I2cStatus>
pub fn uspibridge_system_reset( &mut self, slave_address: u8, ) -> Result<I2cStatus>
Source§impl PoKeysDevice
impl PoKeysDevice
Sourcepub fn enable_pulse_engine(&mut self, enable: bool) -> Result<()>
pub fn enable_pulse_engine(&mut self, enable: bool) -> Result<()>
Enable pulse engine
Sourcepub fn activate_pulse_engine(&mut self, activate: bool) -> Result<()>
pub fn activate_pulse_engine(&mut self, activate: bool) -> Result<()>
Activate pulse engine
Sourcepub fn setup_pulse_engine_with_axes(
&mut self,
config: &PulseEngineConfig,
axis_enable_mask: u8,
) -> Result<()>
pub fn setup_pulse_engine_with_axes( &mut self, config: &PulseEngineConfig, axis_enable_mask: u8, ) -> Result<()>
Setup pulse engine (0x85/0x01) Setup pulse engine (0x85/0x01) with axis enable mask
pub fn get_pulse_engine_status(&mut self) -> Result<()>
Sourcepub fn set_axis_position(&mut self, axis: usize, position: i32) -> Result<()>
pub fn set_axis_position(&mut self, axis: usize, position: i32) -> Result<()>
Set axis position (0x85/0x03)
Sourcepub fn set_pulse_engine_state(
&mut self,
state: u8,
limit_override: u8,
output_enable_mask: u8,
) -> Result<()>
pub fn set_pulse_engine_state( &mut self, state: u8, limit_override: u8, output_enable_mask: u8, ) -> Result<()>
Set pulse engine state (0x85/0x02)
Sourcepub fn reboot_pulse_engine(&mut self) -> Result<()>
pub fn reboot_pulse_engine(&mut self) -> Result<()>
Reboot pulse engine (0x85/0x05)
Sourcepub fn set_axis_configuration(&mut self, axis: usize) -> Result<()>
pub fn set_axis_configuration(&mut self, axis: usize) -> Result<()>
Set axis configuration (0x85/0x11)
Sourcepub fn get_axis_configuration(&mut self, axis: usize) -> Result<()>
pub fn get_axis_configuration(&mut self, axis: usize) -> Result<()>
Get axis configuration (0x85/0x10)
pub fn get_axis_position(&mut self, axis: usize) -> Result<i32>
Sourcepub fn move_axis_to_position(
&mut self,
axis: usize,
position: i32,
_speed: f32,
) -> Result<()>
pub fn move_axis_to_position( &mut self, axis: usize, position: i32, _speed: f32, ) -> Result<()>
Move axis to position using 0x85/0x20 command in position control mode
Sourcepub fn start_axis_homing(&mut self, axis_mask: u8) -> Result<()>
pub fn start_axis_homing(&mut self, axis_mask: u8) -> Result<()>
Start axis homing
Sourcepub fn configure_axis_homing(
&mut self,
axis: usize,
home_pin: u8,
homing_speed: u8,
home_offset: i32,
) -> Result<()>
pub fn configure_axis_homing( &mut self, axis: usize, home_pin: u8, homing_speed: u8, home_offset: i32, ) -> Result<()>
Configure axis homing
Sourcepub fn configure_axis_limits(
&mut self,
axis: usize,
limit_n_pin: u8,
limit_p_pin: u8,
soft_limit_min: i32,
soft_limit_max: i32,
) -> Result<()>
pub fn configure_axis_limits( &mut self, axis: usize, limit_n_pin: u8, limit_p_pin: u8, soft_limit_min: i32, soft_limit_max: i32, ) -> Result<()>
Configure axis limits
Sourcepub fn emergency_stop(&mut self) -> Result<()>
pub fn emergency_stop(&mut self) -> Result<()>
Emergency stop
Sourcepub fn read_pulse_engine_status(&mut self) -> Result<()>
pub fn read_pulse_engine_status(&mut self) -> Result<()>
Read pulse engine status
Sourcepub fn get_pulse_engine_state(&mut self) -> Result<PulseEngineState>
pub fn get_pulse_engine_state(&mut self) -> Result<PulseEngineState>
Get pulse engine state
Sourcepub fn get_axis_state(&mut self, axis: usize) -> Result<PulseEngineAxisState>
pub fn get_axis_state(&mut self, axis: usize) -> Result<PulseEngineAxisState>
Get axis state
Sourcepub fn is_axis_homed(&mut self, axis: usize) -> Result<bool>
pub fn is_axis_homed(&mut self, axis: usize) -> Result<bool>
Check if axis is homed
Sourcepub fn wait_for_axis(&mut self, axis: usize, timeout_ms: u32) -> Result<()>
pub fn wait_for_axis(&mut self, axis: usize, timeout_ms: u32) -> Result<()>
Wait for axis to complete movement
Sourcepub fn set_motor_drivers_configuration(&mut self) -> Result<()>
pub fn set_motor_drivers_configuration(&mut self) -> Result<()>
Set internal motor drivers configuration (0x85/0x19)
Sourcepub fn configure_axis(&mut self, axis: usize) -> AxisConfigBuilder
pub fn configure_axis(&mut self, axis: usize) -> AxisConfigBuilder
Create axis configuration builder
Sourcepub fn set_axis_positions(
&mut self,
axis_mask: u8,
positions: &[i32; 8],
) -> Result<()>
pub fn set_axis_positions( &mut self, axis_mask: u8, positions: &[i32; 8], ) -> Result<()>
Set axis positions (0x85/0x03)
Sourcepub fn move_pv(
&mut self,
axis_mask: u8,
positions: &[i32; 8],
velocity: u16,
) -> Result<()>
pub fn move_pv( &mut self, axis_mask: u8, positions: &[i32; 8], velocity: u16, ) -> Result<()>
Move PV (Set reference position and speed) (0x85/0x25)
Sourcepub fn configure_motor_drivers(&mut self) -> MotorDriverConfigBuilder
pub fn configure_motor_drivers(&mut self) -> MotorDriverConfigBuilder
Create motor driver configuration builder
Sourcepub fn get_motor_drivers_configuration(&mut self) -> Result<()>
pub fn get_motor_drivers_configuration(&mut self) -> Result<()>
Get internal motor drivers configuration (0x85/0x18)
Source§impl PoKeysDevice
impl PoKeysDevice
Sourcepub fn set_pwm_configuration(&mut self) -> Result<()>
pub fn set_pwm_configuration(&mut self) -> Result<()>
Set PWM configuration using command 0xCB
Sourcepub fn update_pwm_duty_values(&mut self) -> Result<()>
pub fn update_pwm_duty_values(&mut self) -> Result<()>
Update only PWM duty values using command 0xCB
Sourcepub fn get_pwm_configuration(&mut self) -> Result<()>
pub fn get_pwm_configuration(&mut self) -> Result<()>
Get PWM configuration using command 0xCB
Sourcepub fn set_pwm_period(&mut self, period: u32) -> Result<()>
pub fn set_pwm_period(&mut self, period: u32) -> Result<()>
Set PWM period (shared among all channels)
Sourcepub fn get_pwm_period(&self) -> u32
pub fn get_pwm_period(&self) -> u32
Get PWM period
Sourcepub fn set_pwm_duty_cycle_for_pin(&mut self, pin: u8, duty: u32) -> Result<()>
pub fn set_pwm_duty_cycle_for_pin(&mut self, pin: u8, duty: u32) -> Result<()>
Set PWM duty cycle for a pin (17-22)
Sourcepub fn get_pwm_duty_cycle_for_pin(&self, pin: u8) -> Result<u32>
pub fn get_pwm_duty_cycle_for_pin(&self, pin: u8) -> Result<u32>
Get PWM duty cycle for a pin (17-22)
Sourcepub fn enable_pwm_for_pin(&mut self, pin: u8, enabled: bool) -> Result<()>
pub fn enable_pwm_for_pin(&mut self, pin: u8, enabled: bool) -> Result<()>
Enable or disable PWM for a pin (17-22)
Sourcepub fn is_pwm_enabled_for_pin(&self, pin: u8) -> Result<bool>
pub fn is_pwm_enabled_for_pin(&self, pin: u8) -> Result<bool>
Check if PWM is enabled for a pin (17-22)
Sourcepub fn set_pwm_duty_cycle_percent_for_pin(
&mut self,
pin: u8,
percent: f32,
) -> Result<()>
pub fn set_pwm_duty_cycle_percent_for_pin( &mut self, pin: u8, percent: f32, ) -> Result<()>
Set PWM duty cycle as percentage (0.0 to 100.0) for a pin
Sourcepub fn get_pwm_duty_cycle_percent_for_pin(&self, pin: u8) -> Result<f32>
pub fn get_pwm_duty_cycle_percent_for_pin(&self, pin: u8) -> Result<f32>
Get PWM duty cycle as percentage for a pin
Source§impl PoKeysDevice
impl PoKeysDevice
Sourcepub fn configure_easy_sensor(
&mut self,
sensor_index: usize,
sensor_type: u8,
sensor_id: &[u8; 8],
refresh_period_seconds: f32,
reading_id: u8,
) -> Result<()>
pub fn configure_easy_sensor( &mut self, sensor_index: usize, sensor_type: u8, sensor_id: &[u8; 8], refresh_period_seconds: f32, reading_id: u8, ) -> Result<()>
Configure EasySensor
Sourcepub fn enable_easy_sensor(
&mut self,
sensor_index: usize,
enable: bool,
) -> Result<()>
pub fn enable_easy_sensor( &mut self, sensor_index: usize, enable: bool, ) -> Result<()>
Enable EasySensor
Sourcepub fn read_easy_sensor(&mut self, sensor_index: usize) -> Result<i32>
pub fn read_easy_sensor(&mut self, sensor_index: usize) -> Result<i32>
Read EasySensor value
Sourcepub fn read_all_easy_sensors(&mut self) -> Result<()>
pub fn read_all_easy_sensors(&mut self) -> Result<()>
Read all EasySensor values
Sourcepub fn configure_sensor_failsafe(
&mut self,
sensor_index: usize,
timeout_seconds: u8,
invalid_value_zero: bool,
invalid_value_max: bool,
) -> Result<()>
pub fn configure_sensor_failsafe( &mut self, sensor_index: usize, timeout_seconds: u8, invalid_value_zero: bool, invalid_value_max: bool, ) -> Result<()>
Configure sensor failsafe settings
Sourcepub fn get_sensor_status(&self, sensor_index: usize) -> Result<bool>
pub fn get_sensor_status(&self, sensor_index: usize) -> Result<bool>
Get sensor status
Sourcepub fn set_custom_sensor_unit(
&mut self,
unit_index: usize,
unit: &CustomSensorUnit,
) -> Result<()>
pub fn set_custom_sensor_unit( &mut self, unit_index: usize, unit: &CustomSensorUnit, ) -> Result<()>
Set custom sensor unit