Seeed-Studio / Seeed_Arduino_AS5600

The library comes with AS5600. Through this library, we can realize read the angles 、get magnetic from a magnet underneath the sensor.
MIT License
105 stars 38 forks source link

Comments in AS5600.cpp incorrect in detectMagnet and getMagnetStrength() #5

Closed steve-arnold closed 3 years ago

steve-arnold commented 3 years ago

Describe the bug Not really a bug but inaccuracies in the comments which confused me

To Reproduce In the function int AMS_5600::detectMagnet() and AMS_5600::getMagnetStrength() The comments describing the status register does not correspond with the way the code is working which is confusing. The incorrect comments :- /0 0 MD ML MH 0 0 0/ / MD high = AGC minimum overflow, Magnet to strong / / ML high = AGC Maximum overflow, magnet to weak/ / MH high = magnet detected/ Purpose of the bits is really self explanatory MD Magnet Detected, ML Magnet Low, MH Magnet High I suggest that the comments be amended to match the published datasheet as follows. It should be /0 0 MD ML MH 0 0 0/ / MD high = Magnet was detected/ / ML high = AGC maximum gain overflow, magnet too weak/ / MH high = AGC minimum gain overflow, magnet too strong/ This should be done in both detectMagnet() and getMagnetStrength() functions. Additionally, the header for detectMagnet is incorrect being-

/ / Method: detectMagnet / In: none / Out: 1 if magnet is detected, 0 if not / Description: reads status register and examines the / MH bit /***/ It should read :- /* / Method: detectMagnet / In: none / Out: 1 if magnet is detected, 0 if not / Description: reads status register and examines the /* MD bit /***/

Expected behavior See texy above Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

steve-arnold commented 3 years ago

Another typo in the header for the function readTwoBytes. The header comments state that the function in readOneByte.

Pillar1989 commented 3 years ago

Can you send us a PR about this? @steve-arnold

steve-arnold commented 3 years ago

PR made and changes have been merged. Thank you.