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

Qmc5883 #14714

Closed
wants to merge 2 commits into from
Closed

Qmc5883 #14714

wants to merge 2 commits into from

Conversation

osgjps
Copy link

@osgjps osgjps commented Feb 4, 2022

Description:

Related issue (if applicable): fixes #

Checklist:

  • [ X] The pull request is done against the latest development branch
  • [ X] Only relevant files were touched
  • [ X] Only one feature/fix was added per PR and the code change compiles without warnings
  • [ X The code change is tested and works with Tasmota core ESP8266 V.2.7.4.9
  • [ X] The code change is tested and works with Tasmota core ESP32 V.2.0.2.1
  • [ X] I accept the CLA.

NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass

@osgjps
Copy link
Author

osgjps commented Feb 4, 2022

This PR is technically for the QMC5883. I don't have an HMC5883L to test with, I misnamed the branch when I created it.

@ascillato2 ascillato2 changed the title Hmc5883l Qmc5883 Feb 4, 2022
@ascillato2
Copy link
Collaborator

ascillato2 commented Feb 4, 2022

Hi,

Thanks for sharing.

This PR will fail for all languages versions except for English due to missing keys. Please, add the missing keys to the rest of language files. Don't need to translate it. Just copy the same you have in the English file. Thanks

Copy link
Contributor

@barbudor barbudor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes to be done to be a good Tasmota driver

Comment on lines +125 to +129
// xsns_96_QMC5883.ino
#define D_JSON_MX "Compass X-Axis"
#define D_JSON_MY "Compass Y-Axis"
#define D_JSON_MZ "Compass Z-Axis"
#define D_JSON_HEADING "Compass Heading"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are wrong names for JSON keys
A JSON key must be a valid variable name in Javascript with only alphanumeric characters + underscore and starting with an alpha character.
Spaces, dash or other separators are illegal.
Please fixe

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, that is not a requirement for JSON keys (which can be any valid string), only if you "happen" to want to use it with backend tools enforcing restrictions on names. Tasmota even introduced an option to replace hyphen with underscore to appease such tools. Still, I'd regard it as "best practice" to avoid names causing hair loss with people wanting to use it with JavaScript or similar....

bool ready;
uint8_t i2c_address;

} QMC5883;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not allocate statically the memory for your driver
This is taking useless amount of RAM when the driver is part of a build but not used

Use dynamic allocation as in the HMC5883 driver

if (FUNC_INIT == function) {
QMC5883_Init();
}
else if (QMC5883.ready) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar, look at the HMC5883 driver. Use the dynamic pointer for that purpose instead of wasting a byte

@github-actions
Copy link

github-actions bot commented Mar 7, 2022

This PR has been automatically marked as stale because it hasn't any activity in last few weeks. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Action - Issue left behind - Used by the BOT to call for attention label Mar 7, 2022
@github-actions
Copy link

This PR was automatically closed because of being stale.

@github-actions github-actions bot closed this Mar 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Action - Issue left behind - Used by the BOT to call for attention
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants