From 509a96aba141d251da65d4110440e9e28efe00a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Wed, 11 Dec 2024 07:47:25 -0300 Subject: [PATCH] wip MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- src/lib.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7073c3ab5..ecc8c9887 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -468,9 +468,9 @@ fn set_pwm_channels_duty_cycle_c(channels: *const usize, duty_cycle: f32, length Examples:\n You can use this method like :py:func:`set_pwm_channel_value`.\n >>> navigator.set_pwm_channels_value([PwmChannel.Ch1, PwmChannel.Ch16], 1000)"] -fn set_pwm_channels_value_py(channels: Vec, value: u16) { +fn set_pwm_channels_value_py(channels: Vec, value: u16) { for i in 0..channels.len() { - with_navigator!().set_pwm_channel_value(channels[i], value); + with_navigator!().set_pwm_duty_cycle(channels[i], value as f32 / 4096.0); } } @@ -482,7 +482,7 @@ fn set_pwm_channels_value_py(channels: Vec, value: u16) { Examples:\n You can use this method like :py:func:`set_pwm_channel_duty_cycle`.\n >>> navigator.set_pwm_channels_value([PwmChannel.Ch1, PwmChannel.Ch16], 0.5)"] -fn set_pwm_channels_duty_cycle_py(channels: Vec, duty_cycle: f32) { +fn set_pwm_channels_duty_cycle_py(channels: Vec, duty_cycle: f32) { for channel in channels { with_navigator!().set_pwm_duty_cycle(channel.into(), duty_cycle); } @@ -500,7 +500,7 @@ fn set_pwm_channels_values_c(channels: *const usize, values: *const f32, length: std::slice::from_raw_parts(values, length) }; for i in 0..length { - with_navigator!().set_pwm_duty_cycle(array_channels[i], array_values[i]); + with_navigator!().set_pwm_duty_cycle(array_channels[i], array_values[i] as f32 / 4096.0); } } @@ -533,14 +533,14 @@ fn set_pwm_channels_duty_cycle_values_c( Examples:\n You can use this method like :py:func:`set_pwm_channel_value`.\n >>> navigator.set_pwm_channels_values([PwmChannel.Ch1, PwmChannel.Ch5], [1000, 500])"] -fn set_pwm_channels_values_py(channels: Vec, values: Vec) { +fn set_pwm_channels_values_py(channels: Vec, values: Vec) { if channels.len() != values.len() { println!("The number of values is different from the number of PWM channels."); return; } for i in 0..channels.len() { - with_navigator!().set_pwm_duty_cycle(channels[i].clone().into(), values[i]); + with_navigator!().set_pwm_duty_cycle(channels[i].clone().into(), values[i] as f32 / 4096.0); } } @@ -553,7 +553,7 @@ fn set_pwm_channels_values_py(channels: Vec, values: Vec) { Examples:\n You can use this method like :py:func:`set_pwm_channel_duty_cycle`.\n >>> navigator.set_pwm_channels_duty_cycle_values([PwmChannel.Ch1, PwmChannel.Ch5], [0.25, 0.75])"] -fn set_pwm_channels_duty_cycle_values_py(channels: Vec, duty_cycle_values: Vec) { +fn set_pwm_channels_duty_cycle_values_py(channels: Vec, duty_cycle_values: Vec) { if channels.len() != duty_cycle_values.len() { println!("The number of values is different from the number of PWM channels."); return; @@ -584,8 +584,6 @@ cpy_module!( read_accel, read_gyro, set_pwm_enable, - get_pwm_enable, - set_pwm_freq_prescale, set_pwm_freq_hz, set_pwm_channel_value, set_pwm_channel_duty_cycle,