#circuitpython-dev
1 messages ยท Page 205 of 1
I'm having an issue with my CPX needed to reflash so i did that with 3.0.3 and then put the whole lib on the board 3.x --- so i can get it to blink with cpy but nothing else - any suggestions - what am i missing.... - am i asking in the right space?
@sabas1080 @deshipu Your boards are in the boards/ directory. Feel free to start a new list "third-party" or "non-Adafruit" boards list with names and links to your things.
@solar whale hmmm. works for me too. i was using: Adafruit CircuitPython 3.0.3 on 2018-10-10; Adafruit CircuitPlayground Express with samd21g18
You fixed it ๐
@warped pendant can you provide more details on what the "else" is that doesn't work
@warped pendant do the examples here work?
https://circuitpython.readthedocs.io/projects/circuitplayground/en/latest/api.html?highlight=CPX
an old program that was on it won't work now. and like right now the board isn't loading -ccable is fine and such mu doesn't see it so i go to bootloader ... and no the readthedocs samples aren't working. - i'm worried my board is failing ๐ฆ
@idle owl is there a spi flash erase bootloader thingy for CPX?
@upbeat plover There is a flash eraser file for CPX, yes. Check the troubleshooting page to find it.
@idle owl i looked through here and didnt see, can you please link
https://learn.adafruit.com/adafruit-circuit-playground-express/troubleshooting-2
Make faster and easier than ever with MakeCode, code.org CSD, CircuitPython or Arduino!
Apologies, we were inconsistent with mirroring the troubleshooting pages appropriately. I believe it is in the troubleshooting page for Trinket M0. Hold on.
We suggest this way though, if at all possible: https://learn.adafruit.com/adafruit-trinket-m0-circuitpython-arduino/troubleshooting#easiest-way-use-storage-dot-erase-filesystem-18-15
i think this may fix your CPX but old code probably still wont work, i have lots of code from 2.0.0 that only works with that version
@upbeat plover in boot just drag that?
yes
@tidal kiln https://forums.adafruit.com/viewtopic.php?f=60&t=142494 maybe they're using the lib/ version of the cpx lib instead of the frozen version?
i tried erase from terminal yesterda --- ok thanks
@tulip sleet good idea. i told them to delete it in the other thread. maybe they didn't see that in this thread. @solar whale what were you doing about that?
boom. memory allocation error...
why i love m4 now... i have yet to get that
who could ever need more than 192K of ram...
we'll get there.
omg thank you @upbeat plover rainbow pixel love happening ๐ ๐ ๐
I was mis-quoting Bill Gates --- long time ago....
Version 4
- Prepend C modules with an underscore
_as CPython instead ofuas MicroPython. Thus the change is:utime->_timeanduos->_os
is it wrong i want a m4 CPX?
could be like "super circuit playground express"
and with 8mb flash instead of 2...
@warped pendant you said you tried to erase flash memory via terminal - did it not work?
i'm pretty sure i did it correct but yes it didn't work
you did this?
>>> import storage
>>> storage.erase_filesystem()
yes and then i also tried
mdutil -i off /Volumes/CIRCUITPY
cd /Volumes/CIRCUITPY
rm -rf .{,_.}{fseventsd,Spotlight-V*,Trashes}
mkdir .fseventsd
touch .fseventsd/no_log .metadata_never_index .Trashes
cd -
3.03 - also my board was deleting when it ran out of battery in my project - this may be fixed now and maybe there was something still there that i couldn't see? arduino seemed to be working it was the cpy that was throwing me in a loop - -- so so far so good from erasing this way.
3.0.3
your code got deleted when your battery ran out?
it's possible the CP file system was getting corrupted when the batteries were getting low - a brown out issue.
but if you were able to get back to REPL, then the erase above should have worked
@solar whale Got ya. Still... we keep saying the same thing every time we make it bigger ๐
Nature abhors free memory ๐
speaking of memory how do you use nvm?
https://circuitpython.readthedocs.io/en/latest/shared-bindings/nvm/__init__.html doesnt give a noob like me enough info
Adafruit CircuitPython 3.0.3 on 2018-10-10; Adafruit ItsyBitsy M4 Express with samd51g19
>>> from microcontroller import nvm
>>> len(nvm)
8192
>>> nvm[0]
255
>>> nvm[0] = 23
>>> nvm[0]
23
>>>
after power cycle:
Adafruit CircuitPython 3.0.3 on 2018-10-10; Adafruit ItsyBitsy M4 Express with samd51g19
>>> from microcontroller import nvm
>>> nvm[0]
23
>>>
Do python works better on NRF52832 or NRF52840 ?
@tepid sapphire nrf52840 has built-in USB, more memory, etc., so better choice
nice Danh
expect Adafruit products with nRF52840
they're on the way - no timetable, but sooner rather than later
i already got NRF52840 samples (u-blox modules)
i want that Python (Adafruit) be the official programming language to our clients
will the nrf52840 require a separate usb chip @tulip sleet ?
no - it has built-in USB like the SAMx1. '832 needs a separate chip (and has less RAM and flash)
cool! ๐ less component count
nice! I can wait to test the new BLUETOOTH API ๐
diff looks clean, and I can't comprehend TravisCI build logs if my live depended on it. I don't even see an error in there. Where are the BIG RED LETTERS?
Restarting travis subjob. Some axtls build failed for reasons I don't see. Let's try again.
It was a travis glitch. A download may have failed or something like that.
These are alphabetized. Could you move arduino_mkr1300 up one line?
We're trying to keep the number of boards listed on each line roughly the same, so the travis subjobs will finish in about the same amount of time. Could you move the arduino_mkr1300 entry down into the line with arduino_zero?
Thanks @tannewt.
I have ported some more of the stdlib tests and I've discovered that several are dedicated to the builtin types and functions. They serve as a nice window into the differences between CircuitPython and CPython: https://github.com/notro/tmp_CircuitPython_stdlib/tree/master/lib/test
@tidal kiln ```python
import time
from microcontroller import nvm
for i in range(8191):
print(nvm[i])
nvm[i] = 255
print(nvm[i])
code stops after first write
this is what im trying to do really but its not work in range
def testtxt(strng):
arr = bytearray(strng)
print(arr)
print(len(arr))
for i in range(len(arr)):
print(nvm[i])
nvm[i] = 255
print(nvm[i])
nvm[0:len(arr)] = arr```
@upbeat plover what board are you using?
featherM4
what do you get from?
>>> from microcontroller import nvm
>>> len(nvm)
Is there circuitpython support for the "Adafruit 1.44" Color TFT LCD Display with MicroSD Card breakout - ST7735R" ? I would like to use it with a Feather M4 express for a display. The MicroSD card access is not that important.
8192
Are the neopixels on the CPX WS2812 or SK6812?
or something else?
I also noticed the circuitpython neopixel_write and the C++ neopixel library have different numbers of nops. The circuitpython one references SK6812.
@upbeat plover worked for me:
Adafruit CircuitPython 3.0.2 on 2018-09-14; Adafruit Feather M4 Express with samd51j19
>>> from microcontroller import nvm
>>> for i in range(10):
... print(nvm[i])
... nvm[i] = 42
... print(nvm[i])
...
255
42
255
42
255
42
255
42
255
42
255
42
255
42
255
42
255
42
255
42
>>>
ill try different version, i was using Adafruit CircuitPython 4.0.0-alpha.2 on 2018-10-16; Adafruit Feather M4 Express with samd51j19
i get same problem with your above code
working now with 3.0.3 ๐
wow... printing and writing the whole nvm takes some time
@exotic pumice we don't have different code for the two types. Are you having trouble? The latest Adafruit_Neopixel uses rjmps instead of nops
@tulip sleet I wrote a rust driver for them and I can only get white pixels no matter what data I send. You use nops here. This is what I based my driver on https://github.com/adafruit/Adafruit_NeoPixel/blob/7057dd26210870a422c7d6fd5e5d4f45b18857bd/Adafruit_NeoPixel.cpp#L1532
this is my driver https://paste.pound-python.org/show/mSumVXZSbENURFUiOPDl/
it looks like you're using the 400 kHz code, but the 2812's are 800 kHz
all the modern ones we use are 800 kHz
good to know
@exotic pumice see the comments in the second code block on this page: https://learn.adafruit.com/adafruit-neopixel-uberguide/arduino-library-use
@tulip sleet thank you
I don't know if it works yet, I don't have my device with me, but it sounds like that could be the fix.
is there a different format to store values bigger then 255 in nvms? when i try bytes(300) it just makes \x00\x00\x00\x00\x00\x00\x00\x00\x00.... ect... seems like a horrible format, can you store like 32 bit integer?
@tidal kiln
@upbeat plover you can use struct.pack and .unpack to turn whatever you want into a byte string
thank you ill play with struck now๐
how do you use struct?
Adafruit CircuitPython 3.0.3 on 2018-10-10; Adafruit Feather M4 Express with samd51j19
>>> import struct
>>> dir(struct)
['__name__', 'calcsize', 'pack', 'pack_into', 'unpack', 'unpack_from']
>>> struct.calcsize(300)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't convert 'int' object to str implicitly
>>> struct.calcsize(b)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'b' is not defined```
@tulip sleet it doesn't work, do I need to disable interrupts or something?
the neopixels only light as I unplug power now
actually they light kinda semi-randomly
Yes, you do need to disable interrupts, because the timing has to be precise. An alternate way of doing it is to dedicate a PWM peripheral to it as a waveform generator. That technique is used for the nrf52 NeoPixel implementation. Then interrupts don't matter, because the peripheral is doing all the work. But you need a lot of memory for that.
ok let me see how to do that
Do you have a logic analyzer like a Saleae? Try looking at a simple NeoPixel waveform for a few pixels or even one pixel, and see how your impl compares with the CPy or Arduino one.
@upbeat plover what danh said. each location nvm[i] is a single byte, so you only have 8 bits to play with. how you use that is up to you. think of struct.pack and .unpack as helpers. it can take a bit to get used to using them also.
yeah
No, the board restarts whenever I add or change a file using the Finder, so when I rename the .py file to code.py and hit enter, the Feather restarts.
hmm think i got it working
should I be following this https://github.com/adafruit/circuitpython/blob/master/ports/atmel-samd/common-hal/neopixel_write/__init__.c or this https://github.com/adafruit/Adafruit_NeoPixel/blob/master/Adafruit_NeoPixel.cpp#L1490
they're rather different
from microcontroller import nvm
import struct
def nvmnumread(address):
print(struct.unpack('lb', nvm[address:(address + 5)]))
def nvmnumwrite(x, address):
print(struct.pack('lb', x))
if address < 8186:
nvm[address:(address + 5)] = struct.pack('lb', x)
else:
print('not enough space at address')
def nvmtext(strng, address):
print(strng)
print(len(strng))
if address + len(strng) < 8191:
nvm[address:(address + len(strng))] = bytearray(strng)
else:
print('not enough space at address')
nvmnumwrite(300, 0)
nvmnumread(0)
nvmtext('hello world', 10)
print(nvm[10:21])```
what is the max integer the "nvmnumwrite" can handle?
i tried -9999300 and it still packed and unpacked it so im not sure how vast the range is
@upbeat plover I think lb means a long and a byte so a 5 byte number
yeah i was thinking that too but it stores stuff strange like this b'<lg\xff\x00
when python prints a byte it tries to convert it to characters and fails miserably
that was -9999300
b'\xc4\x93\x98\x00\x00'
is 9999300
have a look here for how to print hex properly https://stackoverflow.com/questions/19210414/byte-array-to-hex-string
oh ok, so that's not the issue
@exotic pumice there's the nrf version too: https://github.com/adafruit/circuitpython/blob/master/ports/nrf/common-hal/neopixel_write/__init__.c They all work, with quite different implementations. it's your choice. The Arduino one is fancier, I think.
the main difference I saw was number of nops
cut out the 400khz code to avoid confusion
not that part
@exotic pumice i guess it is 5 bytes or 40 bits, max is 1.0995116e+12
the nops are different between 800khz arduino and 800khz circuitpy
both for samd21g18a
@exotic pumice they've been tuned to work, but could still be a little different - not sure what I would say. The CPy driver was taken from the Arduino driver a couple of years ago
I turned off interrupts and set nvmctrl to deterministic
yeah I'll see if I can rig something up on the bus pirate
where would I probe?
just the data line to the first neopixel, not sure the bus pirate is fast enough to do the monitoring. no scope?
I could use one at my college possibly
http://dangerousprototypes.com/blog/2009/11/03/bus-pirate-logic-analyzer-mode/ only 4096 samples at 1MHz, not fast enough
is open drain output correct?
No, you need to send a real logic level
are you powering the neopixels at 3.3V or 5V. If the latter you -might- need a level shifter, it's marginal
I'm using the cpx
you mean you're using the onboard neopixels?
yes
ok
Hi folks - I know that the new NRF52 is on the horizon, but is there a path to BLE today? Something like the M4 Express + a bluefruit breakout board? Or an M0 Bluefruit that uses the NRF51? Or is the "old" NRF52 workable? I know it won't be perfect, but I'd like a stop-gab if possible
FYI, just looking for HID kbd and mouse
over BLE
@tough flax You could use the Bluefruit SPI or UART Friend: https://learn.adafruit.com/introducing-the-adafruit-bluefruit-spi-breakout/hidkeyboard https://learn.adafruit.com/introducing-the-adafruit-bluefruit-le-uart-friend/hidkeyboard
I got it to work @tulip sleet
@tough flax or you can use the nrF52832 board directly if you're willing to use Arduino: https://learn.adafruit.com/bluefruit-nrf52-feather-learning-guide/blehidadafruit
@exotic pumice woo hoo! anything extra other than what we discussed?
I put a d13 flash after my neopixel code and realized it was never exiting the loop. Somehow when I tried the circuitpython library version I left out the bitmask >>=1
also disabling the interrupts and setting up the nvmctrl breaks it
@tulip sleet - is there a CP library for the Bluefruit SPI/UART?
@tough flax no, though it wouldn't be that hard to work one up. It's just "AT" commands
this actually came up briefly as an idea in an internal mtg today
Yup - OK, perhaps we can port the Arduino lib to the UART chip
Sounds like an option while we wait for the new 52
i have pinged the appropriate person with a ref to this thread
Thanks
While I'm happy I got it working, I'm also sad that I have to use nops to get the timing right, because it makes my code clockspeed dependant. I was hoping to write a cross-platform library
I don't want to have to write an implementation for every mcu like you guys either
@exotic pumice if you use some peripheral the like the PWM waveform generators or SPI data, you can make it more platform independent. But it requires an extra copy of the data, and often a bit expands into a byte or a 16-bit word to drive the pWM peripherals, and several bits per bit for SPI (up/down/up/up/up/down, etc.) . So it's memory hungry, and that wasn't possible in the old days of AVR processors with 8kB RAM. Even on the M0's, a long string can use up a lot of the 32kB RAM.
That's why DotStars are nicer: they take a clock and a data line: it's just SPI
yeah
If I use spi it doesn't work with the built-in ones on your boards though
it's a tradeoff
we used the PWM peripherals on the nrf52 because we can't necessarily turn off interrupts for that long
this is my first module ```python
"""nvms
Non-volatile memory stuff
"""
from microcontroller import nvm
import struct
version = "0.7"
read value stored in NVM
def readnum(address):
return struct.unpack('lb', nvm[address:(address + 5)])[0]
store value with 5 bytes of NVM
def writenum(x, address):
if x < 394860500 and x > -394860500:
print(struct.pack('lb', x))
if address < len(nvm) - 5:
nvm[address:(address + 5)] = struct.pack('lb', x)
else:
print('not enough space at address')
else:
print('number too big or small')
write text to address if enough space for it
def writetext(strng, address):
print(strng)
print(len(strng))
if address + len(strng) < len(nvm):
nvm[address:(address + len(strng))] = bytearray(strng)
else:
print('not enough space at address')
read text stored at address with a size of
def readtext(size, address):
return nvm[address:(address + size)]
erase NVM from "start" address to "finish"
def erase(start, finish):
for i in range(finish - start):
print('before: ', nvm[start + i]) # print address value before erase
nvm[start + i] = 255 # erase NVM at addresses
print('after: ', nvm[start + i]) # print value at address after erase
is this okay, what can i do to make it more efficient?
works on featherM4 not sure about others
@upbeat plover why are numbers stored with 5 bytes?
well when i tried storing them just in a array 300 took 300 bytes
the pack thing helped i guess
@exotic pumice there is a PWM peripheral on SAMD as well
@upbeat plover I'll have t think about that -- Thanks for posting the module. I was not even aware the nvm existed!
ill go back and check just to make sure but i think the store value is bugged if you try to do more then 255 at a single nvm address, like it doesnt fail it just does crazy
I just don't understand th e 5 bytes per entry but I need to study what you are doing first.
oh, i wanted to store values large and small, like over 1 million
or under -1 million
i think if i need bigger i may have to increase the bytes but when i was doing trial and error only 'lb' packed and unpacked,
that link was helpful i was given that after trial and error and found 'lb' so i might find one bigger that works now
are you storing them as text? a 32 bit value can be +/-2147483647 stored in binary
no i dont think it is text right now
OK -- as I said, I need to study it more -- I may have some suggestions about it, but it won't be for a few days.
cool
why some modules have "self" and "_variable"?
also what are class? lol yeah im noob
'm not real good at explaining Python - best to look at an intro guide like https://pythontips.com/2013/08/07/the-self-variable-in-python-explained/
lots more here https://wiki.python.org/moin/BeginnersGuide/Programmers
I was going to suggest the Python Tutorial as a good starting point. Also @upbeat plover, CircuitPython follows CPython 3; using CPython 2 docs may confuse you with certain things that have changed/been deprecated. https://docs.python.org/3/tutorial/index.html
how do I tell how much memory I have free?
gc.mem_free()```
also ```>>> import micropython
micropython.mem_info()
stack: 392 out of 4320
GC: total: 180672, used: 3264, free: 177408
No. of 1-blocks: 77, 2-blocks: 37, max blk sz: 8, max free sz: 11079
turns out wrangling bitmaps is not trivial with limited memory
hmm. simple math tells me that I won't be able to fit 12 25k sprites in the m4
I might have to get fancy
first time I've heard M4 referred to as limited memory ๐
I feel like I should read up on graphics from the c64 era
I'm sure I'm wasting memory like crazy. I just realized that I don't need the full sprite for each frame, just the bit that changes
I was wondering if there was some sort of a bitmap patch format that will just give you the transform between two bitmaps. I could compute it on my laptop and then only have to apply the diff between each frame rather than needing the whole thing
is that how digital tv is? seems like loss of signal just makes the pixels that should update turn black
I'm not much help -- I have only just started looking at graphics stuff in the past few months. Avoided it carefully for the previous 40 years of programming.
totally mystifyed by it so far....
@upbeat plover kinda? Digital tv is compressed and what I'm talking about is a rudimentary type of compression
both are about reducing redundant information
โพ good night all!
nvms.readnum(address)
``` returns ```python
value
``` now instead of ```python
(value, 0)
@raven canopy looks like some diff markup got in on the latest cookiecutter pr:
https://github.com/adafruit/cookiecutter-adafruit-circuitpython/blob/master/{{ cookiecutter.library_name }}/requirements.txt#L1
@pastel panther you seen the imageload library?
no
palettizing the bitmap
and run length encoding
that is why I made OnDiskBitmap though
so it can stay out of memory
@gentle bronze why isn't this an infinite loop? https://github.com/hathach/tinyusb/blob/develop/src/device/usbd.c#L236
it is a inifite loop, the comment is misleading ๐ฆ
haha, its not actually, the _receive is a macro that returns
it is confusing though
yeah, only in no rtos
any rtos API that block the thread will return
to the super loop()
right, which is what I'm doing
when using with rtos, that API is the real blocking, the scheduler will do that for it
us
right, it'll context switch
kind of confusing, but I don't know better way to have both the rtos + non-rtos running with the same code.
does the nrf build use an rtos?
no, circuitpython does not have rtos
kk
but Arduino use freeRTOS
I used to test wtih keil RTX as well, but it must be quite obsolete
I've got the first descriptor returning but the third setup packet is getting lost somewhere
did you call the dcd_xfer_complete/dcd_control_complete
when the DATA phase is done
in the controller port
note: I change the name/API a bit with latest push, (to better support freeRTOS).
let me commit so I can link you
ok
@slender iron will I need to be using displayio for my screen to be able to use that? I've been just sending bytes to adafruit_rgb_display.Display._block
I have no idea, I haven't used rgb_display
it loads the bmp into a bitmap and palette
@slender iron I am not familliar with samd usb, but normally you don't need to call dcd_edpt_xfer() in the port. It will be invoked by USBD upon recieved the setup_received https://github.com/tannewt/tinyusb/blob/tinyusb_samd/src/portable/microchip/dcd_samd51.c#L263
setup_received will push an message to the USBD task queue that you mentioend above, which will examine and call the dcd_control_xfer()/dcd_edpt_xfer() later on.
even for zero length?
zero length will be disacrded by usbd, it is no problem if you call, the usbd currently didn't wait for the status ๐
will it reply with it though? It seemed like usbd wasn't calling another xfer for the next setup transaction
it will skip the status (zero length packet).
my impression was that the nrf automatically listens for a setup packet
ah right
line 263 is to wait for the next setup
ah I see
may be you should use the seperated setup buffer
just in case the setup is the control out
or maybe you can queue for the next setup when the dcd_control_xfer() is called with the len = 0 (status)
the buffer gets copied into the event though right?
ah yet, the setup will be copied into the queue
yes
@slender iron after the desc transfer
there is ACK which is OUT
ya
maybe that call will overwrite or blcoked by this queue transfer already ?
ok, so you got a complete transfer of 1st desciptor, then 2nd setup + ACK, but there is no more DATA
right the IN is being NAKed
hmm, if there is an event waiting in the _usbd_q, and usbd task does not process, it must be blocking wait on something else. Do you know where it is waiting
ah, did the 2nd request is with the new address or still address 0
ya, second request works with the new address
ahh, it is hard to trouleshoot like this, especially my code is far from perfect. I will try to find an samd51 to help debugging as well
@slender iron you should sleep, I will try to find a board to help troublshooting it ๐
ya, good idea. it'll probably be obvious in the morning. thanks!
thanks for the help @gentle bronze !
๐ค
good night ๐
Possibly only tangentially related to CircuitPython but finding the i2s pinout for the M4 Express is tricky! The tutorial page doesn't have a nice detailed pinout image- eventually found the details hiding in a CircuitPython i2s dac tutorial.
@tidal kiln huh. I specifically remember handling the diff... I can put in a fix-the-PR PR later today.
This sounds like a cool workshop at mozilla festival! @slender iron
The stock setting on the pca10059 dongle, and possibly also on the pca10056 DK configures the pins P0_09 and P0_10 as NFC pins, therefore they can't be used as GPIO pins. Also after a full chip erase, the pins are confugured as NFC by default.
Circuitpython allows to define them as GPIOs, without any warning, even if they are reserved for NFC.
As NFC isn't supported by Micropython at this time, and probably for a long time to come, it would make sense to configure those pins as GPIOs by...
There is a CONFIG_NFCT_PINS_AS_GPIOS define that can be used to achieve this, it could be used on a per-board basis, I've been using it locally for my board.
Thank you, arturo182, I didn't see that.
@tidal kiln went ahead and PR'd from my phone. https://github.com/adafruit/cookiecutter-adafruit-circuitpython/pull/37
how do i fix Mu so serial works with hallowing? says "Could not find an attached device." but PuTTY works fine
@upbeat plover what version of Mu are you using? Looks like 1.0.1 is when HalloWing was added.
already uninstalled and installing "portamu_1.0.1_win64" to usb drive to test out
ok folks - Python on hardware (weekly video newsletter) ... trying this format out, suggestions welcome https://youtu.be/2ySrgjGgMQY
The wonderful world of Python on hardware! This is our first video-newsletter-podcast that we're trying out! The news comes from the Python community, discor...
@raven canopy thanks for quick fix! @idle owl this was simple clean up (cookiecutter), so i just went ahead and merged.
plans for higher level lib for hallowing like circuitplayground express?
this is just so great for cpx i think a hallowing one would be cool https://circuitpython.readthedocs.io/projects/circuitplayground/en/latest/api.html?highlight=CPX#adafruit-circuitplayground-express
@upbeat plover maybe one that would also work on upcoming boards
xmass board?
no that super secret credit card sized one with a display
@upbeat plover https://youtu.be/i0jc4sutspU?t=3461
Multistreaming with https://restream.io/ ----------------------------------------- Visit the Adafruit shop online - http://www.adafruit.com Subscribe to Adaf...
can i preorder now?
i don't think so ;3
thats like what i got going on my featherM4 with miniTFT but better if it has speaker too
yup and nice compact size
i recall a few days ago a discussion about gpu would that be where it would be good to be used? on that gaming board thing?
like m4 for code and ATmega32u4 for screen?
i'm using CP on rasp pi...blinka...i am using a PIR motion detector on a GPIO pin. I want to get a callback when the signal goes from LOW to HIGH. With RPI.GPIO it seems I can do add_event_detect ... but i don't see an equivalent w/ digitalio.DigitalInOut?
@upbeat plover that'd be cool :3 if it means faster gfx
was just thinking sounds and gfx is kinda much for 1 chip?
@tidal kiln Perfect, thanks!
@bronze geyser I haven't used Blinka (or my RPi in ages), but it looks like each pin object in Blinka should inherit all of the GPIO functions. You should be able to use them...
@raven canopy ...oh, right...i guess i should check the code first. I just did a dir() ... and didn't see the methods. Looks like there is more for me to learn. As always, thank you.
Not sure how any other objects will react though...
Did you dir(pin)? That should show any RPI.GPIO funcs.
@raven canopy yah I did...looking at digitalio.DigitalInOut and noticing it inherits ContextManager...which turns out to be nothing much: https://github.com/adafruit/Adafruit_Blinka/blob/master/src/digitalio.py .... i don't see the inheritance.
@bronze geyser I was looking here: https://github.com/adafruit/Adafruit_Blinka/blob/master/src/adafruit_blinka/microcontroller/raspi_23/pin.py
In looking again though, each pin doesn't necessarily inherit GPIO. Maybe try importing RPI.GPIO on you own, and using add_event_detect. I would run any attempts of it without hardware attached to minimize any un-desired results first.
@tidal kiln https://github.com/adafruit/Adafruit_CircuitPython_ADXL34x/blob/master/adafruit_adxl34x.py Does this actually require register or was that a cookiecutter fail?
it doesn't require register from what i'm seeing. but cookiecutter may have just been doing what it was told. who ran it initially?
no idea, but I was typing "no" and that made it include it, and that's fixed, but only recently.
it's fine, I didn't think it did, so I'll take it out. If Travis fails, I know where to start ๐
yep. saw those changes when i was trying to figure out why cookiecutter wouldn't run last night.
anything other than "" was considered a yes
but also, could just be confusion, i remember the first several times i ran cookiecutter i said "yes" to that because i was definitely going to be register read/writes. even though i never used the register module.
This may not be the best topic for asking this question but... I have a very simple wifi project that will energize a relay at specific times of the day. My question is, what feather do I use in terms of circuitpython support, ESP8226 Huzzah, M0 wifi or ?
@silver sage the only MCU that has wifi support under Circuitpython is the ESP8266 ,at this time.
Thanks, that was the answer I expected, was hoping for something more like the M0 in terms of circuitpython drag and drop updating.
You are not alone ๐
@slender iron There are a bunch of early entries in the .gitmodules file in the bundle that are inconsistent with how we're doing it now. Is it ok to manually fix them to match or will that break something? Sommersoft thought it should be fine, that another file is used by the bundle, but thought we should check with you.
Things like this: https://github.com/adafruit/Adafruit_CircuitPython_Bundle/blob/master/.gitmodules#L34
We're going to be using that file to create the library list using Adabot to parse it, I don't know if it's breaking that or not. Sommersoft brought it up when doing the initial example lists, so he might know better. It might not be breaking anything, but is simply inconsistent I guess.
Does this seem "odd" to you? there is digitalio.DigitalInOut ...that doesn't support callback. There is microcontroller.pin which import RPi.GPIO but doesn't inherit - so we lose callback...
hi
@idle owl I don't know why that matters. its an internal git file so I wouldn't mess with it
ok
#rust-embedded on mozilla irc is mad the neopixels on cpx aren't connected to a timer lol
@exotic pumice you may be able to use the event system to output to a different pin. its quite the hack though
I think sercoms are usually used to output neopixel data, not timers
hmm
@idle owl can you make me an empty repo for MPL115A2? working on library. no canadian rock band. probably be a couple of days before i PR to it.
@tidal kiln Well if there's no Canadian rock band... I'm not sure you can have a repo.
no rush ๐
I know. I'm hassling you anyway.
@tidal kiln https://github.com/adafruit/Adafruit_CircuitPython_MPL115A2 good?
yep. awesome. thanks.
@idle owl could you parse this line instead?
https://github.com/adafruit/Adafruit_CircuitPython_Bundle/blob/master/.gitmodules#L36
@tidal kiln I don't think it's causing issues with the parsing. I think it was simply noticed as an inconsistency.
i think that other line is just a free text label, based on stuff i was reading trying to undo my CAP1188 mess
agree
too bad it's not consistent, but explains why it's not breaking anything
what info are you trying to parse out of it? just a lib name for the list?
That's already sorted, there's a module in Adabot that parses it, and now it produces a .md file that has the list of libraries with links to their repos etc.
which it will commit to the bundle repo eventually
ok folks, post a #leek over on #general-tech an open-source circuitpython powered badge and gaming platform, FEATHER compatible - enjoy
@tulip sleet fyi - you were right:
https://forums.adafruit.com/viewtopic.php?f=60&t=142494#p704915
thanks again! i keep forgetting about that...
V 0.8
checks if addresses are not already written to
nvms.checkfree(size, address)
checks if space isnt in use and then uses 5 bytes to stores value at address, values range from -394860500 to 394860500
nvms.writenum(value, address)
store text to addresses if they aren't in use
nvms.writetext(text, address)
clear NVM for use at addresses
nvms.erase(size, address)
read address as number
nvms.readnum(address)
read addresses as text
nvms.readtext(size, address)
i like to use nvm now cause with storage i have to lock it and stuff
works on both hallowing and featherM4
shows how big NVM is
len(nvms.nvm)
sorry for errant .gitmodules suggestion; standard for standards-sake can be a byproduct of day_job. ๐
np
I have a PR where it says the checks are still in progress, but Travis says it passed
38d99b1 Copy wiznet drivers over from MicroPython 1.9.4 - nickzoic
8670215 Fixups for wiznet 5500 driver - nickzoic
3c32d04 Copy wiznet module across from MicroPython - nickzoic
27fc84a Modify wiznet module for circuitpython - nickzoic
f4c3213 Copy modnetwork and modusocket across from Micr... - nickzoic
0
@exotic pumice At least every time I've dealt with them in CircuitPython, they start at 0.
does storing to NVM work cross CP and Arduino?
Hi
New list "third-party" or "non-Adafruit" boards list with names and links to your things.
for issue in #1296
nope
Trying to figure out the best way to go about adding RPi support to the RGB Character LCD library - there's no Blinka pulseio support so we have to get it to use digitalio instead. Please take a look at this PR and provide thoughts if you get a chance. I added CircuitPython Librarians, but I'd specifically like to hear from @raven canopy , @solar whale or @tidal kiln https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/pull/16
that list is rad, thanks @raven canopy & @idle owl
@river quest You're welcome!
i did a quickie blog post to test it and replied back with a link, that worked well too
I saw that, nicely done
ALL THE LIBRARIES https://blog.adafruit.com/2018/10/25/adafruit-circuitpython-libraries-there-are-104-at-this-time-circuitpython-adafruit-adafruit/
if switch.value:
dot[0] = (255,0,0)
elif clpbd = 1:
dot[0] = (0,255,0)```
I keep getting invalid syntax
what is wrong with this/
maybe you need an else
@haughty bobcat when checking values in a conditional (if/elif), you need to use two equal signs: elif clpbd == 1:
yw!
Is there Circuit Python for Arduino Uno?
@sick yacht No, sorry, there's not nearly enough memory on an Uno for CircuitPython.
I see. Thanks for the reply!
Hey @tulip sleet while we're on the subject of "will it run on..." ๐ Will it run on the non-express M0 boards? Like the ones w/Bluetooth, Wifi, and Radio boards on them?
@tough flax Yes, it will, with a limited-size CIRCUITPY drive, like on the Gemma or Trinket M0. Most don't have UF2 bootloaders, so you'd need to use bossac to load the .bin.
Once the bin is loaded, does it start a USB storage device? Or just a REPL?
It's just like the other boards. The bootloader doesn't matter about USB or not. For the WINC1500 board, we have no CPy libraries for that, so it's not that useful
Thanks ๐
I have two M0 Express boards that are showing different behaviors when disPeriphs() or disClocks() is called. The "newer" board really does disable everything and the older one does not. Sound familiar at all? (newer has a red circle around board dates)
I have an idea for a game, but im not sure how to do it.
i want main code to be engine and then it loads rooms/levels from other code but im not sure how to do that
like i want main.py to have spi, display and all that stuff, and for rooms just draw commands and a two variable like "start_position" "end_position"
i want main.py to always be running and just loads a few commands from different rooms like room1.py room2.py ect...
can someone give an example of this? im not sure how to use more then one code.py at once
i want game to use rgb command "pixel(x, y, color=None)" each step to check where the player is and if it will hit a wall in the room next move or if it touches "end_position" next room is triggered
Hey.. bit new to python and circuitpython i got a Adafruit Oled wing but is it anyway to "rotate" the display like in arduino with setRotation(2) ?
I dont think so, not in RGB display ether
oh well i guess i can just "rotate" the device i working on for now lol
@strange pumice where are those functions coming from?
@azure tendon display stuff in general is still a work in progress for CP, it'll be part of the 4.0 release that's currently in alpha
@tidal kiln i using adafruit_ssd1306 libary
@tidal kiln does reading pixels work for rgb displays? when i try the value changes from 0 to 65535 but the pixel is still the same, im using version 3.0.3 of cp
@azure tendon sounds like the arduino library?
ah. was reading that as a repo name.
@upbeat plover how are you trying to read a pixel?
print(display.pixel(64, 64,))
or
print(display.pixel(64, 64, color=None))
looks like it's suppose to:
https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display/blob/master/adafruit_rgb_display/rgb.py#L122
the return is a color565 instance:
https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display/blob/master/adafruit_rgb_display/rgb.py#L117
wait. nvm. that's just a helper func:
https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display/blob/master/adafruit_rgb_display/rgb.py#L52
this is my code for hallowing
import board
import busio
import digitalio
import time
from adafruit_rgb_display import color565
import adafruit_rgb_display.st7735 as st7735
import pulseio
backlight = pulseio.PWMOut(board.TFT_BACKLIGHT)
backlight.duty_cycle = 2 ** 15
spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)
display = st7735.ST7735R(spi, cs=digitalio.DigitalInOut(board.TFT_CS),
dc=digitalio.DigitalInOut(board.TFT_DC), rst=digitalio.DigitalInOut(board.TFT_RESET), width = 130, height = 131)
display.fill(color565(6, 6, 0))
time.sleep(0.3)
display.reset()
display.init()
def xfix(x):
x = x + 2
return x
def yfix(y):
y = y + 3
return y
while True:
time.sleep(1)
time.sleep(0.3)
display.fill_rectangle(xfix(0), yfix(0), 128, 128, color565(0, 0, 0))
display.pixel(xfix(64), yfix(64), color565(255, 0, 0))
print(display.pixel(xfix(64), yfix(64)))
print(display.pixel(xfix(64), yfix(64), color=None))
display.vline(xfix(128), yfix(0), 128, color565(255, 255, 255))
display.vline(xfix(0), yfix(0), 128, color565(255, 255, 255))
display.hline(xfix(0), yfix(128), 128, color565(255, 255, 255))
display.hline(xfix(0), yfix(0), 128, color565(255, 255, 255))
no clue why but had to make display width 130 and height 131 then use x offset of 2, and y offset of 3 for it to display everything correctly, yet upside down
@upbeat plover can you reproduce the issue with a simple program that just sets the pixel then reads it back?
So, I read last night that someone working on the display code was looking for c64-era graphics guides... Iโve had these since college (I just replaced in that was damaged) and theyโre probably a good start. I think they are out of print but I found one used for like $6 and it was worth it
@upbeat plover not sure. post an issue in the repo. provide a simple example showing the issue.
does seem like something's up?
>>> display.pixel(0,0,color565(0,0,0))
>>> display.pixel(0,0)
65535
>>> display.pixel(0,0,color565(255,0,0))
>>> display.pixel(0,0)
65535
>>> display.pixel(0,0,color565(255,255,255))
>>> display.pixel(0,0)
65535
>>>
yeah but it doesnt stay the same, 65535 or 0
@marble hornet i have this same issue with your custom mod
@idle owl when i ran cookiecutter for MPL115A2 it added register to the dependencies in README.rst even though i said no - so maybe something is up with cc
hmph.
File an issue and ping Sommersoft.
or
yah do that
even if it's something that's fixed and we're still doing it wrong, file an issue.
done.
@tidal kiln - woops. I realized that disPeriphs() and disClocks() were a custom github project focused on getting deep sleep and minimal power draw working with CP. Perhaps a better question for me to stay with is there a way I can decode the hardware changes between Feather revisions?
By restart you mean the code reruns right? (We usually call that reload) Or does the usb connection actually drop?
So to summarize, we should:
- [ ] Enable
CONFIG_NFCT_PINS_AS_GPIOSby default because NFC isn't currently supported - [ ] Have DigitalInOut verify the pins aren't configured for NFC.
Anything else?
@strange pumice You can look for commits on the github repo for the pcb but there aren't any of note for the feather m0 express. From what I've seen hardware revisions are relatively uncommon and when they happen they're announced as a 'new product'. Honestly I think a software issue is more likely than a hardware change affecting what you're seeing
@strange pumice the marks you've circled are added by the pcb manufacturer. The B in a circle is the adafruit rev. So, I think @pastel panther is right that its a software thing
Is there a way to call a member of a tuple? Like you can call a member of a list listname[1], if it's a list of tuples, can you then also call out the tuple members?
Nevermind. I was headed down the wrong rabbit hole with that. In other news, I just wrote code that I have literally no idea why it works. But it works apparently....
oh boy, hacktoberfest shirt time.
Hooray!
@idle owl fwiw, yes. just keep appending index.
what does it look like?
>>> thing[0][0]
1```
list of tuples
'[(1,2,3), ("foo", "bar")]'
(er, i misunderstood the question, but same syntax.)
got samd51 serial working with tinyusb!
@slender iron That's great!!
@slender iron yaaaaaaaay
@upbeat plover use the 'colorst' func in mine, it switches r and b
I missed this weeks cp-meting but here is an update. all the code is up on my git and free to use for personal projects! (will adapt tg_gui to displayio when displayio is out fully and v1.0.0 of tg_gui has shipped)
ok. did it again. PR'd to a new repo that was not enabled on travis. i went to travis and enabled it. but now how do i trigger a build without pushing another commit?
i've looked on both the GH side and travis side and don't see anything obvious.
@tidal kiln push an empty commit.
--allow-empty i think is the option...
and sorry if i keep breaking cookiecutter. ๐ฆ
breaking == making it better. ๐
@idle owl yah. just wondering if there's a "fancy" way. since i seem to do this every time ๐ฆ
once the "Trigger Build" gets out of beta, it can hopefully trigger a PR.
yah. saw that. but having that "beta" tag made me think that wasn't the answer.
there was also a "resend" on GH under the webhook, but that didn't work either
just pushing another commit of course worked.
Odd things happening when accessing my Trinket M0 over Serial... I'm not expecting any output and I'm getting this:
thoughts?
obviously the empire has landed their ground forces and are advancing
@tough flax what os? linux has modem manager
linux - fedora server 28
When I connect via screen, it does that garbage... then I hit Control-C and I get the REPL... once I've done that I'm good and it behaves as expected
Traceback (most recent call last):
File "main.py", line 164, in <module>
File "adafruit_dotstar.py", line 229, in fill
File "adafruit_dotstar.py", line 178, in __setitem__
KeyboardInterrupt:
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
Press any key to enter the REPL. Use CTRL-D to reload.soft reboot
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
main.py output:
red
green
@wheel
#990099
@blink
ya, you need to disable modem manager
pointers? links?
If you're on Linux, and are seeing multi-second delays connecting to the serial console, or are seeing "AT" and other gibberish when you connect, then the modemmanager service might be interfering. Just remove it; it doesn't have much use unless you're still using dial-up modems. To remove, type this command at a shell:
sudo apt purge modemmanager
Ugh
That's not what I wanted to hear... is there a way to disable it on a particular tty?
I don't want to have to make people uninstall a standard program to use these lights
If you have system level access, modemmanager causes nothing but nightmares, and from someone who's had to ISP flash back MANY pro micros due to that, it's the best solution by far.
i'm not sure, but wouldn't that also be a step they would have to do?
No, I'm writing a script that will send specific commands to the trinket - the script will be stored on the trinket
it works on windows using PowerShell
no problem scripting it on linux
but uninstalling a package can't be in the script
I can detect it and notify them... but it sucks
@tough flax There has been a way to disable modem manager using udev rules, but it doesn't work all the time. It appears modemamanger is not a well-behaved program (it's supposed to obey the env var ID_MM_DEVICE_IGNORE and it doesn't). I tried this already. Uninstalling modemmanager is really the easiest way
Ugh. Ok... I'll writing something to detect it.
sudo stop modemmanager
echo manual | sudo tee -a /etc/init/modemmanager.override
Needs root, but can temp stop it.
e.g. https://linux-tips.com/t/prevent-modem-manager-to-capture-usb-serial-devices/284 this doesn't work any more. I think there might even been an outstanding bug
@tidal kiln when you ran the cookiecutter, did you have it download the new one? I just ran it, and requirements.txt is behaving as expected for me...
it was README.rst
OHHH. quickly learns to read
if i understand that cryptic macro syntax, the code you put in requirements.txt just need to be there also
yep. on it! (unless you've already done it?)
nope. go for it. thanks!
Guys, I don't think it's modemmanager... that's not installed
Sorry - language I know
Caps
is this ubuntu and what version?
It's Fedora Server 28 and I found it - they PolyCapped the name
got it - yeah I had to help someone at PyCon fix this, and it took a while to find it.
@tulip sleet with the current master on a pca10059 (dongle) if I try to configure a second spi device -- should I see an error? I was trying something and I did not get erros, but it did not work properly. Just curious what to expect. Am I correct that - at present, only one spi device can be used?
@solar whale right it should be only SPIM2, because SPIM1/TWIM1 and SPIM0/TWIM0 are reserved for TWIM (I2C). I thought I tested that.
i do not know if it's on the RPi
the first device works fine -- just I don't get an error on the second, just very strange results ๐
i can check raspbian lite if that would help - have one handy
is it lite or full?
lite
@tulip sleet don't spend any time on it -- I just forgot it was not working -- I'll wait to try it when SPI is fixed.
Either would help @tidal kiln - thanks
@tulip sleet how to check? ps?
anyone know why adafruit bus device is missing read_then_writeinto???
@solar whale when it tested it, it should assign only SPIM2 and then complain there are non left.
@tidal kiln dpkg --list |grep modem
perhaps grep -i modem
on debian it's lower case, but yes grep -i is safer
@tulip sleet now taht I think about it, somthing else was going on -- I also tried it with jsut the one device and it behaved the same -- Sorry for the flase alarm -- I'll look into it.
Any and all help welcome
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.14.71-v7+ #1145 SMP Fri Sep 21 15:38:35 BST 2018 armv7l GNU/Linux
pi@raspberrypi:~ $ dpkg --list | grep -i modem
pi@raspberrypi:~ $
great, thanks @tidal kiln
I removed it from my server and can connect and control the Trinket via screen... I love the 'by-id' directory ๐
Connect to the most recently connected Adafruit device =
```screen -r /dev/serial/by-id/ls -1t /dev/serial/by-id | grep Adafruit | head -1
no -r
@marble hornet the spi function calls are passed directly to the busio.SPI object from busdevice
and over i2c?
no, for i2c, there are wrapper functions, because the args are different
The function is write_readinto(), not write_then_readinto()
i'm using the mpr121 simpletest. okay. thanks!
@marble hornet the simpletest is i2c. Are you using the CircuitPython and not the plain Python one??
are you still having an SPI problem? I'm confused.
i'm gonna check one more thing then get back to you, that okay?
sure!
Harumph. So, my garbage being written is fixed... and I can connected with screen and type my commands. But if I use basic writing to the TTY it doesn't have any effect.
``` echo -e "green\r\n" > /dev/serial/by-id/ls -1t /dev/serial/by-id | grep Adafruit | head -1
Should have the same effect as opening screen and typing "green + enter" I thought
@tulip sleet should i use: https://github.com/adafruit/Adafruit_CircuitPython_MPR121
this lib?
for i2c mpr121
yes, that lib should be in the bundle
The right hand of that works - I can manually put in /dev/ttyACM0 and it works the same
@tough flax is this still on Fedora?
yup
ok, ubuntu/debian doesn't have /dev/serial; it has /dev/input
is this your linux machine or the client's?
I can use lsusb
mine
This machine is not the target environment - it's just an example linux box I had around
ok, now i see /dev/serial - i had a bad CPy load on the test board
I want to add linux versions of the serial solutions I have on Windows
green\r\n is not the same as green + enter, maybe. I think it would green\n without the \r
I've tried both
@tough flax put the green\n in single quotes, not double quotes
also echo foo will send foo\n. echo -e 'foo\n' will send foo\n\n. Did you want echo -n?
ok, after testing, maybe the single vs double quotes doesn't matter, but it's best practice to use the single quotes
npe
It's not that - it seems like it's never making it to the device at all
but screen connects and works fine
is there a buffer that needs flushing?
Does it need to be read?
so echo green >/dev/ttyACM0 works, but echo green >/dev/serial/by-id/blahblahAdafruit does not?
well, with screen there's a full-duplex connection, so maybe it's blocking trying to write?
cause there's nothing trying to read
should I open a read session in the background first?
trying...
in one terminal window I did cat </dev/ttyACM0, in the other i did cat >/dev/ttyACM0, yes, it's a weird repl
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 100; time = 2;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread clocal -crtscts
-ignbrk brkint ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke -flusho -extproc
But I'm not in the REPL - I can see that my code is running
(the light is changing
try what I did an see what's going on; you could even put some print statements in
ok. hold on
The side that's listening just keeps typing 'green..... over and over'
Yeah, this is frustrating, but I don't think this is a CP issue ๐
I think there's some kind of weird loopback thing going on. I tried this as main.py:
while True:
a = input()
print("got", a)
when I cat </dev/ttyACM0 in one and cat >/dev/ttyACM0 in the other I get infinite output and then a memory problem. So I think maybe you need to turn off echoing for /dev/ttyACM0.
Here's my stty output - which echo do I change?
[root@edge ~]# stty -F /dev/ttyACM0 -a
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 100; time = 2;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread clocal -crtscts
-ignbrk brkint ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke -flusho -extproc
SOOO strange - I turned off -echoe and -echok and i got sane two windows
When I use screen, the one cat'ing /dev/ttyACM0 works as expected
green
when I send it through echo, it looks identical, but doesn't work
OOHHHH
I bet I know
I bet I'm sending UTF-8 from the command line!
and ASCII from the screen
This might by a python problem! I'm comparing it using
inText.lower().startswith("red")
But the terminal and the command line might have different encodings
the utf-8 for "green" is the same as ascii. I don't think that's it - I think the issue is trying to use the single serial channel in a way that's not expected. That's why we want to implement a second CDC serial
whne you use screen, check the stty settings
im starting it from the same shell -- how else do I check them?
is there a .screenrc?
open another terminal window. Do screen in one and look at stty -F /dev/ACM0 in the other after screen starts
Ok... hold on
but you have -echo so that should be ok
speed 9600 baud; line = 0;
min = 100; time = 2;
-icrnl -imaxbel
-opost -onlcr
-isig -icanon -echo
want -a?
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 100; time = 2;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread clocal -crtscts
-ignbrk brkint ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke -flusho -extproc
it has -iutf8
utf8 encoding for ascii is the same as ascii. you only get two-byte chars for non-ascii chars
could you point to your program?
Yes, let me grab the exact one from the device
hold on
HandRaiser code (send text in over serial console)
here's the key part:
while True:
#Check to see if there's input available (requires CP 3.3+)
if (supervisor.runtime.serial_bytes_available):
#read in text (@mode, #RRGGBB, %brightness, standard color)
#input() will block until a newline is sent
inText = input()
#Sometimes Windows sends an extra (or missing) newline - ignore them
if(inText == ""):
continue
#Process the input text - start with the presets (no #,@,etc)
#We use startswith to not have to worry about CR vs CR+LF differences
if (inText.lower().startswith("red")):
#set the target color to red
targetColor = (255, 0, 0)
#and set the mode to solid if we're in a mode that ignores targetColor
if (mode == "wheel"):
mode="solid"
this is not a bug, but you can use inText = inText.strip() to remove all leading or trailing whitespace (including \r and \n)
so you don't need startswith()
or just inText = input().strip()
FYI I'm moving the atmel-samd port to tiny usb and factoring out all of the usb stuff from the ports. This includes MSC so I plan on factoring out the spi flash chip support as well. I'll add support for QSPI on nRF based on this PR (thanks for it!) but will not merge it directly. Expect to see a PR for it next week sometime. Thanks!
So... I added a line to print what we read - here's what it shows:
[root@edge ~]# cat /dev/ttyACM0
red
GOT 'red'
red
GOT 'red'
GOT 'red'
GOT 'GOT 'red''
red
GOT 'red'
...................................LOTS OF THISS
File "main.py", line 101, in <module>
MemoryError: memory allocation failed, allocating 4696 bytes
Adafruit CircuitPython 4.0.0-alpha.2-36-g5360a4161-dirty on 2018-10-23; Adafruit Trinket M0 with samd21e18
right, that's what happened to me, so the print statement output is going back in as input
But I had addedthe stty -echok and -echoe
and -echo
it was already there
right, so I don't understand where the echo is coming from, unless it's internal to CPy. But you say this works on Windows?
Yes, it sends extra \r's but that's kinda expected
let me try stripping and not using lower - but after dinner (wife's calling)
Thanks for all your help!
sure, this is mysterious
lower doesn't matter, but you coudl lower up front and not do it every time: inText = input().strip().lower()
@tough flax If you have an FTDI cable or similar you could create a UART object and send back the data you're receiving on a separate serial channel to monitor it. Then we could remove this weird echo thing from the debugging loop.
So, I just made some unexpected progress
It might be the implementation of serial_bytes_available
I think it returns true when there's nothing connected to it
Here's my thinking
I wrote the text out and saw that it was getting into the if() block
for red
Then, the loop goes back (without changing the color yet) and checks the serial input again
when I removed that else: so that it DID change the color (~ line 150)
it did!
but if I sent it blink or wheel, it was static like it was waiting on input()
So it's waiting on input but the command is done
aha! well, you could write a simple test program that monitors value of serial_bytes_available in a neopixel or the led as you type at it.
I was thinking maybe it was returning false incorrectly
I added a test for "serial_connected" and that didn't help
if (supervisor.runtime.serial_connected and supervisor.runtime.serial_bytes_available):
did you eat already??
yep, it is waiting for input
No, I'm in trouble
I need to head out
Ping me if you think of anything
And thanks again
sure, food is important for thought
struct.pack/.unpack is my new favorite thing. wish i had read up on it sooner.
it's magically useful:
coeff = self._read_register(_REGISTER_CAL_DATA, 21)
coeff = struct.unpack("<HHbhhbbHHbbhbb", coeff)
Hi! I just followed the whole instructions for the lightsaber on the hallowing and all i have is a green blinking neopixel ,can anyone help me?
you're following this guide?
https://learn.adafruit.com/hallowing-lightsaber/overview
Yes
do you know your hallowing is OK? have you tried some other simple program just to make sure the basics work?
I know that the demo works good
the one it shipped with - the eyeball thing?
Yes
you've gone through the setup for CircuitPython part?
Yes, everything is updated
how are you programming the board? with mu, etc?
I used MU
hmmm. the guide isn't very specific about saving the file it just says "Copy the code, then paste it into Mu and save it to your HalloWing."
what file name did you save it as?
Yes
do you know how to connect to the REPL?
No
in Mu, click the button the says "Serial"
Ok
do you see the >>> prompt?
No
try pressing <CTRL>-<C>
Ok, i got it
ok. now you can type commands at the >>> and press enter to execute them.
try this:
print("hello world")
It works
cool. is all the lightsaber hardware connected?
Yes
ok. try this:
import lightsaber
Ok
what happened?
It seems frozen
it may be running and just needs to be turned on...looking at the code...
touch the copper teeth
I have no sound effect though
but the neopixels did something?
Yes ,the A2 copper tooth light up the leds
move your wav files into a folder called sounds on the CIRCUITPY drive
and then you'll need to restart the program
do all of this in the Mu serial window:
press <CTRL>-<C> to stop it, then <CTRL>-<D> to restart, when you see the >>> again, redo the:
import lightsaber
The REPL is frozen
you can't break out of the program by pressing <CTRL>-<C>?
No
close and open the serial again, sometimes this happens to me too on MU
but it doesn't always mean REPL is frozen, could be a MU bug?
Ok thanks cascade! Restarting it worked
(REPL would appear frozen but after closing and opening serial i can invoke Ctrl+C etc. again)
interesting. thanks @tawny creek . haven't seen that.
could it be that the REPL window didn't have focus?
happens to me often enough that it was a gut recommendation hehe
I typed " import lightsaber" and i'm waiting
even if you click into the REPL window, Ctrl +D etc it doesn't show anything
press the copper teeth again
the A5 tooth turns the light saber on/off
@tawny creek what OS?
The A2 turns the lightsaber on/off on this hallowing
uh. hmmm. me too.
code's just doing what it's told
TOUCH = touchio.TouchIn(board.A2) # Rightmost capacitive touch pad
why does guide say?
Press A5 to turn on lightsaber
might be a copy error in guide.
Mac OS
@tawny creek i'd say file an issue. sounds repeatable enough to be something that should be looked at.
@stoic wraith sounds now?
that was from pressing <CTRL>-<C>?
Yes
have you moved the wav files?
Yes
ok. click the REPL window so it's active. then press <CTRL>-<D>.
should do a reset and then bring you back to >>>
may have to hit <ENTER> to get >>>
is it frozen as in your last photo?
Yes
try the open/close REPL window thing again
Ok got it
you were able to <CTRL>-<D>?
Yes
ok. try to "run" the program again via the import
import lightsaber
Ok it works
woot!
it scared me. didn't realize how loud it would be.
the program expects the wav files to be in that folder, you can see it hardwired here:
wave_file = open('sounds/' + name + '.wav', 'rb')
and if you want the program to run automatically, you just need to save it with a certain name:
https://learn.adafruit.com/welcome-to-circuitpython/creating-and-editing-code#naming-your-program-file-6-30
up to you. just kind of depends on how you want it to act.
if you want to disconnect from the computer and run it from batteries, then you'll need to rename it so it'll run when power is applied
Ok
main.* is there for historical reasons. the *.txt extension is there to support users with text editors that don't like the .py extension
tldr - just use code.py unless you have reason not to
Ok, thank you for your help!!
np. have fun. may the force be with you.
@slender iron I've sprung a leek!
Wew!
>>>
Just to be sure. If you build a new CP version from GIT (which is now 4.0.0-alpha.somethingsomething) it doesn't have any debug stuff in it etc. which would bog down performance, is that correct? I mean it's just another version of CP on par with what is released, right?
@timber mango debug is disabled by defaults, but can be enabled by adding โDEBUG=1โ to the make command.
nice, thanks a bunch @solar whale
@pastel panther Hey that looks interesting! What is it? Do tell.
@tulip sleet I think I sorted out mu SPI confusions from yesterday. The problem I was actally havig was that I was trying to run a LoRa Radio from the Dongle VDD which looks like it can ouly provide ~25mA ( I needed ~100) THe SPI communication was fine!
To clarify one thing -- If I ceate one spi instance can I then use 2 devices on the same spi interface on the 52840 at this time? Like this: I did not get an error.
import busio
import digitalio
import adafruit_sdcard
import storage
import sys
# Connect to the card and mount the filesystem.
spi = busio.SPI(board.P0_17, board.P0_24, board.P0_20)
sd_cs = digitalio.DigitalInOut(board.P1_10)
sdcard = adafruit_sdcard.SDCard(spi, sd_cs)
vfs = storage.VfsFat(sdcard)
storage.mount(vfs, "/sd")
sys.path.append("/sd")
sys.path.append("/sd/lib")
import adafruit_rfm9x
# Define pins connected to the chip, use these if wiring up the breakout according to the guide:
rf_CS = digitalio.DigitalInOut(board.P0_02)
rf_RESET = digitalio.DigitalInOut(board.P1_13)
rfm9x = adafruit_rfm9x.RFM9x(spi, rf_CS, rf_RESET, RADIO_FREQ_MHZ)
@keen anvil It's a secret! (It's not a secret)
๐ต
It's an express-like SAMD51/M4 board in a ESP-32 footprint
@solar whale those LoRa work good? i was reading about in learn docs and they can send/recive "252 bytes" ? I was wondering if it is possible to set up a basic chat app with 2, 252 bytes is a big line of text i think
@upbeat plover both the LoRa (RFM9x) and the RFM69 work fine for exchainging messages between a pair. The LoRa has better range.
is there a breakout board for the LoRa?
i dont see it here https://www.adafruit.com/category/859
Adafruit Industries, Unique & fun DIY electronics and kits : Radio - Tools Gift Certificates Arduino Cables Sensors LEDs Books Breakout Boards Power EL Wire/Tape/Panel Components & Parts LCDs & Displays Wearables Prototyping Raspberry Pi Wireless Young Engineers 3D printing N...
If you are going to use them with CircuitPython - I suggest the feather wing or breakout and combine it with an M4 Express board. Although for basic chat, a feathe M0 express might be fine. I don't recomment the "allin in one board for CP"
yes -- looking for the link -- I have a few LoRa breakouts running...
nice, they seem fun, and the range looks like it will work between me and a neighbor
I am just using a simple wire, but have not done ,much range testing. Hope to do some soon.
I'd like to know what kind of range you get out of it
me too ๐
for simple chat app, would you have like a switch on both to set into send mode or into receive mode? kinda like how walkie talkie works?
Typically you just send then listen for responses. You can set up a handshake to confirm taht the mesage was received. That is have the receiver send an acknowledment of the message. If it is not received - resend. Lots of options, Thre are dropouts and missed messages so it is good to consider. It's not necessary - you can just send an hope for the best....
the rfm9x example is a simple send then wait -- It only sends one message, but can be adapted easily. https://github.com/adafruit/Adafruit_CircuitPython_RFM9x/blob/master/examples/rfm9x_simpletest.py
@idle owl @tidal kiln i think i have a plan for adabot checking libs with updates since last release. @tidal kiln, in the issue you posted, were you thinking only "first release" or any subsequent releases?
and since i've been working in adabot pretty much all week...might as well tackle it. ๐ 
subsequent, but if you can check all might as well. it could even happen with the initial release.
well, the way i'm thinking should catch both. just wanted to make sure it shouldn't be limited.
actually, the situation is for when there is no release
commits were pushed, but a release wasn't done
this should just be a "warning" level flag, since there may reasons why commits have been pushed but no release done
ok. i could probably make it two different ones:
if no_release_at_all:
[ERROR_ZERO_RELEASES]
if commits_since_last_release:
[ERROR_NEW_COMMITS_SINCE_LAST_RELEASE]
and this is for the weekly notes. not on a Travis run...
i'd so no release at all could be an "error"
that'll only happen at the start.
but, yah, i think they checks are like what you posted.
k. thanks for confirmation on expectations. eegads! i only have 4000 api requests left for the hour.. ๐ฑ ๐
make a real time strip chart of something
@raven canopy I can't help but think that there must be a bulk API if you're having to make 4000+ requests
maybe not but that seems excessive; what are you calling?
@pastel panther adabot checks * 114 repos = approx 600 requests.
hmm.
@raven canopy How's it going
๐
I have a Feather M4 that dir(board) doesn't have D6 in it. ๐ค
what board? what firmware?
https://github.com/adafruit/circuitpython/blob/master/ports/atmel-samd/boards/feather_m4_express/pins.c#L23 shold be a D6
nmwhat -- never happened ๐
Does this still need help to be implemented?
I checked the Nordic documentation about ESB and maybe the API on circuitpython should be similar, i don't own any Nordic kits but i would like to help.
-carlos
what? did something happen? i didn't see nuthin... ๐
Hi Guys,
I'm still a bit of a newb. I'd like to try this, but have no clue how. Is that something you could explain or point me to, please?
Thanks,
-Parsko
Hi folks... I'm curious if anyone has experience driving a decent amount of neopixels (364 in my case) with circuitpython?
to probably nobody's surprise, things look very "slow" when running that many in serial
looking for some ideas to make things a bit snappier
now that I think about this, I'm going to move over to #help-with-projects as it's probably not just a code thing
@full ginkgo use brightness=1 (default value)
no, this is probably really CircuitPython-related. The libraries are not fast - we are working on writing more of the low-leve parts of the libraries in C
I'm having some memory issues too depending on what code I'm running
Sometimes you can skip updating every pixel in a rainbow effect and similar, and still get an acceptable-looking display. Setting brightness to other than 1.0 will use double the memory
that's interesting... the brightness = 1 does actually speed things up
gotcha
well, I have caps and a 200 watt supply to accommodate the max brightness so I'll keep that in mind
You can lower the RGB values to control the brightness, though you may have color fiedlity issues more easily that way
for the time being, I'm just looking to get some orange and maybe purple for halloween
def rainbow_cycle(delay):
for j in range(0, 255, 8):
for i in range(ring.n):
idx = (i * 256 // ring.n) + j
ring[i] = wheel(idx & 255)
ring.show()
time.sleep(delay)
the lights are placed inside the front window frames at my house, it's going to be an evolving project to accommodate holiday decorations ๐
above is an example of doing rainbow cycle skipping some steps, notice the 8 in the range() call.
gotcha
also make sure auto_write=false and you only call .show() when everything's been updated
yup, I have that in there
going to look to see if there any other published hints...
nothing obvious right now. see how those help and you can ask here again if still troubled by speed
thanks!
yw!
the brightness has already made a difference... I'm going to start playing with the step value...
also notice the // in the computation: integer division instead of float -- helps a little
didn't know about that one, thanks
@tidal kiln thanks so much for assisting @stoic wraith with the saber project! I've just fixed that 'A5' typo, and added more clarity about naming the file code.py
@split ocean np. easy peasy. thanks for updating!
@tulip sleet brightness at 1 and messing around with fancyled is looking better. Thanks! https://imgur.com/gallery/6ikruEM
Am I correct in thinking the wait_until() function waits for the start of a new millisecond?
Update/append some french translation.
FYI https://github.com/rabbithat/micropython_nRF52840 RX/TX lowlevel radio demo, straight-register but perhaps useful!
Hello everyone, i'm designing a board based on nrf52832 and i'm interested in using circuitPython on it. My main issue is about the filesystem space (~100k), i may need more space for my application. I saw that the nrf52840 is supporting qspi for flash access and as i understand it circuitPython is able to use it transparently (not sure about this).
So i was wondering if the port to nrf52832 is also able to use a spi flash with single or dual IO. Is there somebody who did something like this ?
thanks for your help
@exotic pumice what wait_until function are you referring to?
it's used in the neopixel port for samd, I think the write has to be at the start of a new millisecond?
It looks to me like it waits for the specified ms and microseconds -- in neoopixel_write, the desired values ared calculated to control the timing.. at least thats how I am reading it. I am not an authority - hopefully someone else with more definitive knowledge can confirm/deny.
oh, it's just 0, 1000
it looks like it is being used to wait 100 microsec.
basically what I've run into is that if I write my neopixel soon after boot, it works, but if I do some other stuff first, it fails
in my own library
so I think this might be why
100 microseconds not 1000?
neither delay is helping my problem
I really need a scope as you guys have recommended
Or a logic analyzer
I've done my d13 trick again and it seems execution is stuck somewhere again
or it's crashed or something
on top of a logic analyzer I need a swd/jtag device
I could use my pi, I just have to attach wires to my cpx
is there a circuit python equivalent to cpp's millis function?
i know there's time.monotonic(), but can that be used in the same fashion as millis for a state machine?
yep. use time.monotonic(). that's generally the equivalent. how tight are your timing requirements?
right now you can get sample_rate as a property, but not bits/channels (which could help auto-config the mixer/audio playback
https://circuitpython.readthedocs.io/en/latest/shared-bindings/audioio/WaveFile.html
it would be really rad if you could auto-mix mono to stereo. there's no warning if you do so, but it doesnt work.
ill add example repro code later
yeah we shouldnt clip audio but perhaps theres an offbyone that makes it sound particularly sad
softvol isnt as nice as hardware but its better than nothing. maybe best to put it into the mixer? might be handy for smaller boards tho (in which case it goes into the DAC)
maybe could have both....0.0 to 1.0 range multiply
@slender iron it looks like the sercom pin corresponding to the neopixel is rx only?
another massive python on microcontrollers newsletter coming out tues - https://adafruitdaily.com here is a preview
@tidal kiln not very, just new to python and didn't know if it was the right tool for the job or not
thanks!
Help --
Help -- I have a M0 Trinket. I also have two computers. When connected to one of the computers everything works as excepted.
On the other computer the M0 Trinket has Reload Exceptions followed by soft reboots every couple of seconds.
I have two M0 trinkets both react in the exactly the same manner.
I have checked the voltages and on both computers Bat is 4.88 volts.
The line numbers that the soft reboots occurs varies, it is not always the same lline number
I have even tried the basic blink code and it get Reload Exception followed by soft reboot.
import board
import digitalio
import time
led = digitalio.DigitalInOut(board.D13)
led.direction = digitalio.Direction.OUTPUT
while True:
led.value = True
time.sleep(0.5)
led.value = False
time.sleep(0.5)
@sinful spruce that happens when your computer is writing to the CIRCUITPY drive. Are you editing the file? What OSes?
@tulip sleet does the built-in busio.i2c have trylock?
@marble hornet yes, try_lock()
i'm getting this error:
File "/lib/adafruit_bus_device/i2c_device.py", line 62, in __init__
AttributeError: 'I2CDevice' object has no attribute 'try_lock'```
add ()
but when i tried inputting a raw busio.i2c instance it gave a different error?
That's I2CDevice, not buiso.I2C. I2CDevice takes care of the try_lock for you, using with ... :
ah. good catch.
I2CDevice is a wrapper
okay, so the busio is the 'bus object?' and bus device is chip specific ??
like an object representing that chip?
no, you use busdevice to help you manage using multiple devices on one I2C bus easily.
I2CDevice takes care of locking/unlocking the bus for you when you use the context mananger
You pass a busio.I2C instance to I2CDevice when it's created
okay
reading sc
That link explains the motivation
any of the drivers for an i2c device would also be a good example usage to look at
an i2c sensor / breakout....maybe poor choice of words
okay, so the mpr121 class takes a i2c bus, but once it makes the device inside it it treis calling read_then_writeinto but i'm getting File "/lib/tg_io/staging/touch_brd0.py", line 10, in <module> File "/lib/adafruit/adafruit_mpr121.py", line 106, in __init__ File "/lib/adafruit/adafruit_mpr121.py", line 145, in reset File "/lib/adafruit/adafruit_mpr121.py", line 133, in _read_register_bytes File "/lib/adafruit/adafruit_mpr121.py", line 133, in _read_register_bytes AttributeError: 'I2CDevice' object has no attribute 'write_then_readinto'
and in the i2cdevice.py i see no read_then_writeinto method in the class
am i using thewrong port?
looks like you're just trying to use the mpr121 library?
if touch_brd0.py isn't too large, post it here
I think you have an old copy of adafruit_busdevice. write_then_readinto() was added a couple of months ago
working on it... thank you
@tulip sleet is this teh right one ?https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
that's the right library, but the copy you have on your board appears to be out of date. You could do to see the version numberadafruit_bus_device.__version__
sorry wrong adafruit_bus_device.i2c_device.__version__
2.2.5 is latest write_then_readinto was added in 2.2.4, and fixed in 2.2.5
download the latest bundle and update your libraries
>>> abd.__version__
'0.0.0-auto.0'
>>> ``` ๐
the version number is filled in when the library is put in the bundle. The raw library doesn't have it.
what board is this?
Get the latest bundle here: https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/latest
Yup! Getting dev board for the nRF52840 is the best way to start. It includes debugging onboard which makes it easier. If you need links to it let me know and I can help.
Ya, I was thinking about this. I think it'd be cool to have it based on another stream. That way we can also provide ADSR envelopes over tones.
Ya, I think there is an overflow somewhere.
Weird, I thought the mixer validated that its channel count was the same as the inputs.
Yup! Good idea! This is a good first issue because one can follow how sample_rate is done.
@parskofamily Thanks for wanting to help! This is actually a pull request where @jepler imlemented it. Take a look at the "Files changed" tab to see how things were changed to add it.
<@&356864093652516868> Here are meeting notes for tomorrow's meeting: https://docs.google.com/document/d/1bh0Pc59vV6MjAQh8HW8BL0-z_xoGAhe73tW0ledflIs/edit?usp=sharing
i want to record voice with circuitpython. Advice on how to do this appreciated.... i thought maybe this would work: ``` import array
import audioio
import audiobusio
import board
import digitalio
import time
mic = audiobusio.PDMIn(
board.MICROPHONE_CLOCK,
board.MICROPHONE_DATA,
bit_depth=16
)
enable the speaker
speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
speaker_enable.direction = digitalio.Direction.OUTPUT
speaker_enable.value = True
print("...start recording...")
r = array.array('H', [0] * 20)
mic.record(r, len(r))
time.sleep(3)
print("stop recording")
time.sleep(5)
print("...playback...")
audio = audioio.AudioOut(board.A0)
sample = audioio.RawSample(r)
audio.play(sample,loop=True)
time.sleep(1)
audio.stop()
@caternuson heya wanna take a look at adding this? lil different than userland but a good first issue if you are interested in poking into internals!
mixer to inputs yes they are validated. mixer to audioout no
totally. but...straight up volume would be a good start. that way, might not be a bad beginner issue? you'd pass volume into the mixer during play()?
Is it ok to ask troubleshooting questions here?
i think so
@autumn geyser Yes -- responses may have to wait for someone who can help
@autumn geyser yes, if it's circuitpython related. if it's not, you can still ask, but one of the other channels might be better. if you're not sure, no worries, just ask. we'll do what we can.
TY! - I am trying to run circuitpython code on a gemmaM0. I ran into a memory allocation problem as my code reached 6kb. From there, I deleted the Win7 drive. The code still works & I can move stuff around. But if I try to add more than a few assignments, then MU reports a memory allocation error. I am confused because after deleting the win7 drive, I have 11.5 kb reported as available by my PC.
I initially brought my question to the MU discussion here:https://gitter.im/mu-editor/general & they recommended I come to you guys.
General chat, help, discussion and ideas about the Mu code editor. Don't be afraid to ask a question. We're friendly! Please follow the Code of Conduct (https://www.python.org/psf/codeofconduct/)
(I am ranger turner on that chat)
@autumn geyser teh memory allocation errors are due to running out of RAM in the processor, not the File system space. What libraries are you importing?
import time; import board;
import pulseio; import neopixel
import math; import adafruit_dotstar
from digitalio import DigitalInOut, Direction, Pull
^ I could remove the dotstar import, because it's just to turn off the on-board LED
TY by the way for the clarification
remove as much as you can ans see if it works -- then add things back and see where it runs out -- that is a lot for a gemma m0
T.T Thank you.
you're welcome -- alos for the "external" libraries -- make sure you are using the .mpy version as opposed to the .py version. (look like only adafruit_dotstar applies)
I'm not sure waht will help -- maybe others have suggestions. you can check avaliabe ram ```import gc
gc.mem_free()
also to try to free space
gc.collect()
^super helpful. I'll read the wiki / docs on these. & stop bothering you. THANK YOU!
no bother -- good luck!
yes clearing variables and dinit stuff after use will help save RAM
@autumn geyser fwiw - i was able to get through all the imports:
Adafruit CircuitPython 3.0.3 on 2018-10-10; Adafruit Gemma M0 with samd21e18
>>> import time
>>> import board
>>> import pulseio
>>> import neopixel
>>> import math
>>> import adafruit_dotstar
>>> from digitalio import DigitalInOut, Direction, Pull
>>>
Yah I was able to import everything & use it. I actually have a fair amount of functionality. I'm just running out of space 3/4 of the way through what I want to code. TY though.
YUS! TY
๐
@autumn geyser
while hungrytime is True:
with digitalio.DigitalInOut(board.SPEAKER_ENABLE) as speaker_enable:
with analogio.AnalogIn(board.TEMPERATURE) as anatemp:
with analogio.AnalogIn(board.LIGHT) as analight:
with audioio.AudioOut(board.SPEAKER,sine_wave) as tuneply:
lux = (analight.value * 3.3 / 100) / 2
if lux < 900:
print("I'm hungry for more LIGHT!")
feedcheck = 0
red_led.value = 0
else:
print("Yay, loving this light.")
ftemp = anatemp.value / 450
happytemp = ftemp / 5
if happytemp > 16 and happytemp < 17:
if lux > 900:
tuneply.play(loop=True)
time.sleep(0.1)
tuneply.stop()
feedcheck += 1
print('Feeding now...')
red_led.value = 1
if lux > 900 and feedcheck == 3:
feedcheck = 0
red_led.value = 0
hungrytime = False
break
else:
if happytemp < 16:
print("I'm too cold. Can't feel my Bits...")
if happytemp > 17:
print("Temperature is getting hot.")
print("I'd like a cooler environment.")
feedcheck = 0
red_led.value=0
time.sleep(3)
print('####')
this is what i did to save RAM with a CPX pet thing i made back in cp version 2.2.0 use "with" and "as" to dinit stuff easy after use
that only helps if your not using the stuff later in script
I found something that will also help anyone w/ same problem:
^ Suuuper good. DIdn't realize I could do it function by function
(Not with board currently Ill report back when I verify it works.)
You can but it's not always a better way to do it. The memory is handled differently depending on how you do the imports. Sometimes that's a better way to do it, other times it makes more sense to import math and go from there.
So if you run into issues, try both ways and see which works better for you.