Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[ports/rp2] new machine_rtc.c module #6923

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

Closed
wants to merge 22 commits into from
Closed

[ports/rp2] new machine_rtc.c module #6923

wants to merge 22 commits into from

Conversation

astrorafael
Copy link

Hi
Although I was delighted to see micropython support in the new Raspberry Pi Pico, I as a bit surprised that there was no machine.RTC class for this port. So I took the plunge and began writting a basic machine_rtc.c module and learning in the process a bit about how to make an extension C module. This module is very basic for the time being (no interrupt handling) and conforms (I hope) to the interface documented in the MicroPython 1.14 official documentation.

The python test code is this:

from machine import RTC
from utime import sleep, sleep_ms

def test_main():
    rtc = RTC(0)
    print(rtc)
    print(rtc.now())
    remaining = rtc.alarm(0, 5000, repeat=False)
    while (remaining >0):
        print("{0:d} ms. left".format(remaining))
        sleep(1)
        remaining = rtc.alarm_left()
    print("done")

def test_cancel():
    rtc = RTC(0)
    print(rtc)
    print(rtc.now())
    remaining = rtc.alarm(0, 5000, repeat=False)
    while (remaining >0):
        print("{0:d} ms. left".format(remaining))
        sleep(1)
        remaining = rtc.alarm_left()
        rtc.cancel()

def test_1sec():
    rtc = RTC(0)
    rtc.init((2015, 1, 1, 1, 0, 0, 0, None))
    sleep_ms(1002)
    print(rtc.now())

@astrorafael
Copy link
Author

Ok. I see that I have to get throught the formatting code & commit workflow. Will resubmit when ready.

@stinos
Copy link
Contributor

stinos commented Feb 18, 2021

Looks ok on first sight, but can you start by fixing style inconsistencies and other issues: squash in everything into logical commits (in this case: 2 of them, one which modifies .gitignore because that is unrelated to the rest, the other one which ads the module). Then, some things are pretty hard to read: we don't generally use hard-to-maintain mixed comment styles like // -------------------- or //###### or '/**'. Instead just use one single comment style with // . Except for the license (which should also look like all others i.e. not start with your custom text). Also only use comments when needed: stating the obvious is not needed. Likewise for dead code: generally not left as-is.

#include "pico/util/datetime.h"

// ------------------
// Exported constants
Copy link
Contributor

Choose a reason for hiding this comment

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

There's no such thing as 'exporting' a PP define

Copy link
Author

Choose a reason for hiding this comment

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

ok

Copy link
Author

Choose a reason for hiding this comment

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

Regarding the number of commits, this means that I'll have to delete my fork and start from scratch, right?
Also I have to fix the commit message style.

Copy link
Contributor

Choose a reason for hiding this comment

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

this means that I'll have to delete my fork and start from scratch

No. There are a bunch of ways to do this. Given the number of commits: something like git reset --mixed will keep all your changes but erase all commits, so you can create a single new one.

Copy link
Author

Choose a reason for hiding this comment

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

Finally I started from scratch and issued PR #6929 . I tried git reset --mixed but wasn't sure about the results and didn't want to mess it up with the commits.
In the mean time, it seems another developer wants to PR (#6928) another implementation of the same port and functionality.
Funny ...

Copy link
Author

Choose a reason for hiding this comment

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

t seems that, somehow, updating my local & remote repos with upstream and doing git reset --mixed, made PR #6929 to close. I did not want to close it on purpose. Now there is a #6932, with all green lights. Sorry for all this mess and thank you for your support. It is also ok with me if the project chooses #6928.

@astrorafael
Copy link
Author

Closed, since it is duplicated with #6932 and I know now how to make PRs complying with MicroPython standards

tannewt pushed a commit to tannewt/circuitpython that referenced this pull request Oct 22, 2022
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