<re_irc>
A "short" video in which I bang on about Embedded Rust and the wonders of the community and our portable drivers.
Socker has joined #rust-embedded
Socker has quit [Ping timeout: 265 seconds]
Socker has joined #rust-embedded
Dr_Who has joined #rust-embedded
Socker has quit [Ping timeout: 252 seconds]
Socker has joined #rust-embedded
Socker has quit [Ping timeout: 255 seconds]
Socker has joined #rust-embedded
starblue has quit [Ping timeout: 260 seconds]
starblue has joined #rust-embedded
Socker has quit [Ping timeout: 240 seconds]
Socker has joined #rust-embedded
Foxyloxy_ has joined #rust-embedded
Foxyloxy has quit [Ping timeout: 265 seconds]
Dr_Who has quit [Quit: ZZZzzz…]
Socker has quit [Ping timeout: 240 seconds]
Socker has joined #rust-embedded
Socker has quit [Ping timeout: 240 seconds]
Socker has joined #rust-embedded
<re_irc>
<@imdoor:ilgt.lv> hi, how should i go about using the "PwmPin" trait from "embedded-hal" (v0.2.7) if i want the duty cycle be some fraction of the maximum (as returned by "get_max_duty()")? e.g., i want to be able to say stuff like
<re_irc>
fn set_pwm_duty<P>(pwm_pin: &mut P)
<re_irc>
P: PwmPin,
<re_irc>
where
<re_irc>
// How do i achieve this? This won't work without some
<re_irc>
{
<re_irc>
// extra constraints on the PwmPin::Duty associated type
<re_irc>
let new_duty = pwm_pin.get_max_duty() * 3 / 256;
<re_irc>
pwm_pin.set_duty(new_duty);
<re_irc>
}
<re_irc>
<@imdoor:ilgt.lv> but how to do it safely? i guess i could require that "P::Duty: From<u8>, P::Duty: Div, P::Duty: Mul" or something, but that doesn't guarantee that i won't end up with overflows, i.e.,:
<re_irc>
fn set_pwm_duty<P>(pwm_pin: &mut P)
<re_irc>
where
<re_irc>
P::Duty: Div,
<re_irc>
P: PwmPin,
<re_irc>
P::Duty: Mul,
<re_irc>
P::Duty: From<u8>,
<re_irc>
{
<re_irc>
let three = P::Duty::from(3_u8);
<re_irc>
let other = P::Duty::from(255_u8);
<re_irc>
// This might overflow
<re_irc>
let new_duty = pwm_pin.get_max_duty() * three / other;
<re_irc>
pwm_pin.set_duty(new_duty);
<re_irc>
}
<re_irc>
<@vollbrecht:matrix.org> because it is not independent of the concrete pwm implementation this is not simply general usable.
<re_irc>
/// Type for the `duty` methods
<re_irc>
///
<re_irc>
/// The implementer is free to choose a float / percentage representation
<re_irc>
/// (e.g. `0.0 .. 1.0`) or an integer representation (e.g. `0 .. 65535`)
<re_irc>
type Duty;
<re_irc>
so one hal implementer may implement the float variant while one other may implement it as an u32
<re_irc>
i think thats why this was axed and is now changed in the embedde-hal alpha releases.
<re_irc>
<@dirbaio:matrix.org> oh boi the riscv atomics issue
<re_irc>
<@shakencodes:matrix.org> I am working with stm32wlxx-hal (with the defmt dependency popped up to 0.3.4, fixing a defmt wire format version issue) and am attempting to run the testsuite and am getting the following error:
<re_irc>
"Error: failed to demangle defmt symbol "{"package":"testsuite","tag":"defmt_debug","data":"I2C2 ISR={:#08X}","disambiguator":"362709172824667103"}": missing field "crate_name" at line 1 column 106"
<re_irc>
I do not find "crate_name" anywhere in the stm32wlxx-hal crate and am not sure where to start to make this work. Any suggestions?
<re_irc>
<@jamesmunns:beeper.com> that looks like the the defmt wire format issue. What does "probe-run -V" say?
<re_irc>
<@jamesmunns:beeper.com> (the answer is you probably need to update probe-run or downgrade your defmt dependency, I can't remember what the "blessed" compatible versions are off the top of my head. ^ )
<re_irc>
<@shakencodes:matrix.org> : Yes, this looks like the exact same thing. I am going to try to install the older version of probe-run to see it that will work around the problem today.
<re_irc>
<@shakencodes:matrix.org> ... which worked. Thank you, James!
<re_irc>
<@peter9477:matrix.org> : Full circle. :-) The source shared this above just a bit earlier today (?): https://matrix.to/#/!BHcierreUuwCMxVqOf:matrix.org/$vSWzAjM2inDVpm936gPu-N9TRZQcvrFpXTK3HV-g8k8?via=matrix.org&via=psion.agg.io&via=tchncs.de
<re_irc>
<@tschundler:matrix.org> : 😅 oops, didn't scroll back far enough