JohnDoneth / hd44780-driver

Implementation of the embedded-hal traits for the HD44780.
MIT License
37 stars 40 forks source link

Add write_byte method #22

Closed bollian closed 4 years ago

bollian commented 4 years ago

I'm currently implementing uWrite from the ufmt crate (https://github.com/japaric/ufmt) for this driver. This, similarly to core::fmt, wants you to implement the writing of a UTF-8 slice of bytes to the object. As a result, it makes the most sense to simply write each byte to the object in a loop.

Would it be possible to add some sort of write_byte function to the HD44780 struct to enable this? Obviously the write_char function would work, but it feels weird to convert each byte into a 32bit char, only to convert it back into a byte before writing it to the bus.

The current implementation of core::fmt::Write also suffers from this issue.

JohnDoneth commented 4 years ago

Thanks for the issue!

That seems like a good idea to me. ufmt is a crate I definitely want to support. I can't think of any downsides of having a write_byte function. Refactoring HD44780::write_char to use HD44780::write_byte internally and documenting the differences between the functions would be a good additional step as well.