esp-idf-lib
esp-idf-lib copied to clipboard
Request driver for DS2438 (Battery Monitor)
Hi, I would like to request a driver for Dallas DS2438, please. Need it so much for my school task.
Regards
Hello, @kusumy @UncleRus
I tried to port the driver code of Dallas DS243. Here is the link, I do not have the device so not tested the code on the device if anyone has can test and update me. If it works I will try to create the merge request. It's building successfully on esp idf v4.4.1.
Thanks.
Hi @Raghav3107 ! First of all, thank you.
- The first and most important note: drivers must be stateless! If you need to save some state between calls, the device descriptor structure is used. Your library can only be used with single device, because of the saving device GPIO and mode to internal
_pin
and_mode
variables. The same goes for theds2438_update()
function: it should just read and return the voltage and temperature values without saving them. To avoid this, declare device descriptor struct and pass it by pointer to all functions. - Please avoid
int
parameters when they can be replaced with enums. - Please add C++ guards in header.
- Move internal definitions such as register numbers from the header to the source. They are only used internally and pollutes the global namespace in header.
- Clean includes in header. Why is there
stdio.h
andstdlib.h
? - Avoid using of
func(void)
instead offunc()
. - Do not use tabs. Spaces only.
Hello @UncleRus
Thanks for the advice and guidance.
The first time, I m trying to contribute to the open-source repo, I m not well known about coding standards and other things. I will update lib as per the coding standard and your instructions.
Thanks!
Hello @UncleRus.
I updated the repository as per your instruction. Can you please check it once again?
Thanks!