#circuitpython-dev

1 messages ยท Page 205 of 1

solar whale
#

I posted to the Forum

warped pendant
#

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?

manic glacierBOT
tidal kiln
#

@solar whale hmmm. works for me too. i was using: Adafruit CircuitPython 3.0.3 on 2018-10-10; Adafruit CircuitPlayground Express with samd21g18

solar whale
#

You fixed it ๐Ÿ˜‰

tidal kiln
#

@warped pendant can you provide more details on what the "else" is that doesn't work

upbeat plover
warped pendant
#

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 ๐Ÿ˜ฆ

upbeat plover
#

@idle owl is there a spi flash erase bootloader thingy for CPX?

manic glacierBOT
idle owl
#

@upbeat plover There is a flash eraser file for CPX, yes. Check the troubleshooting page to find it.

upbeat plover
idle owl
#

Apologies, we were inconsistent with mirroring the troubleshooting pages appropriately. I believe it is in the troubleshooting page for Trinket M0. Hold on.

upbeat plover
#

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

warped pendant
#

@upbeat plover in boot just drag that?

upbeat plover
#

yes

tulip sleet
warped pendant
#

i tried erase from terminal yesterda --- ok thanks

tidal kiln
#

@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?

solar whale
#

I always delete the lib version on a CPX

#

delete all the builtins

tidal kiln
#

boom. memory allocation error...

upbeat plover
#

why i love m4 now... i have yet to get that

solar whale
#

who could ever need more than 192K of ram...

idle owl
#

we'll get there.

warped pendant
#

omg thank you @upbeat plover rainbow pixel love happening ๐Ÿ˜ƒ ๐Ÿ˜ƒ ๐Ÿ˜ƒ

solar whale
#

I was mis-quoting Bill Gates --- long time ago....

manic glacierBOT
upbeat plover
#

is it wrong i want a m4 CPX?

#

could be like "super circuit playground express"

#

and with 8mb flash instead of 2...

tidal kiln
#

@warped pendant you said you tried to erase flash memory via terminal - did it not work?

warped pendant
#

i'm pretty sure i did it correct but yes it didn't work

tidal kiln
#

you did this?

    >>> import storage
    >>> storage.erase_filesystem()
warped pendant
#

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 -

tidal kiln
#

what version of CP are you running?

#

looks like 3.0.3?

warped pendant
#

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

upbeat plover
#

your code got deleted when your battery ran out?

tidal kiln
#

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

idle owl
#

@solar whale Got ya. Still... we keep saying the same thing every time we make it bigger ๐Ÿ˜„

solar whale
#

Nature abhors free memory ๐Ÿ˜‰

upbeat plover
#

speaking of memory how do you use nvm?

tidal kiln
#
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
>>> 
upbeat plover
#

awesome

#

00 to FF on nvm[0] to nvm[8191]

tepid sapphire
#

Do python works better on NRF52832 or NRF52840 ?

tulip sleet
#

@tepid sapphire nrf52840 has built-in USB, more memory, etc., so better choice

tepid sapphire
#

nice Danh

tulip sleet
#

expect Adafruit products with nRF52840

tepid sapphire
#

yes

#

i hope

tulip sleet
#

they're on the way - no timetable, but sooner rather than later

tepid sapphire
#

i already got NRF52840 samples (u-blox modules)

#

i want that Python (Adafruit) be the official programming language to our clients

tawny creek
#

will the nrf52840 require a separate usb chip @tulip sleet ?

tulip sleet
#

no - it has built-in USB like the SAMx1. '832 needs a separate chip (and has less RAM and flash)

tawny creek
#

cool! ๐Ÿ˜„ less component count

tepid sapphire
#

nice! I can wait to test the new BLUETOOTH API ๐Ÿ˜ƒ

manic glacierBOT
manic glacierBOT
upbeat plover
#

@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```
tidal kiln
#

@upbeat plover what board are you using?

upbeat plover
#

featherM4

tidal kiln
#

what do you get from?

>>> from microcontroller import nvm
>>> len(nvm)
reef mantle
#

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.

upbeat plover
#

8192

exotic pumice
#

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.

tidal kiln
#

@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
>>> 
upbeat plover
#

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

tulip sleet
#

@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

exotic pumice
tulip sleet
#

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

exotic pumice
#

good to know

tulip sleet
exotic pumice
#

@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.

upbeat plover
#

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

tulip sleet
#

@upbeat plover you can use struct.pack and .unpack to turn whatever you want into a byte string

upbeat plover
#

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```
exotic pumice
#

@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

tulip sleet
#

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.

exotic pumice
#

ok let me see how to do that

tulip sleet
#

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.

exotic pumice
#

I have a bus pirate that's semi-broken

#

that's it

tidal kiln
#

@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.

exotic pumice
#

what is nvm?

#

oh, non-volatile memory?

upbeat plover
#

yeah

manic glacierBOT
upbeat plover
#

hmm think i got it working

exotic pumice
#
#

they're rather different

upbeat plover
#
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

exotic pumice
#

@upbeat plover I think lb means a long and a byte so a 5 byte number

upbeat plover
#

yeah i was thinking that too but it stores stuff strange like this b'<lg\xff\x00

exotic pumice
#

when python prints a byte it tries to convert it to characters and fails miserably

upbeat plover
#

that was -9999300
b'\xc4\x93\x98\x00\x00'
is 9999300

exotic pumice
#

oh ok, so that's not the issue

tulip sleet
exotic pumice
#

the main difference I saw was number of nops

tulip sleet
#

cut out the 400khz code to avoid confusion

exotic pumice
#

not that part

upbeat plover
#

@exotic pumice i guess it is 5 bytes or 40 bits, max is 1.0995116e+12

exotic pumice
#

the nops are different between 800khz arduino and 800khz circuitpy

#

both for samd21g18a

tulip sleet
#

@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

exotic pumice
#

ok

#

neither are working at 800kHz for me

#

maybe something is soaking up cycles

tulip sleet
#

it's hard to debug this stuff without looking at the actual timing

#

and waveforms

exotic pumice
#

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?

tulip sleet
#

just the data line to the first neopixel, not sure the bus pirate is fast enough to do the monitoring. no scope?

exotic pumice
#

I could use one at my college possibly

tulip sleet
exotic pumice
#

is open drain output correct?

tulip sleet
#

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

exotic pumice
#

I'm using the cpx

tulip sleet
#

you mean you're using the onboard neopixels?

exotic pumice
#

yeah

#

push pull output?

tulip sleet
#

yes

exotic pumice
#

ok

tough flax
#

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

tulip sleet
exotic pumice
#

I got it to work @tulip sleet

tulip sleet
#

@exotic pumice woo hoo! anything extra other than what we discussed?

exotic pumice
#

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

tough flax
#

@tulip sleet - is there a CP library for the Bluefruit SPI/UART?

tulip sleet
#

@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

tough flax
#

Yup - OK, perhaps we can port the Arduino lib to the UART chip

#

Sounds like an option while we wait for the new 52

tulip sleet
#

i have pinged the appropriate person with a ref to this thread

tough flax
#

Thanks

exotic pumice
#

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

tulip sleet
#

@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

exotic pumice
#

yeah

#

If I use spi it doesn't work with the built-in ones on your boards though

#

it's a tradeoff

tulip sleet
#

we used the PWM peripherals on the nrf52 because we can't necessarily turn off interrupts for that long

exotic pumice
#

would those work on samd?

#

or there is no such peripheral?

upbeat plover
#

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?
upbeat plover
solar whale
#

@upbeat plover why are numbers stored with 5 bytes?

upbeat plover
#

well when i tried storing them just in a array 300 took 300 bytes

#

the pack thing helped i guess

tulip sleet
#

@exotic pumice there is a PWM peripheral on SAMD as well

solar whale
#

@upbeat plover I'll have t think about that -- Thanks for posting the module. I was not even aware the nvm existed!

upbeat plover
#

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

solar whale
#

I just don't understand th e 5 bytes per entry but I need to study what you are doing first.

upbeat plover
#

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

solar whale
#

are you storing them as text? a 32 bit value can be +/-2147483647 stored in binary

upbeat plover
#

no i dont think it is text right now

solar whale
#

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.

upbeat plover
#

cool

#

why some modules have "self" and "_variable"?

#

also what are class? lol yeah im noob

solar whale
raven canopy
#

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

pastel panther
#

how do I tell how much memory I have free?

solar whale
#
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

pastel panther
#

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

solar whale
#

first time I've heard M4 referred to as limited memory ๐Ÿ˜‰

pastel panther
#

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

upbeat plover
#

is that how digital tv is? seems like loss of signal just makes the pixels that should update turn black

solar whale
#

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....

pastel panther
#

@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

solar whale
#

โšพ good night all!

upbeat plover
#
nvms.readnum(address)
``` returns ```python
value
``` now instead of ```python
(value, 0)
tidal kiln
slender iron
#

@pastel panther you seen the imageload library?

pastel panther
#

no

slender iron
#

palettizing the bitmap

#

and run length encoding

#

that is why I made OnDiskBitmap though

#

so it can stay out of memory

gentle bronze
#

it is a inifite loop, the comment is misleading ๐Ÿ˜ฆ

slender iron
#

haha, its not actually, the _receive is a macro that returns

#

it is confusing though

gentle bronze
#

yeah, only in no rtos

#

any rtos API that block the thread will return

#

to the super loop()

slender iron
#

right, which is what I'm doing

gentle bronze
#

when using with rtos, that API is the real blocking, the scheduler will do that for it

#

us

slender iron
#

right, it'll context switch

gentle bronze
#

kind of confusing, but I don't know better way to have both the rtos + non-rtos running with the same code.

slender iron
#

does the nrf build use an rtos?

gentle bronze
#

no, circuitpython does not have rtos

slender iron
#

kk

gentle bronze
#

but Arduino use freeRTOS

#

I used to test wtih keil RTX as well, but it must be quite obsolete

slender iron
#

I've got the first descriptor returning but the third setup packet is getting lost somewhere

gentle bronze
#

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).

slender iron
#

let me commit so I can link you

gentle bronze
#

ok

slender iron
pastel panther
#

@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

slender iron
#

I have no idea, I haven't used rgb_display

#

it loads the bmp into a bitmap and palette

gentle bronze
#

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.

slender iron
#

even for zero length?

gentle bronze
#

zero length will be disacrded by usbd, it is no problem if you call, the usbd currently didn't wait for the status ๐Ÿ˜„

slender iron
#

will it reply with it though? It seemed like usbd wasn't calling another xfer for the next setup transaction

gentle bronze
#

it will skip the status (zero length packet).

slender iron
#

my impression was that the nrf automatically listens for a setup packet

gentle bronze
#

ah right

slender iron
#

line 263 is to wait for the next setup

gentle bronze
#

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)

slender iron
#

the buffer gets copied into the event though right?

gentle bronze
#

ah yet, the setup will be copied into the queue

#

yes

#

@slender iron after the desc transfer

#

there is ACK which is OUT

slender iron
#

ya

gentle bronze
#

maybe that call will overwrite or blcoked by this queue transfer already ?

slender iron
#

the beagle shows the next setup being acked

#

and I can see it in dcd_setup_received

gentle bronze
#

ok, so you got a complete transfer of 1st desciptor, then 2nd setup + ACK, but there is no more DATA

slender iron
#

right the IN is being NAKed

gentle bronze
#

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

slender iron
#

ya, second request works with the new address

gentle bronze
#

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 ๐Ÿ˜„

slender iron
#

ya, good idea. it'll probably be obvious in the morning. thanks!

#

thanks for the help @gentle bronze !

#

๐Ÿ’ค

gentle bronze
#

good night ๐Ÿ˜„

hybrid scarab
#

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.

raven canopy
#

@tidal kiln huh. I specifically remember handling the diff... I can put in a fix-the-PR PR later today.

fluid helm
manic glacierBOT
#

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...

raven canopy
manic glacierBOT
upbeat plover
#

how do i fix Mu so serial works with hallowing? says "Could not find an attached device." but PuTTY works fine

raven canopy
#

@upbeat plover what version of Mu are you using? Looks like 1.0.1 is when HalloWing was added.

upbeat plover
#

already uninstalled and installing "portamu_1.0.1_win64" to usb drive to test out

river quest
tidal kiln
#

@raven canopy thanks for quick fix! @idle owl this was simple clean up (cookiecutter), so i just went ahead and merged.

upbeat plover
tawny creek
#

@upbeat plover maybe one that would also work on upcoming boards

upbeat plover
#

xmass board?

tawny creek
#

no that super secret credit card sized one with a display

upbeat plover
#

can i preorder now?

tawny creek
#

i don't think so ;3

upbeat plover
#

thats like what i got going on my featherM4 with miniTFT but better if it has speaker too

tawny creek
#

yup and nice compact size

upbeat plover
#

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?

bronze geyser
#

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?

tawny creek
#

@upbeat plover that'd be cool :3 if it means faster gfx

upbeat plover
#

was just thinking sounds and gfx is kinda much for 1 chip?

idle owl
#

@tidal kiln Perfect, thanks!

raven canopy
#

@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...

bronze geyser
#

@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.

raven canopy
#

Not sure how any other objects will react though...

#

Did you dir(pin)? That should show any RPI.GPIO funcs.

bronze geyser
raven canopy
idle owl
tidal kiln
#

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?

idle owl
#

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 ๐Ÿ˜„

tidal kiln
#

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.

silver sage
#

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 ?

solar whale
#

@silver sage the only MCU that has wifi support under Circuitpython is the ESP8266 ,at this time.

silver sage
#

Thanks, that was the answer I expected, was hoping for something more like the M0 in terms of circuitpython drag and drop updating.

solar whale
#

You are not alone ๐Ÿ˜‰

idle owl
#

@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.

slender iron
#

how are they inconsistent?

#

why change them? is it breaking something?

idle owl
#

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.

bronze geyser
#

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...

timber mango
#

hi

slender iron
#

@idle owl I don't know why that matters. its an internal git file so I wouldn't mess with it

idle owl
#

ok

exotic pumice
#

#rust-embedded on mozilla irc is mad the neopixels on cpx aren't connected to a timer lol

slender iron
#

@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

exotic pumice
#

hmm

tidal kiln
#

@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.

idle owl
#

@tidal kiln Well if there's no Canadian rock band... I'm not sure you can have a repo.

tidal kiln
#

no rush ๐Ÿ˜ƒ

idle owl
#

I know. I'm hassling you anyway.

tidal kiln
#

yep. awesome. thanks.

idle owl
#

@tidal kiln I don't think it's causing issues with the parsing. I think it was simply noticed as an inconsistency.

tidal kiln
#

i think that other line is just a free text label, based on stuff i was reading trying to undo my CAP1188 mess

idle owl
#

Scott said to leave it if it's not breaking anything.

#

So it is what it is.

tidal kiln
#

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?

idle owl
#

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

river quest
#

ok folks, post a #leek over on #general-tech an open-source circuitpython powered badge and gaming platform, FEATHER compatible - enjoy

tidal kiln
upbeat plover
#

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)
raven canopy
#

sorry for errant .gitmodules suggestion; standard for standards-sake can be a byproduct of day_job. ๐Ÿ˜„

slender iron
#

np

idle owl
#

I have a PR where it says the checks are still in progress, but Travis says it passed

manic glacierBOT
exotic pumice
#

are neopixels numbered starting from 0 or 1

#

in set_pixel_color() for example

idle owl
#

0

#

@exotic pumice At least every time I've dealt with them in CircuitPython, they start at 0.

upbeat plover
#

does storing to NVM work cross CP and Arduino?

manic glacierBOT
upbeat plover
#

nope

idle owl
#

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

river quest
#

that list is rad, thanks @raven canopy & @idle owl

idle owl
#

@river quest You're welcome!

river quest
#

i did a quickie blog post to test it and replied back with a link, that worked well too

idle owl
#

I saw that, nicely done

river quest
#
Adafruit Industries - Makers, hackers, artists, designers and engineers!

Adafruit CircuitPython Libraries Here is a listing of current Adafruit CircuitPython Libraries there are about 104 at this time. Drivers: Adafruit CircuitPython ADS1x15 (PyPi) Adafruit CircuitPythoโ€ฆ

haughty bobcat
#
    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/

upbeat plover
#

maybe you need an else

raven canopy
#

@haughty bobcat when checking values in a conditional (if/elif), you need to use two equal signs: elif clpbd == 1:

haughty bobcat
#

Ok

#

Thanks

raven canopy
#

yw!

sick yacht
#

Is there Circuit Python for Arduino Uno?

tulip sleet
#

@sick yacht No, sorry, there's not nearly enough memory on an Uno for CircuitPython.

sick yacht
#

I see. Thanks for the reply!

tough flax
#

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?

tulip sleet
#

@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.

tough flax
#

Once the bin is loaded, does it start a USB storage device? Or just a REPL?

tulip sleet
#

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

lone sandalBOT
tough flax
#

Thanks ๐Ÿ˜ƒ

strange pumice
#

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)

upbeat plover
#

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

azure tendon
#

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) ?

upbeat plover
#

I dont think so, not in RGB display ether

azure tendon
#

oh well i guess i can just "rotate" the device i working on for now lol

tidal kiln
#

@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

azure tendon
#

@tidal kiln i using adafruit_ssd1306 libary

upbeat plover
#

@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

tidal kiln
#

@azure tendon sounds like the arduino library?

upbeat plover
#

its CP too

#

mine issue is with adafruit_rgb_display.rgb though

tidal kiln
#

ah. was reading that as a repo name.

#

@upbeat plover how are you trying to read a pixel?

upbeat plover
#
print(display.pixel(64, 64,))

or

print(display.pixel(64, 64, color=None))
upbeat plover
#

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

tidal kiln
#

@upbeat plover can you reproduce the issue with a simple program that just sets the pixel then reads it back?

upbeat plover
#

yes

#

is it issue with ST7735R driver?

tough flax
#

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

tidal kiln
#

@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
>>> 
upbeat plover
#

yeah but it doesnt stay the same, 65535 or 0

#

@marble hornet i have this same issue with your custom mod

tidal kiln
#

@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

idle owl
#

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.

tidal kiln
#

done.

strange pumice
#

@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?

manic glacierBOT
pastel panther
#

@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

slender iron
#

@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

idle owl
#

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....

gusty kiln
#

oh boy, hacktoberfest shirt time.

idle owl
#

Hooray!

tidal kiln
#

@idle owl fwiw, yes. just keep appending index.

idle owl
#

what does it look like?

gusty kiln
#
>>> thing[0][0]
1```
tidal kiln
#

list of tuples
'[(1,2,3), ("foo", "bar")]'

gusty kiln
#

(er, i misunderstood the question, but same syntax.)

tidal kiln
#

Yep.

#

Im mobile right now. But that's it.

idle owl
#

I thought I tried that, but ok

#

maybe I had extra parens or something

slender iron
#

got samd51 serial working with tinyusb!

idle owl
#

@slender iron That's great!!

pastel panther
#

@slender iron yaaaaaaaay

marble hornet
#

@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)

tidal kiln
#

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.

idle owl
#

@tidal kiln push an empty commit.

raven canopy
#

--allow-empty i think is the option...

#

and sorry if i keep breaking cookiecutter. ๐Ÿ˜ฆ

idle owl
#

breaking == making it better. ๐Ÿ˜ƒ

tidal kiln
#

@idle owl yah. just wondering if there's a "fancy" way. since i seem to do this every time ๐Ÿ˜ฆ

idle owl
#

nope.

#

Not that we've found.

raven canopy
#

once the "Trigger Build" gets out of beta, it can hopefully trigger a PR.

tidal kiln
#

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.

tough flax
#

Odd things happening when accessing my Trinket M0 over Serial... I'm not expecting any output and I'm getting this:

#

thoughts?

tidal kiln
#

obviously the empire has landed their ground forces and are advancing

slender iron
#

@tough flax what os? linux has modem manager

tough flax
#

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
slender iron
#

ya, you need to disable modem manager

tough flax
#

pointers? links?

tidal kiln
#
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
tough flax
#

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

bronze shadow
#

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.

tidal kiln
#

i'm not sure, but wouldn't that also be a step they would have to do?

tough flax
#

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

tulip sleet
#

@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

tough flax
#

Ugh. Ok... I'll writing something to detect it.

bronze shadow
#
sudo stop modemmanager
echo manual | sudo tee -a /etc/init/modemmanager.override
#

Needs root, but can temp stop it.

tulip sleet
raven canopy
#

@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...

tidal kiln
#

it was README.rst

raven canopy
#

OHHH. quickly learns to read

tidal kiln
#

if i understand that cryptic macro syntax, the code you put in requirements.txt just need to be there also

raven canopy
#

yep. on it! (unless you've already done it?)

tidal kiln
#

nope. go for it. thanks!

tough flax
#

Guys, I don't think it's modemmanager... that's not installed

#

Sorry - language I know

#

Caps

tulip sleet
#

is this ubuntu and what version?

tough flax
#

It's Fedora Server 28 and I found it - they PolyCapped the name

tulip sleet
#

got it - yeah I had to help someone at PyCon fix this, and it took a while to find it.

solar whale
#

@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?

tulip sleet
#

@solar whale right it should be only SPIM2, because SPIM1/TWIM1 and SPIM0/TWIM0 are reserved for TWIM (I2C). I thought I tested that.

tough flax
#

Ok, it's removed

#

Can I assume it's not installed on a rPi?

tulip sleet
#

i do not know if it's on the RPi

solar whale
#

the first device works fine -- just I don't get an error on the second, just very strange results ๐Ÿ˜‰

tidal kiln
#

i can check raspbian lite if that would help - have one handy

tulip sleet
#

is it lite or full?

tidal kiln
#

lite

solar whale
#

@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.

tough flax
#

Either would help @tidal kiln - thanks

tidal kiln
#

@tulip sleet how to check? ps?

marble hornet
#

anyone know why adafruit bus device is missing read_then_writeinto???

tulip sleet
#

@solar whale when it tested it, it should assign only SPIM2 and then complain there are non left.

#

@tidal kiln dpkg --list |grep modem

tough flax
#

perhaps grep -i modem

tulip sleet
#

on debian it's lower case, but yes grep -i is safer

solar whale
#

@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.

marble hornet
#

Any and all help welcome

tidal kiln
#
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:~ $
tough flax
#

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

tulip sleet
#

@marble hornet the spi function calls are passed directly to the busio.SPI object from busdevice

marble hornet
#

and over i2c?

tulip sleet
#

no, for i2c, there are wrapper functions, because the args are different

#

The function is write_readinto(), not write_then_readinto()

marble hornet
#

i'm using the mpr121 simpletest. okay. thanks!

tulip sleet
#

@marble hornet the simpletest is i2c. Are you using the CircuitPython and not the plain Python one??

marble hornet
#

yes

#

i am

tulip sleet
#

are you still having an SPI problem? I'm confused.

marble hornet
#

i'm gonna check one more thing then get back to you, that okay?

tulip sleet
#

sure!

tough flax
#

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
marble hornet
#

this lib?

#

for i2c mpr121

tulip sleet
#

yes, that lib should be in the bundle

tough flax
#

The right hand of that works - I can manually put in /dev/ttyACM0 and it works the same

tulip sleet
#

@tough flax is this still on Fedora?

tough flax
#

yup

tulip sleet
#

ok, ubuntu/debian doesn't have /dev/serial; it has /dev/input

#

is this your linux machine or the client's?

tough flax
#

I can use lsusb

#

mine

#

This machine is not the target environment - it's just an example linux box I had around

tulip sleet
#

ok, now i see /dev/serial - i had a bad CPy load on the test board

tough flax
#

I want to add linux versions of the serial solutions I have on Windows

tulip sleet
#

green\r\n is not the same as green + enter, maybe. I think it would green\n without the \r

tough flax
#

I've tried both

tulip sleet
#

@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

tough flax
#

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?

tulip sleet
#

so echo green >/dev/ttyACM0 works, but echo green >/dev/serial/by-id/blahblahAdafruit does not?

tough flax
#

nope

#

non of them work

#

but screen /dev/ttyACM0 (and then typing green) does

tulip sleet
#

well, with screen there's a full-duplex connection, so maybe it's blocking trying to write?

#

cause there's nothing trying to read

tough flax
#

should I open a read session in the background first?

tulip sleet
#

trying...

#

in one terminal window I did cat </dev/ttyACM0, in the other i did cat >/dev/ttyACM0, yes, it's a weird repl

tough flax
#
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

tulip sleet
#

try what I did an see what's going on; you could even put some print statements in

tough flax
#

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 ๐Ÿ˜‰

tulip sleet
#

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.

tough flax
#

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

tulip sleet
#

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

tough flax
#

im starting it from the same shell -- how else do I check them?

#

is there a .screenrc?

tulip sleet
#

open another terminal window. Do screen in one and look at stty -F /dev/ACM0 in the other after screen starts

tough flax
#

Ok... hold on

tulip sleet
#

but you have -echo so that should be ok

tough flax
#

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

tulip sleet
#

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?

tough flax
#

Yes, let me grab the exact one from the device

#

hold on

#

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"
tulip sleet
#

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()

manic glacierBOT
#

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!

tulip sleet
#

normally input() strips the newline

#

but maybe not the \r?

tough flax
#

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
tulip sleet
#

right, that's what happened to me, so the print statement output is going back in as input

tough flax
#

But I had addedthe stty -echok and -echoe

tulip sleet
#

and -echo

tough flax
#

it was already there

tulip sleet
#

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?

tough flax
#

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!

tulip sleet
#

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.

tough flax
#

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

tulip sleet
#

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

tough flax
#

I added a test for "serial_connected" and that didn't help

   if (supervisor.runtime.serial_connected and supervisor.runtime.serial_bytes_available):
tulip sleet
#

did you eat already??

tough flax
#

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

tulip sleet
#

sure, food is important for thought

tidal kiln
#

struct.pack/.unpack is my new favorite thing. wish i had read up on it sooner.

manic glacierBOT
tidal kiln
#

it's magically useful:

        coeff = self._read_register(_REGISTER_CAL_DATA, 21)
        coeff = struct.unpack("<HHbhhbbHHbbhbb", coeff)
stoic wraith
#

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?

tidal kiln
stoic wraith
#

Yes

tidal kiln
#

do you know your hallowing is OK? have you tried some other simple program just to make sure the basics work?

stoic wraith
#

I know that the demo works good

tidal kiln
#

the one it shipped with - the eyeball thing?

stoic wraith
#

Yes

tidal kiln
#

you've gone through the setup for CircuitPython part?

stoic wraith
#

Yes, everything is updated

tidal kiln
#

how are you programming the board? with mu, etc?

stoic wraith
#

I used MU

tidal kiln
#

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?

stoic wraith
#

Maybe this can help

tidal kiln
#

yep. looks like you saved it as lightsaber.py

#

are you running Mu right now?

stoic wraith
#

Yes

tidal kiln
#

do you know how to connect to the REPL?

stoic wraith
#

No

tidal kiln
#

in Mu, click the button the says "Serial"

stoic wraith
#

Ok

tidal kiln
#

do you see the >>> prompt?

stoic wraith
#

No

tidal kiln
#

try pressing <CTRL>-<C>

stoic wraith
#

Ok, i got it

tidal kiln
#

ok. now you can type commands at the >>> and press enter to execute them.

#

try this:

print("hello world")
stoic wraith
#

It works

tidal kiln
#

cool. is all the lightsaber hardware connected?

stoic wraith
#

Yes

tidal kiln
#

ok. try this:

import lightsaber
stoic wraith
#

Ok

tidal kiln
#

what happened?

stoic wraith
#

It seems frozen

tidal kiln
#

it may be running and just needs to be turned on...looking at the code...

#

touch the copper teeth

stoic wraith
#

I have no sound effect though

tidal kiln
#

but the neopixels did something?

stoic wraith
#

Yes ,the A2 copper tooth light up the leds

tidal kiln
#

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
stoic wraith
#

The REPL is frozen

tidal kiln
#

you can't break out of the program by pressing <CTRL>-<C>?

stoic wraith
#

No

tawny creek
#

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?

stoic wraith
#

Ok thanks cascade! Restarting it worked

tawny creek
#

(REPL would appear frozen but after closing and opening serial i can invoke Ctrl+C etc. again)

tidal kiln
#

interesting. thanks @tawny creek . haven't seen that.

#

could it be that the REPL window didn't have focus?

tawny creek
#

happens to me often enough that it was a gut recommendation hehe

stoic wraith
#

I typed " import lightsaber" and i'm waiting

tawny creek
#

even if you click into the REPL window, Ctrl +D etc it doesn't show anything

tidal kiln
#

press the copper teeth again

#

the A5 tooth turns the light saber on/off

#

@tawny creek what OS?

stoic wraith
#

The A2 turns the lightsaber on/off on this hallowing

tidal kiln
#

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.

tawny creek
#

Mac OS

tidal kiln
#

@tawny creek i'd say file an issue. sounds repeatable enough to be something that should be looked at.

#

@stoic wraith sounds now?

stoic wraith
#

It is ok

tidal kiln
#

that was from pressing <CTRL>-<C>?

stoic wraith
#

Yes

tidal kiln
#

have you moved the wav files?

stoic wraith
#

Yes

tidal kiln
#

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 >>>

stoic wraith
#

Frozen again

#

Crtl-d does not work

tidal kiln
#

is it frozen as in your last photo?

stoic wraith
#

Yes

tidal kiln
#

try the open/close REPL window thing again

stoic wraith
#

Ok got it

tidal kiln
#

you were able to <CTRL>-<D>?

stoic wraith
#

Yes

tidal kiln
#

ok. try to "run" the program again via the import

import lightsaber
stoic wraith
#

Ok it works

tidal kiln
#

woot!

#

the program expects the wav files to be in that folder, you can see it hardwired here:

        wave_file = open('sounds/' + name + '.wav', 'rb')
stoic wraith
tidal kiln
#

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

stoic wraith
tidal kiln
#

nothing. except order.

#

if you have both, only code.py will run

stoic wraith
#

Ok

tidal kiln
#

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

stoic wraith
#

Ok, thank you for your help!!

tidal kiln
#

np. have fun. may the force be with you.

pastel panther
pastel panther
#

Wew!

>>>
timber mango
#

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?

solar whale
#

@timber mango debug is disabled by defaults, but can be enabled by adding โ€œDEBUG=1โ€ to the make command.

timber mango
#

nice, thanks a bunch @solar whale

keen anvil
#

@pastel panther Hey that looks interesting! What is it? Do tell.

solar whale
#

@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)
pastel panther
#

@keen anvil It's a secret! (It's not a secret)

#

๐Ÿ•ต

#

It's an express-like SAMD51/M4 board in a ESP-32 footprint

upbeat plover
#

@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

solar whale
#

@upbeat plover both the LoRa (RFM9x) and the RFM69 work fine for exchainging messages between a pair. The LoRa has better range.

upbeat plover
#

is there a breakout board for the LoRa?

solar whale
#

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...

upbeat plover
#

nice, they seem fun, and the range looks like it will work between me and a neighbor

solar whale
#

I am just using a simple wire, but have not done ,much range testing. Hope to do some soon.

upbeat plover
#

I'd like to know what kind of range you get out of it

solar whale
#

me too ๐Ÿ˜‰

upbeat plover
#

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?

solar whale
#

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....

raven canopy
#

@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. ๐Ÿ˜„ adabot

tidal kiln
#

subsequent, but if you can check all might as well. it could even happen with the initial release.

raven canopy
#

well, the way i'm thinking should catch both. just wanted to make sure it shouldn't be limited.

tidal kiln
#

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

raven canopy
#

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...

tidal kiln
#

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.

raven canopy
#

k. thanks for confirmation on expectations. eegads! i only have 4000 api requests left for the hour.. ๐Ÿ˜ฑ ๐Ÿ˜†

tidal kiln
#

make a real time strip chart of something

lone sandalBOT
pastel panther
#

@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?

raven canopy
#

@pastel panther adabot checks * 114 repos = approx 600 requests.

pastel panther
#

hmm.

idle owl
#

@raven canopy How's it going

raven canopy
#

๐Ÿ‘‹

idle owl
#

I have a Feather M4 that dir(board) doesn't have D6 in it. ๐Ÿค”

tidal kiln
#

what board? what firmware?

idle owl
#

Feather M4. Running the wrong firmware...........

#

nm.

#

explains a lot.

solar whale
idle owl
#

I know, I checked pins.c

#

the problem is running incorrect firmware.

#

so nm ๐Ÿคฆ

solar whale
#

nmwhat -- never happened ๐Ÿ˜‰

manic glacierBOT
raven canopy
#

what? did something happen? i didn't see nuthin... ๐Ÿ˜Ž

manic glacierBOT
manic glacierBOT
full ginkgo
#

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

tulip sleet
#

@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

full ginkgo
#

I'm having some memory issues too depending on what code I'm running

tulip sleet
#

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

full ginkgo
#

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

tulip sleet
#

You can lower the RGB values to control the brightness, though you may have color fiedlity issues more easily that way

full ginkgo
#

for the time being, I'm just looking to get some orange and maybe purple for halloween

tulip sleet
#
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)
full ginkgo
#

the lights are placed inside the front window frames at my house, it's going to be an evolving project to accommodate holiday decorations ๐Ÿ˜ƒ

tulip sleet
#

above is an example of doing rainbow cycle skipping some steps, notice the 8 in the range() call.

full ginkgo
#

gotcha

tulip sleet
#

also make sure auto_write=false and you only call .show() when everything's been updated

full ginkgo
#

yup, I have that in there

tulip sleet
#

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

full ginkgo
#

thanks!

tulip sleet
#

yw!

full ginkgo
#

the brightness has already made a difference... I'm going to start playing with the step value...

tulip sleet
#

also notice the // in the computation: integer division instead of float -- helps a little

full ginkgo
#

didn't know about that one, thanks

split ocean
#

@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

tidal kiln
#

@split ocean np. easy peasy. thanks for updating!

full ginkgo
exotic pumice
#

Am I correct in thinking the wait_until() function waits for the start of a new millisecond?

manic glacierBOT
manic glacierBOT
unreal hearth
#

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

solar whale
#

@exotic pumice what wait_until function are you referring to?

exotic pumice
#

it's used in the neopixel port for samd, I think the write has to be at the start of a new millisecond?

solar whale
#

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.

exotic pumice
#

oh, it's just 0, 1000

solar whale
#

it looks like it is being used to wait 100 microsec.

exotic pumice
#

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?

exotic pumice
#

neither delay is helping my problem

#

I really need a scope as you guys have recommended

stuck elbow
#

Or a logic analyzer

manic glacierBOT
exotic pumice
#

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

exotic pumice
#

I could use my pi, I just have to attach wires to my cpx

manic glacierBOT
uneven yarrow
#

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?

tidal kiln
#

yep. use time.monotonic(). that's generally the equivalent. how tight are your timing requirements?

manic glacierBOT
exotic pumice
#

@slender iron it looks like the sercom pin corresponding to the neopixel is rx only?

river quest
uneven yarrow
#

@tidal kiln not very, just new to python and didn't know if it was the right tool for the job or not

#

thanks!

sinful spruce
#

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

sinful spruce
#

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)

slender iron
#

@sinful spruce that happens when your computer is writing to the CIRCUITPY drive. Are you editing the file? What OSes?

marble hornet
#

@tulip sleet does the built-in busio.i2c have trylock?

tulip sleet
#

@marble hornet yes, try_lock()

marble hornet
#

i'm getting this error:

marble hornet
#
  File "/lib/adafruit_bus_device/i2c_device.py", line 62, in __init__
AttributeError: 'I2CDevice' object has no attribute 'try_lock'```
tidal kiln
#

add ()

marble hornet
#

but when i tried inputting a raw busio.i2c instance it gave a different error?

tulip sleet
#

That's I2CDevice, not buiso.I2C. I2CDevice takes care of the try_lock for you, using with ... :

tidal kiln
#

ah. good catch.

tulip sleet
#

I2CDevice is a wrapper

marble hornet
#

okay, so the busio is the 'bus object?' and bus device is chip specific ??

#

like an object representing that chip?

tulip sleet
#

no, you use busdevice to help you manage using multiple devices on one I2C bus easily.

tidal kiln
#

I2CDevice takes care of locking/unlocking the bus for you when you use the context mananger

tulip sleet
#

You pass a busio.I2C instance to I2CDevice when it's created

marble hornet
#

okay

tulip sleet
marble hornet
#

reading sc

tulip sleet
#

That link explains the motivation

tidal kiln
#

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

marble hornet
#

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?

tidal kiln
#

looks like you're just trying to use the mpr121 library?

#

if touch_brd0.py isn't too large, post it here

tulip sleet
#

I think you have an old copy of adafruit_busdevice. write_then_readinto() was added a couple of months ago

marble hornet
#

working on it... thank you

tulip sleet
#

that's the right library, but the copy you have on your board appears to be out of date. You could do adafruit_bus_device.__version__ to see the version number

#

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

marble hornet
#
>>> abd.__version__
'0.0.0-auto.0'
>>> ``` ๐Ÿ˜•
tulip sleet
#

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?

marble hornet
#

@tulip sleet and @tidal kiln It's working!! thank you!

#

๐Ÿ˜„

manic glacierBOT
manic glacierBOT
manic glacierBOT
slender iron
#

<@&356864093652516868> Here are meeting notes for tomorrow's meeting: https://docs.google.com/document/d/1bh0Pc59vV6MjAQh8HW8BL0-z_xoGAhe73tW0ledflIs/edit?usp=sharing

bronze geyser
#

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()

manic glacierBOT
autumn geyser
#

Is it ok to ask troubleshooting questions here?

upbeat plover
#

i think so

solar whale
#

@autumn geyser Yes -- responses may have to wait for someone who can help

manic glacierBOT
tidal kiln
#

@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.

autumn geyser
#

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 am ranger turner on that chat)

solar whale
#

@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?

autumn geyser
#

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

solar whale
#

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

autumn geyser
#

T.T Thank you.

solar whale
#

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)

autumn geyser
#

Will clearing variables as I can free up RAM

#

?

solar whale
#

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()

autumn geyser
#

^super helpful. I'll read the wiki / docs on these. & stop bothering you. THANK YOU!

solar whale
#

no bother -- good luck!

upbeat plover
#

yes clearing variables and dinit stuff after use will help save RAM

tidal kiln
#

@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
>>>
autumn geyser
#

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.

slender iron
#

you can turn off the status led without dotstar to save memory

autumn geyser
#

YUS! TY

slender iron
#

๐Ÿ˜ƒ

upbeat plover
#

@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

autumn geyser
#

^ Suuuper good. DIdn't realize I could do it function by function

#

(Not with board currently Ill report back when I verify it works.)

idle owl
#

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.