#circuitpython-dev
1 messages ยท Page 140 of 1
there is a limited amount of stuff we can do at the branch level
yells "fork it" and then looks around nervously for dynobot
๐
any objections to me making 9.806 a constant?
nope
Do you also want to enable #define MICROPY_ENABLE_SOURCE_LINE (0) in the nerf build?
@jerryneedell Good idea. I didn't do any kind of comprehensive look at what's different in nrf. If you know of anything else let me know.
tony uses two spaces after a period. I will begrudgingly match in this comment I'm appending to.
That is the one I usually add along with uncommenting out the BLE_MODULE and UBLUEPY_MODULE but I think Kevin wants this tested more before they are mainstreamed. I have been playing with them a little but happy to deal with them myself for now.
getting a pylint error: E:286, 0: invalid syntax (syntax-error)
for existing code, def __init__(self, i2c, *, address=0x18, int1=None, int2=None):
it doesn't seem to like the bare asterisk, but that's valid...
I may have arguably made it slightly harder to understand, though I would argue more pythonic https://github.com/adafruit/Adafruit_CircuitPython_LIS3DH/pull/23
pylint --rcfile=.pylintrc adafruit_lis3dh.py in a python3 venv
hrm
build failed. sigh.
yeah, I was gonna
I was going to suggest we lint for that but if it's mpy and not CPy that's fine
(is CPy accepted nomenclature?)
I've used it plenty, and noone has been like "whaa?"
along with MPy (seen uPy too) [for micropython]
const is good for ints. mpy-cross is smart with it
cpy is a bit weird because desktop python is also called CPython
ah yeah
I probably wouldn't do the list comprehension
in the library
because it makes a tuple, outputs a list and then makes another tuple
I was getting the line-too-long error so I did that but yeah, I agree
I'm gonna need to squash these commits.
good to know
I left it out of the library, still
and also did a force push because three commits for this makes me look bad
np
it wounds my pride.
I'm pretty new to python 3, though. been 2.7 for a few years but I'm forcing myself to get with the times.
@timber mango have you done anything with making the onboard storage mounted?
Not that I know of
@timber mango check this out: https://learn.adafruit.com/welcome-to-circuitpython/troubleshooting#circuitpy-drive-issues
That worked, thank you!
I'm keeping that file handy, this probably won't be the last time this happens
@opal elk two spaces after a period was standard at one time. Later it was referred to as French spacing. I've always used it.
@timber mango :
https://en.wikipedia.org/wiki/History_of_sentence_spacing#French_and_English_spacing
I generally joke that it's for grandpas but I don't want to offend anyone
I mean, I don't use the oxford comma. so we all make questionable decisions.
I have a grand nephew. ;) My niece's son.
it's one of those things where I don't actually care but it's fun to be cantankerous
I think consistency is a good idea but only within one person. ;)
french spacing is a space before ? and !
@timber mango is it bad to point out that you didn't use two spaces after those sentences above?
but seriously, it's probably why we have style sheets for things..
Let me know when there's prize money involved. If people are using one or two spaces (or more) after a sentence, variably from one person to the next .. I am not noticing it.
What I am noticing is an impoverished use of language, due solely to brevity. Grunts and emoticons.
the two spaces after a period is important for some tools to be able to distinguish the sentence-ending period from other kinds of periods, and format it accordingly
for instance, LaTeX
Right you are. That's my point: obsessing over someone else's use of spacing is one thing; breaking machine-based tools (diff comes to mind, here) is another thing.
โค LaTeX
On the whole, defending a position is also an impoverished strategy, especially when there is no prize money involved. ;)
I'm trying to learn something new, something different, about this, and it involves the avoidance of the rapid selection of a 'position' and then defending it, in favor of a differing process from that one.
Other than that, I need an assistant to follow along behind me to close a lot of open parentheses, and this hasn't changed in decades of writing.
Several users have asked for time reporting that's more precise than the millisecond ticks provided by time.monotonic(). Use cases and proposals welcome here.
I'm going to close this issue for now, since we've documented the problem thoroughly in the Learn Guides and described and implemented mitigations such as editor plugins that force immediate writes. If/when there's some movement on the Windows side or we figure out an alternate filesystem that works on all the platforms, I'll reopen or create a new issue.
I was attempting to work with a 433Mhz radio transmitter which required writing to a pin at 200 microsecond intervals. Even if a function similar to the Arduino micros() had less than 1 microsecond resolution this would allow time calculations that are not possible with the time.monotonic() function.
@CameronDevine Interesting! How much data do you know you need to write ahead of time? Something like PulseOut might be adequate. It looks like it requires a carrier PWM signal though it could just be constant.
fyi, I'm fixing the bundle
Nice
adabot was confused by the directories that moved around
Ah
@slender iron subrepos and directories
yeah, and ones that move
ruh-roh - I think I know what caused that ๐ฆ
came from here: asking there as well: https://forums.adafruit.com/viewtopic.php?f=60&t=129222
@solar whale it was me too deleting circuitpython
phew _ I thought it was my request to fix the typo in a link name...
that did it too but its fine ๐
oops - thought it would be ok
np, its good for me to figure out
gah, adabot added the circuitpython directory back
@slender iron So should I start by changing the name of the Adafruit_CircuitPython_Featherwing/adafruit_featherwing/motor_featherwing.py to featherwing.py since we're going to be adding other wings to it? (This is on my fork, I'm not talking making changes to the current version yet.)
nope, add more python files instead
Ah ok. Each wing will have its own file?
yup, so you only load what you need
Ok got it
what i have seen that like some have made all or targets like to include all but only load what you need from nuget
could somebody review this: https://github.com/adafruit/Adafruit_CircuitPython_Bundle/pull/42
Yep
thanks
Is there a reason the two new URLs have .git at the end and the other one doesn't?
Ah nm, some do, some don't.
Must work either way
Want me to merge?
yes please
I assume I don't need to do a release since it's the bundle
yeah, I'm working on it
thats why I wanted to get the PR in before I uncomment adabot's release powers
ah nice
ah ouch that's weird it uses .git URLs
why?
that's going to break the adabot change i made, it does URL comparisons by chopping off the schema (up to ://) but still assumes the rest of the URL is the same
i'll update it to chop off .git if it exists too
ah
@slender iron did you use git's submodule add to add that config or did you manually edit the .gitmodules file? just curious why it's not matching the rest of them
if it was manually added it might have knock on implications with git submodule init.. be sure to try it
I used git submodule add
ah cute, must be git version differences
cool i'll update adabot script to handle both csaes
the url is just different because people got them different ways
yeah the git submodule config schema has no preference
it's a github-ism to allow both .git and not .git at the end i think
there were a bunch before this latest one that used .git suffixes
yeah it works fine if the clone_url from github has .git and the submodule config has .git
ah I see
also some ssl urls were changed to https by hand
better safe to handle any permutation
yup yup
yeah those should be ok, i strip out URL schema and ignore git:// http:// https:// etc
As a side note, personally I would love to have some way of triggering this "bug" on purpose โ the solution with Arduino programs for erasing the flash doesn't work with custom boards, as I would need to make Arduino board definitions for them first, etc.
@deshipu I have been thinking of adding something like storage.format(...), with maybe some required True parameter to make clear it was dangerous.
just sent over a pull with the change
i have no idea why git is so mad at it
it works fine.. the merge is angry for whatever esoteric git reason
Reminds me of the --clobber-my-computer option we have in some OpenStack tools. We could make it a required keyword argument, something like storage.format(delete_all_files=True) or such, but I wonder how much of a warning we actually need here?
@timber lion its because I rebased your last PR which changed the commit shas
you need to rebase onto the new master commit
@idle owl @slender iron @tulip sleet I have a question about the use of the "frozen-modules" that are used with the CPX. As soon as someone copies the bundle /lib to their CPX, then the .mpy files in the /lib directory will get used in favor of the frozen modules, correct? In that case, users will not achieve the memory benifits of freezing the modules in the first place. Is this a concern? Should the guide instruct users to delete the forzen modules from /lib? Do we need a CPX bundle? Am I making sense?
You're making sense.
@solar whale we've talked about this. sys.path puts .frozen last. The Adafruit_CircuitPython_CircuitPlayground library changes sys.path itself to use the frozen modules. The real reason to use the frozen modules is to make things fit that would otherwise not fit in RAM.
like the Express class in the CPlay library
but people have said that a separate bundle would be confusing
this is a hard decision, because on one hand you want to use the frozen libraries to save space, on the other hand you want to be able to override whatever is in the firmware
OK so if you load the Express module then you get the frozen modules first
Yes
could it be done so that frozen modules have priority over lib/ but not over /?
OK - that covers the "worst case" I think - I ran into this when I was trying some accelometer stuff and it would not fit with the .mpy lis3dh but it was ok with the frozen.
I was not using Express
@stuck elbow that is an interesting idea, but perhaps hard to explain to laypeople. If you want to update a broken frozen module, you have to put the replacement in / not lib/
good luck with that!
the idea now is that if/when you run out of RAM, you learn the secret incantation to use the frozen modules, otherwise you don't have to know anything special
perhaps we could have something like overrides/
@idle owl you have a comment re the beginner and the intention?
For the "experienced" user it is not a problem - just manage /lib's content. For the newcommer, it may just have to be a learning curve.
Hmm
My real question was if it should even be mentioned in the guide?
I think we sort of had something like it initially but then took it out.
I does not sound like its been a big issue (yet) so I may be just looking for trouble.
Better to discuss it now than when we're panicking because something isn't working
I think this is a case where it works as it is, and if we run into mutliple use cases where another method makes more sense, we explore it at that point.
we haven't had many people complain yet about running out of RAM on CPX. Esp if they use Express, it's taken care of. We could add a "Using Builtin Frozen Modules" to the CPX guide if/when it becomes more of a support issue
Thanks for hearing me out.
@solar whale np! we went through very much this conversation a month or two ago
Ah - sorry I missed it! I did not know about the "sys.path" change in Express.py -- clever!
Yep! It's a totally valid concern! We're happy to hear you out
imho it's good to think about board specific bundles, eventually we'll need them when the bundle is too big for 2mb
it's 451kb right now so 1/4 of the way there
on CPX SPI libs for example aren't really possible to use and could be cut out
yeah not needed yet but eventually we might have to pick and choose
I have some problem with making a pull request
for some reason it's trying to change the submodules
did you do a git submodule update locally after pull/fetch?
hrm
maybe compare these sha's:
halbert@salmonx:~/CP/2.x-circuitpython/frozen$ git submodule status
7d8a8f99989a4de5b3fbf491df956d1aaca2c172 ../atmel-samd/freetouch (heads/master)
9a49ca04e3754be246524e57f8c1810c76be5948 Adafruit_CircuitPython_BusDevice (2.0.2)
74afff3ff912c9711d207671b8b9068358eaa0d2 Adafruit_CircuitPython_LIS3DH (4.0.0)
8e1e5bbb86e03d539103c6d73ccac0cb27711b77 Adafruit_CircuitPython_NeoPixel (3.0.1)
6c281ed26a2b38060e6a8c37c16f3bf6345cec2d Adafruit_CircuitPython_Thermistor (3.0.0)
9b3092eb3b4b230a63c0c389bfbd3c55682c620f ../lib/axtls (heads/master-35-g9b3092e)
dab957dacddcbf6cbc85d42df62e189e4877bb72 ../lib/berkeley-db-1.xx (heads/master-6-gdab957d)
e9de7e35f2339598b16cbb375f9992643ed81209 ../lib/libffi (v3.2.1-146-ge9de7e3)
5b8b5d459e7dd890724515bbfad86c705234f9ec ../lib/lwip (STABLE-1_4_1-RC1-13-g5b8b5d45)
2001c62d1a0361c44acc7076d8ce91e1d1c66141 ../tools/python-semver (2.7.8-4-g2001c62)
449f26673855736dbc0fc3f18d72403f25f62974 ../tools/uf2 (449f266)
was that after you commited it locally?
I just reset the head and commited it again, and seems good now
sorry for the kerfuffle
The example code for the gamepad module would skip detected
button presses in the code that waits for a button to be released,
because it would run it even when no button is pressed.
Also updated the example pin names to not use RX and TX.
np
buttons are tricky
I'm like trying to find the right package for a project that includes: circuit python or micro python, accelerator, magnetometer, micro sd card, and either wifi or bluetooth? Any suggestions?
hi all
i'm still testing my motor shield with CPX and arduino uno
weirdly, CPX only accepts max values of 127 when using analogWrite .. whereas arduino accepts 255
thats 7 bit vs 8 bit
anybody knows if the cpx board has a limit on pwm write of 7 bits?
the hardware can do higher than 8. are you using arduino on the circuitplayground?
it depends on the pin
the DAC is 10 bit I believe but PWM timers can do higher resolution than that
hmm, all the pins do pwm for cpx, accordinging to the docs
thats not surprising
I can't speak to the arduino implementation though, I only do circuitpython (and this is the #circuitpython-dev channel)
Hi Rajiv, looking for the smallest form factor I can find
@slender iron : fair enough, however this has made me curious now, since you'd do something similar using circuitpython and surely you should be able to query the board for max value an analogwrite would accept
yes, I'm just looking for the best hardware for the functionality that I can control with circuit python
@lucid arch yeah, we've done similar. Our analog writes are always 10 bit because we only use the DAC to do it
@scenic maple we don't have a single board that does all that you listed
i see ... you mean circuitpython always writes analog through the DAC, right?
but was wondering if there was a better solution
@lucid arch yeah, if people want to pwm they can do it explicitly
arduino uses pwm to fake analog sometimes
i see ... thanks @slender iron .
np
there does not seem to be a channel here that talks about cpx with arduino
#help-with-projects would work
or possibly a pi zero based solution?
7 bit doesn't make sense to me. I'd expect it to be 8 at least
@scenic maple pi zero support normal python but not circuitpython
why would it not make sense? is there something obvious?
@lucid arch it seems low to me. likely a bug somewhere
the support forums are also a good place to ask arduino questions
np, sorry I can't be more helpful. I live in a circuitpython bubble
you should try it if you haven't
it won't work on the uno but it would on a metro m0
try what
circuitpython ๐
definitely!
most definitely:
https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-quick-start
@lucid arch
carter, that looks interesting
@scenic maple with the wifi being the limiting factor, the Feather Huzzah ESP8266 + Adalogger RTC/SD FeatherWing + FeatherWing Proto + accel/mag, would be your best bet with circuitpython.
Feather HUZZAH: https://www.adafruit.com/product/2821
Adalogger FeatherWing: https://www.adafruit.com/product/2922
FeatherWing Proto: https://www.adafruit.com/product/2884
would still mostly be a "roll you own". you could skip the Adalogger and try and implement an SD on a Proto.
@raven canopy Thank-you
yw. 
@scenic maple mind you, i didn't look at pin usage to see if the ESP8266 will be able to support all that...
also...afterthought. you could skip the Proto + accel/mag and use one of the accel/mag/gyro breakout boards. I think there are already circuitpython libraries for a couple of them.
@slender iron @tulip sleet @solar whale I am happy to report, I have the combined vagrant working. compiles both SAMD & ESP8266. I'm fairly certain the problem was trying to use SMB share folders & the VM.config for allowing symlinks. I am going to run one more destroy and rebuild test to verify. Even if that doesn't confirm an out-of-the-box solution, I have the workflow steps to make it manually work. THANK YOU ALL again for the help!
nice work @raven canopy !
This is a weird REPL session:
>>> import gc
>>> gc.mem_free()
19696
>>> from adafruit_featherwing.motor_featherwing import MotorFeatherWing
>>> gc.mem_free()
1360
>>> wing = MotorFeatherWing()
>>> gc.mem_free()
MemoryError: memory allocation failed, allocating 512 bytes
>>> gc.mem_free()
6784
>>> wing
<MotorFeatherWing object at 20005a50>
Hmm
how did I get 6000 bytes back between mem_frees? maybe the file system cache?
Maybe?
That's odd
Maybe gc actually did it's thing between
and you had a bunch of garbage.
the gc should try collecting before it throws a MemoryError though
should... maybe it reported too quick for itself for some reason?
looks like its reproducable
the constructor created a bunch of things that were not garbage at the time it tried to allocate something new. That failed, it tried to gc, that failed, it threw an exception. scope closed, now the assignments are garbage
or maybe it doesn't really try to gc if alloc fails
the memory error is thrown from mem_free
oy
Hey everyone! I've really been enjoying playing around with the esp8266 feather and circuitpython. Really cool stuff. I'm trying to use it to control some equipment here in our chemistry lab
Hi @granite vapor. That's neat!
I was wondering if anyone knows the situation with the TTL serial ports. One port, as I understand is used for the programmer, another for the REPL. Is there a third? I'm trying to use RS232 and am trying to decide if this is possible.
I haven't worked with the ESP enough to know. Someone will know though!
There is only 1 uart, and it's used both for programming and for repl
Esp8266 has a second uart, but it's on pins that you cam't use
s/cam/can
You can connect directly to the RX/TX as well. Bypass usb.
But that's still the first uart with the repl on it
Yes
Hey, thanks. Hmm. In this application I'll not be using the REPL (nice as that would be), because the esp8266 is receiving its commands via wifi. Do I need to disable the repl in my main.py for the rx/tx to function properly?
I'm afraid you can't. The things you type and see on the webrepl will also appear on the serial port.
There is a pull request enabling this in review in micropython since about a year
It's not the webrepl, just a rest api
Then as long as your program is running, there shouldn't be anything on the serial.
The exceptions will still get printed there.
oh, okay. good to know about exceptions. Can stdout/stderr be redirected?
(sorry about the incessant questions)
Not at the moment. You can catch the exceptions, but there is very limited set of informnation you can gfet from it, not enough to generate a proper traceback.
gotcha. I guess if there is an unhandled exception then the program is stopped, so it doesn't really matter what happened to the serial port...
Well, if the other end is connected to, say, a nuclear reactor...
XD
The random strings may get misinterpreted
no radioactivity. just some pumps haha
In the micropython project I was reading about their asyncio port. I was thinking about implementing my internet i/o using coroutines, but this isn't part of circuitpython, right? how do y'all handle i/o that might block for a while during execution? is there enough memory to use threading
@granite vapor we don't have the asyncio stuff enabled and we are tight on memory for the M0 chips at least
And no threads.
So the answer is, I guess, you don't do multiple things at once.
Some things are built-in, like audioio can play a file in the background.
Gotcha. The dream would be to read data and push it to the cloud asynchronously. Alas, haha.
You might need to switch to micropython for that.
uart buffers in the background (aka c interrupts too)
And wifi on the esp8266 has buffers too
So you can read a few bytes, write a few, etc.
cool, okay
This was very helpful, thanks @stuck elbow @idle owl @solar whale @slender iron
np
yw!
its been so long since I've run gdb
I got so far as finding the memory error is in parsing the repl input
it allocates a stack of 512 bytes
Anyone have some time to help a beginner with libraries, buttons, and general questions?
@hallow moss yeah! post away. (even when we're not post and we'll get back to you)
Great! Let me find out where to begin. I have a Gemma M0 with 1 neopixel hooked up to D1. I've gotten the blinky example running on that neopixel. I'm now trying to get the button I've hooked up to D2 configured to change the color of the Neopixel.
I'm not sure if the code takes a long time to save to the Gemma, or if I missed a start-up guide to onboard LED flashing codes, but it doesn't seem to like the button changes I've added.
Here's the btn part that's not working as expected:
from digitalio import DigitalInOut, Direction, Pull, digitalRead
btnPIN = board.D2
bool btnPressed = false;
btn = DigitalInOut(btnPIN)
btn.direction = Direction.INPUT
btn.pull = None
mode = 0 + 2
while True:
if (btnPressed and digitalRead(btnPIN)):
if mode == 5:
mode = 0
else
mode = mode + 1
btnPressed = digitalRead(btnPIN)
if mode == 0:
pixels.fill((0,255,0))
pixels.show()
elif mode == 1:
pixels.fill((0,0,255))
pixel.show()
@hallow moss do you have a serial connection through screen or putty?
it flashes the on board led when errors occur. you can get more info about them through the serial connection
I don't. I just set it up with Mu.. I think that was the recommended IDE.
From what I've researched, the Repl will show the serial, but I need to get MicroPython on the gemma before that'll work.
I fixed the else to else:
@hallow moss Mu should work pretty reliably. The instructions are here: https://learn.adafruit.com/welcome-to-circuitpython/kattni-connecting-to-the-serial-console
getting serial going will let you read error text
@slender iron Yep! That's where I found out about Mu. Clicking my REPL button gives this error: Could not find an attached BBC micro:bit.
ah! In the bottom right there is something you can click to switch the mode
it must be in micro:bit mode and not adafruit mode
(I don
Hm.. I'm not seeing anything like that.
I don't use mu so I can't be more specific
I don't think it looks like a button, could you take a screenshot?
in the screenshot here: https://learn.adafruit.com/welcome-to-circuitpython/installing-mu-editor
there is "adafruit" and a gear. my guess is yours says something like mciro:bit
Mu screenshot
oic.
I don't know why my Mu doesn't have it. Must have chose wrong initially. I downloaded it again and it seems to have that option now.
YES!! I don't think I've even been so excited to see an error console! ๐
@slender iron Thanks so much for getting me going! Few more issues to wade through, but that's what makes it fun.
great! come back if you need more help
WIll do!.
good night! I'm off to bed
Good morning! I posted on here a few days ago about trying to make a timer in CircuitPython. I got great advise on how I needed to use the time.monotonic() function. Now I am seeking help in the formatting of my code: https://github.com/Bazooka77/Relay_Timer. I am new to both CircuitPython and GitHub so any help is greatly appreciated! Thanks!
Your if and else and elif statements need to end in colons (:), right? Also I don't think this is a thing: elapsed > 0 < duration. You want elapsed>0 and duration>0. Your if elapsed = 0 needs double-equal, otherwise it's an assignment, so if elapsed==0:.
@heavy galleon few issues, nothing major and @robust coral caught most of them. You might want to run this on your hardware and pop open the REPL to see any errors. Mu has a "checker" feature that's super helpful, if you have it installed (https://learn.adafruit.com/welcome-to-circuitpython?view=all#installing-mu-editor)
much to my surprise this is valid in Python: ```>>> x= 10
x >0 < 100
True
If all your relays always need to do the same thing together, maybe make an array of them instead of 4 separate variables, and write a little setRelay(value) routine to enforce the uniformity.
^ this, and iterate thru them with a for loop
I have something similar in how I set the R, G, B cathodes of a RGB LED in this snippet on Line 30 (https://github.com/brentru/METROX-Examples-and-Project-Sketches-1/blob/master/circuitpython/CIRC12/colorful_light.py#L30)
I want to type the duration variable into the program so that when button is pressed all relays activate for the given value of that variable. Also I want to have it so if the button is pressed a second time before the duration is finished the timer stops.
@robust coral Making an array seems like the right way to go, I attempted this at first but it didn't work because I am learning the formatting
@heavy galleon you have several calls to time_monotonic(), are those suppose to be time.monotonic()?
somewhere around line 20, could do:
relays = [ relay1, relay2, relay3, relay4 ]
then the looping is like:
for r in relays:
r.value = True
nothing special about use of r, just needs to be some available valid variable name
Ok I was going to ask about that
@prime flower in the MU checker why does it say my indentation is incorrect it seems fine to me
if you don't have the : in place, then it's going to be very confused
try backspacing up to the start of the line and hitting tab to fix your indentation
@hallow moss if you have version 1 of mu editor, you should be able to use REPL
as in, there's a button on top that says 'REPL' which will give you a python shell to debug with
def setAllRelays(v): for r in relays: r.value = v
ok i added the relay array but I need to figure out why it doesn't like my conditional statements first
if elapsed = 0:
==
you need double =
i cant get this to work right
sounds = [sound265(), sound330(), sound392(), sound530(), sound675(), sound1075(), time.sleep(1), 'test']
while True:
random.choice(sounds)
but this horrible mess works
while True:
sounds = random.randrange(0,7)
if sounds == 0:
sound265()
elif sounds == 1:
sound330()
elif sounds == 2:
sound392()
elif sounds == 3:
sound466()
elif sounds == 4:
sound530()
elif sounds == 5:
sound675()
elif sounds == 6:
sound1075()
elif sounds == 7:
time.sleep(0.5)
seems like when the defined command gets called from the random choice it does nothing
I'm not a Python expert, but if you did that in C, it would put the return values of your functions into the array since you added the ()
@upbeat plover remove ()s from array
๐ฎ okay
then do:
random.choice(sounds)()
thanks
won't work for the last two entries though: time.sleep(1), 'test'
yeah i noticed that part but im okay with adding some other code
your array is an array of pointers to functions, time.sleep(1) will put its return value (if any) and 'test' is a pointer to a string
replace the last 2 entries with: my_delay and my_print_test. Functions you write which take no parameters and do the actions you wanted.
nice dude
@stuck elbow Want me to test your gamepad PR?
@prime flower there is a syntax error there, I travelled today whole day, so I couldn't fix it
fixing it now
np, lmk when so I can test on HW.
Works, looks good.
Tested on:
Adafruit CircuitPython 2.2.0 on 2017-10-17; Adafruit Metro M0 Express with samd21g18
how come if I set a variable like a = 0 then inside a function do if a == 0: i get local variable (defined in enclosing scope) referenced before assignment? I assigned the variable then asked if it was == 0 , I did not ask then assign?
can you paste a working example?
yes
def funct1():
if buttonpress == 0:
butonpress = 1
funct2()
else:
buttonpress = 0
print("Started at: ", ticks)
print("Stopped at: ", elapsed)
print("Duration: ", duration)
for r in relays:
r.value = False
elapsed = 0
start_time = 0
end_time = 0
time.sleep(.5)
heres the main loop
while True:
if button.value:
funct1()
time.sleep(.5)
else:
print("Elapsed Time: ", elapsed, "/", duration)
time.sleep(.5)
I set all the variables to 0 at the begining
trying to say has the button been pressed before? with buttonpress = 1 for yes and 0 for no
@heavy galleon full code might help better. can you just commit your current changes and push to your repo which you linked above? or put the current version in a gist?
@heavy galleon an assignment inside a function creates a new local variable, instead of assigning to a global variable
@heavy galleon to change it, you need to use the global (or nonlocal) keyword
to "pull" the global variable into the local scope
cool, i thought it might have to do with global and local varibles I did read you have to do something extra to set it globally while inside a function do remember what I look it up
you need global buttonpress at the beginning of funct1 for instance
also, small typo line 28
for illustrative purposes:
>>> def foo():
... if a == 42:
... print("correct")
...
>>> foo()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in foo
NameError: global name 'a' is not defined
>>> a = 0
>>> foo()
>>> a = 42
>>> foo()
correct
>>>
note you don't need global inside the function if you are just checking the value
but if you do modify:
>>> def foo():
... a = 42
...
>>> a = 0
>>> foo()
>>> a
0
>>>
you need global:
>>> def foo():
... global a
... a = 42
...
>>> a = 0
>>> foo()
>>> a
42
>>>
Well, I don't have anymore syntax errors but my code still doesnt work๐
that's harsh
part of learning right? I'm gonna figure this thing out eventually
Thanks for everyones help today, I will be back tomorrow with more problems ๐
I will do that and add in some comments explaining aswell
Hi @slender iron @stuck elbow or anyone else who might know, are there plans for adding USB HID data to the usb_hid C core module? I'm looking to start adding it myself and want to make sure I'm duplciating effort.
either @slender iron or @tulip sleet would know
Thanks. Looks like micropython has it but for pyboard, so not too useful I think for SAMD21
I don't even know if the peripheral is capable of it
The SAMD21? I'm pretty sure it's possible to add a descriptor for HID data alongside the mouse and keyboard ones that are already there. Just a matter of code
@tulip sleet @slender iron odd behavior with new bundle and CP3.0 master - on my metro M4 Express - every time I try to import adafruit_ssd1306 it hangs - then dismounts the FS and the FS appears to be corrupted. I have restored the FS 3 times and it is very repeatable. I am using the py verisom of the bundle. Just before the last import, I opened lib/adafruit_ssd1306.py and got no complaint. Any clue waht is going on. Is anyone willing to try to repoduce this?
@devout jolt I don't know what hid data is but I'm hoping to allow for dynamic descriptors in 3.x
@solar whale dan is on vacation through tuesday. I'd suggest filing a bug. I'm deep in memory debugging in 2.x now
ok - trying to figure out if the issue is with the bundle or CP 3.0 - I'll file an issue somewhere soon....
after reboot - the FS seems to be intact
sounds like cp 3.0 since it dismounts
yup - I'll file it there
thanks!
Hi @slender iron , I mean the "HID raw"/"hid-data" technique seen in Teensy and many old V-USB projects where the descriptor is just a single 64-byte buffer that can be sent and Input, Output, or Feature reports. cf https://www.pjrc.com/teensy/rawhid.html
but dynamic USB HID descriptors would be super keen
@devout jolt I started: https://github.com/adafruit/usb_descriptor hoping we'd be able to use it from within circuitpython too
I haven't added HID yet though IIRC
@slender iron I was just looking at that. Thanks for your work!
np ๐
WIth CP.3.0 master and l20180110 Bundel release I amm running into a problem on my Metro M4 Express.
Every time I try to import adafruit_ssd1306 the system hangs then eventaully dismounts the FS and dmesg reports a read error. I have recreated and relaoded the FS several times and this is very repeatable. I am using the "py" version of the bundle, but I did verify that is also occurs with the .mpy version.
I am able open and read the lib/adafruit_ssd1306.py file.
I have run a few ot...
@slender iron So I picked the Joy Featherwing to start with and it seems like this should have had a library to begin with. It's using const in the code itself. But I'm having a lot of trouble translating the code into a lib. I changed up some stuff including typos from the guide version (half fixed already in the guide).
Is where I'm at with the code. Here's all I have for the lib:
Didn't update that for linting before pasting it, apparently.
And just fixed a couple of other things too.
@idle owl try starting with what attributes you'd expect it to have
like button_down
ok
I wonder how that library would be used in practice in the first place
you would have to keep polling the button state in a rather tight loop all the time
yeah, I assume the arduino one works with IRQs
except that doesn't help with the analog joystick
but that's much slower than button presses, so maybe you would get away with just polling there
especially if you have some histeresis in how you interpret the readings
wouldnt you want lower latency for the joystick?
depends on the use case, if it's some game-like thing, you want one reading per frame
(just asking, I don't have any experience with gamepad-like peripherals but they're interesting to me)
because that's how fast you are updating the state anyways
if it's more of a menu-like thing, I don't know
maybe we should start with use cases first
then write the code that seems obvious for those use cases
and then design the api so that this code works
good way to go about it
I can thiink about three main uses: remote-controlled toy, video game and menu
what type of menu?
like you have in your mp3 player
so, interfacing with an OLED display maybe?
it waits for you to do something, and then something happens
as opposed to a video game, where something happens all the time
well, there are many different kinds of displays that could be used, you could even just display it in the console
narrowing it down - this line causes it to hang:
from adafruit_bus_device import i2c_device, spi_device
or just
from adafruit bus_device import i2c_device
also causes hang
but
import adafruit_bus_device is OK ??
the point is, you have a different event model in "wait for the user to do something, then react" than in "continuously relay what the user is doing to the toy" and "run the game and react to what the user did at the same time"
interesting
though the first two can be pretty similar
The hang can be caused by:
from adafruit_bus_device import i2c_device
or
from adafruit_bus_device import spi_device
Adafruit CircuitPython 3.0.0-alpha.1-53-gd201ac2-dirty on 2018-01-11; Metro M4 Express with samd51j19
import adafruit_bus_device
dir
<function>
dir()
['name', 'adafruit_bus_device']
dir(adafruit_bus_device)
['path', 'name', 'file']
@stuck elbow yeah thats a good point. I had to ditch my joy featherwing because i couldnt get the buttons to work the way i wanted it to
I had a similar problem to be honest
The only way I could think of would be to modify the seesaw firmware to add buffering on the featherwing side
but that would make it much less universal
I dont recall but I think i had similar issues getting it to work on arduino too, not cp specific
the polling model is tricky
was a lot easier to wire up a joystick and 4 buttons on a pcb and use 5 pins
especially since the operating systems, to which people are used, usually have a keyboard buffer and joystick events
hmm
I don't understand why debouncing couldn't happen on the featherwing
it has a full-blown microcontroller with a lot of spare room
Is that a matter of a driver for it?
ah.
but I think that it would be super-cool if the driver did debouncing if the firmware doesn't
of course that is difficulty nightmare
Do you think it's worth putting a stripped down version of the seesaw lib into the joy_featherwing helper lib I'm doing
I just saw this
no probably not. I don't think it would be as stripped down as I think it would really end up being.
yeah, and then you would need to update it if the seesaw stuff is ever updated
yeah nm.
better keep the maintenance costs low
valid.
@tawny creek that looks interesting!
@stuck elbow I'm gonna try it out later, see if it works alright ๐
c++ source file
Ah
.h are header files
Is // a comment in c++
I don't know why that seems familiar to me.
JavaScript
Java
Nope
any other C-like language
That's the thing, I don't know what falls into that category. Obviously something I've used or at least know how to read.
pretty much anything that uses braces for grouping code
What does the int8_t part of int8_t x = ss.analogRead(JOYSTICK_H) / 4 - 128; mean?
8 bit integer
ah
in C variables have types, not their values
hmm ok
a better way of saying that is C requires variable types be explicitly declared while Python implies the type from the value you first assign it
in C, the actual size of an int is "implementation dependent"
@prime grove that's not true, as you can always assign something else
which usually means the native register size (except in the case of AVR 8-bit MCUs)
so the type defs in stdint.h provide fixed sized options
I'm not a python expert, thanks for the clarification
@prime grove python's variables are more like pointers, they just point to values, which in turn have their types
this CircuitPython code for this was definitely translated directly from the Arduino code. The oddness of it is making a lot more sense. @tawny creek did you get that link from the featherwing guide? It's there too if that's not where you got it
@stuck elbow So would all of this work better if CircuitPython were using an interrupt pin as well? I didn't realise it had the optional interrupt pin jumpers on the bottom. Obviously a lib would have to work with and without the interrupt pin but still.
Looking at the schematic I'm not even sure how it interacts with interrupts.
I'm honestly not sure how well the interrupt pin would work with debouncing on the CP side
Ok
I suppose you could record events with timestamps in a buffer, and use the timestamps to decide if a button is bouncing or not
but I can't think of a way of coding that elegantly
Neither can I, but that's not really saying much. If you can't think of a way, then it's probably unlikely
and then there is the joystick, which has no interrupts because it's analog
ah ok
I guess a library that just copies the Arduino one is a start
ad then we can improve it
I'm not seeing an Arduino lib for it. Are you making a general reference or do you have a specific one in mind?
Also I take it # doesn't comment out in Arduino?
it would be good to see a "scope view" of the bouncing switches. It might be as simple as sampling them at twice the average settling time
the one that @tidal kiln linked?
Oh. Ok. I was trying to find an official one.
FeatherJoyWing - Enables an easy interaction with the JoyWing Feather by Adafruit
Yeah I still have it open, I wasn't thinking about that one. Thanks ๐
@stuck elbow interesting coding style; near zero comments ๐ฆ
@idle owl in c/c++ # is a prefix for preprocessor directives, like #define and #include
welcome to the open source
@stuck elbow you're right of course. I try to make my GitHub projects more understandable
and optimized (when possible)
in general, yes
@idle owl the .h file is copy-pasted where it says #include in the .cpp file
I saw that, wanted to make sure. Ok good.
it's like import, but dumber ๐
the build goes something like: source code -> preprocessor -> compiler
the compiler won't see the #'s
Hi im new to discord and circuit python
I love circuitpython so far, i think i might like it more than arduino (jurry is till out though)
Welcome @little depot !
@idle owl thanks!
@little depot glad to see you like it, we are all very excited by it ourselves
if you start to play a file, then do some neopixel stuff before the file is done playing, you get a hardcrash!
verified with 2.1 and 2.2
@stuck elbow yeah i cant wait untill there is widespread library support
Question:
Im using the Feather Adaloger M0 and
i was wondering
how to drive a pin with pwm?
this is what i found on pwm
https://learn.adafruit.com/adafruit-gemma-m0/circuitpython-pwm
@little depot that should work, only pins will be different
what would be the equvelant of
analogWrite(255) => pwm is 100%
im trying to dim an led
set duty_cycle to 65535
So I wrote some simple code to make my CPX tell me what the IR sensor is reading
from analogio import AnalogIn
import board
import time
while True:
print(AnalogIn(board.A10))
time.sleep(0.1)
It gives me an error telling me
File "main.py", line 6, in <module>
AttributeError: 'module' object has no attribute 'A10'
According to the learn article, A10 should be connected to the IR sensor. What's happening?
if you type in the repl import board and then board. and press tab, you will see what is available
Yah. That's not how board reads it.
But the learn articlehas code that reads pin A1 this way?
A1 is a dedicated analog pin
The IR is named differently in the board module. I don't remember specifically
From the learn article: There's also a secret capability, you can read the 'raw' analog value from the receiver LED diode to do basic IR proximity sensing. The direct analog value is available from pin A10
Can you link please?
I wonder if it's specific to Arduino.
I don't know, I've never tried that in CircuitPython
>>> import board
>>> board.
A0 SPEAKER A1 A2
A3 A4 SCL A5
SDA A6 RX A7
TX LIGHT A8 TEMPERATURE
A9 BUTTON_A D4 BUTTON_B
D5 SLIDE_SWITCH D7 NEOPIXEL
D8 D13 REMOTEIN IR_RX
REMOTEOUT IR_TX IR_PROXIMITY MICROPHONE_CLOCK
MICROPHONE_DATA ACCELEROMETER_INTERRUPT
ACCELEROMETER_SDA ACCELEROMETER_SCL
SPEAKER_ENABLE SCK MOSI MISO
FLASH_CS
>>>
Was just about to paste that
i think you're after IR_PROXIMITY
The guide is written about the CPX, the entire guide is not specific to CircuitPython
How did you get that list?
Connect to the serial console, enter the REPL, type the commands at the beginning of that code block into the REPL.
tab completion
dir(board) will give you a similar but not as cleanly lined up list.
you can also just do dir()
>>> dir(board)
['A0', 'SPEAKER', 'A1', 'A2', 'A3', 'A4', 'SCL', 'A5', 'SDA', 'A6', 'RX', 'A7', 'TX', 'LIGHT', 'A8', 'TEMPERATURE', 'A9', 'BUTTON_A', 'D4', 'BUTTON_B', 'D5', 'SLIDE_SWITCH', 'D7', 'NEOPIXEL', 'D8', 'D13', 'REMOTEIN', 'IR_RX', 'REMOTEOUT', 'IR_TX', 'IR_PROXIMITY', 'MICROPHONE_CLOCK', 'MICROPHONE_DATA', 'ACCELEROMETER_INTERRUPT', 'ACCELEROMETER_SDA', 'ACCELEROMETER_SCL', 'SPEAKER_ENABLE', 'SCK', 'MOSI', 'MISO', 'FLASH_CS']
>>>
ok, you were first that time @idle owl
Ah
Tried loading 3.0 onto Metro M0 Express. No problems executing any of the problematic imports above.
Is there any possible way to call a function asynchronously on CPX?
Thanks for all the help earlier btw, I got that part working
very interesting - making the following changes fixes the problems on the metro M4 express.
I can now import adafruit_ssd1306 !!
a bit more investigation:
the syntax:
import adafruit_bus_device.i2c_device as i2c_device
works as well
most of the modules use this syntax or
from adafruit_bus_device.i2c_device import I2CDevice
it looks like only pca9685, sdcard, ht16k33 and ssd1306 use
from adafruit_bus_device import i2c_device (or spi_device)
which causes the problem for CP3.0
@timber mango Asynchronously, as in having two separate functions happening at the same time?
Yes
Not on Circuit Python. Microcontrollers can't do multi-threading.
Hmm
What are you trying to accomplish?
Basically what I'm trying to do is have the NeoPixel example and the IR Christmas ornament examples work together so when I press a ceertain button on the remote it plays the rainbow demo until another button is pressed to change the color or turn the lights off
Well, that can be done.
It probably doesn't help that I'm fairly new to CircuitPython
Or, more accurately, you can make something like that work. You'd probably have to re-write everything, though.
Well, everyone's a newbie at some point.
And realistically speaking... you can't be TOO versed in CircuitPython. It's not that old
I've rewritten the rainbow demo with if statements instead of for loops, the main problem is that the IR decoding code stops the entire program until it gets a signal to decode
It's more difficult with the animation because the animation will want to go for a certain amount of time. I tried adding the rainbow animation to that example previously and ran into issues with the looping. Other things came up and I never finished trying to sort it.
Yeah, you'd have to check for an incoming signal at pretty much every point.
So for me, either the animation would go for one iteration and then stop, and I could then signal something else, or it would loop and it wouldn't pay attention to the incoming IR signals.
If I remember correctly anyway. Been a while.
That's what happened to me too
I can signal for the animation repeatedy and it will step through
My solution would be to overengineer it. Move the neopixel control to a separate microcontroller. It'd happily run through a loop until a certain pin was pulled high, at which point it'd check I2C, where the main controller would give it instructions.
Of course, my solution to everything is to overengineer it
My possible solution is to get a second IR sensor to detect that a signal exists, then trigger the actual decoding part
I'm sure that could be done on the CPX without an additional sensor. not entirely sure how, though.
I tried to make it work but if I try to have the pin for the IR sensor be used for both detecting the existence of signals and decoding signals it gives me "pin is busy" errors
The error gets set off by just declaring multiple variables that use the pin
The sensor and the receiver are two different things.
No I'm reading what you're saying wrong, sorry
Scratch that.
I'm accessing the digital demodulated pin (39)
I'm not sure the pin itself should be decoding. That might be part of it. I guess I'm not entirely sure what you've tried though.
But not by directly giving it pin 39, I'm using something like IRREMOTE or something
Right
Have you looked at the ir_remote lib itself to see if understanding how the decoding is done will help you with what you're doing?
Not quite yet, I might try that tomorrow
So far I've just observed that when you tell it to listen for a signal it doesn't proceed withthe rest of the code until it gets a signal
I think it might be a limitation of the hardware. But I haven't explored IR that much, so I'm guessing.
silly question: when using
to compile the esp8266 firmware using make BOARD=feather_huzzah, will the .bin work on ANY esp8266 or only on the Huzzah? (trying to make sure my documentation is accurate)
@raven canopy I have used it on the Huzzah breakout as well as the Feather Huzzah. BTW I belive feather_huzzah is the default and the only board included so specifying it does not actually do anyhting. You get the same build for just "make"
@solar whale yeah, i knew that it's the only one listed, so make defaults. just didn't know (haven't peeked behind the curtains on the makey stuff) if there is any adafruit/feather specific stuff going on. thx!
@raven canopy the important thing would be to see if the pinouts of any other board agreed with boards/feather_huzzah/pins.c
well, since this is going to be a
billed SDK...maybe I should just use the Huzzah in the docs. Or let the adafruit folks make the decision. who am i kidding? i'm still going to look... ๐
We are just starting with circuitpython on a Adafruit Feather M0 Adalogger. Where can we see coding examples? I'm a retired engineer, now Astrophysics graduate student, and my friend is a nursing student. I'm teaching him programming and electronics from the ground up using the adaFruit cornucopia. We want to build wearable phsiological monitors, first just monitoring breathing with the stretch sensor, and recording a night's breathing to the microSD, as a sleep apnia detector. Then include heart rate, breathing sound, and whatever else. But just the stretch sensor to start.
@civic socket here is the amazing Welcome to CircuitPython guide that @idle owl wrote. This will get you the overview..
https://learn.adafruit.com/welcome-to-circuitpython
We did get circuitPython loaded, and we worked halfway through that page.
The onboard main.py for the trinket is pretty good, we have two of those also. Is that code applicable?
Sweet! Congrats! If you goto the product page (this is my usual technique), there will be a lot of learn guides associated with that product. They may not be exactly product specific, but a lot are.
@civic socket yes, the main.py should run on either. you just may have to change some pins referenced in your code. they are both non-express boards, so the base firmware is the same.
thanks! will try that
I had it up, so here is a shortcut: https://www.adafruit.com/product/2796
keep in mind there is no "dotstar" on the M0 Adalogger ...
that slipped me mind. so the main.py that is "shipped" with the trinket would fail on that, yes?
yes
actually I'mnot sure what it would do - might fail "silently".
it is not reading back from it so it may not care.
there will definately be some pin names taht have to be changed.
time for bed - good night all.
night jerry
I've got a strange error with trying to initialize a sdcard on a feather HUZZAH with the Adalogger Wing. Once I get to "sdcard = adafruit_sdcard.SDCard(spi, cs)" I get an error saying "function does not take keyword arguments".
I've also downloaded the most recent bundle and pulled out adafruit_sdcard.mpy, and adafruit_bus_device
I'm trying to get an si7021 temp/rh% sensor to log to the sdcard but can't get the sdcard started.
Tried recompiling under gcc 6.3.1 since this seems familiar but the problem still occurs:
from adafruit_bus_device import i2c_device
causes it to hang and dismount.
@stark wolf this works for me on an esp8266 with latest CP2.2 and lib files ```import adafruit_sdcard
import busio
import digitalio
import board
import storage
Connect to the card and mount the filesystem.
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
cs = digitalio.DigitalInOut(board.GPIO2)
sdcard = adafruit_sdcard.SDCard(spi, cs)
vfs = storage.VfsFat(sdcard)
storage.mount(vfs, "/sd")
@stark wolf that was saved as sdmount_adafruit.py and then: ```Adafruit CircuitPython 2.2.0-2-g8251abb on 2018-01-12; ESP module with ESP8266
import sdmount_adafruit
import os
os.listdir('sd/')
['.Spotlight-V100', '.fseventsd', 'sdtest.txt', 'test.txt']
@stark wolf note - I use GPIO2 as my CS - The default is GPI015 - That should not make a difference, but I had to move it for compatibilty with other projects.
@solar whale thanks for poking at that. Thought I had to use bitbangio like I did with i2c. I'll try again after work with busio.
@stark wolf it has hardware SPI for the default MISO/MOSI and SCLK pins. And I think there is an issue open regarding differences in the API for bitbang,
@solar whale I figured as much after reading your post. I need to be more careful to remember which is hardware driven and which is software bit banging in the future. And thanks for the warning about bitbangio's API. Thought they matched.
@stark wolf It may not be relevant, but this issue is open - I have not tried bitbang SPI myself. https://github.com/adafruit/circuitpython/issues/472
@timber mango the pulseio.PulseIn code is buffered so you should be able to make a non-blocking decode for IR. it will take time gaps from your animation but you shold be able to do it without waiting
Here is a sneak peek of what I've been working on. Its a chart of the heap:
woah
heap indeed
Could have made a heap of Blinkas.....
would be happy for heaps
@slender iron seriously though, that's amazing.
Oh nice!
I want to break it down even more and make it easier to generate
That's great ๐
if button.value: does the same thing.
comparison to true should be 'if cond is true
Yep
i thought thats what i wrote is button press is true.. but i keep getting that error
this formatting is killing me
What error are you getting?
if button.value:
print("button pressed")
else:
print("button no pressed")
it doesnt like me having an else in there
same when i do a while loop i cant have an else statement
The else needs to be at the same level as the if
You can have while but it would want the if inside of the loop like so: python while True: if button.value: print("button pressed") else: print("button not pressed")
Python is all about indents. That's why it's being fussy about where you have things.
it was throwing me off too I can't use: if button.value == True:, but if button.value: works fine
Correct, they both work, the second form is more pythonic is all.
I think being explicit only works in some situations. In this situation, it's not needed.
I misread what you said on the first pass.
thanks that helped I do the stuff and understand it then when I go back again I end up formatting something wrong and gives me a headache. Ill get it eventually
It takes a little getting used to. Python works with less code, but it means understanding what Python is inferring from the code you write.
I'm glad it helped!
@heavy galleon what editor are you using to write your code?
@slender iron I'm using MU
cool! it should be helpful then. I was gonna suggest making sure you are using a monospace font. that way everything should line up well
I may have Sparky'd my joy feathering with literal sparks... I static shocked it a few days ago and now it'll disconnect every so often. Just ordered another one to see if it's me or the code.
It returns the same traceback when it drops though, so it might not be the hardware.
@idle owl double check your connections~
It's attached to a feather doubler that worked for a couple of months with another wing. And it wasn't until after I zapped it that it started doing the drop routine. Soldering all seems solid.
I was 'upgrading' a trinket m0 in a project to a feather m0 express last night and the program would upload but no serial, no response but the led status lights.. solder points were good too - then i remembered a quirk with the i2c battery monitor im using (its SCL/SDA lines were pulled up directly from the battery), plugged in the battery and the thing started working \o/
huh.
try a different microcontroller ~
how do you use the mic on CPX? I tried this. when i play it back it doesnt seem to work, the only thing it seems to record are bangs and taps but voice sounds like ticking
b = array.array("H")
def getsound():
for i in range(200):
b.append(0)
with audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, frequency=16000, bit_depth=16) as mic:
mic.record(b, len(b))
print('Sounds Recorded')
print(b)
@upbeat plover make sure you are using 2.2.0 there improvements to the audio stuff in it
im currently using that, do i need some kind of filter to get it to work?
is there an example somewhere?
there is a sinc filter internally
@idle owl do you know where the volume meter demo is?
CPX main guide under CircuitPython Playground. Give me a second, I can grab it
thank you @slender iron and @idle owl
no problem!
For sure!
who in this channel has been building their own boards with circuit python?
(I have a few questions - designing a badge for BSidesBoston this year and I wanna do one with circuit python)
"with" or "for" CP?
I forgot who, but someone was doing blinka-style boards
yes! that's it thanks
hey everyone, happy friday ๐ !
I'm just getting started with circuitpython and i have a couple questions
first, where does this REPL come from that people are talking about? it comes with MU?
looks like a great way to debug things ^^
ahhh ok, i will try this out
i've been using pycharmm but it doesn't really know what to make of the gemma
thanks ๐
my other question is about adjusting the brightness of the neopixels. I'd like to find a way to do this based on user input (ie pressing a capacitive button) instead of plugging in a computer and modifying the code. Is there a way to change the brightness setting after the strip is initialized?
sure - you'd just do something like an if statement to check for the button value to change (false -> true for a debounced pushbutton)
and then adjust the brightness
oh, awesome
so it'll be like pixels[0].brightness(.5)?
and i can do it on a per pixel basis?
or it looks like something like that should work
i don't have my board with me actually but i will try when i get home, thanks so much ๐
yea, np. best part about the repl is "instant gratification debugging"
With a trinket m0 on version 2.2.0 I'm running a loop to read from a DHT11, sleeping 3.0s between reads. I'm only printing the values in the repl.
If I leave the code running for less than 10min, I eventually get on the repl
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "adafruit_dht.py", line 190, in temperature
File "adafruit_dht.py", line 172, in measure
RuntimeError: Checksum did not validate. Try again.
Any ideas?
could be noise in the signal, does it occur after a random period of time?
Hi
It would be cool if circuitpython would support the Adafruit TSL2591 High Dynamic Range Digital Light Sensor right out of the box (or within the bundle). Seems legit to me since this is the most capable light sensor in the Adafruit portfolio, and the only one with is able to handle the range needed for modern photography (as support).
Actually I will work on my own driver, witch i'am willing to share when it is done, but first I need to learn more about i2c communication and python in ...
@tidal kiln It has a very short cable, and is away from other sources of RF other than the laptop I'm using to view the repl.
but does it occur randomly?
I'm adding a variable to count the cycles right now.
It just died at 12 cycles (with time.sleep 2.0), and it just did it again for a second time.
Now on cycle 5.
what are more stable than DHT's?
@timber mango Oh great, I'll try with that code, thanks a million.
@sick creek This is a fresh guide, and that is an excellent sensor, I use it in my brewery all the time.
Now, the sousvidouino code is just asking for a CP port ๐
@timber mango hi!
i can look at metro guide now
Ok I was just about to ping you about it. Nice timing
Feather and CPX are done as well. So once Metro is settled, that's all of them updated.
ok i made https://learn.adafruit.com/admin/guides/1636/editor/11334 live
Ok I'll move the pages around and take the other one down
yah https://learn.adafruit.com/adafruit-metro-m0-express-designed-for-circuitpython/circuitpython-setup can be de-mirrored
yah!
close to wrappin' up!
I'm going to delete it from Feather too now. I only had it left in there because it was mirrored
do you want to point people to https://learn.adafruit.com/welcome-to-circuitpython/installing-circuitpython at the bottom of the quickstart?
ill let you do yer magic
Hmm. Could mirror installing. Is the quickstart enough?
i mean, i think its worth adding a note at the bottom "For more detailed info..."
that sounds like a good way to do it
I couldn't think of how to make it not seem weird, but your way makes perfect sense
Ok. Updated. Last thing is, for CPX, I'm thinking rename "CircuitPython Quick Start" to "CircuitPython" to match the others, delete the current "CircuitPython" page, and mirror in "What is CircuitPython?".
ok keen
Done! We'll update the top of the install page once it starts shipping with CP.
Just tested the Saleae for the first time on this machine, wow is it fast.
FYI I'm working on a couple new pages for my dotstar wing + CP guide: "LED sand" and a simple game.
neat. how's the game work?
Just a simple gauntlet game
If you remember racing games on the Atari2600... it's sort of like that.
yes. i do.
Hello !
ESP8266 uid is now functioning the same as SAMD. machine.unique_id is still available. 2/3rds of the way there. nRF showed up a couple days ago, so that's the next backend to learn! ๐ข
#4 ets_task(40100130, 3, 3fff8380, 4)
boot.py output:
Press any key to enter the REPL. Use CTRL-D to soft reset.
Adafruit CircuitPython 3.0.0-alpha.1-49-g068479d-dirty on 2018-01-13; ESP module with ESP8266
>>> import machine, microcontroller
>>> print(machine.unique_id())
b'\x02\xd8\xc6\x...
I have narrowed town the build that introduced this problem to:
adafruit-circuitpython-metro_m4_express-20180105-5cb361c.uf2
from adafruit_bus_device import i2c_device works on builds prior to this on and fails on builds since.
enabling MICROPY_PY_BLE_NUS in bluetooth_conf.h results in the following error.
It builds fine if this is left disabled.
`$ make BOARD=feather52 SD=s132
Use make V=1, make V=2 or set BUILD_VERBOSE similarly in your environment to increase build verbosity.
Generating build-feather52-s132/genhdr/mpversion.h
GEN build-feather52-s132/genhdr/qstr.i.last
QSTR updated
GEN build-feather52-s132/genhdr/qstrdefs.generated.h
FREEZE freeze
LINK build-feather52-s132/firmware.elf
build-feather5...
I tried adding mp_hal_stdin_any to nrf/drivers/bluetooth/ble_uart.c.
The build compiled with this added, but the BLE REPL did not work.
I added this function to ble_uart.c:
bool mp_hal_stdin_any(void) {
return (!isBufferEmpty(mp_rx_ring_buffer));
}
I attempted to base this on what was in nrf/mphalport.c but is not compiled when MICROPY_PY_BLE_NUS is enabled.
Can't get "pip install circuitpython-build-tools" to work... Any help?
@regal ravine what OS are you using and what problem are you having?
@regal ravine on my linux system it worked for me if did the installation in the Adafruit_CircuitPython_Bundle sudirectory created when I cloned the repository.. python3 -m venv .env source .env/bin/activate pip install circuitpython-build-tools
Okay thanks figured it out... I accidentely used python instead of python3 so it didn't find the "circuitpython-build-tools" package... Now it works!
The REPL/UART code changed with the migration to CircuitPython, which handles the UART abstraction differently. Migrating BLE UART support is at the top of my ToDo list now that the base nRF52 stuff is working ... we've been ignoring the SD until now. The reason the flag fails is because it relies on the MicroPython REPL abstraction layer which we don't use anymore.
Thanks for the update and clarification. I'll look forward to trying it out. Thank you for all the work you have put into this. No rush on my part. I'll (try to) be patient ;-)
I have been playing with some of the ubluepy examples and they seem to work so far. I had tried the NUS in the past and could connect to it, but the apps I was using could not properly send the EOL so I could not get very far. I could see the prompt, but never get it to accept any input since it never saw proper ...
I'll get this fixed this week and a PR sent out. I had the same EOL problem, and the OS X and iOS Bluefruit LE Connect apps now have an option to change the EOL character(s) because of that, which should help. The Android version is updated internally, but I need to schedule in some time with the app dev to do some final tests before pushing it out, but I'll try to get that wrapped up soon as well.
I can't get this code to work
I'm trying to control a motor when with a relay
If I connect it to 3.3v it works, but not with my code
my code is: from digitalio import DigitalInOut, Direction, Pull
import board
motor = DigitalInOut(board.A1)
motor.direction = Direction.OUTPUT
while True:
motor.value = True
Actually, I think this circuit playground is acting weird
I tried it with other things and it didn't work
nevermind, I tried the same code on a trinket m0 (with a different pin) and it didn't work
Can someone please help?
@carmine hornet I may be mistaken, but I donโt think the output pins can provide enough current to drive a motor. You will need something like https://www.adafruit.com/product/2927 or some additional circuitry to be able to drive the motor.
A Feather board without ambition is a Feather board without FeatherWings! This is theย DC Motor + Stepperย FeatherWing which will let you use 2 x bi-polar stepper motors or 4 x ...
They are controlling a relay
@carmine hornet @solar whale Is the relay coil connected directly to the output pin? Via an optocoupler? ...
D4 on the trinket is connected to the relay coil
The output pin might not be able to drive the relay coil directly. Have a look at https://www.allaboutcircuits.com/projects/use-relays-to-control-high-voltage-circuitswwith-an-arduino/
Verify about driving directly, I have a couple different types of relays; one type has a transister driver, and the other has an optocoupler.
MCU output pins can't supply very much current, so you often need a driver of some sort to do much more than light an LED.
Hey all! I got the "digital sand" demo running acceptably on a featherM0/CP/dotstar-wing. Will aim to demo it on Show&Tell this week and add it to my dotstar/CP guide.
how can I see what an OSError means? I know there's an issue on github for reporting it better but I'd settle for a less-better example. I can't seem to find it anywhere in the docs, either
in particular, error 5
it's probably MemoryError, in which case I don't really know how to fix it
(by not importing sys when I didn't need it, it turns out)
(orrrr not)
@opal elk I had to trace it down...but ask, and ye shall receive!
https://github.com/adafruit/circuitpython/blob/master/py/mperrno.h
thank you! I was just starting to look through there
yw
I/O error? wha...
yeah, not exactly verbose.
possibly the least readable code I've ever written... (mostly the second line)
oled.text(" {:0<3} {:0<3} {:0<3}".format(*[abs(int((int(int(v)-v*10)-(int(v)-v*10))*1000)) for v in (x, y, z)]), 0, 20)
that takes a three tuple of accelerometer data, ie (-0.1234567, 0.3141592, 0.9876543) and formats it over two lines with three characters per line, including the negative sign if appropriate
waaaait no it doesn't, not always
"{:.1f}".format(0.987) is '1.0' ๐
(that makes total sense, it just means I can't use it for my dirty deeds)
and also str(abs(v))[3:6] will give me what I need for line 2
@opal elk You're playing with accelerometers too?
yep! I have a CPX strapped to the back of a pinewood derby car
cool
I made an accell/mag featherwing, and used it (just the accel) to do a compact digital sand demo in CP
i'm playing with vagrant/VM and trying to build CP on the Feather nRF. i'm defnitely losing...
@sommersoft#0222 I have been able to get it to work following the instructions in https://github.com/adafruit/circuitpython/tree/master/ports/nrf/boards/feather52. Where are you having problems?
Hi Guys. I want to learn how to use the program language for Arduino to use on Neopixels. I understand that I can copy some of the examples and modify it but I'd like to learn what it all means so I can create and modify understanding what I'm doing. Can you please point me in the right direction?
@solar whale haven't been able to get the VM to use the USBtoUART driver for the board...so I'm stuck at the single-bank DFU bootloader. and that is the guide I've been using.
@raven canopy ah - I have not tried using the VM to upload - I always copy the files to the host then upload, but they may not work for the nrf52 since you need the nrftools.... however under linux, the port normall would be /dev/ttyUSB0 not USBtoUART as in the guide - that is a MACOS name.
try just chaning to SERIAL=/dev/ttyUSB0
i tried with USB0...failed b/c "no serial connection found" or something to that effect
the is a way to route the USB conncections int the VM - Tony Dicola discusses it in one of his videos ...
yeah, that's how i got the VM to see it in the first place (not from his video though). and after burning the DFU with arduino in a desperate attempt...VM won't recognize it anymore. hehe. the joy!
i'll have to see if i can find the tonyd vid...
so it does compile at least - thats a big step!
sidenote: the nRF board package takes FOREVER to install.. โฒ
watching tony's nRF video now. already, he hits me with knowledge. I totally glossed over the fact that it uses the M4 vs the M0.
@raven canopy I suppose you could copy the necesary files to your host system and execute the uplaodfrom there - after installing the nrfutils loaclly -- the commands are in https://github.com/adafruit/circuitpython/blob/master/ports/nrf/boards/feather52/mpconfigboard.mk
It is M4 , but not an ATmel M4 ( it is Nordic Semi ) that also got me confused!
what is the link to his vieo?
It means that much of the device support is using differnt code than on the atmel chips. (not based on asf4)
taht was the vidio I was thinking of. - I think he describes how to do it. trying to find where. Nice video
i'm at 15:xx. he's early in the vagrant setup
its around 31: - he talks about compiler errors around 20 but they don't occur any more
also the desripttion he uses for nrfutil install is old - it is simpler now and I think you already have it done from the guide.
yeah, that was a tricky one. i started reading/planning using the info on the /ports/nrf/readme. I got confused quickly... then, i stumbled on the /ports/nrf/boards/feather52/readme. much easier to follow. ๐
the magic is at 36:30 or so
another sidenote: tony is a nano-ite. i like him even more! hahaha
Anyone knows how to use Sublime Text with Circuit Python? I have already installed Deviot but do not know how to continue from there.
@raven canopy just a heads up: After he gets it loaded, he starts playing with the ubluepy examples. For the default build in the feather52, the BLE support is not enabled so they won't work. I have enabled it ( just uncomment in the mpconfigport.h) and run these examples on the feather52. Also, the new ampy does work, with the -delay parameter set to 1.5
hmm. that's one thing i may have done wrong. i think i ran the nrfutil in a lower tree...hmm.
well, it runs fine from ~, so should be fine.
I don't think it mattrs since it just installs it.
the feather52 port on cicruitpython has come a long way since this video!
I like Tony's predicitions for the future of the nrf52 -- coming true!
@solar whale is it still required to do the single bank step? that's where i'm failing
ye - do the boot-flash first then the dfu-gen dfu-flash - is it just failing to connect?
did oyu get it intp DFU mode - ground the DFU pin then RESET
yeah
nrfutil dfu serial --package boards/feather52/bootloader/feather52_bootloader_2.0.1_s132_single.zip -p /dev/ttyUSB0 -b 115200
Upgrading target on /dev/ttyUSB0 with DFU package /home/vagrant/source/sommersoft/circuitpython/ports/nrf/boards/feather52/bootloader/feather52_bootloader_2.0.1_s132_single.zip. Flow control is disabled.
Failed to upgrade target. Error is: Serial port could not be opened on /dev/ttyUSB0. Reason:
Possible causes:
- Bootloader, SoftDevice or Application on target does not match the requirements in the DFU package.
- Baud rate must be 115200, Flow control must be off.
- Target is not in DFU mode. Ground DFU pin and RESET and release both to enter DFU mode.
so - just to be sure - you ground DFU pin then RESET - remove ground and it in blinking the red LED... corrdct?
correct
and the USB bridge is loaded
vagrant@vagrant-ubuntu-trusty-64:~/source/sommersoft/circuitpython/ports/nrf$ lsusb
Bus 001 Device 002: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
try disconnecting USB port and reconnecting - sometimes it gets aonfused -- is you do ls /dev/ttyUSB* do you see USB0?
yep
what are permissions on /dev/ttyUSB0 ? Do you have to be a member of group dialout to acces it? Are you?
now I have to remember long forgotten linux cmds... ๐
ls -la /dev/ttyUSB0
that one i remembered.
crw-rw---- 1 root dialout 188, 0 Jan 14 15:28 /dev/ttyUSB0
grep dialout /etc/group
if not in it : sudo adduser <username> dialout
not sure if thsi will help, but worth a try
I think you are user vagrant
yeah. giving it a run now
but since tony did not run ito it, I'm not optimistic...
no go. โน
yeah
I have "gotten" stuck at thsi point - disconnecting the USB usually helped.. You are so close.....
when you connect, do you gnd -> dfu? or do you just rst after connecting?
I just connect ground ->DFU press reset then remove the jumper -- sometimes I power down the feather (disconnect) connect the jumper power up then remove the jumper.
well, there is a win32 binary for nrfutil...maybe i'll try that route.
worth a try -- but it has to be the same version to support dfu, I think -- Do you have python on the windows system - can you just do the install steps there? AS in the feather52 guide?
yeah, i have 2 & 3, and have figured out run pip/etc through powershell/cmd. i haven't program hopped like this in a long time. ;D
good luck --- I'll be off for a bit. Hopefully you'll crack this soon. BTW if you get boot-flash to work, I find taht is stays in DFU mode so I dont have to reset it to load the dfu-flash.
thanks. we'll see. i have to get moving myself, so this may be on pause until tonight.
Please ask on the support forum: https://forums.adafruit.com/viewforum.php?f=60
GitHub issues should be used for bugs and feature requests.
Do the workarounds for CPython compat still work in CPython? I don't want us teaching bad habits that break when moving to CPython.
Camerutttt, It is possible, just write your python code, and when you save it, call it 'main.py' or whatever filename you like.
/\ me
sorry, scott. :)
<i class="fa fa-check-square" aria-hidden="true"></i>
I found this summer camp at brown college: https://precollege.brown.edu/catalog/course.php?course_code=CECS0604
It's a 2 week course on micropython
wow ๐
@solar whale finally got it to run the single bank dfu. i edited the usb passthrough name in virtualbox; the name had the version at the end [100] which i think was tripping up ubuntu.
Is there a way to trigger cap touch with an object that has copper tape on it and you aren't touching the copper tape?
I tried putting conductive tape on the end of a syringe for a project but it won't work
What do you mean by a cap @stuck elbow
a capacitor
actually, a capacitor alone could be not enough, the other end would probably need to be grounded somehow
but what are you trying to actually do?
maybe there is a simpler way
Sense when the syringe has moved to a specific point
The syringe is powered by hydraulics
What's that?
I need the syringe to be able to move past the point though
Would it let me do that?
well, some smart mechanical design would be required for that
another way is to use a led and a photosensitive element
and a hole in that thing that moves
I think an endstop switch would be best
It think I could place it in the right stop so that it only trigger at that spot
a hall effect sensor and a magnet would work too
or even a simple reed switch and a magnet
I'll see what works best for me
@carmine hornet IR break beam set, would work and are really cheap.
@slender iron working on nRF uid right now. however, seems that struct hasn't made it into the build yet. so, the ability to unpack the bytearray won't be there. i can add a note to the spinx-doc that nRF isn't unpackable yet...
@raven canopy thats fine. PLease file an issue for struct too
can do, but its not just struct. most of the shared modules are commented out of the Makefile:
* bitbangio/__init__.c \
bitbangio/I2C.c \
bitbangio/OneWire.c \
bitbangio/SPI.c \
busio/OneWire.c \
gamepad/__init__.c \
gamepad/GamePad.c \
struct/__init__.c \
uheap/__init__.c \
ustack/__init__.c
i'm going to move it out of the commented section and see if i can get it to compile. might be better to put in an issue for all of the (desired) shared modules? @slender iron
yeah. that's why i wasn't stressing it too much and just going to add the note..
it built just fine with struct. now to see if it actually works.
nope. still get no module named
The shared modules below are not currently included in the nRF port build (taken from Makefile). Obviously, some will be easier than others so I put them in as a task list.
- [ ] bitbangio/init.c
- [ ] bitbangio/I2C.c
- [ ] bitbangio/OneWire.c
- [ ] bitbangio/SPI.c
- [ ] busio/OneWire.c
- [ ] gamepad/init.c
- [ ] gamepad/GamePad.c
- [ ] struct/init.c
- [ ] uheap/init.c
- [ ] ustack/init.c
@raven canopy looks excellent thanks!
<@&356864093652516868> Our meeting will not be tomorrow due to the US Holiday Martin Luther King, Jr Day. We'll do it on Tuesday instead at the normal time 11am Pacific / 2pm Eastern here on Discord.
/shared-bindings/index.rst: updated Support Matrix format as discussed in PR #503 & Issue #448.
Issue #462 :
/shared-bindings/microcontroller/Processor.x:
- Added functionality for retrieving the unique identifiers for all ports that support it.
- Sphinx-rST documentation is in place, to include a note that the nRF port does not currently include
structfor bytearray unpacking.
/shared-bindings/ports/XXXX/Processor.x:
- Added functions to retreive unique identifiers for t...