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

Add some functions to PCF8523 (Alarm) #291

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

aurelihein
Copy link

Thank you for creating a pull request to contribute to Adafruit's GitHub code!
Before you open the request please review the following guidelines and tips to
help it be more easily integrated:

  • Describe the scope of your change--i.e. what the change does and what parts
    of the code were modified.
    This will help us understand any risks of integrating
    the code.
    This PR just add few functions to PCF8523, and add Alarm function

  • Describe any known limitations with your change. For example if the change
    doesn't apply to a supported platform of the library please mention it.
    It should work straight everywhere

  • Please run any tests or examples that can exercise your modified code. We
    strive to not break users of the code and running tests/examples helps with this
    process.

It is straight forward

Thank you again for contributing! We will try to test and integrate the change
as soon as we can, but be aware we have many GitHub repositories to manage and
can't immediately respond to every request. There is no need to bump or check in
on a pull request (it will clutter the discussion of the request).

Also don't be worried if the request is closed or not integrated--sometimes the
priorities of Adafruit's GitHub code (education, ease of use) might not match the
priorities of the pull request. Don't fret, the open source community thrives on
forks and GitHub makes it easy to keep your changes in a forked repo.

After reviewing the guidelines above you can delete this text from the pull request.

Let me know if you need any modification
Best regards,
Aurelien BOUIN

Copy link
Contributor

@edgar-bonet edgar-bonet left a comment

Choose a reason for hiding this comment

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

I have a few suggestions that could help make this pull request better. Note, though, that this is just my opinion: I am only a contributor here, not a maintainer.

  • Name the new methods using camelCase rather than snake_case, as this is the style used in the current code.
  • Make sure your code does not introduce new warnings, even when the IDE is configured to show “All” warnings. Specifically, you should have seen a couple of warning: '<<' in boolean context that reveal actual coding errors.
  • Test the code, even if it is straight forward.
  • Write a more descriptive commit message.
  • When writing the pull request cover letter, remove the default text with the guidelines.
  • If the CI reports a failure, check what is wrong and fix it.

/**************************************************************************/

bool RTC_PCF8523::is_alarm_fired(void) {
return (read_register(PCF8523_CONTROL_2) && (1 << 3));//Check AF
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return (read_register(PCF8523_CONTROL_2) && (1 << 3));//Check AF
return (read_register(PCF8523_CONTROL_2) & (1 << 3));//Check AF

/**************************************************************************/

bool RTC_PCF8523::is_any_alarm_setup(void) {
if(read_register(PCF8523_CONTROL_1) && (1<<1)){
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if(read_register(PCF8523_CONTROL_1) && (1<<1)){
if(read_register(PCF8523_CONTROL_1) & (1<<1)){

Comment on lines 207 to 216

#ifdef DEBUG_RTCLIB
DEBUG_RTCLIB.printf("I2C_W(0x%02X,0x%02X)\n",3,buffer[1]);
DEBUG_RTCLIB.printf("I2C_W(0x%02X,0x%02X)\n",4,buffer[2]);
DEBUG_RTCLIB.printf("I2C_W(0x%02X,0x%02X)\n",5,buffer[3]);
DEBUG_RTCLIB.printf("I2C_W(0x%02X,0x%02X)\n",6,buffer[4]);
DEBUG_RTCLIB.printf("I2C_W(0x%02X,0x%02X)\n",7,buffer[5]);
DEBUG_RTCLIB.printf("I2C_W(0x%02X,0x%02X)\n",8,buffer[6]);
DEBUG_RTCLIB.printf("I2C_W(0x%02X,0x%02X)\n",9,buffer[7]);
#endif /* DEBUG_RTCLIB */
Copy link
Contributor

Choose a reason for hiding this comment

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

Debug statements probably do not belong to this pull request.

src/RTClib.cpp Outdated
Comment on lines 68 to 70
#ifdef DEBUG_RTCLIB
Serial.printf("I2C_W(0x%02X,0x%02X)\n",reg,val);
#endif /* DEBUG_RTCLIB */
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#ifdef DEBUG_RTCLIB
Serial.printf("I2C_W(0x%02X,0x%02X)\n",reg,val);
#endif /* DEBUG_RTCLIB */

src/RTClib.cpp Outdated
Comment on lines 85 to 87
#ifdef DEBUG_RTCLIB
DEBUG_RTCLIB.printf("I2C_R(0x%02X)=0x%02X\n",reg,buffer[0]);
#endif /* DEBUG_RTCLIB */
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#ifdef DEBUG_RTCLIB
DEBUG_RTCLIB.printf("I2C_R(0x%02X)=0x%02X\n",reg,buffer[0]);
#endif /* DEBUG_RTCLIB */

@aurelihein
Copy link
Author

Thank you @edgar-bonet for your time
I have updated the PR following your advice

@edgar-bonet
Copy link
Contributor

Great!

LGTM, but note that clang-format is being picky about your formatting, hence the CI failure. You may want to

clang-format -i src/*

or, alternatively, patch the output of the clang-format test failure to git apply.

@aurelihein
Copy link
Author

Thanks again @edgar-bonet
clang-format applied

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