Conversation
|
Does the count from 255 to 0 constitute 1 second? Or does it roll around many times in 1 second? |
|
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())) |
|
Actually, it's not multiple roll arounds. Try: 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). |
|
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 I'll do a rebase to squash the commits... |
|
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: will run myscript.py (from the local PC) on the pyboard. |
No description provided.