avr-hal icon indicating copy to clipboard operation
avr-hal copied to clipboard

Example: uFmt_f32/uFmt_f64

Open chevdor opened this issue 3 years ago • 4 comments

I was surprised hitting bigger problems than expected when trying to format a string and writting to a serial port. This issue is partly related to #302.

In a nutshell, it would be great to see a working example such as:

let value = 3.1415926_f32;
let value_write = uFmt_f32::Two(value); // 3.14
ufmt::uwriteln!(&mut serial, "value: {}", value_write);

The issue I hit was the trait uDisplayis not implemented foruFmt_f32despite the fact thatuFmt_f32` does implement it.

chevdor avatar Aug 31 '22 07:08 chevdor

Can you check your dependency tree on whether avr-hal and ufmt_float both depend on the same version of ufmt? Easiest way to do this is using cargo tree.

Rahix avatar Aug 31 '22 10:08 Rahix

Ah indeed:

c tree -i ufmt
error: There are multiple `ufmt` packages in your project, and the specification `ufmt` is ambiguous.
Please re-run this command with `-p <spec>` where `<spec>` is one of the following:
  [email protected]
  [email protected]

chevdor avatar Aug 31 '22 14:08 chevdor

NOTE: heapless::string (and alloc::... even less) is, unlike what I initiall thought, not required for such an example to work.

chevdor avatar Aug 31 '22 14:08 chevdor

FYI: ufmt_loat was published on crates.io but there was no public repo. I contacted the author who nicely published the repo. I also lined up a PR so ufmt_float no longer depends on an ancient ufmt.

chevdor avatar Sep 07 '22 13:09 chevdor