8000 RTC doc fix by lurch · Pull Request #555 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

RTC doc fix #555

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

Merged
merged 3 commits into from
May 3, 2014
Merged

RTC doc fix #555

merged 3 commits into from
May 3, 2014

Conversation

lurch
Copy link
Contributor
@lurch lurch commented May 3, 2014

No description provided.

@dpgeorge
Copy link
Member
dpgeorge commented May 3, 2014

Does the count from 255 to 0 constitute 1 second? Or does it roll around many times in 1 second?

@lurch
Copy link
Contributor Author
lurch commented May 3, 2014

Multiple roll-arounds. Tested with this code:

subsecs = dict()
for i in range(256):
    subsecs[i] = 0

rtc = pyb.RTC()
func = rtc.datetime
startsecs = (func()[6] + 1) % 60
while func()[6] < startsecs:
    pass

while True:
    tup = func()
    subsecs[tup[7]] += 1
    if tup[6] > startsecs:
        break

print(sorted(subsecs.values()))

@dpgeorge
Copy link
Member
dpgeorge commented May 3, 2014

Actually, it's not multiple roll arounds. Try:

rtc = pyb.RTC()
for i in range(10000):
  dt = rtc.datetime()
  print(dt[6], dt[7])

You may already be doing this, but, FYI, you can run scripts directly from your PC (ie without copying to the pyboard) using pyboard.py (see comment at top of that file).

@lurch
Copy link
Contributor Author
lurch commented May 3, 2014

Doh! I feel so stupid now. Of course there was a bug in my code. The fixed version is:

subsecs = dict()
for i in range(256):
    subsecs[i] = 0

rtc = pyb.RTC()
func = rtc.datetime
last_ss = None
startsecs = (func()[6] + 1) % 60
while func()[6] < startsecs:
    pass

while True:
    tup = rtc.datetime()
    if last_ss != tup[7]:
        last_ss = tup[7]
        subsecs[last_ss] += 1
    if tup[6] > startsecs:
        break

print(sorted(subsecs.values()))

which then indeed only prints 1s.

I'll do a rebase to squash the commits...

@lurch
Copy link
Contributor Author
lurch commented May 3, 2014

I've simply been copy-pasting my scripts into the interactive REPL :)
Take that, Arduino! ;-D

@dpgeorge
Copy link
Member
dpgeorge commented May 3, 2014

I've simply been copy-pasting my scripts into the interactive REPL :)

I just pushed a change to pyboard.py so that it can be used as a command-line program that runs a local script on the pyboard. Eg:

$ python pyboard.py myscript.py

will run myscript.py (from the local PC) on the pyboard.

dpgeorge added a commit that referenced this pull request May 3, 2014
@dpgeorge dpgeorge merged commit b4bb3fd into micropython:master May 3, 2014
@lurch lurch deleted the patch-1 branch May 3, 2014 17:48
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
0