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

drivers: pcf8583 minor cleanup #14085

Merged
merged 1 commit into from
Feb 3, 2020
Merged

drivers: pcf8583 minor cleanup #14085

merged 1 commit into from
Feb 3, 2020

Conversation

dagar
Copy link
Member

@dagar dagar commented Feb 2, 2020

This is a quick followup to #14018

  • split out header and main
  • move to ModuleParams
  • add copyright header everywhere
  • don't store unnecessary state (new data is published in the same iteration)

@roman-dvorak @slimonslimon we didn't have a great simple driver example to point to, so I thought it might be easier to try and get the new pcf8583 rpm driver to that point. The only other thing I'd want to change here is the constants for the register addresses and any special values. Lately I've been trying to break out the subset of the datasheet we use separately.

Example:
Invensense ICM20602 registers: https://github.com/PX4/Firmware/blob/c8a58c5c9daa6e5d9c1646407ef3e25b3a448d96/src/drivers/imu/invensense/icm20602/InvenSense_ICM20602_registers.hpp#L61-L87

Then the actual usage becomes quite readable.
https://github.com/PX4/Firmware/blob/c8a58c5c9daa6e5d9c1646407ef3e25b3a448d96/src/drivers/imu/invensense/icm20602/ICM20602.cpp#L150-L151

 - split out header and main
 - move to ModuleParams
 - don't store unnecessary state
@codecov
Copy link

codecov bot commented Feb 2, 2020

Codecov Report

Merging #14085 into master will decrease coverage by 17.41%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           master   #14085       +/-   ##
===========================================
- Coverage   53.82%   36.41%   -17.42%     
===========================================
  Files         605      545       -60     
  Lines       51373    46998     -4375     
===========================================
- Hits        27649    17112    -10537     
- Misses      23724    29886     +6162
Flag Coverage Δ
#mavsdk 36.41% <ø> (+0.08%) ⬆️
#python ?
#sitl_mission_FW ?
#sitl_mission_MC_box ?
#sitl_mission_MC_offboard_att ?
#sitl_mission_MC_offboard_pos ?
#sitl_mission_Rover ?
#sitl_mission_VTOL_standard ?
#sitl_mission_VTOL_tailsitter ?
#sitl_python_FW ?
#sitl_python_MC_box ?
#sitl_python_MC_offboard_att ?
#sitl_python_MC_offboard_pos ?
#sitl_python_Rover ?
#sitl_python_VTOL_standard ?
#sitl_python_VTOL_tailsitter ?
#unittest ?
Impacted Files Coverage Δ
src/systemcmds/tests/test_bezierQuad.cpp 0% <0%> (-100%) ⬇️
src/lib/controllib/BlockLimitSym.cpp 0% <0%> (-100%) ⬇️
src/modules/navigator/mission_block.h 0% <0%> (-100%) ⬇️
src/systemcmds/tests/test_search_min.cpp 0% <0%> (-100%) ⬇️
src/systemcmds/tests/test_hrt.cpp 0% <0%> (-100%) ⬇️
...c/modules/mavlink/mavlink_tests/mavlink_ftp_test.h 0% <0%> (-100%) ⬇️
src/modules/navigator/takeoff.h 0% <0%> (-100%) ⬇️
src/modules/navigator/land.h 0% <0%> (-100%) ⬇️
...ontrollib/controllib_test/controllib_test_main.cpp 0% <0%> (-100%) ⬇️
src/systemcmds/tests/test_autodeclination.cpp 0% <0%> (-100%) ⬇️
... and 286 more

@slimonslimon
Copy link
Contributor

The code of driver looks much better after yours cleanup. But my English is not good, so I am not sure if I understand your comment correctly. Correct me if I am wrong:

You would like to use this driver as new example, instead of https://github.com/PX4/Firmware/tree/master/src/drivers/distance_sensor/sf1xx. (pointed form https://dev.px4.io/v1.9.0/en/sensor_bus/i2c.html, - my first code was modification of this example) .

But you would like to add some names for registers by enum class Register. I can create this modification, in about one week (When I will have time for it).

And last but not least: I don't understand code coverage, why it decrease so much?

@dagar
Copy link
Member Author

dagar commented Feb 3, 2020

You would like to use this driver as new example, instead of https://github.com/PX4/Firmware/tree/master/src/drivers/distance_sensor/sf1xx. (pointed form https://dev.px4.io/v1.9.0/en/sensor_bus/i2c.html, - my first code was modification of this example) .

Yes, this is what I'd like the current "good" example to be (for a simple driver). Most of the other drivers in the system are very slowly being updated to that level.

But you would like to add some names for registers by enum class Register. I can create this modification, in about one week (When I will have time for it).

No rush, but I think it's quite helpful for readability.

And last but not least: I don't understand code coverage, why it decrease so much?
It appears to be codecov.io misconfiguration and needs to be fixed.

@dagar dagar merged commit 36b3718 into master Feb 3, 2020
@dagar dagar deleted the pr-pcf8583_cleanup branch February 3, 2020 15:01
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.

2 participants