#circuitpython-dev
1 messages ยท Page 169 of 1
ah - it complained about an invalid kewword!
I figured out a thing!!
I need to put 3.0 on a CPX
Or rather a new version of it. I have one I bet isn't up to date.
I'm glad I had some time to play with CPX on 3,0 today -- With Dan's help got audio.play working again. my examples from 2.x all needed to be updated. Even found a bug!
Are you updating to master?
yes - but I didn't fix the bug -- just found it ๐
No, I was going to ask if you could drop me a uf2 ๐
Brilliant, thank you so much
let me make sure it runs ๐
@solar whale can you drop me a working FrequencyIn that doesn't lock up past 512kHz and clears the registers when I want them to be clear? kthx. ๐
sweet! hehe
i wish i could trust this darn datasheet. i'm tempted to try and cross the DMA threshold, but not sure if it works for capture.
Well this fixes the 3.0 issue with my additions: ```python
# Define sound sensor/mic:
try:
self._mic = audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA,
sample_rate=16000, bit_depth=16)
except TypeError:
self._mic = audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA,
frequency=16000, bit_depth=16)
self._samples = array.array('H', [0] * 160)
self._mic.record(self._samples, len(self._samples))
Does not fix the rest of the problems with the lib.
@raven canopy someday I hope to get as deeply into thi as you have!
@raven canopy As do I! seriously.
jump on in you two! the waters fine! hehe. C only looks scary. plomise.
I would but I only know Python, really.
I'm fine with C -- its the nested and convoluted calling paths that get me lost...
as good as you're getting at Python, C won't be too difficult to tackle methinks.
Thanks... ๐
and C lint is much more forgiving than pylint ๐
@solar whale i feel ya on that. its why things take me so long. "but....why does this need to be done?". ๐
I'm half tempted to make a 3.x compatible version of this lib but that defeats the purpose.
Also, wait, does that mean LIS3DH doesn't work with 3.0 regardless?
not unlees you fix the driver!
So it would look like this? ```python
try:
import collections
except ImportError:
import ucollections as collections
That's what struct looks like.
it just needs a try...yep. that's it
but it does not impre all of collections - wasn't shure how to handle it
Also means updating the usage of it because they bloody imported it as "from blah import whatever" so I have to update every instance of it too apparently.
Here's what's in there now from ucollections import namedtuple
So I guess ```python
try:
from collections import namedtuple
except ImportError:
from ucollections import namedtuple
?
looks good to me
Ok. Man.. This driver and I have history. glares
lis3dh, have you met my friend ๐ฅ ?
made taht change --- ```Adafruit CircuitPython 3.0.0-alpha.6-149-gbe12e07 on 2018-05-19; Adafruit CircuitPlayground Express with samd21g18
import lis3dh_simpletest
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "lis3dh_simpletest.py", line 7, in <module>
MemoryError: memory allocation failed, allocating %u bytes
it worked just deleteing th "u"
ohnoes! i thought we (Dan) fixed the %u occurrence...
wait
my bad - I used a .py by mistake -- all good with a .mpy
need to check it on 2.0 now.
I had to juggle the sys.path order to move .frozen
not for lis3dh, but for express
or else it picked up the .frozen lis3dh driver
I changed it.
Yeah that's what I checked first. Scroll up
it worked for me
I'm so turned around trying to test this on 2x and 3x lol
no it's only PDMIn I think
Yeah that's all it uses.
I created a PR and added you as a reviewer @solar whale . For LIS3DH.
Still building travis. Should have linted it. Always forget when it's something simple.
thanks
ooh passed.
ah -- play_file will fail under3.0
Ok.
PR looks good - have you tried it under 2.x yet?
thought so, but now I'm looking at it and I think I have a memory failure. so let me try it by itself. hold on.
ok good
do you want me to approve it or do you want other reviews?
I got it working! Nope go ahead and approve it
Making a list of everything that needs to be done now. Since it's turning into a list.
should I merge it as well?
Yah might as well. It's necessary for 3.x right? And we were making this change where we find it as we go.
I'll do the release.
should we re-open the "change ucollections to collections" issue, and add the library list?
Well it's done now ๐
I don't think we need to reopen the issue to add it and say it's done.
cool - my frsit merge!
Oh nice!
No idea, @raven canopy
ahh. well, like i (think) i said earlier, adabot should put out a list of autodoc fails...
Oh right.
I wasn't sure how it covered this though. It might.
Ok so play_file will fail.
thsi should fix it ``` wav = open(file_name, "rb")
audio = audioio.AudioOut(board.SPEAKER)
audio.play(wav)
I can imprt cpx now
RuntimeError: Unable to allocate buffers for signed conversion
That's not in the lib
that's just trying to do it in code.py
ok
try ``` # Play a specified file.
self._speaker_enable.value = True
data = open(file_name, "rb")
f = audioio.WaveFile(data)
audio = audioio.AudioOut(board.SPEAKER)
audio.play(f)
the loud detector ran ' for ahwile " with my updated express - then it hung my baord ๐ฆ
import audioio
import audiobusio
import digitalio
speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
speaker_enable.switch_to_output(value=False)
file_name = "eep.wav"
data = open(file_name, "rb")
f = audioio.WaveFile(data)
audio = audioio.AudioOut(board.SPEAKER)
audio.play(f)
print("stopped")
had to hard reset, but its progress
Prints "stopped" and does nothing.
I'm trying to get this to run simply in code.py before trying to mess with the lib.
add somethting like ```
print("playing")
a.play(f)
while a.playing:
pass
print("stopped")
need to let it ply
need to let it play
f = audioio.WaveFile(data)
audio = audioio.AudioOut(board.SPEAKER)
print("playing")
audio.play(f)
while audio.playing:
pass
print("stopped")```
prints playing and stopped.
so it's running...
the wav file is there and the laptop plays it
thsi works for me ```import board
import audioio
import digitalio
Required for CircuitPlayground Express
speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
speaker_enable.switch_to_output(value=True)
data = open("WhoHitMe.wav", "rb")
f = audioio.WaveFile(data)
a = audioio.AudioOut(board.A0)
print("playing")
a.play(f)
while a.playing:
pass
print("stopped")
ok works for me too
working backwards
ok
ยฏ_(ใ)_/ยฏ
It works even with starting with speaker_enable = false, and then enabling and disabling it later
Ok so ```python
def play_file(self, file_name):
self._speaker_enable.value = True
audio = audioio.AudioOut(board.SPEAKER)
file = audioio.WaveFile(open(file_name, "rb"))
audio.play(file)
while audio.playing:
pass
self._speaker_enable.value = False
I think that should work
looks OK to me - let me try it.
I took out touch and the rest works on 3.x!
hmm - somehting not right - cant import cpx now
trying again
can you post your new express.py
I think this is right.
can you post the .py? my Filesystem just got corrupted -- need to rebuild
yes.
I'm working in two places with this because I think some things won't work on 2.x that work on 3.x so hopefully that's the right one
So glad I held my PR for this back
Hehe. instead of a Travis & Rosie CI...we need to build a Jerry CI. ๐
Jerry already is CI ๐
ok.
So there needs to be two versions of this file then, apparently.
if we intend to freeze it in to both.
Wait!
No I'm wrong!
nope - FS i s gone -- ๐ฆ
We figure out the error on 2.x and have it say "UPDATE ALREADY"
except nicer.
And that error would be this: TypeError: function takes 2 positional arguments but 1 were given
so no more play_file on 2.x basically.
or detect version and use different API's -- yuk
i was about to say that. import os and check the version...
oh well get all fancy why don't you
๐
File "code.py", line 4, in <module>
File "/Users/kattni/CPXDev/express.py", line 610, in play_file
RuntimeError: Oops! You need a newer version of CircuitPython (3.0 or greater) to use this feature.```
Is what I just made it do.
not worth the overhead really if you're already close to import limit...
how do you check version with os
runs to look since he opened his big mouth before looking
๐
os.uname
>>> import os
>>> os.uname()
(sysname='samd21', nodename='samd21', release='3.0.0', version='3.0.0-alpha.1-514-g83e3907-dirty on 2018-04-29', machine='Adafruit Feather M0 Express with samd21g18')
Ok.... so what does that do for me. How do I use that
i think there is even a simple way - trying to find it.
Ok, I see that gets the "release='3.0.0'`
oh
ok
>>> if os.uname()[2] = '2.3.0'
... print("true")
...
Traceback (most recent call last):
File "<stdin>", line 1
SyntaxError: invalid syntax```
So that doesn't work that easily ๐
can you regex it
? you're the python expert...
>>> version = os.uname()[2]
>>> version
'3.0.0'
>>> print(int(version[0]) < 2)
False
>>> print(int(version[0]) < 4)
True
>>>
python is too modular sometimes... haha
So let's take this one step further
So ok let's take this one step further... we've identified the OS. What does that do for me? Do I include both versions of play file and have it skip over one and go to the other or something?
That's the part I'm fuzzy on
I just found that yesterday and took awhile to find it again
or you just raise the exception at init and say "UPGRADE SILLY!"
I was going to suggest split('.') but sys.implementation is a better approach
in the code you could test and have an if/else foe each API variant -- messy
Yeah and this lib is already huge.
Mostly I'm thinking we're stuck in a limbo place at the moment. Because of touchio.
hey, we try and stay inline with CPython, right? we need a 2to3 module now. ๐คฃ
we do have differnt libs arerady -- at leas with the ,mpy
And this is going to be frozen in, so it can be big.
But that's my concern is we'll still freeze it into 2.x, and features will fail.
so could have a py2x and a py3x for the .py files
for the record: THAT WAS A JOKE! please, please, don't make me write that module... ๐
And stop updating the 2.x version. So we're done with it.
yes - frozen...
Right.
Except for the part where I want the sound stuff I just added for the guide I'm doing that will be due in 2 weeks likely. Unless I figure something else out and put it off.
touchio will be done in less time than that, I bet. But still my point stands.
Scott started touchio already, right?
Yes, but then PyCon
well, yeah. that.
at least I think he did
he might have only looked into it, not sure how far he got.
I remember now thinking he was ok with other people looking at it, so maybe he didn't get so far.
At the PyCon sprints I mean.
well, when it comes to those datasheets, looking at it is what takes the most time. ๐
Yeah.
This really only impact audio stuff -- so may ahve to just keep compatibility by testing version.
hmm
this could be done in C in the audioio code, no?
maybe not -- there are a lot oc changes in 3.0
if sys.implementation(whatever):
else whatever:
Not sure how long we want to be backwards compatible. But we've already put in a lot that is like with ustruct and so on.
if sys.implementation.version[0]==3:
use 3 stuff
else
use 2 stuff
yeah I can put that inside play_file right?
I think so.
about to find out ๐
should be able to. and there should be a place a C land to find the info. otherwise sys.implementation wouldn't work...
Memory error.
@raven canopy I'm sure you can detect the version - but there are some any API changes, I'm not sure it will e so easy to map.
On this line audio = audioio.AudioOut(board.SPEAKER, open(file_name, "rb"))
on 3,0 cant have 2 arguments
that's in the else, I'm testing on 2.x
ah -- I was hoping it did not check the API if i did not execute
# Play a specified file.
self._speaker_enable.value = True
if sys.implementation.version[0] == 3:
audio = audioio.AudioOut(board.SPEAKER)
file = audioio.WaveFile(open(file_name, "rb"))
audio.play(file)
else:
audio = audioio.AudioOut(board.SPEAKER, open(file_name, "rb"))
audio.play()
while audio.playing:
pass
self._speaker_enable.value = False```
memory allocation error -- just too much code
Doesn't matter if the while is inside the if/else
no it just say s"memory error"
with no info
sys is in py/modsys.c, so should've survived revision. still digging.
MemoryError
ok now it's doing it in 2.x regardless. give me a few minutes here.
ok I reverted to the earlier version and it works. it was giving me MemoryError even without any of the 3.x code in it. bleh.
the if/else code works on 3.x
now testing again on 2.x
File "code.py", line 3, in <module>
File "/Users/kattni/CPXDev/express.py", line 614, in play_file
MemoryError:```
That's with less code because this version of the lib has no touchio in it.
๐
MemoryError isn't memory allocation.
is the erro on 2.x or 3.x
2.x
does using a context manager use more or less memory? with open("filename","rb") as f: -- that way the file gets closed
Oh!
I just added the code to the 2.x version of the lib, with touchio in it, and it worked!
woohoo!
I have two working versions
break time for me. see ya'll later. and yay!!!!!!!!!!!!!!!
one with only the loud_sound stuff added
later @raven canopy !
so it still has touchio in it.
@raven canopy have fun!
and it works...
nice!
ok I removed touchio and put it back on 2.x and it still works. And it works on 3.x
As long as it's using the updated lis3dh
(had to go alter that back as well)
so it works.
sounds good.
so that only leaves touchio. Which will come. And probably won't change. ๐
Not a bad days work! Actually this went much more smoothy than I feared.
Agreed
So I'll put in a PR for this version:
And we need to get the frozen version of LIS3DH updated.
does it need the new lis3dh?
right
Only for 3.x
it'll work for both but no need to change 2.x
So it'll work on 2.x as is, and 3.x with the new version of LIS3DH
right
Well, it won't work on 3.x until we have touch, but otherwise yes.
true - so should the PR go in now or wait for touchio
So my list is PR for this, get LIS3DH refrozen, and this lib refrozen. Which means another 2.x release ๐ And we're about to do another 3 alpha as well so
Depends. It's already frozen into 3.x and not working, so no reason not to update it. Also, the sound_level and loud_sound, I'd like to have for the guide I'm working on.
It's up to what Dan wants to do probably
right, but unless you take out touchio, it won't load in 3.0
true!
The guide will assume the latest stable version
OK - I see - makes sense - no harm done.
That was fun! ๐
It was! Well done!
Thanks! You too!
cool ! new play_file works on my 3.0
nice!
but loud still locks up my system ๐ฆ
hmm.
works for a few seconds then freezes
Oh hmm.
while True:
print(cpx.sound_level)
if cpx.loud_sound():
cpx.pixels.fill((50, 0, 0))
else:
cpx.pixels.fill(0)
Yah I'm getting that.
I guess I feel better ๐ฆ
Why though?... all it's doing is checking levels against a threshold...
Oh.
That's what's crashing.
Sound levels.
while True:
print(cpx.sound_level)``` just crashed.
need more noise ??
(back from being out) another 2.x release is fine, since it fixes the "SD card" bug that was really boot_out.txt
Hi @tulip sleet ๐
only on 3.x
did you have the absolute latest build since Scott accepted my PR's today?
Not sure, do I @solar whale ?
yes
hmm, i was hoping not ๐
what's the version line in boot_out.txt or the REPL?
I just want to see the commit
um... bootout is saying 2.3 on both. let me reload and try to get to the REPL
Adafruit CircuitPython 3.0.0-alpha.6-149-gbe12e07 on 2018-05-19; Adafruit CircuitPlayground Express with samd21g18
๐
I was so excited I managed to get to the REPL before it crashed. I pasted anyway ๐
pulled and built at ~1945
darn, thought maybe it was the boot_out.txt fix that would fix it. I will try a
while True:
print(123.4567)
to see if it's print or the sound code
but it does fail in the repl if you the same thing with cpx.sound_level?
just strated in REPL (via paste 9control-e) running happily --- oops just froze
๐
oh the print buffer was killing it
I just reloaded and it let me import at least
ran longer than before
after printing (123.4567)
indeed it does
run longer
Way longer
Still going for me
mine died again after 10 seconds
I had my FS corrupted earlier but then I waited for the terminal session to close itself. Now I am dismounting CIRCUITPY when it freezes the doing hard reset - so far so good.
Oh I keep hitting reset. Probably not the best way to do it.
i'm confused. is it dying at all just printing 123.4567?
ok, good. no that's fine
I am going to have to bail and get some sleep -- good luck!
me too
g'night!
my pleasure -- good night!
Goodnight!
Wondering if anyone can help me with a micropython issue. I am trying to store a file for reading in folder/subfolder/file.text. Everything I try fails to read the subdirectory. I was able to create it with os.mkdir('folder') then another call os.mkdir('folder/subfolder') but every attempt to read/write the contents of subfolder fail with a "OSError: [Errno 2] ENOENT"
this all works perfectly if I do: folder/file.txt
Can I ask more about sercom
Selection
?
@hellsbreath#6510 have you tried. . dots. Instead of slashes ?
@tiny bramble do you mean CircuitPython or MicroPython? Which board and which version of Python?
@marble hornet what's your question
@tulip sleet MicroPython but I am guessing it should be the same for CircuitPython (maybe?). the ESP8266 port v esp8266-20171101-v1.9.3 - Python version 3.4.0
@marble hornet Same result using dots vs forward slashes
@tiny bramble
This works for me with CircuitPython 3.0 on the ESP8266:
>>> import os
>>> os.listdir()
['boot.py', 'foo.txt']
>>> os.mkdir('dir1')
>>> os.mkdir('dir1/dira')
>>> f = open('dir1/dira/foo.txt', 'w')
>>> f.close()
>>> os.listdir('dir1/dira')
['foo.txt']
let me run that exact script
oh I feel dumb... I was doing os.listdir('folder/subfolder') but it had no contents so it was complaining
Thanks Dan!
apparently empty results are the same as no path found
I was expecting listdir to return [] on the folder/subfolder
os.listdir('rooms')
['town', 'wilderness', 'tavern.json']
os.listdir('rooms/town')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 2] ENOENT
town and wilderness subdirs were created with mkdir
Creating new folders works there
this is part of a much larger script so I am trying to isolate where my build script failed
could you try:
>>> os.rmdir('rooms/town')
>>> os.mkdir('rooms/town')
>>> os.listdir('rooms/town')
os.rmdir('rooms/town')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: 20
I am guessing it created it as a file
let me stat it
yes, I get the same sorts of errors if it's really a file
irony: including a procedure to check if a function is in "lockup territory", then the checking procedure results in a lockup. ๐ค
unrelated to current discussion ๐
I'm now thinking about the details of implementing cached bus objects. The busio I2C and UART allow some settings (like frequency, baudrate, parity) when they are created. So perhaps I should throw an error if there's a matching cached bus object, but its current settings do not match the settings requested in the __init__ call?
Great! You're welcome!
is there ANY way we can catch interrupt overflows and SUCCESSFULLY bail? i've tried 3 different ways, and it just causes a non-responsive state anyway. get's hung up in USB write land during mp_raise_SomeException. i'm trying inside the interrupt_handler function...
@raven canopy does it work in 2.x? The USB stack is different there.
haven't even tried building this in 2.x. (tbh..i don't want to) ๐
Is this FrequencyIn?
yessir
what do you mean exactly by interrupt overflows? You mean an interrupt while inside an interrupt handler?
but, if we can get this to work, i can also apply it to PulseIn (original issue).
well, the problem is we're getting stuck in CircuitPython when the interrupts happen quicker than we can process.
i've tried to implement a hardline check to bail. psuedocode:
void frequencyin_interrupt_handler {
if (tc->COUNTER_value < MAX_FREQUENCY) {
frequencyin_pause;
mp_raise_RuntimeException("BAIL!");
}
}
even wrapping the pause with common_hal_mcu_disable_interrupts and re-enable before raising the exception doesn't work...
are there other examples of raising an exception inside an interrupt handler? I wasn't sure that was a good idea?
checking the TC error and overflow registers bails to quickly, but even results in the same behaivor.
you could set a flag to raise an exception in the non-interrupt code
no, there aren't. and maybe that's why (bad idea). might just be a documentation thing: "doesn't work beyond XkHz".
yeah, i also tried something on the python side. didn't work, but i may have tried too close to the curve.
i'm still tempted to give DMA a shot. but the SAMD21 datasheet cannot be trusted on some things... ๐
an mp_raise (calls nlr_raise) doesn't return. I don't think you want to enter the Python world in the interrupt handler.
ahh. no..not that way. tried it like this on the python side:
if (tc.value > 0):
if (tc.value < 95):
#bail
print(tc.value)
no, but I mean you can't throw an exception inside an interrupt handler. You just want to note the problem, return from the interrupt handler, and in the C code that's running the Python code you'll check for the problem and then throw there. Also once you bail you want to turn off further interrupts until you've had a chance to recover.
hmm. so maybe in the frequencyin_get?
all our Python code that uses interrupts is synchronous at the higher level. It's busy-waiting on completion (or failure). We don't do interrupts in Python space. We just use interrupts for convenience at the lower level. So frequencyin_get waits for the frequency measurement to complete, or it sees that an error happened. If there's an error, it will throw the exception, not the interrupt handler. The interrupt handler would just note something bad happened by recording that in a status variable
ok...more psuedocode incoming, to make sure i understand what you're saying. ๐
void frequencyin_interrupt_handler {
if (tc.CAPTURE < MAX_FREQUECNY) {
self->overflow = true;
}
self->frequency = tc.CAPTURE
}
void frequencyin_get {
if (self->overflow) {
frequencyin_pause();
mp_raise_Expection();
}
}
it isn't completely true that nothing is asynchronous: e.g., audio playing is in the background, but there's nothing that can go wrong. If there were, we'd probably just give up quietly. But if we need a value, we wait for it. When we do audio recording, we block until the sample is all in memory.
yah, something like that, though you may want to shut things down (to prevent further interrupts) in the interrupt routine itself.
in your case you are waiting for a value, so you'd just wait until you do the measurement
yeah, that's the heart of the problem. keeping the handler from taking total control of the loop by repeatedly firing. obviously have to make the conditional conservative...
FrequencyIn MK 134 coming up... ๐
i don't know how your code works. Is the interrupt firing on input on a pin, and you're timing the frequency of those interrupts to measure the frequency? Could you also do something like PulseIn at a very high frequency and just look at the bits to measure the freq?
e.g. 111 000 111 000 means the freq is 1/3 of the PulseIn freq?
it's similar in structure to PulseIn, but using the SAMD's TC capture capability. unfortunately, the SAMD21 requires the EIC.EXINT and EVSYS for capturing from a pin... SAMD51's TC can tap the pin's input directly.
does frequencyin_get busy-wait right now waiting for the result? if you overflow in the interrupt handler, I think you'd want to disable the whole mess by turning off interrupts immediately and shutting down the TC, while you're in the handler. Then set the "uh-oh" flag. frequencyin_get will busy-wait on done or uh-oh.
frequencyin_get is "slim":
uint16_t common_hal_pulseio_frequencyin_get_item(pulseio_frequencyin_obj_t* self) {
return self->frequency;
}
let me put up a gist...
excuse the bloated garbage code/comments. :D
https://gist.github.com/sommersoft/d4dad82efba9ef0421452e690b51b308
so you can call frequencyin_get anytime? Is it up to the Python code to wait sufficiently long for it to get an accurate reading?
I thought maybe you would set a sampling period in which to measure the frequency. (I have not been paying attention to this whole thing.)
the TC does all that for you.
but suppose you have a really slow-frequency signal? what happens if you call frequencyin_get too early?
you could buffer it at the C level, but that's just going to give you a averageable range.
well, that's a good test point i didn't think about. let me check real quick (i've been using a feather m0 to gen the signal; 8khz to like 3Mhz).
so how about if the interrupt handler detects overflow, it does the equivalent of pause? That's just a register operation, so it can do that fine. and also sets the overflow flag. Then when the Python code calls frequencyin_get, it clears the overflow flag and throws an overflow exception. The Python code can do a resume later to restart the measurement. The overflow doesn't get noted until frequencyin_get is called.
i was thinking about like 1 Hz signals.
just started at 8hz...picked it up as soon as it started.
the overflow and error intflags actually get turned on pretty early at 8kHz. they're tripped when a capture is detected, but the CCx registers haven't cleared. which works well enough in a real-time environment i would think. but our VM can't keep up...
to save you (maybe too late) from digging through the datasheet, here is a visual on how the TC captures the freqency:
can we do a voice chat? I'm confused and it would be a lot faster.
yeah, let me grab my phone. also, just ran a test starting at 1Hz...it jumps a bit through about 4 or 5 different values.
i thought the overflow was your own creation. didn't realize it was the TC overflow
phone and app at the ready..
I'm in CircuitPython chat
der... ๐
@Dan Halbert#1614 , sorry was driving a robot at battlecry, I realised that my project is going to need a lot more memory. And a speed upgrade can't hurt. So I'm switching to the d51. But I will need to choose an spi port and other functionality. My question is:
For each serial com port how do you differentiate between each pin's purpose? And how do you set it ( pin name excluded) ?
Some boards (like the uGame10) may want to have their own set of extra
modules. This change lets them override EXTRA_BUILTIN_MODULES in their
mpconfigboard.h and makes the ugame10 board do that.
I'm trying the current master (be12e07d7437b9f2a75659bc944c15cccc8e93c1) on a crystal-less SAMD21 board with external flash (ugame10), and this code:
>>> import time
>>> time.sleep(0.1)
blocks forever.
It's fine on trinket m0.
I have some issues getting the adafruit_ssd1306 to work with the Feather express M0 board. I get a value error upon loading the lib. (saving the py file with import adafruit_ssd1306) is this a known issue? How can I solve it?
can you paste the complete error?
Traceback (most recent call last):
File "code.py", line 6, in <module>
File "adafruit_ssd1306.py", line 34, in <module>
ValueError: Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/mpy-update for more info.
Ah, you have the wrong .mpy file for the version of your circuitpython
I downloaded the latest version of circuit python earlier today. What can I do?
which one exactly?
hmm, I see the bundle only for 2.2 and 3.0
2.2 will work for 2.x
and this is the bundle that I was using: adafruit-circuitpython-bundle-2.2.3-mpy-20180520 (3)
Should* work...
you have several options: you can build the .mpy files yourself, or you can downgrade to 2.2
Also if that's the case, file an issue, because it should work. (Sorry cooking too, so I'm back and forth)
ok, good idea. I will rebuild. But you also build it May 20th 2018, I tried that one also with no luck.
no prob kattni. catch up later. I will report after my rebuild
Thanks, let us know!
@timber mango I just tried duplicating your setup, with a Feather M0 Express, and the bundle version and CircuitPython version you specified above. I did not get an error.
It's possible you might have multiple versions of the library on your CIRCUITPY. Did you ever download the 3.0 bundle by accident?
I know I tried it in an attempt to fix the problem. But quite sure that I restored the 2.2 version
also facing issues building.
building from OSX.
line 34 in adafruit_ssd1306.py is an import for adafruit_bus_device. So it may not be the ssd1306 library is that is the wrong version, but the adafruit_bus_device library
don't bother doing all these builds now, you should not need to do that yourself. I'd suggest saving any files of your own that are on CIRCUITPY, and then erasing and reformatting it:
>>> import storage
>>> storage.erase_filesystem()
then copy a fresh lib/ directory and your code.py/main.py back onto the drive.
Not unless you have the file elsewhere or are referring to the demo it shipped with (which is usually available for download).
is it still in your editor?
Well thank you for explaining @idle owl with your help and the help of @tulip sleet I can continue my journey. Super!
These are working:
Adafruit CircuitPython 3.0.0-alpha.6-149-gbe12e07d7 on 2018-05-20; Adafruit Feather M0 Express with samd21g18
>>> import time; time.sleep(0.1)
>>>
Adafruit CircuitPython 3.0.0-alpha.6-149-gbe12e07d7 on 2018-05-20; Adafruit CircuitPlayground Express with samd21g18
>>> import time; time.sleep(0.1)
>>>
@tulip sleet , sorry was driving a robot at battlecry, I realised that my project is going to need a lot more memory. And a speed upgrade can't hurt. So I'm switching to the d51. But I will need to choose an spi port and other functionality. My question is:
For each serial com port how do you differentiate between each pin's purpose? And how do you set it ( pin name excluded) ?
@marble hornet not sure I get the question exactly. You mean how do you decide which pins for which functions? On the Metro M4 using the labelled pins as such (TX, RX, SCL, SDA, and the SPI pins on the 2x3 header) works fine because we set it up so that they work. Otherwise you have to try them all, or look on the datasheet and schematic, or do something like this to enumerate the possibilities: https://learn.adafruit.com/circuitpython-essentials?view=all#wheres-my-uart (example is for UART)
Thanks, sounds good
Two things
I guess I'm curious on how the atSam D seecoms work. And how to say, figure out if a0 it is click line or a0 is data line
For example
@marble hornet The basic idea is explained here: https://learn.adafruit.com/using-atsamd21-sercom-to-add-more-spi-i2c-serial-ports?view=all. Involves studying the datasheet carefully
Throwing an error on mismatched settings is ok with me.
Why is this undef needed? My guess is there is somewhere we're including mpconfigboard.h directly when we should use py/mpconfig.h instead
@deshipu have you tried using GDB to see where its hanging?
<@&356864093652516868> and everyone else. We'll have our meeting at the regular time (11am Pacific / 2pm Eastern) here on Discord in the CircuitPython voice channel.
@slender iron If the lib is frozen, how does that affect how it's holding onto those bytes?
@idle owl those bytes will be in memory but I had forgotten the library is frozen
(they are in memory since they are writeable)
Ok. hmm.
I think it's worth having in the lib.
But now I'm wondering if I should try to initialise it only when it's used instead. And what that would look like.
okie, just beware space is precious
Agreed.
Would it be worth trying to initialise it when it's used then? Or does that not really solve the problem. Because at the moment it's taking up that space as soon as you load the lib, right?
I think so. It depends on where you want to error if you are out of memory
Ok so I have this in the express class python def sound_setup(self): # Define sound sensor/mic: try: self._mic = audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, sample_rate=16000, bit_depth=16) except TypeError: self._mic = audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, frequency=16000, bit_depth=16) self._samples = array.array('H', [0] * 160) self._mic.record(self._samples, len(self._samples)) and this is what it looks like in the code ```python
from express import cpx
cpx.sound_setup()
while True:
print(cpx.sound_level)
if cpx.loud_sound():
cpx.pixels.fill((50, 0, 0))
else:
cpx.pixels.fill(0)```
Like detect_taps, for tapped, it would be required for using the sound features.
wait a minute. @slender iron which line is taking up that memory? python self._samples = array.array('H', [0] * 160) self._mic.record(self._samples, len(self._samples))
the array.array
@tulip sleet @solar whale Ok so I can get 2.x to fail exactly the same way that 3.x is failing if I try to use cpx.start_tone/cpx.stop_tone with cpx.sound_level. What's weird is cpx.play_tone works fine with it. And play_tone is literally made up of start_tone/stop_tone. play_tone has a time.sleep() in it, but even adding a time.sleep into my start_tone/stop_tone code still allows it to crash.
cpx.play_file works fine.
It feels like a memory issue. Both sound_level and start_tone/stop_tone use arrays for samples.
Still doesn't explain play_tone working.
Hmmmmm.... Dabbling with colour cycling a little, pondering whether depending on FancyLED means the memory/code will be a problem and whether even a subset of FastLED would be worth porting to a C extension would be needed (still ahead of myself a bit, only have the small dotstars on the Gemma/Trinket to play with so far).
@idle owl i feel your desk throwing. kind of reversed though, like my desk should throw me. spent an hour combined fighting a hang because i failed to realize i did this:
return value;
common_hal_mcu_enable_interrupts;
oi... yes. We could eliminate the desk and I'll throw you? ๐
offtopic: loved the movie, but the book was soooo much better.
@idle owl negative results are still results.
@ruby atlas As for your bit, no idea. Definitely worth testing once you have eq.
i'm also worried about performance when dealing with larger strips or matrices ๐ so might need fastled or C helpers anyhow.
Right
@ruby atlas i think it'll definitely need to be in C land to take advantage of DMA.
may not be fast enough to keep up, even though she's awesome.
step 1: make it go. step 2: make it pretty. step 3: make it fast.
@raven canopy exactly.
but i still want a very pythonic interface ๐
@idle owl if the array is giving you fits, can you get by with a smaller array?
I don't know. Wondering the same thing.
Staring at this code.
It seems like it's filling up and failing though
Like maybe it's not actually clearing anything
And is just making a giant array or something
for color in color_cycle(steps=30):
dot[0] = color
dot.show()
``` is my current interface to give me a rainbow with default colour points.
Because it goes for x-amount of time and fails on 3.0. On 2.0, it makes a strangled tweak sound and then hangs once I try to use start_tone with it.
kind of kludgey, but you could use the del(array) and recreate to make sure...
Except with the sound_level code it's constantly taking one
so I'm not sure how to even include that
trying to remember...can you pop an array?
I guess I don't understand why this has never come up before.
Or why we haven't managed to crash it like this with anything else
@raven canopy >>> dir([]) ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'clear', 'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
(not CP, but yup)
>>> dir([])
['append', 'clear', 'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
@idle owl memory fragmentation problems?
Ok I just tried this: python while True: if cpx.button_a: print(cpx.sound_level) cpx.start_tone(262) else: cpx.stop_tone()and it crashed after printing one value, so it's not even getting very far into these arrays.
code.py output:
86.4737
what does start_tone look like? or at least whichever function is manipulating the array.
@staticmethod
def _sine_sample(length):
tone_volume = (2 ** 15) - 1
shift = 2 ** 15
for i in range(length):
yield int(tone_volume * math.sin(2*math.pi*(i / length)) + shift)
def _generate_sample(self):
if self._sample is not None:
return
length = 100
self._sine_wave = array.array("H", Express._sine_sample(length))
self._sample = audioio.AudioOut(board.SPEAKER, self._sine_wave)```
start_tone: python self._speaker_enable.value = True self._generate_sample() # Start playing a tone of the specified frequency (hz). self._sample.frequency = int(len(self._sine_wave) * frequency) if not self._sample.playing: self._sample.play(loop=True)
sound_level:python self._samples = array.array('H', [0] * 160) self._mic.record(self._samples, len(self._samples)) return self._normalized_rms(self._samples)
Why is one 'H' and one "H"
or does that not matter.
shouldn't matter. at least in my experience.
I changed the first one, didn't change the results.
Simply to see.
Tried making the sound_level array size 20, and it was the same results.
and no pop available.. ๐ฆ
>>> foo = array.array('H', [0] * 160)
>>> dir(foo)
['append', 'extend']
>>>
oh right, array, not list.
And I think the sine_wave array has to be that size for the sounds to be right.
in sound_level you have self._samples vs self._sample. on purpose?
actually, it's all "samples" in there, so i assume yes.
tbh, I had forgotten that there was even a samples being used. And sample carried over from the sound meter code I used to build these functions in the lib
Could be any name, it just happened to be those two. They're simply variables.
ok, so two unrelated objects. jus checkin...
brains are difference engines, after all. ๐
shouldn't this be subracting 1 from the length, since _sine_sample uses it in the for...loop?
self._sine_wave = array.array("H", Express._sine_sample(length))
for i in range(100):
// loop gets to 100, but the array index ends at 99
Yikes! Looks like I missed a fun evening! I wonโt be much help tonight. Will try to come up to speed tomorrow.
@raven canopy I'm not sure. I know we hammered on it for a long time.
That's the current iteration of the whole thing if you want the whole picture.
that sample samples thing...nightmareish. not like i haven't been guilty of the same, though. ๐
I had help.
i don't see anywhere that would progressively increase the memory. well, other than the values that are contained inside of array.
e.g. array('H', [1,2,3]) is smaller than array('H', [1234, 1234, 1234]).
@idle owl you still around?
Yah
k. i'll lead this off with the following: i have zero experience in using generators.
but, is _sine_sample generating a huge-a-normous sine wave? like 100*100?
_generate_sample calls _sine_sample(100), then the for...loop yields... ugh. nvm. i keep having to type this out until i fully understand. ๐
it's been so long and it's late. so I'm fuzzy on both counts
wait. its only returning one value, right?
yeah at a time
at least that's how generators work
or rephrase
how the other generators I've written work
i just read that yield acts the same as return....
so I assume it's a concept
so your for..loop runs the first and then exits?
a generator yields all possible iterations before stopping
I'm seriously simply saying the things I know here. I'm not sure I'm even answering your question
either way I should really bail and go to bed.
ok. later. and i think it's my not understanding...will read some more.
thanks for helping ๐
hehe. did i? ๐
I really appreciate it. My brain is melting out of my ear is the problem at this point
well you're looking into it... the more brains on it the better, melty or not
fair enough. schlaf schoen.
danke
hey! someone knows german! ๐
melty brain is usually a sign a drink or break is needed (or both)
or the drink break needs to end... ๐
Hi folks! where can I find a reference on pin assignments for m0-based boards?
I want to try making a 16-button, 2-axis gamepad around an itsy bitsy m0 express, and I'd like to know how to reassign the SERCOM and SWD pins as digital IO
Hi everyone! Similarly to @clear pecan's question, Does anyone know how to initialize the signal IO pins on the CRICKIT board? Specifically, how do I assign the Signal I/O pins for digital read/write via seesaw?
in theory it shouldnt make a difference whether we collect() after each import in a sketch but ive found that "sketch that work but then fail after a while with memerrors dont have failures if we gc.collect after each import" im testing CPX in 3.0.0
we don't import a lot, its not a time sensitive event, and there's a huge memory slush...why not :)
That's the next step, but I'm time constrained, so I'm reporting those bugs here so I don't forget.
Oops, it's not needed, It's left over from my previous attempt at this. I will remove it.
I've updated the nonblocking_timer code according to the CircuitPython library doc from above.
Unit tests are running on travis-ci, but build is failing when building the circuitpython bundle.
See https://travis-ci.org/mikepschneider/CircuitPython_nonblocking_timer Could use some eyeballs on that @tannewt
/home/travis/build/mikepschneider/CircuitPython_nonblocking_timer
Multiple...
I could not find a driver for the TMP007 IR Temperature sensor https://www.adafruit.com/product/2023
There is a Python Driver for the Raspberry Pi and I now have adapted it to work under CirCuitPython.
MY initial version seems to be functional.
@tannewt when you have a chance, please create a template for Adafruit_CircuitPython_TMP007
Good morning everyone. Is there a neomatrix library for CP?
We are trying to run text on an Adafruit 8x8 NeoPixel matrix using CP
@compact solstice there are some approaches to this: The framebuf module http://circuitpython.readthedocs.io/en/2.x/docs/library/framebuf.html is inherited from MicroPython and is available on Express boards. It has text support. We have some older guides that are relevant: https://learn.adafruit.com/micropython-hardware-ssd1306-oled-display https://learn.adafruit.com/micropython-displays-drawing-text. There is also an HT16K33 library but it currently only has builtin text support for multisegment (not LED array) text: https://github.com/adafruit/Adafruit_CircuitPython_HT16K33. We would like to have a more integrated solution, but it's still a work in progress.
There is not a NeoMatrix CircuitPython library.
@tannewt @dhalbert ready for review again. Should I rebase and/or squash?
The two failures were on not nrf builds that passed on HEAD~1. Error is The command "sudo apt-get install realpath" failed and exited with 100 during . which seems like a flake.
(I have not been in the loop on this, so @tannewt and @margaret please let me know if you've discussed this already).
mp_obj_new_int_from_uint() will silently truncate the common_hal_precise_time_monotonic() value when it overflows 2^32. 2^32 msecs is about 49.7 days. I could imagine a long-lived sensing program that hits that limit. If the incoming common_hal_precise_time_monotonic() is > 2^32 you could call mp_obj_new_int_from_ull(), which takes a long long (which is 64 bits).
...
This gave an error on the nrf build. I think you meant precise_time_module on line 224 here.
./mpconfigport.h:275:62: error: 'precise_time_module' undeclared here (not in a function); did you mean 'precise_time'?
{ MP_OBJ_NEW_QSTR (MP_QSTR_precise_time ), (mp_obj_t)&precise_time_module }, \
^
../../py/objmodule.c:233:5: note: in expansion of macro 'MICROPY_PORT_BUILTIN_MODULES'
MICROPY_PORT_BUILTIN_MODU...
@tannewt @margaret Maybe this should be called precise_time.sleep_ms, since the units are different than time.sleep? If we ever implement microsecond sleeps then we can have a precise_time.sleep_us as well.
I restarted the failed jobs and they ran fine.
I made some inline comments a while ago but I think GitHub didnt show you them because I hadn't started a review. Now I did, see what you think.
@clear pecan Most of the M0 boards' doco follows this same pattern:
The Board:
https://www.adafruit.com/product/3333
The Schematic diagram:
https://learn.adafruit.com/adafruit-circuit-playground-express/downloads
SEE ALSO
.arduino15/packages/adafruit/hardware/samd/1.1.0/variants/circuitplay/variant.h
Despite it being less than an hour away, I won't be attending today's CP meeting. We will be clearing out of the hotel room and wandering into Seattle about that time.
Test
@tulip sleet Thanks for the reply . I didn't realize that you replied until a few moment ago. I will go over this now.
The deeper I go in CP the more I realize that all of you that work on CP are taking on a monumental task. Thank you all for taking on this work, it truly is remarkable.
@spare storm the SeeSaw base documentation should give you an idea.
โคโ http://adafru.it/3657 SeeSaw module (SAMD09)
โคโ https://learn.adafruit.com/adafruit-seesaw-atsamd09-breakout
@spare storm To reprogram the module, you need
โคโโคโ source:
โคโhttps://github.com/adafruit/seesaw
โคโโคโ reprogramming guide:
โคโhttps://learn.adafruit.com/programming-an-m0-using-an-arduino/overview
I'm going on an assumption that cricket functions similarly to the standalone SeeSaw in this.
โคโEDIT: Yes, indeed:
https://github.com/adafruit/seesaw/blob/master/boards/crickit/board.mk
I've used that guide myself -- you need an Adalogger M0 board (or similar) and an SD card. It works!
SEE ALSO
https://github.com/adafruit/seesaw/issues/4 which has a .ZIP file of the updated SeeSaw firmware (newer shipments may have this already?)
... And I'm back quiet. ;)
That makes sense. I'll rename it to sleep_ms.
We hadn't discussed how to deal with overflow, but these suggestions sound good. I'll work on these items later today.
<@&356864093652516868> and anyone else who would like to join us: CircuitPython Weekly meeting in about 10 minutes!
For anyone new to the weekly, click on the CircuitPython voice chat on the left side of the Discord chat window to join the audio chat. If you don't have a mic, you can listen in and type out any responses in the chat window, and we'll read them out.
I think i may be able to join hopefully @idle owl
@fluid helm Sounds good!
I'll be listening but as usual I won't be able to talk.
I'll probably be the same tonight
@idle owl I've got my mic setup, and everything tests ok
ooo Les is on
Oooh generators. My favourite!
Hi Les!
Darn it - old messages which hadn't scrolled. @idle owl is generator world still your purgatory or did it all get landed OK?
This is my first time on the call. I will be listening to the conversation.
Welcome, @tidal verge ๐
@hollow ingot Still fighting with it, not sure it's necessarily the generator causing the issue. I think it's an array issue.
Yay, I can say purgatory. Is there source?
https://github.com/adafruit/Adafruit_CircuitPython_CircuitPlayground/pull/31 is the current code.
hi kattni
๐
Thanks @timber mango !
Hmm @idle owl I'm not seeing any 'yield' what file should I be looking at?
@wraith tiger can you mute for now?
@hollow ingot But weirdly, I can use sound_level and play_tone just fine. and play_tone is literally made up of start_tone/stop_tone
Thanks @slender iron for subscribing to the VGKits channel! https://www.youtube.com/channel/UCFZJppDOyrbhDqnBDVFmhHw
Cool !
The chatroom's gonna need a bigger couch!
working mic, unable to chat tho. Will mostly be listening. Will chime in over chat if I have anything to add ๐
@gaunt breach Perfect
all the peeps! ๐ฒ
I forgot there was no meeting last week. I showed up and went where is everyone - OH! PyCon.
Yay! Mechanical Keyboards ๐
๐
Yay! Great job everyone!
Great stats!

I'd hate to do all this work and end up with something that can't keep precise time indefinitely without needing to use longints. 12.4 days to OverflowError on a non-express board is not a great outcome. 12.4 days until your carefully crafted code becomes markedly slower because it switched to 'long's isn't that hot either.
To that end, I have two general ideas. Option 1, return a preallocated list of two ints, for example [seconds,microseconds] or [seconds,milliseconds]. Now you're goo...
Yes, totally agreed. You were amazing @tulip sleet & @idle owl
that's a huge list WoW
Group hug this week. Thanks to all who suggested possible fixes for serial noise on Vanguard board, and had suggestions on Circuitpython startup. Also a hug for Les Pounder. @heavy pasture being on means I'm no longer first alphabetically!
changes name to Ziglesp ;)
Interestingly he's about 20 miles from me geographically!
Here here @tulip sleet
My group hug this week is for @plucky flint for the amazing work on Mu and his Education summit talk, truly amazing. Also huge thanks to @tulip sleet , @slender iron & @idle owl for spending time with me and @heavy pasture at PyCon. Also, thanks for the Gemmas, they were amazing ๐
zbigniew
Yay, @Josh too. Big up the UK Maker corridor https://bit.ly/2rXYEcY
Thanks to @slender iron, @idle owl, @tulip sleet and everyone I met at the Pycon sprints for being patient with me and helping me get setup in the ecosystem. Also a big thanks for the Gemma's and for the Adabox donated to PyLadies. โค
Sprint hug report: Roy, Adam, Chris, Margaret, Matt L, Matt W, Karin, Lady Red and anyone else I've missed!
Hug Report: @solar whale for a friendliness ... (a friendly sort of a friend) and to all the PyCon newcomers -- how awesome to meet you each! @split ocean for Adafruit awesomeness and the mysterious @Dean Miller, who makes things happen.
Also a hug repot to Wolf for talking so much about CircuitPython at PyCon that I had to keep giving him CircuitPython cards to hand out because he kept handing them all out.
@timber mango thanks!
You can ignore me. This is my first time here and I am listening to the call.
Oh yes, very nice to meet you @quick oyster
Nothing specific, just general kudos to Scott, Katni, Dan & the rest of the community.
@tannewt, @Dan Halbert, and @ kattni for attending PyCon and spreading the
love. Hug to everyone @PyCon that helped with sprints/etc, and have joined the community. Last but not least, extra hug to @Dan Halbert for taking some weekend time to help.
Ok, can I go last. I shall get mic sorted hopefully @slender iron
Oh I can do normal spot @slender iron , got mic sorted
yay!
It was really fun to tweet at PyCon with @gaunt breach 's gemma!
@ruby atlas is that what you borrowed my Gemma for? ๐
Finally got the first Youtube video out https://vgkits.org/blog/2018/05/08/introductory-video-tutorial/ (thanks for feedback from those who went out of their way and out of their comfort zone to watch it!).
Finally told twitter about the VGKits Vanguard board and put up some Paypal buttons to buy the Rainbow kit. Tested to prove minimum function on the board in both v2 and v3 of Circuitpython.
Trying to figure out whether to go strong on Circuitpython or Micropython. Currently as per the demo shown in the video everything is dependent on exporting main.py symbols to the REPL shell, and having in-memory continuity between main.py and the REPL. Need to work through this to work out how to spin this up on Circuitpython, or rethink our approach.
Oh and saved my PhD (continuation panel) and rebuilt my laptop which imploded.
This week I'll be figuring out how to keep up with @heavy pasture's prolific blogging and actually putting some content up on VGKits.
Need your ideas what to build which would be the most affordable for educators?
imploded?
Distracted from the coding side of projects for the last couple of weeks -- was focused on music (composing, building synth circuits) and learning KiCad. First batch of boards came back and were awesome! Sent in six more board designs and anxiously waiting for the post to arrive. Working on robotizing the sound boxes from an ancient cuckoo clock, using CircuitPython of course.
It all began with a little pip
pip install implode ?
ended up with core dumps from running pretty much every binary on the system, so I bailed and installed the Bionic LTS
No idea what broke, but it was bad
Surely pip3 install implode @idle owl ?
Could be aliased!
LOL
I was exploring screen overlay programs, to reveal keypresses - installing screenkey key-mon and gromit-mpx, then pycairo to achieve X11 transparency, then somewhere along the way messing with config, packages (deleting user site-packages) boom!
jas
I've continued working on low-level issues with uzlib and ujson because they're likely to be used in IoT type devices where security is important. The most interesting bug I've discovered while looking for bugs in ujson actually affects regular circuitpython, where a numeric literal with a very large exponent evaluates to the wrong value (including when you write them directly in a .py source, not in json). The number-parsing bugs I found are all fixed in micropython now, but they have a low impact so I'm not planning to pull-request them in circuitpython. As far as uzlib goes, the maintainer has been optimizing some of my changes to have the minimum possible impact on code size. It will take some time to get them all accepted, but things are progressing and I'm confident we'll get to the point of having a uzlib that can be fed untrusted input.
18446744073709551615
>>> 1e18446744073709551615
0.1```
same here!
Very cool @fluid helm !
@onyx hinge If there's any interest in a 'pure python' type of JSON parser, which can consume any byte generator, there's a reference implementation at https://github.com/ShrimpingIt/medea
"It was a fourteen-day week."
๐ thanks @fluid helm !
New to the world of Adafruit & CircuitPython, but loving it. ๐
- Will be introducing my coworkers to the Gemma and CircuitPythonExpress today.
- Possibly do some project work with the boards I have.
- Some day I will bash through the sphinx code and generate the circuitpython C code into Python stub code... one can dream
yep!
๐
Receiving my first M4 was like being let out of jail, so I'm still on tilt about that. ;)
โคโHave not taken a survey of what we can already do in CircuitPython with QSPI flashrom (assumed a lot here) but went right into Ardino for this:
โค
Arduino Forth (YAFFA-ARM) ported to the SAMD51 M4 chip:
โคโ*https://github.com/wa1tnr/ainsuForth-gen-exp-m4*
I did a 3.x alpha 6 build -- having tested @tulip sleet 's new CircuitPython Firmware Build Guide (HUG) and it worked -- but I don't remember what MCU it was for. Metro M0 Express or Metro M4 Express (one of the two).
โคโWorking on QSPI flash read/write primitives for Arduino and this Forth interpreter (more thinking than working/typing/coding).
โคโI did a full memory dump of the M4 to convince myself there's really that much space inside that thing.
โคโThere is. ;)
We're going to have to be careful not to forget about M0 as M4 takes over!
nah we're going to have to make noise until we get trinket m4
@jepler My initial thought is that something like option 1 would be a nicer interface from the user's POV since they won't have to write their own logic to handle the switch every 12 days
Other than helping bisect the bug Dan fixed over the weekend and the work I did at the sprints, I have been and will continue to be exploring LED colours and existing code samples and libraries like FancyLED and FastLED as well asl tons of code samples on the adafruit site, for arduino, in preparation to write higher order animation methods (specificall generators) to help with LED animations. The goal is to to make it dead simple to animate LEDs. This has led me down the path of reading up on RGB light perception and gamma and the like. I have some hardware arriving tomorrow that will help me with animating more than just single dotstars - such as strips, matrices and rings. I expect to be able to drive a number of different devices shortly with acceptable looking colour cycles. Time permitting, i'll follow on with a bunch of other common patterns like comet, which will help stucture the library to be easy to extend. I expect to run into performance challenges, and will eventually have to start to move some code into C, but will delay doing so until I run into problems where I need to free up cycles or memory.
@solar whale won't let us forget M0. No worries. ๐
Thonny is pretty darn good
Thonny is great, slowly stepping through code is great
Stepping is a bit confusing for someone used to a debugger, though - the nesting levels.
They claim it makes more sense for learners, which may be true.
Good luck @wraith tiger I'll be interested to hear how you go with this!
There's an issue on the repo from ladyada for breakpoints too.
A python debugging channel would be extraordinary for Circuitpython and transformative for learning, for just the same reasons that Thonny is good.
Atmel Studio debugging guide has had some reviews and edits from suggestions.
High Frequency PulseIn: SAMD21 framework is done, and "working". Still trying to figure how to fail gracefully (can maybe apply to PulseIn too). May end up attempting DMA to maybe help alleviate endless interrupt loop. SAMD51 will start after that, and most likely be quicker since I don't have to mess with EVSYS and EIC.
My use of the REPL is pretty-much a way to get a poor-mans debugger.
I worked with JuPyter/iPython in a class and missed the ability to step through code.
sometimes I want a terminal-mode editor built into circuitpython, just run it in the terminal window
I had to doa lot of if debug print()
too many videos...
The 3 hour ones are rough... ๐ด
The PyCon channel: https://www.youtube.com/channel/UCsX05-2sVSH7Nx3zuk3NYuQ
There's a runtime optimisation setting in Micropython which you could track... http://docs.micropython.org/en/latest/wipy/library/micropython.html#micropython.opt_level "Source-code line numbers: at levels 0, 1 and 2 source-code line number are stored along with the bytecode so that exceptions can report the line number they occurred at; at levels 3 and higher line numbers are not stored."
Then you could get good error messages when you want, and opt out if you want.
Thanks everyone!
๐ thanks!
Thanks everyone!!! Have a great day/week!
๐ ๐
Bye all, thanks.
Now you can say what's really on your mind. ;)
๐
I use the REPL for tab-completion as a shortcut to refering to proper documentation.
That gets folded back into the local copy of the code stored on the host PC.
it's like a "python -i" mode, so that it can drop into the repl in case of exception or when the main program exits
Right everyone I'm off to eat a steak ๐ Great chatting, laters!
Later @heavy pasture
Gotta run myself. Later taters!
(that's aloha in our limited emoji vocabulary)
Yeah I overwrite main.py constantly. ; Generally by copying from the host PC to the target, at the host PC command line (bash shell).
$ cd /media/nis/CIRCUITPY
$ cp -p /home/nis/Project/main.py . ; sleep 45 ; sync ; sleep 1 ; sync
Sorry I have to mis the rest of this dicsussion -- good stuff -- off for awhile.
@slender iron (from 'the weeds' in audio only) That explains a lot I wasn't aware of.
Well I gotta have that extra RAM (6x!) so I'm interested in working with M4 as it is found. ;)
Taraa
@stuck elbow I tried the bouncing ball example and it went good. I now try to understand how to use vacuum-invaders. Once you get the .mpy file, how to start it? I'm not familiar with the process to transform .py to .mpy
Whee, slammed it into safe mode this time. ๐
I have a use case which may be relevant to this, depending on the breadth of functionality in a boot.py explicitly-coded python supervisor.
If the python-implemented supervisor was explicit in boot.py and oversaw the policy decision of dropping the VM after main.py and giving a fresh VM to the REPL, tweaking boot.py would enable alternative VM management strategies to be employed. Importantly no circuitpython-compatible fork would be needed to achieve this, since it happens in 'user...
@lethal abyss can you point me to the bouncing ball example? .mpy files are run just like .py files, except they don't need to be 'compiled' before running, which saves memory. To create a .mpy file, I use the mpy-cross utility which can be built by running 'make' within a git-checked-out or downloaded-unzipped copy of the https://github.com/adafruit/circuitpython/tree/master/mpy-cross folder. I don't know if there is an easier way provided by other circuitpython tools. Calling mpy-cross mysource.py causes a mysource.mpy to be made.
@lethal abyss If you ever explore 'frozen modules' then the mpy-cross utility is effectively run automatically on source files in the modules folder to turn your .py files into .mpy files which are mapped in flash memory not stored to the filesystem and loaded in RAM. However, I don't know if you are forced into building your own circuitpython images or not at this stage, and frozen modules are avoidable hassle if you're not forced to use them by memory limitations. They are the last resort if you can't fit stuff into memory otherwise.
@spare storm best evidence of seesaw crickit firmware is:
https://github.com/adafruit/seesaw/blob/master/boards/crickit/board.mk
couldn't get my Gemma working. swapped usb cords, tried with the battery pack. nada. Then I remembered "wait, the Gemma has a built-in on/off switch..." looks at switch OFF ๐ :head_desk: ๐
Scott kept trying to unplug his to turn it off. I had to remind him there was a switch at all. ๐
Even better to confuse: the switch on the CPX is a toggle input, not power. ๐
I have it working. It means the sound_level and loud_sound will not do anything if start_tone is playing and hasn't found it's matching stop_tone yet. Still works with play_tone. It makes a clicking noise if you try to use loud_sound/start_tone at the same time because it's blocking it. I can document that.
<@&356864093652516868> Here is the meeting recording for today. Thanks to everyone who joined! https://youtu.be/9Mrq4rp72Zk
Notes with timecodes are available here: https://gist.github.com/tannewt/fdfa8bdab5cd21c1486dafeb34cc3922 Join here for the chat all week: http://adafru.it/d...
Thanks for doing the notes and video @slender iron!
@slender iron I managed to crash it into safemode earlier multiple times with trying to do the sound_level and playing at the same time. I'll still file an issue on that. But I did get the lib into a working state so I'm going to update the PR. We can use this version for freezing into 2.x - Dan said we're unlikely to fix this audio issue in 2.x, so I don't see why we can't have this version of the lib frozen into 2.x and then an updated version eventually frozen into 3.x.
issues for safe mode crashes would be good
yah
Cool, thanks again @timber mango!
@tulip sleet question on building circuitpython : your Building Circuit Python document is excellent ( thank you very much ) i have one question in regards to supporting other SAMD21 variants ... i need to work with the SAMD21J18 ( note the J and not G ) following your guide i have been able to build circuit python for boards like the feather_m0_adalogger or basic on windows without a problem. But for the board i have i need to change the device to the J18 vs G18. And when i try to do that I get build errors in regards to the number of parameters for macro's TC and PIN and there is also the Endian multiple referece due to the samd21j18.h file and its definition. The endian issue can be fixed but i am not sure where to start in understanding why the macro's are incorrect. I understand Adafruit does not have any boards with the J18, so maybe no one has tried this. I just wanted to know if i should expect to be able to switch the device to the J18 and be able to properly build. One should be able to just switch the device reference in the files for the basic or adalogger to samd21j18 and see the issue. I did not try to add addtional pins that are available on the J18 at this point. .... i am using the latest master branch ... A long time ago i asked a similar question but was taken off the project and never did figure this out, but now i am back on the project again, so starting over with the latest master branch. If you have any suggestions that would be very much appreciated. Ken
@hollow ingot bouncing ball is here :
http://ugame.readthedocs.io/en/latest/tutorial.html
But the mpy I try to run is there :
https://github.com/python-ugame/vacuum-invaders
@lethal abyss just import it in your main.py
@lethal abyss there is an example main.py in the repo
basically copy all the files except for game.py to the board
@stuck elbow oh... I tried the import but was from the REPL. I understand my mistake
thanks much @timber mango !
@hollow ingot just watched your intro video, very nicely done!
will be dropping some #circuitpython-dev related #LEEKS in #general-tech in a min'
@solar whale I cancelled the PR, separated out the 3.0 updates and resubmitted. The sound stuff isn't going to happen right now. The lib still won't work without touchio being removed and the updated version of LIS3DH, but it's ready.
not quite yet. still waiting on @brentru to finish his review (not calling you out! take your time), as well as another Discord user and @kattni (super-busy, as she is).
@solar whale Thanks for all your help this weekend, and sorry for what turned out to be a rabbit-hole.
@idle owl no problem. It was fun to participate. Rabbit holes can be very educational spaces!
@weary spindle while the samd21j header file is in the repo's ASF4 folder, it could possibly be quite an undertaking setting up the PMUX and periphs. could you put up a gist of the exact errors you're getting? might help us help you pinpoint a way forward.
@solar whale remind me again where the i2c bitbang updates are included. are they in latest release, or do i need to compile from head?
@tidal kiln youโll need to compile the current master
@idle owl isn't that what i just did? albeit passive aggressively? ๐
and you got plenty going on. that guide is in no hurry...
cool. will give me an excuse to finally update my setup so i can build again.
@tidal kiln good to get up to date, but let me know if you just want a .uf2
@solar whale I feel like some of the memory errors would have gone away with the libs frozen, but eh. I guess it's not worth fighting with right now.
Plus I don't remember how to build with updated frozen libs. Or know whether I even remember how to build 2.x.
@idle owl hard to say. But probably best to wait before going to full battle mode on it๐
Yeah exactly.
@solar whale make BOARD=feather_huzzah ?
To build 2x checkout 2.x branch and do git submodule update step. Also re-make mpy-cross
@tidal kiln in ports/esp8266. Just make clean then make
things moved? 2.x vs. master?
@tidal kiln just realized there is no .uf2 ! Just a .bin
in 2.x branch there's no ports/esp8266
Yes 2x has no ports top lever folder
Are you doing 2xor 3.0 . New bitbang is only in 3
yah, after new bitbang. wondering why you said to checkout the 2x branch?
That was for @idle owl
Yah me.
Sorry
I guess I was on the right track there at least.
ha! np. perfect how the discussion was so similar. ๐
I was clearly looking at her when I typed that ๐
huh. realizing i've never actually built for esp8266. looks like i need some tool chainery i don't currently have...
yep. and it takes a minute, or 30+....
@raven canopy This review is long but it's not because there's a lot to it, it's because it's turning into a conversation with you with myself. What with it being one sided over here. ๐
๐ i knew if anyone would get EVERY single snark, it would be you...
but just follow this?
https://learn.adafruit.com/building-circuitpython/esp8266-and-nrf-builds#esp8266-build
@tidal kiln yep. building esp-open-sdk seriously does take like 30 minutes.
hmmm. so....how 'bout that .bin?
lol
All about that .bin. No .uf2. (sorry.)
if i didn't have a ton of local work sunk in right now, i'd build you one. (windows woes make updating treacherous)
@tidal kiln sure . Just a minute
thanks. i'll still launch a build. what option should i do for STANDALONE ?
esp8266 3.0 master
@tidal kiln STANDALONE=y, but it default to yes iirc.
yep. looks like.
ok. make hamsters are spinning. while they're at it, will try that .bin file. thanks @solar whale
no problem -- good luck!
yanny?
i don't know. i think i might have heard laurel...
oi to both of you
My daughter's name is Laurel -- this has been fun ๐
i kinda want to make a hamster wheel CPU utilization meter.
"I have made an animated circle in Terminal. You are welcome, humans." ๐
but suspect it would be too noisy.
@solar whale oh no! lol ๐
i read a really good technical article on the whole deal. was on slashdot, i think.
@tidal kiln check the build version on that . bin ```
Adafruit CircuitPython 3.0.0-alpha.6-149-gbe12e07 on 2018-05-21; ESP module with ESP8266
If something exists on the internet, there's a technical article about it. Right?
or fakenews
i sure hope so! otherwise...why?
if any doubt - use this - just rebuilt -- I built it a lot over the past few days!
@solar whale the only thing different in my banner text is date. 2018-05-19
note-to-self: if you want to debug a chip, it helps to connect it to the debugger. ๐คฆ
Don't know if you are using a Linux system (may also work on MAc) but I love the esp8266 make PORT=/dev/ttyUSB0 deploy
@tidal kiln -- you're good then
Wheee Neopixel RGB spectrum data https://forums.adafruit.com/viewtopic.php?f=47&t=66146&p=335445
This color LED rabbit hole is very deep
Yikes - I just thoughtthey were pretty lights ...
@ruby atlas nice find. i've never seen that.
I've been aware of human perceptual sensitivity discrepancies, but also knew that RGB(W) spectrum from LEDs varies by product (and even by batch). Combine that with, say, wanting Red and Orange and Yellow at the same luminance, you've got a lot of fun things to juggle.
And with playing with simple colour loops that don't adjust for these, it's really obvious to my eyes right now.
@tidal kiln to cahnge the deafult timeout for bitbang clock-stretch i2c_bus = bitbangio.I2C(SCL, SDA, timeout = 5000) will give 5 ms timeout. My guess it it won't help.... rather try slowing the clock -- frequency=100000 fo 100KHz - default is 400KHz
@ruby atlas yah, i like seeing these curves for "white" LEDs. very telling.
also, just in case you haven't come across this yet:
https://learn.adafruit.com/led-tricks-gamma-correction/the-issue
yep, got that bookmarked. Already played with the gamma tables here https://learn.adafruit.com/led-tricks-gamma-correction/the-quick-fix too
If anything, the gamma table made things worse without total (perceptual) luminance adjustment.
I want one before Oct 31
๐
I've also been wondering how big a neopixel driven "TV" I could build with 3d printed diffusers.
(or dotstar)
@solar whale which version of the bundle lib(s) should i work with?
I'd go with latest, but I don't think it matters much - no changes there for this.
ooo. toolchains built.
time to figure out din din. don't break anything without me! ๐
@solar whale is default timeout same as previous? i.e. if i don't specify it, it behaves as before?
@tidal kiln correct - default is 255microsec -as before
Someone should make an Eye of Sauron version of the giant eyeball.
@solar whale no change :(
still getting same trace / behavior as here (last one):
https://github.com/adafruit/Adafruit_CircuitPython_BNO055/issues/9#issuecomment-384137352
It would be nice if there was something like DBGP (https://xdebug.org/docs-dbgp.php) to allow remote debugging.
@tidal kiln not surprized -- and since it is < 255 microse, the timeout change won't help.. tryl the lower frequency
tried both
rats. sorry. not much I can offer.
specifically, tried with these:
i2c = busio.I2C(board.SCL, board.SDA)
i2c = busio.I2C(board.SCL, board.SDA, frequency=100000)
i2c = busio.I2C(board.SCL, board.SDA, timeout=1000)
i2c = busio.I2C(board.SCL, board.SDA, frequency=100000, timeout=1000)
try slowing it down to 10000
๐ works!
woohoo!
prbably no need
yup -- taht is waht I saw with CCS811 as well
not sure how 10Khz will impact performance -- you can try raising it until it breaks.
cool. let me try the actual bno055 library now. i was just testing by creating an I2CDevice...
Good luck - fingers crossed - this is a popular sensor!
no luck with the lib ๐ฆ
it doesn't error out, but return values are, it appears, all 0
@raven canopy here is an example of the build error when trying to build for SAMD21J18
^```
```samd21_pins.c:502:17: error: macro "PIN" requires 8 arguments, but only 6 given SERCOM(5, 3)),
^```
I will dig deeper into this. Just was wondering if the experts could point me in the right direction, or had seen something like this before
@tidal kiln I took a quicklook at the data sheet and it did not have a minimum I2C speed so I was hopeful...
@weary spindle I only have a minute but I think it there are just some typos for PB22 and PB23 in those files. We changed the macros but forgot to change those. You can probably drop the third arg to TC. On line 502 there is an extra paren by mistake.
@solar whale the clock trace should be at the set frequency, correct? (or close to it)
checking code