Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pwm upgrades #13

Merged
merged 7 commits into from
Jun 29, 2023
Merged

Conversation

RaulTrombin
Copy link
Member

@RaulTrombin RaulTrombin commented Jun 28, 2023

Add Logger and Log crates, RUST_LOG=debug ./raspberry-pi
image

Create a field deticated to navigator's defaults (PWM crystal)

Add new functions and documentation to pwm module:
image
image
image

On some descriptions, the links points to manufacturer's data-sheet and page for further info.

Copy link
Member

@patrickelectric patrickelectric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation and updates on the new functions should be on the same commits where there functions were added.

@RaulTrombin
Copy link
Member Author

RaulTrombin commented Jun 28, 2023

The documentation and updates on the new functions should be on the same commits where there functions were added.

Ok, squashed the commits

Copy link
Member

@patrickelectric patrickelectric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not ignore code in the doc files.

@RaulTrombin
Copy link
Member Author

We should not ignore code in the doc files.

They need to run on a armv7-target

**
image
**

@RaulTrombin RaulTrombin mentioned this pull request Jun 28, 2023
2 tasks
@RaulTrombin RaulTrombin force-pushed the pwm_upgrade branch 3 times, most recently from 4360639 to e01a6d8 Compare June 29, 2023 00:53
@RaulTrombin
Copy link
Member Author

@patrickelectric

found the '''not_run" resource for rust doc.

Changed last commit.
So CI compile the examples, just not run.
Did a fallback on CI changes.

src/lib.rs Outdated
@@ -21,6 +22,9 @@ pub use ads1x1x::ChannelSelection as adc_Channel;

use std::fmt::Debug;

//Navigator Defaults
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//Navigator Defaults
/// Navigator Defaults

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the idea is to create a header to organize defaults,
constants, adresses and other values.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm suggesting to make generate the documentation for it, implied by ///

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated
Comment on lines 360 to 374
pub fn set_pwm_freq_hz(&mut self, mut freq: f32) {
if freq < 24.0 {
warn!("Invalid value. Value must be greater than 24.0.");
freq = 24.0;
}

if freq > 1526.0 {
warn!("Invalid value. Value must be less than 1526.0.");
freq = 1526.0;
}

let prescale_clamped_value =
(NAVIGATOR_PWM_XTAL_CLOCK_FREQ / (4_096.0 * freq)).round() as u8 - 1;

self.set_pwm_freq_prescale(prescale_clamped_value);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub fn set_pwm_freq_hz(&mut self, mut freq: f32) {
if freq < 24.0 {
warn!("Invalid value. Value must be greater than 24.0.");
freq = 24.0;
}
if freq > 1526.0 {
warn!("Invalid value. Value must be less than 1526.0.");
freq = 1526.0;
}
let prescale_clamped_value =
(NAVIGATOR_PWM_XTAL_CLOCK_FREQ / (4_096.0 * freq)).round() as u8 - 1;
self.set_pwm_freq_prescale(prescale_clamped_value);
}
pub fn set_pwm_freq_hz(&mut self, mut freq: f32) {
let min_freq = 24.0;
let max_freq = 1526.0;
if freq < min_freq {
warn!("Invalid value. Value must be greater than {min_freq}.");
freq = min_freq;
}
if freq > max_freq {
warn!("Invalid value. Value must be less than {max_freq}.");
freq = max_freq;
}
let prescale_clamped_value =
(NAVIGATOR_PWM_XTAL_CLOCK_FREQ / (4_096.0 * freq)).round() as u8 - 1;
self.set_pwm_freq_prescale(prescale_clamped_value);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be greater/less than or equal to, not just greater/less than.

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@patrickelectric patrickelectric merged commit 00f6c2d into bluerobotics:master Jun 29, 2023
2 checks passed
@RaulTrombin RaulTrombin deleted the pwm_upgrade branch July 13, 2023 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants