#circuitpython-dev

1 messages · Page 168 of 1

ruby atlas
#

I feel like I live in my childhood dreams every day. So much fun and cool technology and so much more every day!

idle owl
#

It's true!

slender iron
ruby atlas
#

Love it!!

#

OK time to go catch another plane!

idle owl
#

Have a boring flight!

slender iron
idle owl
#

Only if exciting means something bad. Really have a good flight, @ruby atlas 😃

manic glacierBOT
ruby atlas
#

Boring flights are the way to go.

marble hornet
#

@stuck elbow hi, thanks for all your help last time! may i pick your or anyone elses' st7735r knowledge ?

#

i'm having trouble understand what is being sent over spi. and how to configure what to send

#

i want to send a different _MADCTL value to rotate the display. currently b'\xc8' is being sent and it makes the display look normal, but sending bytes(0b011000 & 0x07) also shows normal. and(_MADCTL, b'\128')shows it rotated 180.
ive looked up the datasheet (http://www.displayfuture.com/Display/datasheet/controller/ST7735.pdf) and ive tried sending the bin values specified on page 61. no avail. was that descriptive enough ?

timber mango
#

Just figure out what bits need to be set.

marble hornet
#

i did, page 62 tells you what bits to send

#

i need 110

#

if i try writing 0b110

solar whale
#

@marble hornet you want MY =1 Mx =1 Mv = 0?

marble hornet
#

wait no

#

mv = 1, mx = 1 ,my =0

#

which is 6, right?

solar whale
#

they go in th upper 3 bits of the MADCTL byte binary 111xxxxx or 0xE0 masked into the other bits of _MADCTL

#

sorry 0xC0

marble hornet
#

ah

solar whale
#

binary 110xxxxx or 0xc0

marble hornet
#

so,, (my_bin << 5 ) + ?

solar whale
#

Note: Data is always written to the Frame Memory in the same order, regardless of the Memory Write Direction set by MADCTL bits B7 (MY), B6 (MX), B5 (MV). The write order for each pixel unit is

#

that should work or better (my_bin<<5) | (lower 5 bits)

marble hornet
#

| is a thing ?

timber mango
#

yes indeed. ;)

solar whale
#

the B7 B5 B5 refet to the bit postion, I think

#

| means bitwise OR

timber mango
#
def disp_logo_geom(page):
    global cmd
    column =  0 # must be zero or a multiple of 16
    icol   = column + 16
    cursor_right = (icol // 16) - 1
    cmd = (0x10 | cursor_right) ; display.write_cmd(cmd) # upper x positional byte
    cmd = (0x00 | 0)    ; display.write_cmd(cmd) # lower x positional byte - fine tuning
    cmd = (0xb0 | page)    ; display.write_cmd(cmd) # only  y positional byte - page 0 is middle row
    cmd = 0xe0          ; display.write_cmd(cmd)
    # write data here
#

That's from some private ST7565 code I wrote in February.

solar whale
#

nice @timber mango

raven canopy
#

@slender iron belated response RE: .subscr. you were spot on. i went and read the code in py/objtype, and i was trying to use it incorrectly (without array/indexing). switched to frequencyin.value... thanks for the quick eye/feedback!

marble hornet
#

@solar whale @timber mango um... TypeError: unsupported types for : 'bytes', 'int'

#

for this code :

#

b'\xc8' | (bytes(0b110)<<5)

solar whale
#

bytes(0b110<<5) but why are you oring it with 0xc8

marble hornet
#

b/c i need the last 5 bytes

#

oh

#

i need to replace

cunning trail
#

@slender iron Thanks for showing the CP team. I like this pic of @tulip sleet

solar whale
#

if you have lower 5 bits = lowbits then use (0xc0 | lowbits)

#

great picture!

marble hornet
#

i don't, unless the lower 5 bits can be extracted from \xc8, but i haven't been able to translate \xc8 to bits

solar whale
#

0xc8 os 11001000 --

timber mango
#

  0xc8     1100    1000

marble hornet
#

|facepalm|

solar whale
#

My =1 Mx =1 Mv = 0 - low bits are 01000

marble hornet
#

c = 1100 8 = 1000

timber mango
#

four bits per hexadecimal digit

#

(three bits per Octal digit)

solar whale
#

@timber mango don't go there 😉

timber mango
#

hahah. When I learned it we had to know it to do our job.

marble hornet
#

( (bytes(0b110<<5) | bytes(0b01000) ) ??

solar whale
#

I guess that'll work, but why not use 0xc8

#

unbalanced parentheses though

marble hornet
#

, have a preference for bin, but thats me

#

(b'\b0b110' << 5) | b'\b01000')) gives (b'\b0b110' << 5) | b'\b01000'))

solar whale
#

byes byt why or -- use 0b11001000

marble hornet
#

okay, i just tried 0b11001000

#

i got TypeError: object with buffer protocol required

solar whale
#

x = 0b11001000

manic glacierBOT
solar whale
#

what is the line of code you are writing?

raven canopy
#

One of the greatest things Microsoft ever did for me: added the "Programmer" calculator. i avoided bitwise/binary experience for so long, that i require a visual for it. 😄

marble hornet
#
                (_CASET, cols),
                (_RASET, rows),
                (_NORON, None),
                (_DISPON, None),
          (_MADCTL, ( (b'\b0b110' << 5) | b'\b01000')),
        ):
            self.write(command, data)```


ah, i think i'm a little out of my depth. (he says spreading sarcasm like butter), so thank you so much for all the help.
#

for**

solar whale
#

try (_MADCTL, ( 0b11001000)),

#

or (_MADCTL, 0b11001000),

marble hornet
#

@solar whale main.py output: Traceback (most recent call last): File "main.py", line 11, in <module> File "/lib/adafruit_rgb_display/st7735r.py", line 128, in __init__ File "rgb_text_.py", line 198, in __init__ File "rgb_text_.py", line 74, in __init__ File "/lib/adafruit_rgb_display/st7735r.py", line 146, in init File "rgb_text_.py", line 217, in write File "rgb_text_.py", line 217, in write TypeError: object with buffer protocol required

timber mango
#
def char_out():
    global cmd, mbytes
    for p in range(0,6):
        cmd = mbytes[p]
        display.write_data_out(cmd)

def write_short_phrase_to_lcd():
    global mbytes
    mbytes = bytearray(b'\x3e\x48\x88\x48\x3e\x00')  # A  idea to use bytearray from deshipu's code
    char_out()
    mbytes = bytearray(b'\xfe\x82\x82\x82\x7c\x00')  # D 
    char_out()
    .
    .

again, from unpublished code for ST7565.

marble hornet
#

okay, @timber mango what is the name for the notation inside fo the bytearray()?

timber mango
#

I have no idea I was in a hurry so it was some monkey see monkey do coding all that week. ;)

marble hornet
#

😂 😂 i can relate

timber mango
#

Those are hexadecimal bytes of 8 bits per segment.

#

$fe $82 $82 $82 $7c $00 is how it's written in Forth.

marble hornet
#

forth?

#

base 4 ?

solar whale
#

@marble hornet what was the code that caused that error?

timber mango
marble hornet
#

self.write(_MADCTL, (0b11001000))

#

@solar whale

solar whale
#

looks like data has to be a byte array try ```data=bytearray(1)
data[0]=0b11001000
self.write(_MADCTL,data)

timber mango
#

The original code I wrote called them "muta_bytes" because I think the environment used the word 'mutable' in the error it generated. So I said they were 'mutable bytes'.
Shortened to mbytes in later iterations. ;)

solar whale
#

in python3 ```>>> a=bytearray(1)

a[0]=0b11001000
a
bytearray(b'\xc8')

marble hornet
#

it worked!!

#

thank you

solar whale
#

yay!

timber mango
#

jerry when you typed the 'a' on a line by itself, it generated that? bytearray(b'\xc8')

solar whale
#

yup

timber mango
#

awesome!

#

That's obviously why deshipu chose that notation, then, I'd suppose.

#

(I was working off his driver for a similar problem to mine)

marble hornet
#

hmm,

solar whale
#

I'm still not very well versed in python syntax -- keep googling it!

timber mango
#

I can do the binary to hex conversion in my head so I am comfortable with the hex notation.

marble hornet
#

thank you so much!! jerry is a byte-array just a couple bytes at a time ?

#

or nis

timber mango
#

Yeah. The byte array is used ...

solar whale
#

it can be any number of bytes

marble hornet
#

oh it turns int to bytes ?

solar whale
#

you create the array using bytearray(x) for an x byte array - then populate it

timber mango
#

mbytes = bytearray(b'\xfe\x90\x90\x90\x80\x00') # F

This sets all the pixels needed to form the glyph for the letter 'F' on a monochrome LCD.

0xfe is the first 8 bits, which are set from top to bottom (8 rows of pixels, one pixel wide).

solar whale
#

not really - ints are several bytes long - a byte array is a group of 8bit values in order.

timber mango
#

My bytearrays are 6 bytes each -- five bytes for the glyph and one byte of spacing.

#

(that's why the last number is always \x00)

tulip sleet
#

@cunning trail Thank you! 😃

solar whale
#

@marble hornet I think the main reason bytearrays are used is to remove any uncertainty about the order in which multiple byte values are transferred.

marble hornet
#

got it

#

@solar whale thanks jerry, i owe you one

#

you too nis

timber mango
#

good luck with it. I'm back quiet (watching Rumpole of the Bailey)

solar whale
#

@marble hornet glad to help - and I learned few things as well

timber mango
#

this is always fun. good times!

solar whale
#

bed time here -- good luck with it!

harsh plume
#

hey does the cpx library have any commands for the analog out?

#

trying to write to it using board is returning that the pin's already in use, prob from loading in cpx before it

cunning crypt
#

@harsh plume You need PulseIO

#

I can't really give better guidance right now. On an airport shuttle atm

stuck elbow
#

I thought that PulseIO is for regular digital pins

cunning crypt
#

It's been a while. I could be wrong

solar whale
#

Note to self - and sharing with other nrf52 users... when building CP with a non default SOFTDEVICE - (like SOTFDEV_VERSION=5.0.0) don't mis-spell SOFTDEV_VERSION! the makefile does not complain, but it happily goes ahead an builds wih the Default 2.0.1 SoftDevice and when you load that to the feather52 with a 5.0.0 SD bootloader, it does not go well 😉 It took me quite awhile to figure out what I had done wrong and I was about to create an issue about the nrf52 build was failing to boot properly. All better now... minus a few more hairs.

manic glacierBOT
#

I agree it's better to disable the functionality than to return a value that's 2 minutes off.

Is there a plan to enable long int?

Adafruit CircuitPython patchbase-dirty on 2018-05-10; Adafruit Feather M0 Express with samd21g18
>>> now = 1526400902
OverflowError: long int not supported in this build
>>>
#

This extends from PR https://github.com/adafruit/circuitpython/pull/841 (which should merge first) to add SPI support in a similar fashion as default I2C support.

import board
my_spi = board.SPI()

Boards were chosen for support for having all of the following defined in pins.c for the target board:

  • MP_QSTR_SCK
  • MP_QSTR_MISO
  • MP_QSTR_MOSI

Boards that have support have the following in mpconfigboard.h:

  • #define DEFAULT_SPI_BUS_SCK (&pin_PB11)
  • #define DEFA...
harsh plume
#

@cunning crypt thanks for the tip, at this point honestly i'm just blinking an LED so digital will do :p

manic glacierBOT
manic glacierBOT
prime flower
manic glacierBOT
ruby atlas
#

looking like a lot of the PRs from PyCon are getting merged!

knotty cypress
#

Having an issue creating working firmware for Gemma. Basically the previously loaded firmware determines if the next one works. Help wanted

#

Adafruit Gold Master > Mine <- mine works

#

Mine -> Mine2 <- mine2 does not work

raven canopy
#

@knotty cypress does Adafruit Master -> Mine2 work?

knotty cypress
#

mine 2 will, but i have to go back to adafruit master before i can load my own again

idle owl
#

@ruby atlas I thought of code with some other simple animations in it.

raven canopy
#

hmmm. what are you working on? seems a "breaking" change is getting hung up. could also be OS related; which OS are you on?

knotty cypress
#

im on macOS, and im working on default serial for the board module

raven canopy
#

ahhh. are you able to debug? when it doesn't load, does the port get established?

idle owl
#
knotty cypress
#

i didn't learn how to debug yet

raven canopy
idle owl
#

The slicing is harder to do because you have to do some weird code to make it work on a number of LEDs that aren't divisible by the size of the slice. But if it's behind the scenes, maybe we could make slicing really easy by making it more complicated code in the lib.

ruby atlas
#

@idle owl awesome, i'll have to find myself a neopixel or two asap. looking forward to mucking around more later.

#

@idle owl i agree that we should hide the complexity in the libs to make it really easy to use.

knotty cypress
#

TY

idle owl
#

Agreed entirely, the question was more about whether to add slicing or not because it gets weird, but then I realised we can hide the weird and probably add it nicely.

raven canopy
#

@knotty cypress as an intermediate step, i'm sure macOS has a comparable dmesg to help diagnose the port creation. having done some work with the serial/USB CDC, i can vouch that it is not fun... 😄

slender iron
#

@idle owl when you are ready for code of conduct feedback please make a PR so we can comment inline

idle owl
#

@slender iron Ok I'll branch it and PR it. I linked it to two people and suggested filing an issue because I was still actively working on it.

#

Wait I already branched it. I'll PR it.

slender iron
#

😃

idle owl
#

I was trying to avoid merge conflicts since I was literally working on it that moment.

manic glacierBOT
raven canopy
#

I was in-between build attempts, and needed something to do. 😆

idle owl
#

@raven canopy I took that entire paragraph directly from a CoC we're adapting. Rewording is entirely ok by me. I like your suggestion a lot.

raven canopy
#

like I said, i'm aware that its still WIP. 😄

idle owl
#

WIP that values your input. That's the entire reason it's on GitHub. We want feedback

manic glacierBOT
#

Longints are currently enabled on 3.0 Express builds. I checked again recently about enabling on non-Express builds: https://github.com/adafruit/circuitpython/issues/572#issuecomment-387505388, quoted below. It looks pretty iffy that it would ever fit on 192KB builds (non-Express).

Longints are not going to fit in the non-Express builds for 3.0 without removing other stuff. I recently tried MPZ and LONGLONG. Currently a Gemma M0 build has about 1800 bytes free. If I enable MPZ, it overflo...

#

This implements default UART in atmel-samd boards, similar to how I2C and SPI work.

>>> import board
>>> board.UART()
<UART>

Boards were chosen for support for having all of the following defined in pins.c for the target board:

  • MP_QSTR_TX
  • MP_QSTR_RX

Boards that have support have the following in mpconfigboard.h:

  • #define DEFAULT_UART_BUS_RX
  • #define DEFAULT_UART_BUS_TX

Changing these values will change the default UART pins.

Supported Boards:

  • (A...
idle owl
#

@raven canopy Rust loves their semicolons.

ruby atlas
#

Just randomly pondering LED animations.... I wonder... is (approximately) constant luminosity more important than colour accuracy for the default use case?

idle owl
#

Hmm.

#

Explain further please

ruby atlas
#

Well, say I want a colorloop with say 4 color points... say - blue, yellow, pink, orange - I think the colours will vary quite a bit in luminosity if we cycle through pure colours. Thay may be preferable for some uses. However, I know I'd be happier for some use cases with a relatively constant luminosity and would prefer to shift through Hues at a relatively fixed (or completely fixed) saturation/luminosity and use the colours as hints for what to cycle.

#

I suspect I'll just have to play with lots of combinations 😃

idle owl
#

Ahh ok

#

I see what you're saying

#

I've done both, where I keep the overall RGB number equal when added together, or where I simply make the color I want and don't worry about relative luminosity.

#

Yah I would say experiment with it. And then once it's out in the world, people will use it and provide feedback and we can deal with it then

ruby atlas
#

yep!

idle owl
#

@slender iron Would you say "Adafruit Discord and CircuitPython Community Code of Conduct" is a better title? I thought it was wordy until I gave it more thought and realised it's a much better indication of the scope we're looking for. Now I'm into it.

slender iron
#

I'd drop the Adafruit Discord part. In #code-of-conduct we can make it clear that the CircuitPython Community Code of Conduct covers the entire server.

idle owl
#

Ok

#

I was worried about limiting it because Discord isn't just CP

#

Sounds good

slender iron
#

eh, just because its called that doesn't mean we can't use it other places

idle owl
#

Yep!

#

Thanks!

manic glacierBOT
manic glacierBOT
#

I pulled the latest, but no long int.

pi@agl:~/circuitpython/workdirs/test/circuitpython$ git log --oneline -1
8581ee3f0 (HEAD -> test, tag: patchbase, origin/master, origin/HEAD, master) Merge pull request #844 from matt-land/feature-default-spi-circuit-playground
Adafruit CircuitPython patchbase on 2018-05-17; Adafruit Feather M0 Express with samd21g18
>>> now = 1526400902
OverflowError: long int not supported in this build
>>>
idle owl
#

I'm starting the guide on the CPX Express class and having a debate with myself about how to label the pages.

manic glacierBOT
#

Maybe this?

 STATIC const mp_rom_map_elem_t time_module_globals_table[] = {
     { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_time) },
 
     { MP_ROM_QSTR(MP_QSTR_monotonic), MP_ROM_PTR(&time_monotonic_obj) },
     { MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&time_sleep_obj) },
     #if MICROPY_PY_COLLECTIONS
     { MP_ROM_QSTR(MP_QSTR_struct_time), MP_ROM_PTR(&struct_time_type_obj) },
+    #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
     { MP_ROM_QSTR(MP_Q...
manic glacierBOT
solar whale
slender iron
#

looking now

languid sage
#

@idle owl <SMILE> conventional wisdom says 1,2,3... </SMILE>

tidal kiln
#

@idle owl how about break it by hardware aspect: buttons, slide switch, light sensor, etc

idle owl
#

@languid sage Nice 😄 My debate was whether to call them simply by the sensor they use or include "CPX" before it so the titles of each page stands alone.

#

@tidal kiln That was what I was leaning towards.

#

@slender iron If you're good with it, I can put a final update on the PyCon issue on GitHub and close it out. I wasn't sure if you wanted to get into a bunch of details of the results there or simply update it and close it out.

slender iron
#

@idle owl that sounds good. I didn't have plans for it

idle owl
#

@tidal kiln @languid sage Either way the guide will be broken down by sensor on the Circuit Playground Express, it was simply a matter of whether to include more on each page title.

#

@slender iron Ok great

languid sage
#

@idle owl I know whatever you choose, It'll be fine. I just thought, as it's late in the week, a bit of levity wouldn't hurt.

idle owl
#

@languid sage I've been busy or travelling for nearly two months straight, a little levity is always welcome 😄

tidal kiln
idle owl
#

It's going to be big. So it'll be standalone, but ideally it'll be mirrored into its own section on that guide as well.

#

So there will be a title and a sublist if it's mirrored.

#

But even including "CPX Temperature" doesn't really clarify it from anything else. So I feel like as long as I nail the title on the overview page, each page can be "Temperature" or "Buttons" under that heading and be clear.

manic glacierBOT
#

PyCon was an absolute blast and a complete success. Our Open Spaces were full and people were incredibly engaged. The sprints resulted in tons of updates to libraries, core code and documentation, and continued after we had already departed the conference. We gave the NeoPixel rings and other hardware we had to individuals who were absolutely excited to have them. One of the best moments was when people came to us with new ideas and projects outside the quickstart we created and were so incre...

tidal kiln
idle owl
#

Oh to break up the guide itself. I see. Yeah maybe. I know if it's mirrored in, it'll end up under one heading anyway. But maybe the guide should be broken up a little. I'll keep that in mind

#

I think I'll start with no sublists on the guide itself and see how it plays out

tidal kiln
#

i'd lean toward not having CPX in front of them all also

idle owl
#

keen, that's what I was thinking too

#

I don't think it clarifies anything.

tidal kiln
#

mainly because it's an acronym, a whole bunch of all caps CPX's might look a little heavy

idle owl
#

Also valid

#

I created a bunch of the pages and they look good with only the name of the sensor/LED etc.

tidal kiln
#

and also, yah, unless you know what CPX stands for...what you said

languid sage
#

If its a guide for CPX, then frequent citing of the CPX acronym appears to be a repetious redundancy, and so and so forth :^) (sorry for the bad spelling, it's been a loooong day)

idle owl
#

It is a guide entirely for CPX, so also a good point.

languid sage
#

@idle owl I once new a man who was an expert in his field... working for Title Insurance companies on complex land deeds, disputes, etc. He always said the correct way to write a document was "concise brevity". A lot of folks get the brevity part OK, but not the two of them together. My experience says that writing deeds is a lot like documenting software. Say it with enough words to absolutely cover the subject. No more, no less, and cover the subject well.

idle owl
#

I do my best 😃

modern wing
#

I've tend to find that people who are skilled are first and foremost problem solvers, communicators, and team players.

Then, after that -- they are knowledgable in their specific field....whether it is programming, being a manager, scientist, engineer, etc.

#

Or as they say in my specific field -- "we can teach anyone to do [what we do]. We can't teach someone to be easy to work with, to mesh well with our team. That team fit is more important than their technical skills they bring initially."

Anywho, back to your regularly scheduled Pythonic content 😉

ruby atlas
#

in response to showing my kids the gemma_m0: "change more numbers! change more numbers!" and "ooh that's pretty" "less red" etc.

idle owl
#

That's great! 😃

chilly juniper
#

so i have a circuit express and was working with the IR sensor.. When i first started playing with it I was able to get pretty consistent results from a remote such that I could identify the keys. It was getting like 67 pulses that encoded to something repeatable. Now all I am getting is noise.. even when pointing a remote directly at it and pressing a key, I'm generally only getting 4-6 pulses maybe 10, but not the 67 I was getting before and the pulses are all random and not predictable to get a keypres read from it. I've reset power cycled the board several times, but no luck, it still behaves the same way. Any idea on what is going on? Is the sensor likley bad or is something else going on ?

opaque patrol
#

did anything change? The remote? Did you update libraries? Anything?

chilly juniper
#

nope.. i was testing something in the client code and it worked just fine and then just stopped working.

opaque patrol
#

Perhaps something you set in the client code is causing a problem. Can you paste your code here? You can paste the code by adding three ticks (the key to the left of the 1) before and after the code like this

chilly juniper
#

here's the important part..

    pulses = decoder.read_pulses(pulsein, blocking=False)
    if pulses:
        print("Heard", len(pulses), "Pulses:", pulses)
#        if len(pulses) >= 4:
#            forward = not forward
        try:
            code = tuple(decoder.decode_bits(pulses, debug=False))
            print("Decoded:", code, button.get(code))
            #value = button.get(code)
            #print("Decoded:", code, value)
            #value = button.get(code)
            #if value in ("1", "2", "3"):
            #    color_index = int(value)

        except adafruit_irremote.IRNECRepeatException:  # unusual short code!
            print("NEC repeat!")
            pass
        except adafruit_irremote.IRDecodeException as e:     # failed to decode
            print("Failed to decode: ", e.args)
            pass
#

so i used to get like 64 pulses from .read_pulses, now I'm just getting noise.. it's always dropping to the print("Failed to decode: ", e.args) block because it's so few pulses

#

this exact code was working just fine and then just stopped working

#

even without pointing a remote at it, i have always gotten random noise (2-4 pulses) that couldn't be decoded even when not pointing a remote at it.

opaque patrol
#

What is the exact error message? Is it "10 pulses minimum" or "Not enough data"?

chilly juniper
#

Failed to decode:

#

hold on, let me run and I'll give you some examples

#
Failed to decode:  ('10 pulses minimum',)
Heard 1 Pulses: [193]
Failed to decode:  ('10 pulses minimum',)
Heard 1 Pulses: [166]
Failed to decode:  ('10 pulses minimum',)
Heard 3 Pulses: [167, 1748, 345]
Failed to decode:  ('10 pulses minimum',)
Heard 1 Pulses: [170]
Failed to decode:  ('10 pulses minimum',)
Heard 1 Pulses: [172]
Failed to decode:  ('10 pulses minimum',)
Heard 1 Pulses: [170]
Failed to decode:  ('10 pulses minimum',)
Heard 4 Pulses: [1915, 585, 909, 589]
Failed to decode:  ('10 pulses minimum',)
Heard 1 Pulses: [169]
Failed to decode:  ('10 pulses minimum',)```
prime flower
chilly juniper
#

I'm just getting noise.. pressing the remote doesn't seem to have any affect any more.

#

i'm getting that noise if i am pointing the remote at it or not

opaque patrol
#

What version of CP are you using?

chilly juniper
#

i'm guessing the latest.. i got this board from scott at pycon during the sprint.. how do i confirm the version?

prime flower
#

entering the repl by pressing ctrl+c

opaque patrol
#

You can look at the boot.txt file or the REPL

#

oops, that is the boot_out.txt

chilly juniper
#

Adafruit CircuitPython 2.3.1 on 2018-05-07; Adafruit CircuitPlayground Express with samd21g18

#

looks pretty recent to me.. is it normal for the ir sensor to get noise when nothing is pointing at it?

#

could the board/sensor be going bad?

opaque patrol
#

That is the latest version. I can't say if there is a problem with the board or not

chilly juniper
#

is seeing noise normal for the ir sensor?

opaque patrol
#

No, is it possible there is another remote or something else around you that it is picking up?

#

Did you by chance change this line so that idle_state=False? pulsein = pulseio.PulseIn(board.REMOTEIN, maxlen=120, idle_state=True)

chilly juniper
#

nope, it's pulsein = pulseio.PulseIn(board.REMOTEIN, maxlen=120, idle_state=True)

#

it's constantly picking up noise.. as in, from when I plug it in, it's reporting noise ever few seconds.

#

i covered the board and it's still picking up noise

#

i have a shoe over the board, and it's still reporting 1-7 pulses randomly

opaque patrol
#

I tried that and I am getting noise if I cover the IR tx and rx together...

chilly juniper
#

ok, so noise is normal, but not sure why it isn't picking up signal

#

and it WAS working.. not perfectly, but pretty reliably. then it just stopped.

opaque patrol
#

And you said you tried to reset the board? Did you press the reset button or unplug it?

chilly juniper
#

i power cycled it.. is there something else to do a reset?

#

(removed the power and plugged it back in)

timber mango
#

I would simulate the act of printing the code to paper (by capturing it somehow). Then erase everything. Then retype the entire program in by hand.
But only after verifying the IR remote used is still functional.

chilly juniper
#

ahh.. that did it.. i just put the example in by it's self and it's responding as expected.

#

thanks, I'll figure out what I moved around to causse problems.

#

i think i may have moved the imports around

opaque patrol
#

I looked back at your code and noticed you had blocking set to False in the read_pulses call,

chilly juniper
#

that's a feature i just added during this sprint..

opaque patrol
#
               If False, will return None if no pulses.
               Defaults to True for backwards compatibility ```
chilly juniper
#

that was working just fine.

timber mango
#

If you made a printout, mark it with a pen in your own handwriting to say it's good the way it is printed. ;)

#

digitally take an md5sum up to line number n and append it to the document as line number n + 1

#
 $ cat -n ./myfile.py | sed 22q | md5sum >> to_append.txt

Something like that.

#

sed is just the stream editor, which in this case prints the first 22 lines of what was sent to it.
md5sum is a cryptographic one-way hash function. It's guaranteed to produce a unique number for every unique file (or stream) it is sent.

#

22 is just the length of the file (in counted lines) minus one or two lines of white space at the bottom of the document (it should span the entire entered code in a given file). 'cat -n' is convenient here to determine what to replace '22' with. ;)

ruby atlas
#

@prime flower if the led animation stuff comes together as I envision it, it'll be trivial to use potentiometers to control a colourloop.

chilly juniper
#

hmm.... there might be something wrong with the non-blocking code I added.. it doesn't seem to work so well in the example code now. it's so strange that it was working so well with no problems and now it's giving me trouble. I'll have to play more with this blocking code and see if something can be made better there

timber mango
#

infrared comm is fussy and low bandwidth. ;)

chilly juniper
#

now i'm getting errors like Failed to decode: ('Only mark & space handled',) and Failed to decode: ('Both even/odd pulses differ',)

#

hmm.. it was behaving so well for a while and now it's really misbehaving. it worked great at the sprint and no it's being problematic. so frustrating.

timber mango
#

I usually get my aha moment with at least 15 minutes separation from trying to solve it (and perhaps 25 feet physically from the room where I tried to solve it).
I don't know how I do it. An approach to it just comes to me.

opaque patrol
#

You could try checking the length of pulsein before call the read_pulses function. That is really all the blocking code is doing

chilly juniper
#

thanks for the ideas.. going to poke around with it some more later. my goal is to create something my 2 year old can point at with a remote that doesn't control our tv that will change based on what he presses.

manic glacierBOT
#

I made a hacky version of this today to change input() to not echo the input data. I think there is another day or two of work required to separate this functionality into getpass the "right way" (not that I'm signing up to do that) but I estimate that an initial version is only about 20 lines of code plus a few configuration lines added per port. Here are some notes; I admit I implemented the easiest version which just changes the behavior of input(), rather than really add a getpass modul...

manic glacierBOT
manic glacierBOT
#

I gently want to suggest that we revisit the idea of board.I2C(), board.UART(), board.SPI() as implemented recently in PR's #842, #844, and #845. I think it introduces a new, somewhat weak, shortcut API that doesn't work out well if you need to change your program to use different pins. I suggest instead that we add defaults to the pin args for busio.I2C(), busio.UART(), and busio.SPI().

I'll take board.I2C() as an example. It returns a singleton instance that is `busio.l2C(b...

manic glacierBOT
manic glacierBOT
#

executing this code has repeatedly resulted in a corrupted FS with teh current master CP 3.0
It often fails to allocate enough memory, but sometime runs. If it does all seem ok for awhile -then the FS seem to just disappear....
I have reproduced this on a feather_m0_express and on a feather_m0_supersized.

# Initialize and mount SD card of Featherboard adalogger
import board
import busio
import digitalio
import adafruit_pcf8523
import adafruit_sdcard
import storage
import ada...
#

interestingly - another program that writes to the SDCard runs with no ill effect

import time
import board
import busio
import adafruit_am2320
import adafruit_sdcard
import digitalio
import storage

# can also use board.SDA and board.SCL for neater looking code!
i2c = busio.I2C(board.SCL, board.SDA)
am2320 = adafruit_am2320.AM2320(i2c)


# Connect to the card and mount the filesystem.
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
cs = digitalio.DigitalInOut(board....
#

I can run this with no problem

jerryneedell@Ubuntu-Macmini:~/projects/feather_m0_express$ cat sdtest.py 
import adafruit_sdcard
import busio
import digitalio
import board
import storage

# Connect to the card and mount the filesystem.
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
cs = digitalio.DigitalInOut(board.D5)
sdcard = adafruit_sdcard.SDCard(spi, cs)
vfs = storage.VfsFat(sdcard)
storage.mount(vfs, "/sd")

# Use the filesystem as normal.
with open("/sd/test.t...
#

Of course I would much prefer the solution proposed here by @dhalbert. Not only will it use less memory when you are not using I2C, not only adding it will result in smaller code size, but also it has the advantage of using an existing Python mechanism, which everybody will have to learn about anyways, instead of being something entirely new created specially for the purpose, which has to be learned separately from the documentation.

manic glacierBOT
manic glacierBOT
#

one more test case -- running this seems to execute OK and I can do a soft reboot, BUT at the next hard reset/power cycle, the FS is corrupted - I cant even get to REPL

import adafruit_sdcard
import busio
import digitalio
import board
import storage

# Connect to the card and mount the filesystem.
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
cs = digitalio.DigitalInOut(board.D5)
sdcard = adafruit_sdcard.SDCard(spi, cs)
vfs = storage.VfsFat(sdcard)
storage.mount(vfs, "/s...
stuck elbow
#

@tulip sleet that clock redoing is probably the reason why I can't get gamepad to work

manic glacierBOT
#

hmmm -- cant revert it -- not sure what the conflicts are:

jerryneedell@Ubuntu-Macmini:~/projects/adafruit_github/circuitpython_master$ git checkout -b revert_785
Switched to a new branch 'revert_785'
jerryneedell@Ubuntu-Macmini:~/projects/adafruit_github/circuitpython_master$ git revert -m 1 d3a5d40
error: could not revert d3a5d40... Merge pull request #785 from notro/rtc_calibration
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git...
tulip sleet
#

@stuck elbow try reverting that. It may well be. The testing was not that thorough

#

@solar whale ok, just try going back to the commit before. Not sure what it’s intertwined with.

#

I will be out for an hour or so soon but then will be back and can take a thorough look.

manic glacierBOT
#

after trying th above revert - git diff shows:

jerryneedell@Ubuntu-Macmini:~/projects/adafruit_github/circuitpython_master$ git diff
diff --cc ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h
index bfa8c64,56e9c8b..0000000
--- a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h
+++ b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h
@@@ -46,15 -46,3 +46,18 @@@
                                 GD25Q16C
  
  #include "external_flash/external_flash.h"
+...
solar whale
#

@tulip sleet OK -- will keep trying.

manic glacierBOT
manic glacierBOT
#

PR #785 introduces 3 clock changes:

  1. It enables OSC32K: https://github.com/adafruit/circuitpython/pull/785/commits/f21c2494cb612b9f9316ab97096e55ab30a404b4

  2. It reworks the samd21 clock setup: https://github.com/adafruit/circuitpython/commit/4adba515695eb4eddf994c6847a5b92cffed6c07
    AFAICT this didn't change clock register values. This snippet reverts that change:

diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c
index 8e6f2b185..103f39c7...
#

I tried the changes above on the current master:

jerryneedell@Ubuntu-Macmini:~/projects/adafruit_github/circuitpython_master/ports/atmel-samd$ git diff
diff --git a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h
index bfa8c64..cfe1919 100644
--- a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h
+++ b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h
@@ -47,7 +47,6 @@
 
 #include "external...
candid ravine
#

@timber mango $ cat -n ./myfile.py | sed 22q | md5sum >> to_append.txtThat's a very cool idea, I had never considered applying a hash to my own code

manic glacierBOT
#

One case this is designed to ease is initializing multiple I2C devices on the same bus, which is common when using multiple feather wings. With a singleton in board the device drivers can default to the same bus:

d1 = device1.Device1()
d2 = device2.Device2()

With the proposed default args we'd need:

bus = busio.I2C()
d1 = device1.Device1(bus)
d2 = device2.Device2(bus)

The second option does make it easier to change the pins but how common will th...

long trail
#

Enter

manic glacierBOT
#

I was composing a message with the same idea the @deshipu just posted.

Suppose busio took care of the singleton? Right now:

i2c1 = busio.I2C(board.SCL, board.SDA)
i2c2 = busio.I2C(board.SCL, board.SDA)

will throw a "Pin xxx in use" right now.

We could have busio.I2C keep track of the pins and return the same object. If this is an issue of upward compatibility, we could have a new SharedI2C class. But I think it's probably fine to create and return a singleton as neces...

tulip sleet
#

@solar whale I will try a bisect to narrow this down to a particular commit. Which example is the most reliable in causing problems?

solar whale
#

I don't think you need to run anything -- just load the image and power cycle - that kills it for me.

tulip sleet
#

Feather M0 Express in particular, right? We may not have seen this elsewhere on boards without crystals.

#

@stuck elbow does uGame have a crystal?

stuck elbow
#

no

tulip sleet
#

hmmm

solar whale
#

it seem ok on metro_m4 express

tulip sleet
#

the new clock code is not on m4

solar whale
#

good!

#

my metro m0 express is hosed!

tulip sleet
#

ok, I will try a bisect. I have to leave about 1:15 for a school meeting but then will be back 3:30-4.

#

you mean you can't even get METROBOOT?

solar whale
#

I get to METROBOOT - Just no REPL or CIRCUITPyY --- after power cycle

manic glacierBOT
tulip sleet
#

ok, sounds like some critical clock setting is set by the bootloader but not by CPy, or something like that

solar whale
#

any particulat boards you want me to try?

manic glacierBOT
tulip sleet
#

@solar whale have you done a bisect before?

solar whale
#

BTW - when I reload the olde commit, the FS is till intact.

#

no - happy to learn

manic glacierBOT
tulip sleet
#

you could try a gemma or trinket or cpx to see if the crystal makes a difference

#

prob not based on Radomir's issues, but worth double-checkign

stuck elbow
#

I think my issues are special ;-)

#

as in, not actually related to this after all

#

for example, the not-working gamepad is also not working on m4

#

it almost looks like the tick() function is no longer being called

solar whale
#

good news is that it my not be corrupting the FS at all.. just confusing the USB

manic glacierBOT
#

That might be kind of confusing, since then sometimes a double call would work and sometimes not. I think it might not be too hard to keep track. The I2C objects already keep the pins, so we just have to look over the existing objects. Just have to keep a list of them. We could even use list primitives to manage the storage if we don't want to manage it in a C way on the heap.

solar whale
#

trinket_M0 dies after reboot with current master as well.

tulip sleet
solar whale
#

ok - I have some distractions for the next hour or so as well, but I'll take a look - thanks

#

note: the trinket and probably others -- the Dotstar goes white when I connect to the REPL but there is no prompt. After a few 10s of seconds , it drops the connection.

manic glacierBOT
solar whale
#

trying bisect

manic glacierBOT
ruby atlas
#

Hmm, i wonder if some of that is related to my work on supervisor.reload() and the work to reduce flash size by reducing what pins are defined on trinket_m0 and gemma_m0?

#

(But I wasn't seeing those symptoms and am not currently on the latest master)

#

i'll have to test master later.

manic glacierBOT
#

Oh, I've done all my testing with 'feather_m0_express' and circuitplayground_express and I've never encountered any problems.
I have run run tests for 2 days reading the time every second over raw repl to check for accuracy and never had a hiccup.
I rarely power cycle, but I have done it occasionally to be sure that the clock changes didn't have any ill effects from cold boot.

dusk hemlock
#

Anyone else experiencing issues with paste mode? I get a hard crash to safe mode whenever I try to paste. Metro M0 Express, CP 2.3.1

manic glacierBOT
solar whale
#

I'll be off for a bit -- give the channel a break...

raven canopy
#

@dusk hemlock have you tried writing the code line by line in the REPL to make sure it is paste mode vs the code causing a reboot? We did have to fix paste mode a little in 3.x, but I haven't seen any issues come up with 2.3

dusk hemlock
#

@raven canopy aye, pasting "import board" causes a crash

#

@raven canopy paste works while in safe mode, if I reset the board to go out of safe mode paste mode causes a crash again

raven canopy
#

Hmm. I can try to replicate & debug later, if no one else can get to it. If you like, you can go ahead post an issue on the repo.

manic glacierBOT
dusk hemlock
#

I'll try with a different serial terminal and/or downgrade circuitPython first

#

if I'm able to reproduce it I'll post an issue on github

#

cheers

teal bear
#

and... is there a more formal place to log issues ?

manic glacierBOT
raven canopy
#

@teal bear code.py and main.py are both accepted. And the GitHub repo is the "formal" place to file an issue for CircuitPython. For the guides, there is a Feedback/Corrections link on the left side.

teal bear
#

ah, got it. um.. how do I find the code that is listed on that page?

#

the 'eval()' makes me grumpy

raven canopy
#

The "save this code as main.py" is referencing the code in the code block below it. You can use either the "Download cpx_main.py", "View on GitHub", or "Copy Code". The last two would envolve pasting the code into a file.

manic glacierBOT
teal bear
#

Where is "View on GitHub" ?

manic glacierBOT
raven canopy
#

@teal bear I'm at work, and on my phone, otherwise I'd put up a screenshot. I will say that in order to see all the links for a code block, the browser window needs to be full width/maximized...

#

@solar whale I experienced the "failed to recognize" error that notro reported, a couple times last now. Power cycle always fixed it. I was debugging, so I thought it was a local/JLink issue.

solar whale
#

@tulip sleet when I tried the bisect, it was selecting commits even if they were not merged - in one case it was a commit that failed to compile. Is that expected? I may have confused it by marking the failed compile "bad"

#

@raven canopy its' odd. In my case it seems to be the power cycle that triggers it....

#

@raven canopy what board are you using?

manic glacierBOT
teal bear
#

@raven canopy thanks found it. did a View Source . not sure why FF isn't rendering it.

solar whale
#

I'll be off for awhile -- my head hurst and I need to go for a walk 😉 Maybe it'll all work when I get back ...

raven canopy
#

@solar whale itsy express. I'll be off too..

manic glacierBOT
#

This is the strangest thing.

Looks like I've found a reproduceable way of flipping back and forth between working and not working.
I have a build script that creates a git tag when checking out the code so I can easily dump out the commits I've done using git format-patch patchbase..HEAD.

So with that tag I get a firmware that can handle power cycling:

git tagging:

pi@agl:~/circuitpython/workdirs/test/circuitpython$ git tag patchbase
pi@agl:~/circuitpython/workdirs/te...
idle owl
#

@raven canopy @teal bear The code in some guides isn't in the Learn repo and would therefore not have a "View on GitHub" link. I don't know whether that was relevant to this case, but it's information worth having.

#

@teal bear CircuitPython looks for code.py and main.py in that order. Therefore, if you have both, it will run code.py not main.py. Naming the file main.py is a carryover from lower level programming languages, so we didn't want to eliminate it completely. To make it easier for beginners, we chose to additionally go with code.py because that's where your code lives. 😃

manic glacierBOT
raven canopy
#

That particular code block is on GH, but I know that there are some quirks with how the learn system renders..

idle owl
#

Ok, I simply wanted to make sure so you weren't hammering against something that didn't exist.

#

I've done that too many times 😃

manic glacierBOT
#

I have tried writing the failing firmware 3 times without any changes. I've checked that boot_out.txt gets updated.

Can it be some kind of offset problem? The flash size changes for me between working and not working.

What about this warning?

../../shared-bindings/usb_hid/__init__.h:33:23: warning: size of 'common_hal_usb_hid_devices' differ from the size of original declaration [-Wlto-type-mismatch]
 extern mp_obj_tuple_t common_hal_usb_hid_devices;
                      ...
#

@rhooper yes- that is waht I just found adding #838 to my working version causes it to fail. At lest I think that is what I did. I did:

git checkout 07c0a3227da24ef92e44a2457f94af71cc7f081c

this builds a working version
then I

jerryneedell@Ubuntu-Macmini:~/projects/adafruit_github/circuitpython_master/ports/atmel-samd$ git fetch origin pull/838/head:jerryn_test838
From https://github.com/adafruit/circuitpython
 * [new ref]         refs/pull/838/head -> jerryn_test838
jer...
solar whale
#

Are these flash device only good to 10,000 write cycle ? I may have worn it out today 😉

manic glacierBOT
solar whale
#

I think I've done enough harm for today -- good luck @ruby atlas -- i'll be off for a few hours and be happy to test more later.

ruby atlas
#

I'm going to do some more bisecting, since I can reliably reproduce.

idle owl
#

We love @solar whale's ability to break things!

ruby atlas
#

I'm tempted to rig up a gemma to control the trinket

#

so i can automate bisecting

#

but that'll probably take longer than just clicking the button occasionally.

tulip sleet
#

not sure how it's breaking. I built the latest for Metro M0 (so I could debug it with the jlink). If I power-cycle it it still comes back fine. How to reproducee?

solar whale
#

my metroM0 failed - let me try again

ruby atlas
#

@tulip sleet for me this works: build master, copy new firmware to it, reboot hard (reset button or powercycle).

tulip sleet
#

does there need to be a main.py or code.py? right now I have an empty filesystem

ruby atlas
#
import microcontroller, pulseio, board, supervisor
import adafruit_dotstar, time

pwm1 = pulseio.PWMOut(board.D13, duty_cycle=1, frequency=500, variable_frequency=True)
pixels = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.3)
n = 0

while True:
    pwm1.duty_cycle = 30000
    pixels[0] = (128, 128, 128)

tulip sleet
solar whale
#

ah - in my flow I do a soft reboot after uploading - before power cycling

ruby atlas
#

i stopped seeing blinking. now i want non-green-led 😃

#

my exact test:

  • Double-click reset.
make BOARD=trinket_m0
cp build-trinket_m0/firmware.uf2 /Volumes/TRINKETBOOT/CURRENT.UF2
solar whale
#

my test --

#
build metro_m0_express
copy to METROBOOT
verify REPL is working
power cycle
No response from REPL  -- wite light on Neopixel
after a bit, OS drops the terminal session 
ruby atlas
#

my main.py changes the dostar to white from green and sets the red led on, so I know if main.py was executed.

#

also the lack of /Volumes/CIRCUITPY helps

solar whale
#

then I repeat after ```
git checkout 07c0a3227da24ef92e44a2457f94af71cc7f081c
Note: checking out '07c0a3227da24ef92e44a2457f94af71cc7f081c'.

tulip sleet
#

the debug build does not fail; the non-debug build does, it appears 😦

#

anyway I can do some gdb'ing

solar whale
#

ah - those sneaky DEBUG build 😉

ruby atlas
#

@tulip sleet is there a serial port on the trinket or gemma? (I haven't tried yet)

tulip sleet
#

no, I'm wrong it still works both ways

ruby atlas
#

And/or are there gdb instructions I could follow?

tulip sleet
#

you need a j-link or laboriously set up openocd. Do you have a j-link"

solar whale
#

back later - have fun!

ruby atlas
#

i do not.

tulip sleet
#

bye - thanks for all the testing!

ruby atlas
#

@tulip sleet from segger

#

?

#

wow pricey!

idle owl
#

There is an Edu mini version for 25 ish.

raven canopy
tulip sleet
ruby atlas
#

ooh i was looking at the segger site

idle owl
#

I wasn't thinking about it, I should have had you get one.

tulip sleet
#

with the edu mini, a cable, and a metro you are golden

ruby atlas
#

<shrug> I didn't expect to start debugging pre-boot issues 😃

raven canopy
idle owl
#

Metro is out of stock at the moment 😃

ruby atlas
#

metro rox, not surprised.

#

oh the metro m0 express is avail

tulip sleet
#

for boards without the SWD connector, you'd use the SWD breakout board and solder some jumpers to the SWD pins on the bottom of the board. much easier to use metro

idle owl
#

Oh hey!

#

So it is

tulip sleet
#

so can get a 3571, + 1675 plus the metro

ruby atlas
#

@tulip sleet are you testing on an m0 or m4?

tulip sleet
#

m0

ruby atlas
#

how much more flash does the metro m0 have than the trinket/gemma?

tulip sleet
#

it has the extra 2MB external SPI flash chip. The CPU chip is basically the same (fewer pins).

#

same internal flash size. On the trinket/gemma we take 64kb of the 256kb flash for a tiny CIRCUITPY. On the Express boards like Metro CIRCUITPY is the 2MB SPI flash chip

ruby atlas
#

(scrolling back to see what boards are known to fail on master)

tulip sleet
#

jerry said he failed with metro. I'll try a trinket

ruby atlas
#

trinket def fails

#

i'm building on mac.

#

you?

tulip sleet
#

linux

ruby atlas
#

i could try building in a VM.

tulip sleet
#

the build will be the same - if there's an issue it might be the USB port

ruby atlas
#

fwiw i had a Segfault during a -j16 build earlier, but that explains why my desktop crashes randomly.

#

(time for memtest/cpu burnin tests)

tulip sleet
#

also feather M0 Express failed. that was the original one. I'll try that

ruby atlas
#

ok. i'll keep learning git bisect. (I was manually bisecting before)

tulip sleet
#

if #837 is ok and #838 isn't, may be easier to manually step through them

#

ok, I get failure on Feather M0 Express with no main.py

#

backtrace in gdb on metro m0:

#0  0x0001cf30 in HardFault_Handler ()
#1  <signal handler called>
#2  0x0000e30c in validate.lto_priv ()
#3  0x0000e4e4 in f_write ()
#4  0x0002052e in mp_hal_stdout_tx_strn ()
#5  0x0000dc8c in mp_hal_stdout_tx_str ()
#6  0x00020a7a in maybe_run_list ()
#7  0x00021544 in main ()
#

I need to get the debug build to fail

#

something not initialized on setup, I bet

ruby atlas
#

is all memory initialized to 0 on hard boot?

tulip sleet
#

NO, in fact the double-click checking depends on the RAM being preserved. a signal value is written on the first click

idle owl
#

@slender iron Are you currently working on the newsletter?

slender iron
#

nope, just did the one commit

idle owl
#

ok. I'm going to add the guides then.

slender iron
#

👍

tulip sleet
#

@ruby atlas no luck on getting debug build to fail. I'll take a break and maybe be back in a few hours

ruby atlas
#

i'll try a debug build too. time to eat though 😃

ruby atlas
#

Hmm, what's the standard way to enable debug builds?

solar whale
#

@tulip sleet @ruby atlas just build a DEBUG=1 version for feather_m0_express - as noted, it runs ar power cycle, BUT - even though CIRCUITPY is mounted and seen by OS,, the onboaed FS does not see it!! there are several files on my syste one is sdtest.py```Adafruit CircuitPython 3.0.0-alpha.6-142-g1eb412b on 2018-05-18; Adafruit Feather M0 Express with samd21g18

import sdtest
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: no module named 'sdtest'
import os
os.listdir()
[]

#

@ruby atlas make BOARD=xxxx DEBUG=1

ruby atlas
#

thanks

#

make clean first, though 😃

#

wow, that's quite the flash overflow 😃 region `FLASH' overflowed by 16724 bytes

solar whale
#

even wierder - tried DEBUG build on Metro_m0_express - it come up int REPL after power cycle and at firs shows the files but when I try to acces them., they disappear!

#
Adafruit CircuitPython 3.0.0-alpha.6-142-g1eb412b on 2018-05-18; Adafruit Metro M0 Express with samd21g18
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> import os
>>> os.listdir()
['.fseventsd', '.metadata_never_index', '.Trashes', 'boot_out.txt', 'oled_test.py', 'jewel.py', 'lib', 'si7021_test.py', 'sgp30_test.py']
>>> import oled_test
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "oled_test.py", line 6, in <module>
  File "adafruit_ssd1306.py", line 34, in <module>
ImportError: no module named 'adafruit_bus_device'
>>> os.listdir()
[]
>>> os.listdir()
ruby atlas
#

gremlins!

#

(or more likely what dan said)

solar whale
#

gremlins - uninitalized variables -- potato - potado 😉

ruby atlas
#

🥔

manic glacierBOT
#

just to get this "on the record" DEBUG builds appear to work better, but not so much.

ON a feather_mo_express and Metro_m0_express, I did a DEBUG=1 build of master and at first it seemed to work, but the REPL is not able to acces the FileSystem even though it is visible to the OS as CIRCUITPY. In this case on Metro_m0_express there isa file sdtest.py on the FS and at first is shows up via os.listdir(), but it fails when it tries to load libraries and afterword the FS looks empty.

You c...

ruby atlas
#

thanks for updating that @solar whale (also i have way too many github tabs and windows open)

idle owl
#

Good problem to have 😃

ruby atlas
#

@solar whale It seems like there's a bug in the filesystem drivers. I'm having a look at what os.listdir() triggers, slowly chasing the chain.

#

currently trying to find where mp_state_ctx.vm is initialized

#

mp_init()

idle owl
#

@slender iron I just put in a PR to the Learn repo and it says CI hasn't been setup. Is there something else we have to do to make that happen? Were we waiting for a reason?

slender iron
#

probably have to enable travis

idle owl
#

Ah ok

slender iron
idle owl
#

Excellent

slender iron
#

(it'll fail hard)

idle owl
#

Thank you

#

I know

#

😃

#

Never been so excited for a failure that epic. 😄

ruby atlas
#

did it fail as hard as my desktop just did?

idle owl
#

Hah! No idea! Oi for you though....

ruby atlas
#

pretty sure it's bad ram.

idle owl
#

I got my screenshots for this soil moisture sensor, I should probably water my poor little cacti now.

#

That'll do it, @ruby atlas

ruby atlas
#

did you get one of the capacitive ones, or is it resistive?

idle owl
#

This is using a Circuit Playground Express and cap touch

#

Alligator clip and a nail

ruby atlas
#

hopefully there's no voltage on the pin? i had a cheap moisture sensor completely dissolve the metal of the exposed trace into the soil on me.

idle owl
#

The only plants in the house that aren't in big pots are these tiny little cacti I grew from seeds from a cactus my parents have had for 45 years or something. And I hadn't watered them in ages.

#

Um... It's reading raw capacitive touch values. There is voltage on the pin, you can test for it using analogio, but I'm not sure it's involved with capacitive touch...

ruby atlas
idle owl
#

Ah, oi. Not a great result

ruby atlas
#

i don't know that you're at the same risk - but you can probably clean the nail and see if it looks like it's rusting or dissolving.

idle owl
#

It's also brass it looks like, or brass plated. It was the only nail we had.

#

Yeah brass plated steel.

#

They're supposed to be for mounting pictures to the wall. It's a kit.

ruby atlas
#

i know the ones. tiny little things. 😃

idle owl
#

This one has massive ones! Oddly enough

#

I guess for hanging massive frames.

#

They're 2 inches long.

#

There are tiny ones in there too, but it has the bigger ones as well.

#

Good thing too because those little ones wouldn't have done for this project.

ruby atlas
#

do we have a suggested circuitpython debugging playlist? 😃

idle owl
#

😄 We all listen to different things. We were talking about doing something up on Spotify, but we don't all use Spotify either.

ruby atlas
#

I need to retrain my spotify daily picks somehow. it's gotten boring over time.

#

it seems to be self reinforcing if you keep listening to the daily picks.

idle owl
#

That makes sense. I found the same with Google if I listened to stations from songs I liked, it eventually became all the same things.

#

I'm listening to an electronica stream from Soma.fm. That's my focus music.

#

Someone else is probably still bingeing on the Wicked soundtrack. All depends on what you're into 😃

ruby atlas
#

i had soma's space station on earlier, and before that secret agent. moved on to apple's alternative radio station for now.

idle owl
#

I'm listening to The Trip

#

It's always surprising to me when I find people who know Soma... that's awesome 😃

ruby atlas
#

oh that's one I hadn't listened to before. liking it!

idle owl
#

Nice!!

ruby atlas
#

currently looking for where in the startup sequence the usb mass storage device is started.

#

since in the failure mode that doesn't start up for me.

radiant lichen
idle owl
#

There isn't currently support for the HUZZAH32 in CircuitPython.

ruby atlas
#

So I've been digging, and added a new dotstar colour before reset_port() in main.c, and the am using that to isolate the crash.

idle owl
#

Nice

ruby atlas
#

print-debugging, in glorious colour

idle owl
#

best way to do it

radiant lichen
#

is there a way, while a circuitpython board is plugged in via usb, to have it respond to input from a keyboard or mouse? essentially, can the board act as a keylogger?

manic glacierBOT
#

After spending a lot of time doing print-debugging using colours on the dotstar on trinket_m0, the hang is during maybe_run_list() during

    mp_hal_stdout_tx_str(filename);
bool maybe_run_list(const char ** filenames, pyexec_result_t* exec_result) {
    const char* filename = first_existing_file_in_list(filenames);
    if (filename == NULL) {
        new_status_color(RED);
        return false;
    }
    new_status_color(BLUE);
    mp_hal_stdout_tx_str(filename);
...
ruby atlas
#

well, i'm at a loss as to why mp_hal_stdout_tx_str() would hang now but not before.

idle owl
#

hmm.

#

I'm unlikely to be much help here.

#

btw you can make inline code by surrounding it with a single backtick ` (upper left corner of a US keyboard) on either side or a codeblock with three backticks on either side.

ruby atlas
#

i had 3 or 4 lines pasted before I removed them, and was too lazy to change the block quote to inline

#

i love that markdown inline and block quotes are almost everywhere

#

okay time to try printing a clear abs gemma case

idle owl
#

Ooh nice

manic glacierBOT
ruby atlas
#

also filename is valid.

   new_status_color(CYAN);
    if (strlen(filename) > 1000) {
        new_status_color(RED);
    } else if (strlen(filename) > 500) {
        new_status_color(GREEN);
    } else if (strlen(filename) > 250) {
        new_status_color(BLUE);
    } else if (strlen(filename) > 125) {
        new_status_color(ORANGE);
    } else if (strlen(filename) > 50) {
        new_status_color(YELLOW);
    } else if (strlen(filename) > 25) {
        new_status_color(BLACK);
    } else if (strlen(filename) > 10) {
        new_status_color(WHITE);
    } else if (strlen(filename) > 5) {
        new_status_color(PURPLE);
    }
    mp_hal_stdout_tx_str(filename);
```  stops at PURPLE
#

I need more colour constants for more debugging!

idle owl
#

Sounds like someone needs to make more colour constants.

ruby atlas
#

those aren't actually the web ones, but I liked the layout

opaque patrol
#

I wonder if it because the code is calling mp_hal_stdout_tx_str(MSG_OUTPUT_SUFFIX); when filename is null

idle owl
#

I have a longer list of constants in a piece of code I wrote, but it's all relative. They're what I thought fit the colors I listed 😃

ruby atlas
#

the filename is not null.

opaque patrol
#

#define MSG_OUTPUT_SUFFIX " output:\r\n"

ruby atlas
#

it was between 5 and 10 characters 😃

opaque patrol
#

what was the filename?

ruby atlas
#

my guess is main.py 😃

#

which matches that last case.

#

(and is what's on my device)

#

testing mp_hal_stdout_tx_str("1234.67");

#

also there's a check in maybe_run_list() that returns false if (filename == NULL) right up top.

#
        new_status_color(RED);
        return false;
    }
    new_status_color(CYAN);
    mp_hal_stdout_tx_str("1234.67");
    new_status_color(YELLOW);``` hangs on CYAN
#

i'm really loving this colour based debugging. ALL boards by everyone should have neopixels or dotstars.

#

No neopixel Emoji?

manic glacierBOT
#

this reminded me of an issue a few days ago with the boot_out.txt creation.
this change creates a working version on the metro_m0_express:

diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h
index 27c2480..589a7e1 100644
--- a/ports/atmel-samd/mpconfigport.h
+++ b/ports/atmel-samd/mpconfigport.h
@@ -280,6 +280,6 @@ void run_background_tasks(void);
 #define MICROPY_VM_HOOK_RETURN run_background_tasks();
 
 #define CIRCUITPY_AUTORELOAD_DELAY_MS 500
-#de...
solar whale
#

so not creating the boot_out.txt file fixes it ??

#

also good on feather_m0 _express

#

and trinket_m0

#

@ruby atlas with that line commented out, it still runs maybe_run_list()

manic glacierBOT
solar whale
#

goodnight all!

idle owl
#

Night @solar whale, have a good one !

raven canopy
#

catching up. my pandora is pretty much stuck on my Bassnectar radio. at this point, it rarely plays a non-thumbed song. but when it does, its usually a spot-on pick. 😄

timber mango
#

@solar whale >> Are these flash device only good to 10,000 write cycle ? I may have worn it out today

500 writes per day, working 24 hours a day, averaging 3 minutes distance between writes.

#

24 * 3600 = 86400
86400 / 180 = ~500 (480)

#

Twenty four hours a day, times 3600 seconds per hour, is 86 thousand and 4 hundred seconds per day!
Divide that by 3 minutes (180 seconds) gives 480 iterations a day, at 3 minute intervals.

#

To wear one out (86,400 / 10,000) you'd have to reduce your iterations to 8.64 seconds per iteration! (not possible).
Also I think 10k would be a very low figure.

#

min. 20k typical 100k endurance erase/write for C8051F330D which has 8kb flash and is quite a few years old (< 2004)

timber mango
#

>>[00:44 UTC] @radiant lichen : is there a way, while a circuitpython board is plugged in via usb, to have it respond to input from a keyboard or mouse? essentially, can the board act as a keylogger?

#

(let's toss out 'or a mouse' for this .. I have no idea how to do that)

#

Not sure how this is done in CircuitPython, but the hardware can certainly do this.

#

You are basically using the target board to listen for serial input (via the USB port).

#

You won't be plugging a USB keyboard into the target board to use Serial.read() but instead will plug the target into a host PC as usual (standard USB cable).

#

Oddly enough it seems you can go the other way, and emulate a USB keyboard (or mouse) with specific target boards. Look for the term 'HID' to find out more about this capability.

#

I would think a true keylogger is inserted inline with a USB keyboard, to acquire keystrokes as well as pass them through to the host PC.

manic glacierBOT
raven canopy
#

FrequencyIn success!!! up to 512kHz before REPL stops responding...

#

hmmm. i wonder if pushing the prescaler up will help....

manic glacierBOT
#

I've got a FrequencyIn core module working!

Using the same PWMOut script as above, I'm now getting up to 512kHz before the REPL locks up. Using this script to capture the frequency in:

import board, pulseio
tc = pulseio.FrequencyIn(board.D7)
while True:
    if (tc.value > 0):
        freq = 48000000 / tc.value  // currently only working on SAMD21
        print(freq)

I have the TC prescaler set to 1 right now, and I think it may be hitting max COUNTER. Will continue to d...

manic glacierBOT
manic glacierBOT
radiant lichen
#

@timber mango Thanks for the info! That's unfortunate that there isn't a way to do this with circuitpython. I wanted to make an LED matrix that would light up according to keystrokes as bling for my laptop.

manic glacierBOT
solar whale
#

I must have missed something regarding audioio on CP 3.0 -- I t looks liek the aruments to audioOut have changes so it now just takes one argument for the Pin. I am tryin to play a small .wav file on my CPX here is the code ```
import board
import audioio
import digitalio

Required for CircuitPlayground Express

speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
speaker_enable.switch_to_output(value=True)

f = open("WhoHitMe.wav", "rb")
a = audioio.AudioOut(board.A0)

print("playing")
a.play(f)
while a.playing:
pass
print("stopped")
but I get this errorAdafruit CircuitPython 3.0.0-alpha.6-143-g990da6d on 2018-05-19; Adafruit CircuitPlayground Express with samd21g18

import audio_test
playing
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "audio_test.py", line 13, in <module>
RuntimeError: Unable to allocate buffers for signed conversion

#

this still works under 2.3.1 ```import board
import audioio
import digitalio

Required for CircuitPlayground Express

speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
speaker_enable.switch_to_output(value=True)

f = open("WhoHitMe.wav", "rb")
a = audioio.AudioOut(board.A0, f)

print("playing")
a.play()
while a.playing:
pass
print("stopped")

manic glacierBOT
#

@jerryneedell The problem is that mp_hal_stdout_tx_strn() (called by mp_hal_stdout_tx_str()) would try to write to boot_out.txt via the (bad) file descriptor boot_output_file. This would either happen immediately when main.py or code.py was being run, or if they didn't exist, when you entered the REPL and the REPL started printing things. So a bad write would happen sooner or later. Since this was kind of a second-order bug, the different place where it could occur further confuse...

tulip sleet
solar whale
#

@tulip sleet ah missed the audio.WaveFile

tulip sleet
#

now it will play wav files or play a raw in-memory sample

#

also note new .pause() and .resume() functionality

#

requested by Phil for a robot demo, and Scott was able to implement quickly

solar whale
#

hmmm ```Press any key to enter the REPL. Use CTRL-D to reload.

Adafruit CircuitPython 3.0.0-alpha.6-143-g990da6d on 2018-05-19; Adafruit CircuitPlayground Express with samd21g18

import audio_test
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "audio_test.py", line 9, in <module>
TypeError: file must be a file opened in byte mode

forimport board
import audioio
import digitalio

Required for CircuitPlayground Express

speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
speaker_enable.switch_to_output(value=True)

f = audioio.WaveFile("WhoHitMe.wav")
a = audioio.AudioOut(board.A0)

print("playing")
a.play(f)
while a.playing:
pass
print("stopped")

#

@tulip sleet I think the docs need an update - this works ```

import board
import audioio
import digitalio

Required for CircuitPlayground Express

speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
speaker_enable.switch_to_output(value=True)

data = open("WhoHitMe.wav", "rb")
f = audioio.WaveFile(data)
a = audioio.AudioOut(board.A0)

print("playing")
a.play(f)
while a.playing:
pass
print("stopped")

#

the file has to be opened with "rb" then passed to audio.Wavefile -- passin gthe filename to audioio.wavefile (as in the docs) does not work.

solar whale
#

Am I doing something wrong here or is this an issue?: test code for CP3.0 ```buttonA = DigitalInOut(board.BUTTON_A)
buttonA.direction = Direction.INPUT
buttonA.pull = Pull.DOWN

buttonB = DigitalInOut(board.BUTTON_B)
buttonB.direction = Direction.INPUT
buttonB.pull = Pull.DOWN

The two files assigned to buttons A & B

audiofiles = ["rimshot.wav", "laugh.wav"]

def play_file(filename):
print("playing file "+filename)
with open(filename,"rb") as f:
wav = audioio.WaveFile(f)
with audioio.AudioOut(board.A0) as a:
a.play(wav)
while a.playing:
pass
print("finished")
while True:
if buttonA.value:
play_file(audiofiles[0])
if buttonB.value:
play_file(audiofiles[1])

works 3 times then errorsAdafruit CircuitPython 3.0.0-alpha.6-143-g990da6d on 2018-05-19; Adafruit CircuitPlayground Express with samd21g18

import audio
playing file rimshot.wav
finished
playing file laugh.wav
finished
playing file rimshot.wav
finished
playing file laugh.wav
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "audio.py", line 35, in <module>
File "audio.py", line 30, in play_file
File "audio.py", line 26, in play_file
RuntimeError: All timers in use

solar whale
#

I think is an issue -- same basic thing works under 2.x

tulip sleet
#

@solar whale go ahead and file issues for the doc and the timer problem. Exactly the kind of testing we need

manic glacierBOT
#

on CPX with current master
The following code executes 3 times then works on the 4th try:

buttonA = DigitalInOut(board.BUTTON_A)
buttonA.direction = Direction.INPUT
buttonA.pull = Pull.DOWN

buttonB = DigitalInOut(board.BUTTON_B)
buttonB.direction = Direction.INPUT
buttonB.pull = Pull.DOWN

# The two files assigned to buttons A & B
audiofiles = ["rimshot.wav", "laugh.wav"]

def play_file(filename):
    print("playing file "+filename)
    with open(filename,"rb") as f:
...
#
#
[adafruit/circuitpython] New branch created: jerryneedell\-patch\-1
manic glacierBOT
manic glacierBOT
raven canopy
#

runs to check his FrequencyIn deinit to make sure the clocks are being turned off 😄

#

they weren't 🤦

solar whale
#

Twofer

raven canopy
#

yep. gotta update the comment though (or build a turn_off_clocks function)...

#

forgot that all that's available in timers.c is tc_set_enabled(false) and tc_reset.

manic glacierBOT
idle owl
#

@tulip sleet Great brain dump, slowly adding to it.

raven canopy
#

i should wait until the coffee starts to work before commenting and coding... ☕

#

luckily there are compilers that are smarter than me. 😄

manic glacierBOT
idle owl
#

Figured out that this works: cpx.pixels.auto_write = False which is handy.

tulip sleet
#

worth documenting

idle owl
#

@tulip sleet It'll at least be going into the guide I'm working on. Used it in an example. Redid the NeoPixel-range light-sensor code with the cpx lib.

#

Redid the sound sensor code too, though it doesn't tighten it up much.

#

Might still include it.

manic glacierBOT
tulip sleet
#

@slender iron thanks for the reviews!

slender iron
#

np! thank you for the fixes!

#

I was thinking we should do an alpha 7

tulip sleet
#

I may do the caching of the busio objects next. That will partially undo board.I2C(), etc.

idle owl
#

Should we add the mic to the cpx lib for the purpose of returning a magnitude value? So this bit would be included in something like cpx.mic_samples or something mic = audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, frequency=16000, bit_depth=16) samples = array.array('H', [0] * 160) mic.record(samples, len(samples))

#

Plus the noramlised_rms function so it returns a magnitude of the samples.

#

Then you could print(cpx.mic_magnitude) or something.

#

@tulip sleet This math.pow(10, 2 * -0.1) will always return the same thing, correct? As in it's not a range of math, it's a single equation that results in a number. (0.630957 according to the REPL) I want to make sure I'm not missing something with how that works.

tulip sleet
#

right no vars in there, so hoist it out of a loop if it's in a loop

idle owl
#

ok

#

You had variables in it in the original code, this is for beginners so I'm limiting what can be changed and therefore what must be explained.

tulip sleet
#

MakeCode has a "loud sound" conditional. that's really simple. a numeric value might be useful too

idle owl
#

oh right

#

"On loud sound, do this:"

#

So if magnitude > blah, do the thing

tulip sleet
#

works if you clap, or blow into the mic

#

The Girls Who Code used it quite successfully

idle owl
#

Nice

#

I'll mock it up and have you take a look

tulip sleet
#

but if the idea is to be able to program the soundmeter with cpx lib, then a value would be good too

raven canopy
#

oof. back to the datasheets, unfortunately. i refuse to accept 512kHz as the upper bound! well, at minimum i have to figure out how to catch the upper bound and bail. 😄

idle owl
#

@tulip sleet Are the MICROPHONE_CLOCK and MICROPHONE_DATA pins used for anything else? As in do I need to do anything fancy with init because it might get a pin in use error later?

#

Or can I init it like anything else and be fine.

tulip sleet
#

they are dedicated pins connected solely to the microphone, so no sharing, so you should be fine. Like SPEAKER_ENABLE, etc.

idle owl
#

ok keen thank you

#

Oh snap I did it.

#

(Sorry I'm still utterly amazed when I manage to do this stuff.)

raven canopy
#

saddened that there is no :snap_fingers: so...you have earned a 🌮!!! that is one of the best feelings though, isn't it. grats!

idle owl
#

It is! Thank you!!

#
import array
import audiobusio
import board
import math

def normalized_rms(values):
    minbuf = int(sum(values) / len(values))
    return math.sqrt(sum(float(sample - minbuf) * (sample - minbuf) for sample in values) / len(values))


mic = audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, frequency=16000, bit_depth=16)
samples = array.array('H', [0] * 160)
mic.record(samples, len(samples))

while True:
    mic.record(samples, len(samples))
    magnitude = normalized_rms(samples)
    print((magnitude,))
#

Is now

#
from express import cpx

while True:
    print(cpx.magnitude())```
raven canopy
idle owl
#

Well played @raven canopy

#

@tulip sleet In MakeCode, the loud sound thing, does it only respond once? because if I blow on the mic it prints a bunch of times because there's no delay. Or do you even have any idea. As in, do I need to make it into a sort of state machine or do we leave that to the code to do that, or add a delay in the code if you want it to only respond once

#

Right now it's kind of like touch, where if it's touched, it's returning a value.

#

So right now, if I blow on the mic, as long as the magnitude is above the threshold, it's returning true

tulip sleet
#

Typically in MakeCode you run something that takes time (like play a tune or do an animation), so it gets triggered and then doesn't get checked again until the thing is done

idle owl
#

Right ok

#

I'll leave it without a delay because this works in a super cool way: ```python
from express import cpx

while True:
if cpx.loud_sound(sound_threshold=200):
cpx.pixels.fill((50, 0, 0))
else:
cpx.pixels.fill(0)```

#

Blow on the mic and the lights are on the whole time

tulip sleet
#

oh, I like the option argument

idle owl
#

Super handy

#

It'll default to 200 I think, but I had it at 100, was too reactive

#

so I set it in the code because I haven't moved the updated express.mpy over yet

#

was still tweaking.

#
from express import cpx
import array
import math


def constrain(value, floor, ceiling):
    return max(floor, min(value, ceiling))


def log_scale(input_value, input_min, input_max, output_min, output_max):
    normalized_input_value = (input_value - input_min) / (input_max - input_min)
    return output_min + math.pow(normalized_input_value, 0.630957) * (output_max - output_min)


def normalized_rms(values):
    minbuf = int(sum(values) / len(values))
    return math.sqrt(sum(float(sample - minbuf) * (sample - minbuf) for sample in values) / len(values))


samples = array.array('H', [0] * 160)
input_floor = normalized_rms(samples) + 10

# Lower number means more sensitive - more LEDs will light up with less sound.
sensitivity = 500
input_ceiling = input_floor + sensitivity

peak = 0
while True:
    print(cpx.magnitude())

    c = log_scale(constrain(cpx.magnitude(), input_floor, input_ceiling),
                  input_floor, input_ceiling, 0, 10)

    cpx.pixels.fill((0, 0, 0))
    for i in range(10):
        if i < c:
            cpx.pixels[i] = (i * (255 // 10), 50, 0)
        if c >= peak:
            peak = min(c, 10 - 1)
        elif peak > 0:
            peak = peak - 1
        if peak > 0:
            cpx.pixels[int(peak)] = (80, 0, 255)
    cpx.pixels.show()
#

Sound meter.

#

normalised_rms is already in the lib.

#

Unsure about adding to the lib though. It's neat, but it's not really a "feature of the board" per se.... it's more a fancy project using a feature of the board. How would you include the sound_meter in another project? Not sure you would.

#

I think I'll include it in the guide I'm doing though.

raven canopy
#

hmm...Voice Activated Recorder? not going to get a long recording, but it's possible.

idle owl
#

Eh we thought about it and no. The recordings it does are iffy at best. You can hear clicks and taps but nothing discernible.

raven canopy
#

ahhh.

idle owl
#

Yeah. And you get about 1.5 seconds I think.

#

The functionality is there, but it wasn't worth it

#

the buffer is so small

#

You wouldn't be able to do anything else.

raven canopy
#

security alarm (like a glass break sensor) is about the only other thing that comes to mind... adabox 007 style.

idle owl
#

Right, but you can use magnitude() for that

#

You don't need the entire sound_meter code

#

Was my point.

#

cpx.sound_meter() would simply the board lighting up to sounds .

#

not workable into something else really.

#

cpx.magnitude() and cpx.loud_sound() I'm adding

raven canopy
#

you're making this difficult. 😆

idle owl
#

😄

#

Or am I making it simple............

raven canopy
#

another That 70's Show episode just popped in my head. anywho. gcc throws me an "unused variable" warning even though i named the variable garbage. too smart for its own good. 😄

idle owl
#

lol

#

"Garbage. Nice try. ERROR."

raven canopy
#

zactly

idle owl
#

@tulip sleet Are either of these @propertys:```python
def magnitude(self):
self._mic.record(self._samples, len(self._samples))
return self._normalized_rms(self._samples)

def loud_sound(self, sound_threshold=200):
    if self.magnitude() > sound_threshold:
        return True
#

I'm still unclear on what makes something a property. I did figure out something else was a @staticmethod

tulip sleet
#

you just do:

#
@property
def magnitude(self):
idle owl
#

oh lol that's what makes it one? I knew that part

#

I wasn't sure if they were actually properties or not

#

Some of the other things in the lib don't have the property decorator on them

raven canopy
#

i think she's asking "when is something a property, and when isn't it"?

#

err...considered a property.

tulip sleet
#

it's a property if it looks like a regular attribute .foo but is implemented as a def (or two defs if there's a setter). It doesn't take arguments, so no parens.

#

I'd use a more specific term than magnitude(), which could mean magnitude of a bunch of things, not just sound magnitude. like .audio_level or .sound_level

#

is that what you're asking?

idle owl
#

Yes. I give them both property decorators and the code fails, so I'll keep testing.

#

and I agree on name

tulip sleet
#

yeah, so just say cpx.magnitude, not cpx.magnitude(), when you add the @property

idle owl
#

it doesn't like loud_sound being a property

tulip sleet
#

cause it can take an argument (even if optional), so it's just a function

idle owl
#

ok

#

what is minbuf in normalized_rms ? minimum_buffer ?

tulip sleet
#

it's the average of the values in the buffer. I'm not sure why it's called minbuf!

idle owl
#

ok

#

ok lint time!!!!

#

I'm getting this error Either all return statements in a function should return an expression, or none of them should. on this function def loud_sound(self, sound_threshold=200): if self.sound_level > sound_threshold: return True

#

I think Scott always has an answer to this one

#

something about returning something different.... I don't remember

raven canopy
#
else:
    return False
idle owl
#

or maybe he always wanted them to return True ?... I'm forgetting

#

oh

#

no that's maybe what Scott always tells me not to do because it's implied?....

tulip sleet
#

could also be:

    def loud_sound(self, sound_threshold=200):
        return self.sound_level > sound_threshold
idle owl
#

OH

#

there it is

raven canopy
#

much cleaner! thanks Dan.

idle owl
#

Yep I knew it was something about the returning True that wasn't right. Thank you!!!

#

satisfied Your code has been rated at 10.00/10 (previous run: 9.95/10, +0.05)

tulip sleet
#

why can't we get 11/10?

#

extra credit

idle owl
#

Because pylint is holding out on us.

raven canopy
#

"We are SPINAL TAP!"

tulip sleet
#

if it will give negative scores it can give extra credit

#

does clapping trigger loud_sound?

idle owl
#

yep

tulip sleet
#

great

#

I'm looking for the original soundmeter code to see why it was called minbuf. I think calling it average or avg would be better.

idle owl
#

I called it mean_values

#

just now when I updated it

#

I can refactor to average if you like that better

tulip sleet
#

average or mean is fine, whichever you think is clearer. I could update the example in the CPX Guide.

idle owl
#

I was thinking of including this version of it in the guide I'm doing now for the cpx lib

#

but I can link it instead

#

Or are you talking about only that part of it

#
from express import cpx

while True:
    print(cpx.sound_level)
    if cpx.loud_sound():
        cpx.pixels.fill((50, 0, 0))
    else:
        cpx.pixels.fill(0)
#

Prints the magnitude, and also turns red when you clap or blow on the mic.

idle owl
#

Right I knew what you meant. Did you mean updating the code completely? Or just that variable

#

I ask because none of the code there uses the cpx lib (for the most part) and my plan was to include the examples in my guide written with the cpx class

#

well at least for the sound meter and the light meter.

#

There's code in the repo for all of those examples that have equivalents in the cpx lib. It was never used for anything. Which is fine because I think it should be centralised anyway, and not sporadically spread through the main guide.

#

Either way works, I won't put anything into the new guide that's an exact duplicate, I'll link it instead.

#

@raven canopy Hey buddy........... how's it going?

#

Do you know how to run sphinx now? cringes

#

Because the command I have from before isn't running because, I'm assuming, of directory structure changes

raven canopy
#

run? like local? negative... Travis is my buddy. 😄

idle owl
#

bugger. Ok.

#

HAH

#

(Figured it out)

#

(I think)

raven canopy
#

belated lunch time! ttfn.

idle owl
#

Yeah only sort of figured it out, but it builds. Obviously it's changed. Need to find out about that on Monday.

tulip sleet
#

@idle owl sorry, on and off the computer. I meant just the variable. Also I don't remember if I fixed the overflow problem in that particular example or not. ... will be off for the evening now

idle owl
#

Ok. I'll hang onto the PR then. See if anyone wants to test it first.

#

So FYI anyone with a CPX who wants to test some code for me, let me know.

manic glacierBOT
#

I'm experiencing strange behaviour with REPL in paste mode. After an arbitrary period of time, pasting anything while in REPL paste mode will crash the board and bring it back up in safe mode.

While in safe mode, paste mode works without an issue. Resetting it back to normal mode, paste mode will crash it to safe mode every single time. Typing in 4 characters will cause a crash. The crash will occur while typing in the 4. character. CTRL-C or CTRL-D will cause a crash immediately.

Cycli...

solar whale
#

@idle owl I can do some later this eveining and tomorrow - Do you want it tested on 2.x or 3.x or both

#

I'll be off for a few hours so just send me info on what you want tested.

idle owl
#

@solar whale Both I would say. It's a change to the Express class cpx lib, but it'll be frozen into both

#

It's frozen in right now, so to avoid it using the frozen module vs the one you put on the board, put the express.py file into /lib and then use the following code:

from express import cpx

while True:
    print(cpx.sound_level)
    if cpx.loud_sound():
        cpx.pixels.fill((50, 0, 0))
    else:
        cpx.pixels.fill(0)
#

Here's the lib .mpy file:

#

Instead of the full from adafruit_circuitplayground.express import cpx which will use the frozen version.

#

should print magnitude (cpx.sound_level) and turn red when you clap or blow on it (loud_sound)

solar whale
#

Is that 2.x mpy ? Can you post the .py

idle owl
#

oh

#

yeah sorry

solar whale
#

Thanks. Will try it tonight

idle owl
#

Thank you!

ruby atlas
#

Hmm. Wonder why touchio isn’t part of 3.0.

idle owl
#

We're still working on it 😃

#

It's the last bit before 3.0b

ruby atlas
#

I saw the issue for it but ran out of time to figure out why it’s not in the build 😃

idle owl
#

That's why 😄 We figured it was a bit much to try work on at the sprints, so it wasn't included in the list that we were working with then. 😃

zealous frigate
#

New new to python and micro controllers. I have a trinket m0 and an OLED 128x32 I2C (https://www.amazon.com/gp/product/B074VDTYJR/ref=oh_aui_search_detailpage?ie=UTF8&psc=1)
and can't get it running. Installed updated CircuitPython, and I think all the libs (busdevice, register, ssd1306, & framebuf), but no luck. Even
busio.I2C.scan()
returns

>>> 
>>> busio.I2C.scan()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'busio' is not defined
>>>```
idle owl
#

You need to import the busio library first. >>> import busio

#

Once you have the libraries installed, you have to import them to use them.

zealous frigate
#

hmm maybe I don't have the lib

idle owl
zealous frigate
#

yep, that's where I've been at for 2 days

idle owl
#

Ah ok

zealous frigate
#
>>> busio.I2C.scan()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: function takes 1 positional arguments but 0 were given
>>> ```
idle owl
#

You can't simply call the scan. You have to do it like the code in the link I sent you. You can do it from the REPL but it needs to be done in that manner.

#

You have to tell it where to look first.

zealous frigate
#

guess I have a fundamental misunderstanding of some basic python syntax?

idle owl
#

If I understand it correctly, it's not smart enough to know where to look if you don't give it a place to start. That's what the i2c = busio.I2C(board.SCL, board.SDA) is doing. Telling the code that those are the I2C pins your sensor (or display) is going to use.

#

It's possible that you're misunderstanding basic syntax, but it seems like you're on the right track. It's more that you're not including some important steps in your code.

#
>>> import busio
>>> import board
>>> i2c = busio.I2C(board.SCL, board.SDA)
>>> while not i2c.try_lock():
...     pass
...     
...     
... 
>>> print("I2C addresses found:", [hex(device_address) for device_address in i2c.scan()])
I2C addresses found: []
#

I don't have anything on I2C.

#

So as long as you have it hooked up to the pins on your board that work for SCL and SDA, it should return an address like [0x39] or something like it.

zealous frigate
#

oh, you're supposed to run in from a file? I thought it said to do it from RE

#

PL

idle owl
#

I did that from the REPL.

chilly juniper
#

is there a single place that I can see what is built onto an board and pointers to the libraries for those built in things? For example, I have a circuit express and want to know how to use the buttons and temperature sensor.. how would I know what libraries to use?

idle owl
#

@zealous frigate But you can run it from a file if you wanted to, and have it print to the serial output. But I did that from the REPL. That's directly pasted from my REPL output.

zealous frigate
#

if you close the REPL window... do you have to reload the libs?

idle owl
#

Yes, the REPL isn't persistent.

chilly juniper
#

@idle owl that is awesome, thanks!

idle owl
#

@chilly juniper Sure thing!

zealous frigate
#

aaahhh

#

let's try this from the start

idle owl
#

That's a good place to try from 😃

zealous frigate
#

side question, in normal CLI I can type "clear" to get a fresh looking window... this a thing within Mu? or just reload it?

idle owl
#

@chilly juniper I think that covers most of it. There's also a lib designed to make it all easier to use, it does all of the setup in the background. You import the lib and it's a few lines of code to get going. We don't have a guide yet for it (working on it now) but here's the API documentation for it. It's built into the current version of CircuitPython. https://circuitpython.readthedocs.io/projects/circuitplayground/en/latest/api.html

#

@zealous frigate I don't think it's a thing within Mu, no. Reload it and re-enter the REPL.

zealous frigate
#

k, thanks

chilly juniper
#

@idle owl i likey. this is even better in some respects. thanks

idle owl
#

@chilly juniper Thanks. I wrote it 😊

chilly juniper
#

oh, one more thing.. is there a way to set the brigness on individual pixels? it looked like you could only set the brightness on all of them at the same time.. I'm sure I'm missing something

idle owl
#

I don't think you're missing anything. We set individual brightness by assigning a pixel a lower RGB number, I think. I just tried to set it on a single pixel and it returns an error. So if you wanted a pixel half brightness, you'd do pixel[1] = (125, 0, 0) which would be half bright red. It's not great. I think DotStars have a special extra bit that allows for it, but NeoPixels don't.

chilly juniper
#

i tried doing that and it didn't work so well.. i didn't see a clear reduction in brigness. I'll try again with it being set super bright and see.. there is some reduction, but it doesn't seem to be as proportional as you would think.

#

if i really care, i'll dig into the code more and see if it's something that is able to be set and supported by the hardware or if it's just a code thing.

idle owl
#

Yeah, I agree. It's all in human perception I think. If you set them to full brightness and then assign it (0, 10, 0) it is obviously dimmer, but doesn't seem like 10/255ths of the original brightness.

chilly juniper
#

there was some reduction in brighness, but just not as much as you would expect based on how I changed the values.

idle owl
#

I did a project with sparkle code, and I divided the current brightness by // 2 and // 10 to get dimmer pixels. It affected random pixels as it went (to get the sparkle affect). It was fairly obvious, but again, I'm not sure about it being half or 1/10th the brightness really.

chilly juniper
#

i guess i would need a light meter or someting to see if it is really doing 10/255th brightness.. it might be, but I just can't distinguish with my analog eyes. 😉

idle owl
#

Distinctly possible 😃

zealous frigate
#

progess, up till here... my guess is I'm not supposed to have so many dots?

... 
... 
... 
... 
... 
... import adafruit_ssd1306
... oled = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c)```
#

ooops

idle owl
#

You needed to add another paren 😃

zealous frigate
#

seen as sent

idle owl
#

So it was waiting for whatever else you were planning to put in that bit.

#

Been there 😄

zealous frigate
#

IT BLINKEDDDDD!!!!

idle owl
#

Yay!!

zealous frigate
#

must find that test code

#

bouncing ball.... so tiny and coool

#

thank you!!

idle owl
#

You're welcome!

#

I'm glad you got it working!

zealous frigate
#

dido. I would like to test another identical screen, would I cycle power to do that? ie, is hotswapping a bad idea?

idle owl
#

Hmm... I'd always recommend powering down, just in case something touches where it shouldn't and shorts.

zealous frigate
#

will do

solar whale
#

@idle owl the loudness code with express.mpy works fine on CPX 2.3.1

#

@idle owl expected thsis problem on 3.0 - --- lis3dh uses ucollections, but on 3.0 it is collections lis3dh needs to be updated ```Adafruit CircuitPython 3.0.0-alpha.6-143-g990da6d on 2018-05-19; Adafruit CircuitPlayground Express with samd21g18

import loud
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "loud.py", line 1, in <module>
File "express.py", line 43, in <module>
File "adafruit_lis3dh.py", line 36, in <module>
ImportError: no module named 'ucollections'

#

loud.py is just your test code ```from express import cpx

while True:
print(cpx.sound_level)
if cpx.loud_sound():
cpx.pixels.fill((50, 0, 0))
else:
cpx.pixels.fill(0)

#

@idle owl I tried some simple fixes for 3.0 , but I have not been able to get it to work

#

ah -- it imports touchio - which is not available -- I tried fixing lis3dh, but also had to play with sys.pat and all it did was hang my system when I tried it. no error messages - just hung 😉

#

I think it is not ready for 3.0...

ruby atlas
#

I can't wait to muck around with a CPX.

solar whale
#

@idle owl I was able to workaround the lis3dh issue but then it has some audioio calls that are not compatible with the 3.0 API ```Adafruit CircuitPython 3.0.0-alpha.6-143-g990da6d on 2018-05-19; Adafruit CircuitPlayground Express with samd21g18

from express import cpx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "express.py", line 774, in <module>
File "express.py", line 104, in init
TypeError: extra keyword arguments given

#

and that was just before a bunch of touchio stuff. I think 3.0 will have to wait for touchio but it will need some work on the audioio and audiobusio stuff.

#

@ruby atlas the CPX is a great device. packed full of toys!

raven canopy
#

it's funny. I have two CPXes, and neither have been used yet. i've stayed in debug land for too long.. 😄

solar whale
#

There are SWD pads on the back 😉

raven canopy
#

but i don't have a biscuit (yet). i do have alligator->male jumpers though. 🤔

solar whale
#

looking forward to a CRICKIT

raven canopy
#

hehe. 🕳 🐇

solar whale
#

😂

#

I have way too many toys already -- need to actually make something!

idle owl
#

Hmm... I thought we froze it into 3.0 already

solar whale
idle owl
#

I could be wrong.

#

Yeah we froze it into 2x

#

Looking.

solar whale
#

its frozen into 3.0, but it does not work 😉

idle owl
#

Ah ok. We did not think that through then. 😄

raven canopy
#

here it is:

FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice

FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_CircuitPlayground
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Thermistor
idle owl
#

Why haven't we updated LIS3DH?

#

she asks like you'd know

solar whale
#

good question!

raven canopy
#

didn't mr mcwethy run through all of libs updating that?

#

or am i conflating things again?

idle owl
#

Conflating I think, they did it with some.

#

ucollections wasn't part of that. I think we hadn't considered it yet.

#

At least I thought it wasn't, maybe I'm conflating.

#

¯_(ツ)_/¯

raven canopy
#

alright...where is :conflating: when we need it. 😄

idle owl
#

Nowhere to be found! It's a conspiracy!

#

Ok. So, the issues with 3.0 are there regardless. LIS3DH needs to be updated. This is my takeaway @solar whale

solar whale
#

lis3dh is only part of the problem

idle owl
#

Ok

solar whale
#

I had an error with ausiobusio -- did its API change -- I know aduioio did

idle owl
#

Oh hmm. Might have, yes.

raven canopy
#

would adabot...no, she wouldn't. only sphinx building the bundle would fail on the automocks...

#

well, maybe adabot will, since she looks for autodoc fails.

solar whale
#

I stopped when it corrupted my FS -- need to get latest 3.0 master in place to stop that

idle owl
#

oi sorry

#

wait with the boot_out.txt issue?

#

Oh it's not in the released alpha?

solar whale
#

it just got updated today -- I don't think I had updated my CPX - doing it now

idle owl
#

Ah ok

solar whale
#

released alpha6 is OK -- the bug was between then and now

idle owl
#

oh right

raven canopy
#

it was a busy week...

solar whale
#

I have to stop living on the edge 😉

idle owl
#

So even without the new additions, the lib does't work in 3.0 because of the touchio and LIS3DH issues?

#

right?

solar whale
#

right - and I think audiobusio

#

lis3dh is an easy fix. I was able to get lis3dh_simpletest to work on 3.0

idle owl
#

frequency changed to sample_rate in PDMIn.