#circuitpython-dev

1 messages ยท Page 199 of 1

pastel panther
#

Is it a pylint error or something

tidal kiln
#

no. straight python thing.

pastel panther
#

strange, cause I'm pretty sure it worked just fine

#

maybe I'm smoking something

tidal kiln
#

has to do with being interpreted. so it's like trying to do this:

>>> print(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'a' is not defined
>>> a = 23
>>> 
pastel panther
#

I dunno, that seems different

tidal kiln
#

with additional layers of stuff coming from the behind the scenes syntax sugar that the @ things do

pastel panther
#

I'd put it more in the category of defining a function with a reference to a function that hasn't been defined yet in the file

tidal kiln
#

since it's interpreted, it needs to know about it at that point in the code

pastel panther
#

nope, still doesn't work

#

I don't think classes are interpreted the same way as code on a repl

#

but what do i know...

#

nanny bot doesn't like w t f

#

hmm.. looks like vs code doesn't handle files moving underneath it well and I ended up with two copies of the driver and tried to build against the wrong one

tidal kiln
#

it could be

#

nope. still gripes.

Adafruit CircuitPython 3.0.2 on 2018-09-14; Adafruit Trinket M0 with samd21e18
>>> import foo1
>>> import foo2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "foo2.py", line 1, in <module>
  File "foo2.py", line 2, in Foo2
NameError: name 'bar' is not defined
>>> 
pastel panther
#

heeey, there it goes

#

doesn't like my table

keen aspen
#

@dhalbert thanks for the answer. Are you likely to get your Atmel/MicroChip SAMD code pulled back into MPy at some point? Just wondering how far apart the branches will get, i'm pretty new to all this distributed development stuff

#

@tulip sleet apparently I don't know how to @ people on Discord either, see above

manic glacierBOT
manic glacierBOT
manic glacierBOT
#

This is an implementation of #703 ... porting WizNet 5200/5500 support across from MicroPython.
Tested on Metro M0 Express and Metro M4 Express with WizNet 5500 FeatherWing.

There's no particular reason this shouldn't be adaptable for other architectures which support SPI.

This particular version doesn't use LWIP as that used up too much memory for use with M0. Instead it uses the WizNet native mode which imposes some limitations but reduces demand on the main CPU.

Example code:
`...

dawn rampart
#

@slender iron or @tulip sleet - I just edited a post I made last night tagging you. I'm not sure how to link to a post - discord is brand new to me. ๐Ÿ˜ƒ Anyway, it looks like maybe my mem chip isn't talking. Before I try hot-air rework on the board, just want to rule out anything else.

idle owl
#

@dawn rampart You mean link to a previous message?

#

If they're tagged, they'll see it. There's no way to link to a previous message.

dawn rampart
#

@idle owl - yes, a previous message. I just edited it to tag them. I think that'll work. ๐Ÿ˜ƒ Thanks.

idle owl
#

I don't think it sends a notification if you edit it to tag someone but it does highlight it, and you let them know to look for it, so it should be fine. ๐Ÿ™‚

timber mango
#

Hi everyone

manic glacierBOT
timber mango
#

I'm searching about infos how to change the USB mass storage name on Trinket M0. Any clue?

pastel panther
#

@timber mango You mean you want to change 'CIRCUITPY' to something else?

timber mango
#

@pastel panther exactly

pastel panther
#

I don't think there is an easy mechanism to do that. It's fairly trivial for the bootloader, but the board files don't have a way of specifying it as far as I know.

#

It's all source code so it's certainly possible but it would mean editing the main body of the code to some extent

#

I'm taking a look at it now to see what might be involved

timber mango
#

@pastel panther I'm searching too inside the code but I've no luck so far

#

@pastel panther I'm pretty sure there is a way to do that, becouse if I use the standard UF2 that comes with the Trinket M0, it renames the trinket in CIRCUITPY, and if you change the UF2 with another one compiled that is not including CIRCUITPY, the trinket USB mass storage name became TRINKET_BOOT

pastel panther
#

I think you may be confusing the bootloader with circuitpython

timber mango
#

so the "CIRCUITPY" name should be outside from the bootloader, or at least an alternative name written on the bootloader

pastel panther
#

but regardless it is certainly possible

#

oh no, you got it. you're right

#

this might be worth looking at (from grepping)

ports/atmel-samd/supervisor/filesystem.c:        f_setlabel(&vfs_fat->fatfs, "CIRCUITPY");
ports/nrf/supervisor/filesystem.c:        f_setlabel(&int_vfs->fatfs, "CIRCUITPY");
timber mango
#

I also tried grepping but without ""

pastel panther
#

for a trinket you'd be looking in ports/atmel-samd

timber mango
#

ok, I'll start my search here, it seems that's exactly what I'm searching for. Thank you

pastel panther
#

Do you have it building normally?

timber mango
#

I'm trying to obtain the same result from the Arduino IDE. It's not the same code, but at least I have a point where to start

pastel panther
#

I don't think I understand.

idle owl
tidal kiln
#

@idle owl yep. got that and few others to look at. seems like the hacktoberfest tag is working!

idle owl
pastel panther
#

do either of you guys understand this?:

docstring of adafruit_max31856.MAX31856.reference_temperature_thresholds:1:'any' reference target not found: (low_temp, high_temp)
idle owl
#

At least I think that's what you were asking about earlier.

#

@pastel panther I do!

#

When you reference something in a docstring, you have to do double backticks (``) on either side or Sphinx tries to do something with it.

pastel panther
#

works now!

#

thaaaaaaaaanks kaaaaaaaniiiiiii

#

lol kani

idle owl
#

@tough flax As I know you're aware, the lib is brand new, so please post any issues you run into/feedback you have to the library repo. Thanks!

pastel panther
#

new nickname accquired

idle owl
#

@pastel panther Sounds like how a child might pronounce it ๐Ÿ˜„

pastel panther
#

totally

idle owl
#

That's nickname recursion!

pastel panther
#

"mumma, kani sez i can be prugummer to"

idle owl
#

๐Ÿ˜„ exactly!

#

Which I totally do say, so there!

pastel panther
#

๐Ÿ˜ƒ

#

one more doc/sphinx/rst question: I want the doc for the constructor to make it clear that it can/should take a adafruit_max31856.ThermocoupleType that is included with the lib but it just shows up like ThermocoupleType instead of max31856.ThermocoupleType

The docstring is currently

  """Driver for the MAX31856 Universal Thermocouple Amplifier
  
    :param ~busio.SPI spi_bus: The I2C bus the MAX31856 is connected to.
    :param ~microcontroller.Pin cs: The pin used for the CS signal.
    :param ~adafruit_max31856.ThermocoupleType thermocouple_type: The type of thermocouple. Default is Type K.
  """
slender iron
#

@timber mango @pastel panther you can change the label from python I believe. You'll want to do it in boot.py though

#

I'll test it myself later when I have a chance

idle owl
#

@pastel panther Hmm.

#

@pastel panther I'm only partially understanding what your concern is here.

pastel panther
#

Maybe a screenshot will help, one sec

idle owl
#

Yes please.

pastel panther
#

I would like it to be more clear somehow that ThermocoupleType comes from the driver. Maybe I need to update the docstring(s) for the ThermocoupleType class?

#

so that it shows up as well?

idle owl
#

If that's where the information makes the most sense, then that's where it should be. You could expand the description in the docstring you pasted above to include a note about where it comes from, and then still update the docstring in the class as well if you feel that's not clear enough.

#

As long as the information provided in the documentation is relevant to what it's describing, it's usually ok for it to be more thorough if necessary. It's when it starts to get tangential that it becomes an issue.

pastel panther
#

Oooh, adding the docstring for ThermocoupleType made the reference in the constructor become a link

idle owl
#

Ok nice!

upbeat plover
#

is there a "mpy-cross-4.x-windows" i was only able to find "mpy-cross-3.x-windows"

idle owl
#

The mpy-cross current version is 3.x, it's coincidence that it's been the same as the CircuitPython versions.

pastel panther
#

hey @tidal kiln I don't know if you get notified but I just updated my MAX41856 driver. If you can re-review it when you have a minute, that would be appreciated

tidal kiln
#

@pastel panther cool. yep. looks like i got a notice. will take a look!

tidal kiln
#

hmmmm. any reason to use | vs. + for something like this?

>>> low_byte = 0x42
>>> high_byte = 0x23
>>> (high_byte << 8) | low_byte
9026
>>> (high_byte << 8) + low_byte
9026
>>> 
pastel panther
#

In that case no, I don't think so but you might get a different result if the thing on the left hadn't been shifted? I may be wrong but I don't think or and + work quite the same and or seems more approprite or perhaps traditional when doing bit/byte manipulation

tidal kiln
#

the use case is for building up the value from multiple bytes, so the shifting will be there.

#

i've always just used | also.

#

@pastel panther your latest push didn't show up in the pr. maybe because you rebased it? not sure.

pastel panther
#

@tidal kiln I'll take a look on my lunch

manic glacierBOT
idle owl
#

@tidal kiln Do you have a few minutes? I can get you setup on RTD if you'd like.

#

In the three minutes since I sent that, I forgot whether I actually sent it or not.... ๐Ÿ˜‘

#

@tidal kiln If not, it's fine, I'll add CAP1188 and have you do the process on a different one later. Simply figured since we had one outstanding, it was worth asking if you had the time.

tidal kiln
#

@idle owl afk. if you wanna wait can ping u later

idle owl
#

Ok, I might do it up. There will be plenty more. Ping me anyway in case I decided to wait.

#

Oh hah, the power switch on the Hollowing matters for it working when plugged into USB. ๐Ÿ™„

pastel panther
#

been there, done that.

idle owl
#

It took me significantly less time than I would have guessed if you asked me how long it would take me to figure out if it happened. So I have that going for me.

#

@slender iron When you're around, I'd like to go over the current hollowing image code with you. I mostly understand what it's doing but I'd like a better understanding than that.

sudden coral
#

Hey folks, I've got a bit of a.... bizarre question for y'all with some hypotheses I'd like to bounce off the wall. tl;dr copy-pasting my entrypoint (let's call it a main.py equivalent, though the structure of my app means it's a couple layers deeper than that) line by line into REPL works great, but straight up importing that file (from myentrypoint_frozen import main) will hard lock the board I'm testing on. I ended up narrowing down the problem to an import getting stuck, but ONLY in this scenario - when typing everything into the REPL manually, it works.

My hypothesis here is that I'm somehow running out of RAM (terrifying thought, really, I've got like 256k on the board in question) during the tight import loop, but when punching stuff into REPL, the VM has enough time to breathe and force a GC. This hypothesis seems promising because my friend also working on this project is starting to run into RAM issues on his Pyboard (this project targets MicroPython as well). The thing that confuses me, however, is this piece of the MicroPython docs (I realize CircuitPython deviates from these, but gc seems to be a mostly equivalent-to-upstream module) that implies I should auto-GC if this were actually the case

Automatic GC is provoked under the following circumstances. When an attempt at allocation fails, a GC is performed and the allocation re-tried. Only if this fails is an exception raised. Secondly an automatic GC will be triggered if the amount of free RAM falls below a threshold

(https://docs.micropython.org/en/latest/reference/constrained.html#control-of-garbage-collection)

Do I need to write hooks into __import__ and/or a wrapper function NodeJS-style (mything, mything2, mything3 = customimport('module.path.here', ('mything', 'mything2', 'mything3')) that auto-GCs after imports? Or am I missing something entirely else that would be causing this?

#

That was a novel, if you'd rather I took this to a Github issue, I'd be happy to. The only other piece of context missing from that book is that the board in question is technically not an officially-supported board - I did a pretty hackish port to the Seeed nRF52840 MDK (https://www.seeedstudio.com/nRF52840-Micro-Development-Kit-p-3079.html) based on the Feather nRF52840 code in the tree, which seems to otherwise work basically perfectly, but it's possible some setting is screwy in the port. I'd have no clue what, though, the boards (based on the code I see in the REPL) appear to be fairly close if not identical other than pinout.

manic glacierBOT
pastel panther
#

@sudden coral until @tulip sleet or @slender iron show up, I'm going to venture a guess that they'll want to see the code in question if you have it available

sudden coral
#

I'm at work - I have links to the Github project (and my fork of CircuitPython) but don't have a board on-hand right now to test any potential fixes (though @bronze shadow possibly could). That said, the codebase is... not small or quick to skim through IMO

tulip sleet
#

@sudden coral there has to be enough room to compile the code. It's possible you're also running into memory fragmentation: there's enough RAM but it's broken up into too-small chunks.

#

For large programs, you can use the mpy-cross compilers and run those on the host, and then import .mpy files. Not as convenient a development cycle, but it makes larger programs possible.

sudden coral
#

If I understand correctly, the compilation isn't an issue because I make heavy use of FROZEN_MPY_DIR (and DFU flash new CircuitPython builds with these frozen modules every time the codebase changes). Fragmentation seems... possible and maybe likely.

#

There's a few files that instantiate fairly large consts at import time (one example file is about 20kb in mpy form)

tough flax
#

@idle owl - thanks for the update on the guide - I will be testing this over the next few days (w/a M4 ItsyBitsy)... am I write that there's no C-code for this library? And do we know how fast we can read this sensor?

sudden coral
#

so I'd fully believe the fragmentation idea. As for fixes though.... heavy use of gc.collect() either at the end of imported files or in an __import__ hook?

tulip sleet
#

@sudden coral also, the nrf52840 port is very alpha, so there may be other bugs. Yes you could try gc.collect() after one or more imports, but also print gc.mem_free() and see what's consuming a lot.

sudden coral
#

@tulip sleet would it help you if I tried to repro this on a Feather M0 Express tonight (west coast time)? To isolate if the issue is nrf52840 or my code?
I ran some prints of micropython.mem_info() and it SEEMED like I had... like 75% RAM free right before the hard lock, but @bronze shadow tells me he gets the same thing on his Pyboard right before it OOM crashes ยฏ_(ใƒ„)_/ยฏ

idle owl
#

@tough flax If I understand you right, no, there's no c-code, it's the Circuit/Python lib only. And read-speed I'm unsure of. The example code has a time.sleep(1) in it, but that's typical in examples to keep the serial output from being spammed, so I wouldn't take that to mean anything about the actual read speed. It's running a pressure sensing gauge with a pre-calibrated and compensated 24 bit ADC if that helps (I'm not sure if this has anything to do with speed)

tough flax
#

Just trying to get an idea how fast a sip/puff user will be able to go. On some sensors, they cache the results for a period of time - just wondering if there was something like that to worry about

#

And it's great that the module is Python-only

tulip sleet
#

@sudden coral it may not fit at all on the M0, an M4 is more like the '840.

idle owl
#

Ah yeah I have no idea. Limor might know from testing, but your testing is probably going to be more thorough in the end anyway.

tulip sleet
#

i don't think it's the '840, though it might be, just being cautious.

tough flax
#

Right - I'll know in a few days

sudden coral
#

@tulip sleet Isn't the RAM on M0 Express (the one that shipped with CircuitPython, though I've since reflashed it) 256k as well? Or am I misremembering?

tulip sleet
#

NO, 32kB RAM

sudden coral
#

I own so many Feathers and other dev boards at this point it's hard to keep track

tulip sleet
#

256kB flash

sudden coral
#

oh jeez, okay. Brain wires crossed.

tulip sleet
#

our M4's are 192kB RAM, 512kB flash

#

(there are larger chips available, but they are hard to get)

bronze shadow
#

@sudden coral I will note that this project does in fact run on a pyboard with 192k of ram, though on micropython, and not circuitpython., and GC almost needs run in boot process.

sudden coral
#

Welp.... might be time for my like fourth DigiKey order in two weeks I guess :)
I'll see if the gc.collect() workaround fixes first, though.

I also have a few ESP8266/ESP32 boards (I believe they're all Adafruit boards even?) laying around that don't really work for the ultimate project due to USB issues, but may work for reproing this freeze.

tulip sleet
#

no CircuitPython on ESP32, just ESP8266

#

also if you are building large data structures on import, consider if you can pack them into a bytestring or something

sudden coral
#

Noted. I know there's a MicroPython port, so I could test anything that's generic to python, but I should probably scope this to CircuitPy just to keep this rabbit hole as short as possible.

tough flax
#

You could run CP on RPi Zero?

tulip sleet
#

no, just the blinka wrapper so you can use CPy libraries

tough flax
#

I mean, does that solve @sudden coral 's issues

sudden coral
#

As far as data structures go, they're unfortunately a (huge - I'm considering writing a tool to trim this file before MPY freeze) series of namedtuple and class objects, bytestringing those would be ... fun

bronze shadow
#

@tough flax Unfortunately this project is not suited to run on a realtime OS.

sudden coral
#

Pi Zero has too high of power requirements for this project unfortunately @tough flax , I own a few and considered reusing them.

tough flax
#

Ok, just a thought

tulip sleet
#

if the code is open source, drop a pointer and we can make suggestions

bronze shadow
#

@tough flax That's really useful information. I definately appreciate having it.

sudden coral
tulip sleet
#

lotsa Keycode objects, yes, you might consider bit-encoding that stuff into a single integer to save space

tough flax
#

Is this extended keycodes (Kanji, etc?)

#

Ah - I read the doc

sudden coral
#

If I refactored that Keycode class out into a bunch of helper methods (for some of the crazier stuff I do with them, like chaining modifiers onto them) and left the keycode definitions themselves as, say, tuples of (hid_code, applied_modifiers), would I save much if any RAM here? I realize there's a RAM hit for instantiating classes but I didn't realize it'd be all that extreme

tough flax
#

So, I agree with @tulip sleet - all those object allocations are wasteful & will take up way more space then the actual codes.

tulip sleet
#

is the combination of keycode + modifier bits <= 31 bits?

#

objects know their type, etc., and take more space. Also the long names take space (though maybe not so much of an issue on M4 or '840)

sudden coral
#

almost certainly yes - I could add, say, 5-10k to each ASCII keycode to detect (for example) LCTRL being applied and be fine

tulip sleet
#

a tuple is still an object

#

use or-ing, not addition, etc, so you can check bits easily

sudden coral
#

I'll take a look at refactoring that - sounds probably like less of a headache than changing how importing works to force a bunch of GC events

tulip sleet
#

i know it's not pythonic, but we gotta save space here. code looks interesting but I will not look too deeply to keep it a surprise ๐Ÿ˜ƒ

sudden coral
#

You've saved our bacon at least twice on this project (I was the same guy asking about HID composite devices in MicroPython Github the other week), you can look all you want :)

Is micropython.mem_info() at all accurate? If I were to profile this thing a bit by sprinkling that print statement Infinity-1 times across the codebase, would I actually be learning anything useful? Or should I be using gc.mem_free() instead?

tulip sleet
#

.mem_info() and .mem_free() get their numbers from the same place.

sudden coral
#

awesome

tulip sleet
#

i am all too familiar with HID keycodes ๐Ÿ˜‰

sudden coral
#

I think this gives me a lot of ideas of paths forward and a few test cases to repro and report back on - thanks as always for all the help @tulip sleet and also @tough flax

slender iron
#

@sudden coral circuitpython should collect after import on its own

#

my guess is that it could be a heap/stack collision

#

do you have a jlink or similar you can use to see where its locking up?

sudden coral
#

is that at the end of each nested import? or just at the end of whichever import statement triggered the chain? (ie if I from kmk_keyboard_user import main, will I get GCs for each step along the way, or just when that import returns, which is never on the NRF right now)

slender iron
#

I believe its after nested ones

sudden coral
#

I just got my JLink EDU literally today (ironically, for another board entirely, but obviously it'll work here). If I can find the SCLK and such pins on this NRF I'd be happy to dive in

slender iron
#

@idle owl I'm around but sitting at the bmw dealer

idle owl
#

Ah ok. Might be worth waiting then.

tidal kiln
#

@tough flax is there any open source prior art on sip/puff code?

slender iron
#

meaning I can't video or voice. should be done in the next hour or two

tough flax
#

@tidal kiln Yes, there is sip/puff code in LipSync, but it's not Morse Code.

idle owl
#

Yah I figured we'd do audio or video, that it would take less time than trying to explain it all through typing. I can wait.

tough flax
#

@tidal kiln there may be more... I will be playing around with this tonight, but I have to go heads down on a work issue this afternoon

#

There is open source Morse Code from Android, but not specifically morse code

#

I'll have more later

tidal kiln
#

ok. the sensor data sheet has "data rate 200 samples per second"

#

but other factors could limit that, like pneumatic lag in the tubulation

slender iron
#

kk @idle owl

tough flax
#

200 per second would be fine - generally, good users can do morse code at 50+ words per minute. Average code length is (around) 3.5 dits or dahs (dots or dashes). So, 150 codes/minute + wait time of 100-300ms per code... I think it will work

#

100-300 per letter, not code on the delay

slender iron
#

circuitpython code to do taps to morse code

tough flax
dawn rampart
#

@slender iron - I hate to keep bugging, but would you happen to have time to look into the message I posted earlier?

tough flax
#

But I seriously can't jump into this right now

slender iron
#

๐Ÿ˜„

#

@dawn rampart lemme look. nows a good time for me to look

tough flax
#

I have the storage for LessonPix > 85% and need to slow that growth/clean up so we can make it to our downtime around Christmas. As much as I love working on this stuff... sometimes it's got to wait ๐Ÿ˜ƒ I'm closing Discord - I'll be back tonight ๐Ÿ˜ƒ

slender iron
#

@dawn rampart it does sound like flash issues. is it qspi or spi?

dawn rampart
#

qspi

#

I bought and put in the W25Q16JV

#

Okay - I'll try reworking it tonight. I double checked that my layout/schematic are identical to the itsy bisty m4 and checking the doc for the chip it looks good.

tulip sleet
#

you'd have to add support for that chip, though, I think

slender iron
#

@dawn rampart I usually will use a saleae at that point to verify the data lines are all behaving as expected

tidal kiln
#

@idle owl back if you wanna pypi now

dawn rampart
#

@slender iron I had to google Saleae...hmmm, anyone have a few hundred bucks I could borrow. ๐Ÿ˜ƒ @tulip sleet I will take a look. I might just try the rework.

slender iron
#

an oscilloscope could be used too

vale arch
#

Is there a getting-started guide for CircuitPython on the nRF52 yet? Or really any kind of reference?

stuck elbow
#

@dawn rampart there are saleae clones for $5 at the usual sources

dawn rampart
#

Okay - I have access to an oscilloscope.

sudden coral
#

@vale arch there's READMEs in the ports/nrf directory in the CircuitPy source but I don't think I've seen, like, web documentation. I've usually been told support is "pre alpha or so" in here

vale arch
#

@sudden coral Thanks. Maybe Iโ€™ll wait a while longer before investigating.

sudden coral
#

I'll say that so far the nRF52840 port seems basically rock solid pending whether the issue I had above is device-specific or not (I'm not thinking it is). The Feather nRF52832 port is functionally solid as long as what you're doing is supported by the HW (read: basically nothing over USB unless you want to bitbang it over a breakout)

pastel panther
#

@dawn rampart Saleae offers multiple discounts on the logic 8 for students, enthusiasts and startups https://blog.saleae.com/saleae-discounts/.
I would highly recommend one buying one from them as it's an invaluable tool. Well worth the price, even without the discounts.

Unlike buying the clones if you buy from Saleae you're supporting the development of the Logic software that makes the whole thing useful.

dawn rampart
#

I'll take a look at the discounts.

manic glacierBOT
raven canopy
slender iron
#

@idle owl at my desk for a few hours

upbeat plover
#

If your looking for something to do, I would love for tft stuff in CP like the hallowing and feather joypad wing

slender iron
#

thats on my list after audio mixing

upbeat plover
#

๐Ÿ˜‹

slender iron
#

it got bumped so we can ship circuitpython on something new coming

upbeat plover
#

i can use them with arduino so it not like they are useless, but i really enjoy CP

slender iron
#

๐Ÿ˜ƒ yup, I wish I could do it all at once

#

but we'll get there

tidal kiln
idle owl
#

@slender iron If you're still free, I'm around.

slender iron
#

k in the voice chat

manic glacierBOT
dawn rampart
#

For those following along at home...Mini SAM M4 Update. I removed the 2 MiB flash chip and tried plugging in Mini SAM to the Windows 10 PC...and it registered nothing. No USB device shows up. If I change to BOOT mode, works as expected. Back to CIRCUITPY mode and nothing. I wish I remember, but I think I got a magenta LEG on the APA102 status light. During the chip removal process the markings on the top faded enough I couldn't tell which pin was #1 any more, so I put a new 2 MiB chip back on. Plugged it in and it is back to where it was before. D: and F: drive. REPL works.

#

BTW - in case others are wondering, this is the most fun project I've done in a while. I love this type of work.

tough flax
#

@tidal kiln - that's awesome - have you hooked up a hose & tested it? Any idea how fast it can track accurately?

dawn rampart
tidal kiln
#

@tough flax i repurposed some heat shrink for a hose connection. in terms of speed - it seems pretty responsive, but i have no reference for what is expected. the basic code idea is the same as lipsync - just a polling loop with threshold checks.

dawn rampart
#

AHA!

tough flax
#

I think step one would be to get a good measurement of how fast we can accurately get good dots and dashes using this approach. I tend to think it'll be insufficient with the sleeps.

#

So, the goal is 60 words per minute. Avg 5 letters per word. That's 300 letters/minute or 5/sec. At average 3.5 dots or dashes per letter that's alot

tidal kiln
#

how are sip/puffs translated into dot/dashes?

tough flax
#

sip is dot and puff is dash

#

or vice versa

#

and technically they're call "dits" and "dahs"

dawn rampart
#

I was using this exact flash: W25Q16JVUXIM - the IM version has a different mem_type. Added it to boards.h and voila! Memory working, CIRCUITPY reporting as 1.97MB

tough flax
#

Thinking about possibly asking about an #AssistiveTech topic - thoughts?

tidal kiln
#

3 dots / letter * 5 letters /sec = 15 dots / sec
that's really fast though

tough flax
#

Yup - we need to do track rising and falling edges. - Interrupts or not, we need to restructure that.

#

Very few can get to 60 WPM, but it's doable (did you read Jim's page?)

tidal kiln
#

no, i did not. is it linked from the lipsync pages?

tough flax
#

Hold on

tidal kiln
tough flax
#

I've had success with letting people set thresholds by example (long-sip, press button, then long-puff, press button, then set thresholds at 1/2 way to each).

tidal kiln
#

that sounds more like the first code.

tough flax
#

as for the timing, we need a running loop watching for rises and falls and checking against monotonic()

#

With the switch router, we had a separate mode for tuning where we figured out the thresholds.

#

When we're actually working, we run fast & use monotonic()

#

Timing of each dit/dah isn't important as long as we don't miss a transition. we just need to know when to stop and calculate a character

#

So, for his current setting he has an "accept time". If it's idle for that long, the character is done.

#

Gotta keep track of the current state and how long it's been there. - three options (sip/puff/idle) + a monotonic() when we got there.

scarlet fjord
#

i hate to derail, but:
how do i remove elements from a 2d array?
this is the array:

        (
            (0.000000,1.000000,0.000000,0.000000),
            (0.000000,0.000000,1.000000,-0.000000),
            (0.000000,-0.000000,0.000000,1.000000),
            (1.000000,0.000000,0.000000,0.000000)
        )

I've tried

RotationMatrix = Transform[0:3 , 1:4]

but it complains: TypeError: tuple indices must be integers or slices, not tuple

main meteor
#

I know how to do it in APL, but not in Python.

tidal kiln
#

tuples are immutable

#

use a list instead

#

[] instead of ()

#

but "remove" = delete? or just access them?

scarlet fjord
#

i need to delete the last array, and the first element from each of the nested arrays

#

i tried () but it complained about invalid syntax..?

tidal kiln
#

if you need to modify the data, then use a list

#
>>> data1 = (1,2,3)
>>> data1[0] = 42
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
>>> data2 = [1,2,3]
>>> data2[0] = 42
>>> data2
[42, 2, 3]
>>> 
tough flax
#

What are your plans tomorrow @tidal kiln?

tidal kiln
#

same same

#

will be here and taking care of various work stuff

tough flax
#

How would you like me to coordinate this? Want to add me to the project? fork it? make my own?

tidal kiln
#

i'd go with making your own

#

i'm not sure what i have is worth forking, you can just start new

#

and when/if i can help, i can PR to your project

tough flax
#

So, let me pull together some code before I sleep - not much (I'm beat). I'll assemble the board tomorrow, and we can make progress

tidal kiln
#

sounds good

#

you can totally take the code in that repo if you want

#

it's just so nascent i don't really think it's a true project worth forking

tulip sleet
#

@dawn rampart Congrats! I put in a comment about the different types - hope that helped.

tough flax
#

I'll pull together enough to get the idea - it won't work until I assemble the board, but it should help

manic glacierBOT
dawn rampart
#

@tulip sleet - I was going to submit a pull request, but if you just want to update on your end, that works too.

tidal kiln
#

@scarlet fjord

>>> data = [
...   [1, 2, 3, 4] ,
...   [5, 6, 7, 8] ,
...   [9, 10, 11, 12] ,
...   [13, 14, 15, 16]
... ]
>>> data
[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]

to delete the last "array":

>>> del data[-1]
>>> data
[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]
>>> 

to delete first element (probably a better way):

>>> for d in data:
...     d.pop(0)
... 
1
5
9
>>> data
[[2, 3, 4], [6, 7, 8], [10, 11, 12]]
>>> 
tulip sleet
#

@dawn rampart please submit a PR or an issue, thanks, helps us not forget

scarlet fjord
#

awesome! that worked ๐Ÿ‘

manic glacierBOT
#

Given the recommended playback of 22k samples/sec, that would be 660 sample steps minimum. That's ~2.5mV per step to reach a 1.65V midpoint.

A slow ramp from the current DAC output to the value at the beginning of the sample to be played is an excellent approach and anticipates poorly edited samples. I recommend keeping the ramp steps at no greater than ~2.5mV even though it could take up to 60ms in the extreme case.

Stop, Pause, and Resume would also benefit from the ramp approach. Res...

tidal kiln
#

np. i'm pretty sure my solution is fairly hackish. if you're doing a lot of this, then something like numpy may have some fancier tools.

scarlet fjord
#

its not a realtime script so performance doesnt much matter ๐Ÿ˜…

tidal kiln
#

but it could provide some more capable and easier to use tools for slicing and dicing data

manic glacierBOT
#

In the ports/atmel-samd/external_flash/devices.h file, the current settings for the W25Q16JV only list one device with one .memory_type 0x40. Suggest splitting into IQ and IM versions of the chip with different memory types.

`// Settings for the Winbond W25Q16JV 2MiB SPI flash. Note that JV-IQ has a different .memory_type (0x40)
// Datasheet: https://www.winbond.com/resource-files/w25q16jv spi revf 05092017.pdf
#define W25Q16JV_IQ {
.total_size = (1 << 21), /* 2 MiB */
...

scarlet fjord
#

ok, moving on to a new problem. this 3x3 matrix is a rotation/scale, and i need to convert that to x/y/z rotation, which i found code for, but it gives me this error:

Transform Rotation matrix:
[[1.0, 0.0, 0.0], [0.0, 1.0, -0.0], [-0.0, 0.0, 1.0]]
Traceback (most recent call last):
  File "C:\Workspace\Assets\Blender Scripts\TestArray.blend\foo.py", line 114, in <module>
  File "C:\Workspace\Assets\Blender Scripts\TestArray.blend\foo.py", line 73, in DoTransformArray
  File "C:\Workspace\Assets\Blender Scripts\TestArray.blend\foo.py", line 99, in rotationMatrixToEulerAngles
TypeError: list indices must be integers or slices, not tuple
Error: Python script fail, look in the console for now...

code:

def rotationMatrixToEulerAngles(R) :
     
    sy = math.sqrt(R[0,0] * R[0,0] +  R[1,0] * R[1,0])

RotationMatrix = [[1.0, 0.0, 0.0], [0.0, 1.0, -0.0], [-0.0, 0.0, 1.0]]
rotationMatrixToEulerAngles(RotationMatrix)

now, im pretty sure im using [], which is what I should be using, but... im lost again ๐Ÿ˜…

#

do i have to make some temp variables using that same code you sent before?

manic glacierBOT
scarlet fjord
#

yep, ok... its not clean, but it works:

    R0 = R[0]
    R1 = R[1]
    R00 = R0[0]
    R10 = R1[0]
     
    sy = math.sqrt((R00 * R00) +  (R10 * R10))
tidal kiln
#

change R[0,0] to R[0][0] similar for others

scarlet fjord
#

oh! thanks ๐Ÿ˜

tough flax
#

@tidal kiln that's more what I was thinking

#

ignore "sendCode()" for now - just know that it will lookup the right code in lookup tables (which will be configurable)

tidal kiln
tough flax
#

Similar - I'm shifting bits into a character which will be used to index into a dict or the like

#

I'm hoping to be able to run this on a Trinket so I'm thinking small ๐Ÿ˜ƒ

#

But I'm fine if M4's what we can do

tidal kiln
#

that's why, for now, i'm testing on trinket m0 ๐Ÿ˜ƒ

tough flax
#

Similar approach - just you're bulding a string, not an int

tidal kiln
#

if size is an issue, but M4 would help, how about the itsy?

tough flax
#

That's what I'm building tomorrow

#

I just had to head home before I could wire it up

#

m4 Itsy + sensor

#

Right now I'm just working in idle and syntax checking

#

I think that's what I can do for tonight... tomorrow I am able to work on this until 1:15 EDT. Then after 9pm

tidal kiln
#

ok. feel free to ping me when you want. may be working on other stuff. but happy to help when i can.

#

but also, these modern tools make async collaboration much easier

tough flax
#

Yes, if my code runs (what I sent you) on the setup in the morning, I'll setup a GitHub project page under the ATMakersOrg

#

caternuson on github, right?

tidal kiln
#

i think it might not get successive dit / dahs? from my quick scan...

#

yep. that's me on github

tough flax
#

You have to have an idle in this code (holding DIT longer doesn't matter)

#

I'll talk to Jim about what really happens

#

What probably doesn't work is DIT->DAH without an idle

#

But we can fix that

#

Do you have it working w/the device?

tidal kiln
#

does it work by allowing successive DIT (or DAH)s to be generated by holding breath?

tough flax
#

This code won't do that - I will ask Jim, but I don't think that's part of the normal A-Z style stuff

#

It is used like that on the mouse mode

#

which will be separate

#

We'll have at least 3 modes - Tuning, Typeing, and Mousing

#

Jim is in your neck of the woods so at some point perhaps you can meet him

tidal kiln
#

i'm in same neck of woods as scott

tough flax
#

Yes - Jim's just north of Seattle - I'm in Tampa

manic glacierBOT
pastel panther
#

bah.. pushing a small fix

#

ok, saul goodman

manic glacierBOT
manic glacierBOT
#

Just built current master for pca10059 - after copying .uf2 to board, CIRCUITPY appears for awhile, but
cannot access REPL -- screen /dev/ttyACM0 115200 attaches for awhile, then disconnects -- a few minutes later CIRCUITPY also disappears.

[211289.957497] usb-storage 3-3.2.4:1.2: USB Mass Storage device detected
[211289.957836] scsi host7: usb-storage 3-3.2.4:1.2
[211289.959843] input: Adafruit Industries CircuitPy nRF52 as /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2.4/3...
solar whale
#

@gentle bronze @tulip sleet the current master appears to have broken the build for the nRF52840 (pca10056 and pca10059) have you been able to get it to work with these? I did build/load the latest bootlaoders as well.

#

It builds OK -- just does not work....

gentle bronze
#

@solar whale hmm, let me check

solar whale
#

Thanks!

tulip sleet
#

@solar whale did you update submodules?

solar whale
#

yes

#

does it work for you?

tulip sleet
#

repl doesn't; CIRCUITPY is still tehre

solar whale
#

give it time -- it will go away ....

tulip sleet
#

This may be due to @gentle bronze UART work or updated submodules. We can let him debug for now

solar whale
#

tooks several minutes for CIRCUITPY for disconnect..... thnask for confirming. No problem waiting for diagnosis, just wanted to make sure it was not something I did wrong.

#

BTW - current master OK on Metro_m4, PIRkey and feather_nrf52832 -- issues appear to be limited to 52840.

tulip sleet
#

it appears to be one of the submodules; if I roll back to the commit before the uart fixes but do NOT revert the submodules to their previous versions, then it works ok. Now I'll narrow it down to nrfx or tinyusb

#

I can't update one without the other. @gentle bronze if I roll back nrfx and lib/tinyusb to the versions before the updates, then it works.

gentle bronze
#

@tulip sleet yeah, nrfx did change something with clock and power in latest version, I am rolling it back as well

#

hold on

#

was too focus on testing nrf uarte, nrfx later version fix some bug with uarte, thus I upgraded it

tulip sleet
#

if we can adapt to the clock & power fixes, that's fine too

gentle bronze
#

it could be some wip in my usb stack as well

#

I did make some changes for arduino lately

#

may break something, didn't test again with uart io, just edit the code, since latest nrfx change some enum name

#

seem to be the case with tinyusb wip , hold on, I will comment out those code and push the fix. sorry for the issue ๐Ÿ˜ฆ

solar whale
#

@gentle bronze no worries! Always good to see the WIP activity! Thanks for looking into it. I have to go off for awhile -- I'll be happy to test updates later today if availalbe. No rush. I have plenty of other things to do ๐Ÿ˜‰

manic glacierBOT
gentle bronze
#

I comment out the wip on tinyusb and make the push. I will re-add and tested it later. Was adding while test Arduino.

#

happen to update nrfx to 1.3.1 as well ๐Ÿ˜„

tulip sleet
#

@gentle bronze tested your new branch - looks good! I'll merge after travix is finished

timber mango
#

Hi there,
I'm starting with CircutPy and trying to dump json data over UART to PC. I've tried importing ujson but I don't think it is included in the build. Is there an option to add/install it?

Using: Trinket M0
Version: 4.0 alpha 1

manic glacierBOT
tidal kiln
#

@pastel panther can you make another commit to your MAX repo? it can be trivial - just need it to kick travis. it looks like that repo was not enabled on travis. i've done that now, but can't figure out how to make it force a build on your latest commit. 6faaf66

pastel panther
#

@tidal kiln Let me give it a try

#

just pushed a rebased commit

tidal kiln
#

cool. and travis is churning....

pastel panther
#

weeeeeee

tidal kiln
#

thanks

#

welcome to the world of linting ๐Ÿ˜ƒ

#

do you know how to read all that and fix?

pastel panther
#

hmm.. I'll have to adjust my vimrc for CP projectss

#

@tidal kiln I can run pylint locally, right?

tidal kiln
#

if you want. or just make the changes and commit and let travis check again.

pastel panther
#

ooh, it looks like the pylint I installed with vs code is already running automatically and highlighting the wrongthink

sudden coral
#

@solar whale I'm pretty late (west coast time!) But wanted to chime in about NRF52840 experiences. I had the broken REPL problem as well intermittently. Changing baud from 11-whatever to 9600 fixed it for me, though I have other issues with that chip that I discussed in here yesterday (I've now isolated it to "probably a board issue")

This was all on a Seeed NRF52840 MDK that I ported myself (basically uses Feather code but trivial changes to pinout)

Cc/fyi @gentle bronze @tulip sleet

#

My issues with freezes on import on this device I discussed in here yesterday are now confirmed not to be RAM related - I have like 170k free at time of crash. Seems to be a CPU loop, because dmesg on the host reports all the devices (HID, serial,...) timing out and failing to respond to anything. I tried rebasing off CPY 4.0.0-alpha and ran into git submodule misery so I'm basically stuck until I figure out a workaround there (can shell script around it in my build process)

manic glacierBOT
#

I had the broken REPL problem as well intermittently after rebasing my CircuitPython fork off master. Changing baud from 11-whatever to 9600 fixed it for me, though on rare occasion the device flips back to the higher baud.......

I get the device freezes/hard locks when importing a heavy module, though - feels like something hitting a while True loop, though I know it's probably not :) otherwise at 9600 I can while True: print to REPL literally all day (confirmed by leaving mine running wh...

idle owl
#

Ok so I have a list being generated and saved to a variable. I have another variable that randomises the order of the list, generates a new list in a random order. I can cycle through each of these lists. However, I want the option to generate a random single member of the list, new each time, implying the possibility that it will be two of the same thing in a row.

#

And I have no idea how do do that.

tidal kiln
#

are you just trying to get a random item from a list?

idle owl
#

yes.

raven canopy
#

We have a random function, right? list[I] = list_2[random()]

tidal kiln
#

there are some things in random that can do that

#

choice

pastel panther
#

random.choice(your_list)

tidal kiln
#

^^ yah. take a look at that.

raven canopy
#

Fine..do it the easy way. ๐Ÿ˜†

pastel panther
#

It being random though there is a chance you'll get the same thing twice, I belive

idle owl
#

Yes that's ok

tidal kiln
#
>>> foo = ["red", "green", "blue", "burnt umber", "bisque"]
>>> random.choice(foo)
'red'
>>> 
manic glacierBOT
pastel panther
#

@raven canopy most times I try and do something interesting with a list, it's already there and likely done better

manic glacierBOT
#

works on the pca10059 Dongle

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.

Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 4.0.0-alpha.1-57-g7b95818c4 on 2018-10-05; PCA10059 nRF52840 Dongle with nRF52840
>>> 
>>> 
>>> 
>>> 
>>> 

and on the pca10056 DK

Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 4.0.0-alpha.1-57-g7b95818c4 on 2018-10-05; PCA10056 nRF52840-DK with n...
idle owl
#

so the issue is, I have code that's cycling through the entire list

#

I'm not sure how to get it to grab a different thing each time

tidal kiln
#

what is the cycle?

#

oh..you want to go through the entire list. but in a random order?

idle owl
#

no

#

I already have that

#

ok let me ask you this before we head down this rabbit hole

#

Hypothetically, if you're doing a slide show on your Hallowing, and you want it to be in a "random" order, do you really want it random in the sense that it's a mystery what it will grab next and could be the same image it just showed? Or are you ok with it randomising the list each time and cycling through it.

#

Kind of thinking maybe that's good enough, that we don't need two versions of random.

pastel panther
#

I would just shuffle the list once and go through it

idle owl
#

because I'm also not sure how to even tell whether this is working without staring at it for an hour and waiting to see if the same image pops up twice. ๐Ÿ˜„

tidal kiln
#

i think it could be either

idle owl
#

Well randomising the list, cycling through it, randomising it again and repeating is apparently way easier.

#

since I already have it working.

pastel panther
#

you can test it by printing out the shuffled indexes as a list each time and then diffing them

tidal kiln
#

slideshow software would typically have settings for picking the behavior

idle owl
#

it will have settings yes.

raven canopy
#

I agree with @pastel panther. Shuffle once. Although, you could use a while during shuffle to ensure no duplicates...

idle owl
#

ok two votes for the code I already have working. bonus for me.

tidal kiln
#

^^ agree. just pick one behavior. that one.

idle owl
#

three!

pastel panther
#

my cats agree so thats six

idle owl
#

๐Ÿ˜†

#

Super bonus for me.

#

Ok thanks all ๐Ÿ˜ƒ

tidal kiln
#

bummer. CP doesn't implement shuffle

>>> dir(random)
['__name__', 'seed', 'getrandbits', 'randrange', 'randint', 'choice', 'random', 'uniform']
>>> 
pastel panther
#

hey @idle owl have you heard anything about cap touch on the m4? I neeeds it and I don't want to have to add a seesaw if I don't have to

idle owl
#

It's Weird โ„ข . Really different from the M0, it wasn't as simple as porting over touchio. It's not really a priority so we haven't been working on it.

pastel panther
#

ok

#

I see a cap1188 in my future

tidal kiln
#

do you really need m4 for it? the m0 has it.

pastel panther
#

To be honest, I'm not sure but I have a fair amount in mind for the next board rev like graphics, audio and lots of blinkies

#

plus I have a bunch of m4s and only one or two m0s

idle owl
#

Ok another question. I'm currently looping indefinitely, and I'm not sure how to go through it only once.

gusty kiln
#

the difference in amount of code you can write / libs you can use on the m4 is pretty amazing.

#

it's practically a Real Computer

idle owl
#
i += 1
i %= len(cycle)```is the code that I think is making it loop indefinitely. It's inside a `while True:`
tidal kiln
#

may need to see more of the code

idle owl
#

blergh. ok, I'll do a gist. I don't have a repo for it or anything.

gusty kiln
#

i don't s'pose you could just do for foo in things:?

idle owl
#

oh right

#

maybe?

#

This is destined for a helper library, for what that's worth.

#

For which I will likely need moar help.... ๐Ÿ˜•

tidal kiln
#

for c in cycle:?

idle owl
#

because I need loop or not to be an option to set. I was hoping to keep everything in the slide_show constructor but I'm not sure how to do that here.

gusty kiln
#

i'd kinda pull the while out of image_display and do like for image in cycle:

#

then call image_display repeatedly only if it's supposed to loop forever?

#

something like that.

idle owl
#

I added the while because it whinged about the continue outside a loop.

#

hmm ok

#

what is image in that though?

tidal kiln
#

iteratorfoo

gusty kiln
#

lemme fork this real quick and sketch out what i mean. :)

idle owl
#

right but it's now an unreferenced variable... should I do _ instead?

#

that works actually

tidal kiln
#

image would be an item in cycle

#

the slide show is just going through a supplied list of images and showing them

idle owl
#

right, but image is a variable if you put it there

#

and there's no image=something elsewhere

#

using _ worked

tidal kiln
#

random vs. not random can be done by just how you create the supplied list

gusty kiln
#

doesn't let you use del the same way though

idle owl
#

ah which it needs to for the code to run with unsupported images

gusty kiln
#

could probably just skip them every time

#

(though i s'pose there's a performance hit)

tidal kiln
#

oh. theres another sequencey thing, displayio.Group()

#

so you add it, display it, then pop it back off? is that how it works?

 splash.append(face)
 board.DISPLAY.wait_for_frame()
 splash.pop()
idle owl
#

I seriously feel like there's some other way to call i and it will not loop, this all feels like overengineering it, but I also felt today like I forgot everything I knew about Python for a bit there, so I could be entirely wrong

#

yes

#

At least I kinda think that's how it works. Scott had to explain it all to me last night and I was fuzzy on it

gusty kiln
#

i mean, with your existing code, you could always just conditionalize the i %= len(cycle) bit.

#

do that if loop_forever or something, otherwise not.

tidal kiln
#

maybe refactor image_display to work on just one image, and not a sequence

gusty kiln
#

(also, why the heck did i think python didn't have += style assignment operators?)

idle owl
#

(I have no idea)

#

@tidal kiln not sure how to do that

tidal kiln
#

it has that, but not ++

gusty kiln
#

ah, that's what i was thinking of.

#

a true python wizard.

idle owl
#

I've got a mate who falls into that category too. It's kind of crazy. He's also dropped off for a bit, as he does from time to time.

#

Otherwise this would be running using a generator already ๐Ÿ˜„

tidal kiln
#

@idle owl i'm 96.3% just thinking out loud...i haven't really looked at this displayio api myself yet.

idle owl
#

I feel like that isn't entirely relevant to making it work on one image at a time though... but I don't understand it.

tidal kiln
#

is all that's needed to play along is use a 4.0 alpha build?

idle owl
#

Um.. I think so? If you're really playing along, you'd need a hollowing and some .bmp images too

tidal kiln
#

got the board. are the .bmp's somewhere?

idle owl
#

I can drop them to you in Discord DM so I'm not spamming this

tidal kiln
#

k

#

wow! so many language choices! that's awesome

#

(scrolls looking for klingon)

idle owl
#

Ok, so the plan is a slideshow of images you put on your board, and you're able to specify:

  1. the folder it's in,
  2. whether or not it continues to loop through the images
  3. whether they're in order, alphabetical, or random (I feel like in order/alphabetical are the same thing according to the code, so I don't think these actually need to be separate)
  4. how long each image shows for
tidal kiln
#

OMG. THESE KITTEHZ!!!

idle owl
#

I made all of those before Maker Faire ๐Ÿ˜„

#

Scott had cat pictures on his so I went with that instead of Circuit Playground characters. Which we already had.

#

OH

#

I MADE IT STOP AFTER THE LOOP

#

So if you call slide_show() the way I just changed it not in a while True: loop, it only goes once.

#

oh I didn't even need to change it from what we had

#

just not calling it in a loop ๐Ÿคฆ

#

sighs loudly at herself

#

So what's the benefit or for _ in cycle: vs say for i in range(len(cycle)): or while True: ?

tidal kiln
#

hmmm. no kitteh :(

Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 4.0.0-alpha.1 on 2018-09-21; HalloWing M0 Express with samd21g18
>>> import board
>>> import displayio
>>> import pulseio
>>> backlight = pulseio.PWMOut(board.TFT_BACKLIGHT)
>>> splash = displayio.Group()
>>> board.DISPLAY.show(splash)
>>> with open("kitten1.bmp", "rb") as f:
...     odb = displayio.OnDiskBitmap(f)
... 
>>> face = displayio.Sprite(odb, pixel_shader=displayio.ColorConverter(), position=(0, 0))
>>> splash.append(face)
>>> backlight.duty_cycle = 2**15
>>> 
gusty kiln
#

@idle owl kind of hard to generalize about those patterns, i think - sort of depends on what you're trying to accomplish.

idle owl
#

hmm

gusty kiln
#

i think of for foo in bar: as the fairly standard pythonic way to iterate over a list, but i haven't actually written all that much python so my opinions are probably suspect.

idle owl
#

trying to accomplish the above requirements

#

that sounds right brennen

#

which we're basically doing so

#

ok

gusty kiln
#

probably some memory considerations

#

(i.e., for foo in bar: makes a copy, i think, so if you're dealing with some large structure and memory is tight, you're probably better off indexing into the list.)

idle owl
#

hmm

#

I have for _ in cycle:

#

I updated the gist

#

with my current iteration

pastel panther
#

hey folks, I saw you guys were working on some code together an I thought I would mention this site I ended up doing some coaching with someone on:
https://codeshare.io/

#

you can do simultaneous editing like etherpad or google wave/docs

sudden coral
#

RAM wise the most efficient is roughly counter = 0; len_list = len(mylist); while counter < len_list: (do thing); counter += 1 IIRC

#

@idle owl ^ but speaking strictly of readability for _ in cycle is definitely nicer ๐Ÿ˜ƒ

idle owl
#

hmm

#

I mean, I'm wondering if efficiency is more important, this is going to be a helper lib anyway

tidal kiln
#

@idle owl any idea why no kitteh? i think i pulled out the basics from your gist.

idle owl
#

Not sure. I've never tried it in the REPL or with only one image, so I have no idea what the syntax there is

#

if the files got weird, it won't work, I know that

tidal kiln
#

can see the bmps on my PC - so there at least OK there

#

and didn't get any read errors

idle owl
#

Then I'm not sure at all

tidal kiln
#

can you try above and see if you get kitteh?

pastel panther
#

I want kitteh

slender iron
#

@tidal kiln you closed the bmp file

pastel panther
#

๐Ÿ˜ฟ

slender iron
#

it should error in that case ๐Ÿ˜ƒ

tidal kiln
#

oh! good catch. yah. it's all within the context manager...

idle owl
#

ah ok

tidal kiln
#

hang on kitteh! i tries agin!

slender iron
#

it does read it as needed so it needs to stay open

tidal kiln
#

KITTEH!!!!

Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 4.0.0-alpha.1 on 2018-09-21; HalloWing M0 Express with samd21g18
>>> import board
>>> import displayio
>>> import pulseio
>>> backlight = pulseio.PWMOut(board.TFT_BACKLIGHT)
>>> splash = displayio.Group()
>>> board.DISPLAY.show(splash)
>>> with open("kitten1.bmp", "rb") as f:
...     odb = displayio.OnDiskBitmap(f)
...     face = displayio.Sprite(odb, pixel_shader=displayio.ColorConverter(), position=(0, 0))
...     splash.append(face)
...     backlight.duty_cycle = 2**15
...     board.DISPLAY.wait_for_frame()
... 
0
>>> 
idle owl
#

๐Ÿ˜บ

tidal kiln
#

thanks @slender iron

idle owl
#

@sudden coral Why does this work: python def image_display(cycle): i = 0 counter = 0 len_images = len(cycle) while counter < len_images: with open(cycle[i], "rb") as f: try: odb = displayio.OnDiskBitmap(f) except ValueError: print("Image unsupported {}".format(cycle[i])) del cycle[i] continue face = displayio.Sprite(odb, pixel_shader=displayio.ColorConverter(), position=(0, 0)) splash.append(face) board.DISPLAY.wait_for_frame() for b in range(100): backlight.duty_cycle = b * max_brightness // 100 time.sleep(0.01) i += 1 i %= len(cycle) for b in range(50, -1, -1): backlight.duty_cycle = b * max_brightness // 100 time.sleep(0.005) splash.pop() counter += 1

#

That little orange kitten with its paws up is kind of my fave of the bunch.

#

Also, it loops now even outside a while True loop, so maybe that doesn't work so well for what I need.

#

Oh I added a separate counter variable and now it acts like it was.

#

Edited.

sudden coral
#

Hold up, what am I comparing against to answer why that works but something else didn't? The above-linked gist?

idle owl
#

Oh, no it's not that something else didn't

sudden coral
#

(sorry I'm at work, so a liiiiiitle slow to see these things ๐Ÿ˜ƒ )

idle owl
#

I simply don't understand why your suggestion works ๐Ÿ˜ƒ

#

(no problem, I totally understand.. thank you for taking any time at all!)

sudden coral
#

The loop in there is basically a really long winded version of a C/Java/Javascript/almost-every-other-language for loop, where we'd write for (var i=0; i<some_huge_number; i++), to take JavaScript for an example. Python (to my knowledge?) doesn't support that, so the manual hackaround with a while loop lets you access the list by indexes to save perhaps a few bytes of RAM here or there (which normally is completely overkill but depending on MCU may matter here?)

idle owl
#

It's an M0 with a lot of flash space, so there's a lot of space for files, but the RAM is, as far as I understand it, limited to the M0 limitation, so I figured it might be worth it to try to be more efficient.

sudden coral
#

I know in CPython for blah in big_list is implemented as a view object that is no-copy, I'm not at all sure about MicroPython. The overhead from that syntax comes from the iteration object magic under the hood (__iter__ and __next__ magic methods)

stuck elbow
#

@sudden coral of course python has for loops

sudden coral
#

C-style? I only know of for blah in blah2 syntax. I'd love to be wrong!

stuck elbow
#

@sudden coral for index, image in enumerate(cycle):

#

however, removing items from a list you are iterating over is a big no-no

sudden coral
#

ah, yeah, I make heavy use of that, but IIRC that's still RAM-heavier than the while loop, so if we're really crunching for RAM, the C-style loop (or while workaround) is probalby still better. M0 has like 32K RAM unlike the huge boards I work on like NRF ๐Ÿ˜ƒ

stuck elbow
#

for some values of better

gusty kiln
#

ask n programmers for a technique, get n+1 techniques back. :D

idle owl
#

ok so is using for _ in cycle: good enough then?

slender iron
#

haha, I found 3k @tulip sleet. we were freezing in the stepper tests

idle owl
#

Nicely done!

sudden coral
#

@idle owl probably - and certainly more readable ๐Ÿ˜ƒ

tulip sleet
#

holy moly!

gusty kiln
#

concur.

idle owl
#

ok I'll stick with that then.

slender iron
#

3k for crickit boards at least

tulip sleet
#

you mean rotaryio?

#

or the crickit examples?

slender iron
tulip sleet
#

aha, we got rid of examples/ in the lib builds, but not tests/

slender iron
#

ya, just added that to the same list

stuck elbow
#

@idle owl as long as you are not using gettext...

idle owl
#

I do not believe I am.

stuck elbow
#

or plan to add it ever

idle owl
#

I don't know what it is, so I have no idea if we plan to....

sudden coral
#

gettext is for translations, mostly: https://en.wikipedia.org/wiki/Gettext

In computing, gettext is an internationalization and localization (i18n) system commonly used for writing multilingual programs on Unix-like computer operating systems. The most commonly used implementation of gettext is GNU gettext, released by the GNU Project in 1995.

stuck elbow
#

it traditionally uses _("foo") to mark strings for translation

#

so if you use the _ variable for anything else...

idle owl
#

oh

tidal kiln
stuck elbow
#

@tidal kiln is that the new bmp code?

manic glacierBOT
#

The nRF5 chips have a proprietary rf mode, that allows them to communicate with older chips like the nRF24.
Would it be possible to support that in the nrf port?

From the nRF5 SDK documentation:

"Enhanced ShockBurst (ESB) for the nRF5 Series is a simple, lightweight protocol, that is on-air compatible with Nordic's nRF24Lxx devices. ESB for the nRF5 Series provides a simple upgrade path for nRF24Lxx based applications."

tidal kiln
#

@stuck elbow yep. using the latest 4.x UF2.

stuck elbow
#

I need to figure out how to get it going on one of my boards

tidal kiln
#

scroll back a bit. i posted a simple example of loading and showing an image.

stuck elbow
#

well, sure, but first I need the board definition matching to my display setup

tidal kiln
#

ooooohhh. "my board" = one of your boards. gotcha!

stuck elbow
#

yeah, I don't have any adafruit boards with displays, they never seem to be available together so that I could order them

dawn rampart
#

I've noticed the CircuitPython Library Bundle doesn't have some of the latest libraries updated. I found the error in the DotStar library from here: https://github.com/adafruit/Adafruit_CircuitPython_DotStar/issues/27 and it looks like the issue was fixed, but it's not in the latest bundle builds.

tidal kiln
#

@dawn rampart you are correct. @slender iron is that something we have an automated check for?

manic glacierBOT
tulip sleet
#

@dawn rampart @tidal kiln we're adding or have added something to adabot to report on libraries with commits newer than releases. @idle owl will be following up on these.

solar whale
pastel panther
#

@tidal kiln or @idle owl should I be addressing all of these lint errors or can some of them be ignored/overridden? It doesn't like my ThermocoupleType class because it has no methods and the members are all single character variables

manic glacierBOT
raven canopy
#

@pastel panther my non-authority answer: you are allowed to disable specific lint complaints, and they should be accepted with justification.

pastel panther
#

how does one figure out what to call the warning/error as to ignore it?

raven canopy
#

are the single chr variables axis ('x', 'y', 'z')? i would say those are acceptable to ignore pylint.
use the wording in the pylint error. got a travis run link?

pastel panther
#

I fixed all the indentation bugs

#

Let me push again

raven canopy
#

example to grab the pylint disable:

C: 55, 0: Exactly one space required before assignment
_MAX31856_CR0_REG           = const(0x00)
                            ^ (bad-whitespace) <<<<
# pylint: disable=bad-whitespace
pastel panther
#

ah yes, ok

tidal kiln
#

@pastel panther yah. fix as many as you can. then disable specific ones. ideally, as few as possible.

raven canopy
#

if in doubt, i would leave it as failing pylint, and allow discussion during the PR review.

tidal kiln
#

and re-enable after you disable a section. that's commonly done at the top where the const-y things are defined:

# pylint: disable=bad-whitespace
SOME_CONST         = 0x42
SOME_OTHER_CONST   = 0x23
# pylint: enable=bad-whitespace
manic glacierBOT
pastel panther
#

@tidal kiln travis is greeeeen ๐ŸŒž

tidal kiln
#

Woot!

pastel panther
#

And now I know enough about the process to do more significant tests before filing a PR.

That said, my local pylint didn't seem to catch the 'no-member' errors for some reason. ๐Ÿคท

#

They also seem incorrect in that they're not getting that the readinto and writes are being passed through to the underlying SPI object

slender iron
#

anyone object to disabling framebuf in 4.x?

raven canopy
#

well, displayio is a replacement, yes?

#

or, a planned replacement, i should say...

tidal kiln
#

@solar whale nice doggo!

solar whale
#

@slender iron is there a guide or doc for migrating from framebuf.

slender iron
#

planned replacement

#

not yet @solar whale

#

I'm getting back to display after this audio work

solar whale
#

For example : how would ssd1306 work?

slender iron
#

with displayio

solar whale
#

The problem with removing framebuf is that there is no python replacement. The python version does not support text

slender iron
#

I want to add it to displayio though

#

before the 4.x release

solar whale
#

Sure. Iโ€™ll be happy to help. May need some guidance.

slender iron
#

๐Ÿ‘

raven canopy
#

I would vote remove it then. just eats up space in the interim...

slender iron
#

ya, I am because I need the space on the cpx for mixer

manic glacierBOT
#

Test script is:

import board
import audioio
import digitalio
import time
import array
import math

# Generate one period of sine wav. 16 bit unsigned
length = 16000 // 440
sine_wave440u = array.array("H", [0] * length * 16)
for i in range(len(sine_wave440u)):
    sine_wave440u[i] = int(math.sin(math.pi * 2 * i / length) * ((2 ** 14) - 1) + 2 ** 15)

sine_wave440u = audioio.RawSample(sine_wave440u, sample_rate=16000)

length = 16000 // 880
sine_wave880u = array.ar...
tulip sleet
#

@slender iron do you have some idea of what is useful for expected range of PWMOut? Revising the current nRF impl -- it wasn't doing variable freq allocation quite right, and some other stuff needed fixing. Looks like max for simple PWMOut is 16MHz/3. I can prescale clock freq,16MHz down to 125kHz and then the count-up reg can be 3..32767, so I can get pretty good resolution.

idle owl
#

@pastel panther If you use the .pylintrc file that we use, you get a more accurate result locally. We ignore some things by default.

pastel panther
#

@idle owl hmm. pylint kinda automagically installed itself(with permission) into vs code so I'll have to figure out how to specify a config file

idle owl
#

Pylint has an order that it looks for that file, in a particular list of places

pastel panther
#

I'm not even sure about the environment it's being executed in because it's run automatically on save by the IDE

idle owl
#

I don't know if that helps

#

yah

pastel panther
#

it doesn't help that you can arbitrarily add directories to the workspace. Presumably it would at least be run from the root of the directory you're editing it from if not the directory that the file is in but who knows. Not a huge deal

idle owl
#

The other option is to grab the pylint disable command out of .pylintrc and run the whole thing. I do that on files going into the Learn repo.

#

But you said it's all running automatically, so that's still not an option for you I guess

#

either way, you'll start to figure out what's ignored and what isn't and ignore it locally without putting a disable into your code.

pastel panther
#

so far it seems like everything is in sync except the no-member thing which I can hopefully just keep in mind

idle owl
#

that's good at least then

pastel panther
idle owl
#

I approved it, I'll wait on @tidal kiln to take a look since most of the changes requested were his.

pastel panther
#

okie dokie, thanks

tidal kiln
#

@pastel panther me and a bowl of ice are reviewing it right now ๐Ÿ˜ƒ

pastel panther
#

I use my hot air station but that works too. Let me tell you, the CJ in the max doesn't like to cool down in my rather hot office

#

I took to spraying the probe with water and putting a fan on it.

#

lol at first I was like "wow @tidal kiln must really like chewing on ice"

๐Ÿคฆ

tidal kiln
#

were you able to go T < 0C?

pastel panther
#

no. To be honest I probably didn't go below 20C

#

@tidal kiln one thing to note if you're checking the threshold faults is this tidbit from the datasheet that caught me off guard:
" There is a 2ยฐC hysteresis when in comparator mode for threshold fault conditions. "

#

I had planned to mention that when I added an example for the thresholds

tidal kiln
#

because...

>>> tc.temperature
22.7969
>>> tc.temperature
1.46875
>>> tc.temperature
1.03906
>>> tc.temperature
0.445313
>>> tc.temperature
1.04858e+06
>>> tc.temperature
1.04858e+06
pastel panther
#

weeeeeeee

#

welp, I guess I know what I'm doing when I get home

tidal kiln
#

it's just gotta be the conversion from the register bits when the sign bit kicks in

pastel panther
#

ya

tidal kiln
#

here:

        # fix sign if needed
        if raw_read & 0x800000:
            raw_read |= 0xFF000000
tidal kiln
#

@pastel panther just as a sanity check, hooked it up to an UNO, works with that setup:

Thermocouple Temp: 23.10
Cold Junction Temp: 26.39
Thermocouple Temp: 23.10
Cold Junction Temp: 26.42
Thermocouple Temp: 22.45
Cold Junction Temp: 26.39
Thermocouple Temp: 3.99
Cold Junction Temp: 26.42
Thermocouple Temp: 4.36
Cold Junction Temp: 26.42
Thermocouple Temp: -0.68
Cold Junction Temp: 26.45
Thermocouple Temp: -1.89
Cold Junction Temp: 26.39
Thermocouple Temp: -1.84
Cold Junction Temp: 26.39
Thermocouple Temp: -1.87
Cold Junction Temp: 26.39
Thermocouple Temp: -1.89
pastel panther
#

huh

#

@tidal kiln same cp version? What board was the original test on?

tidal kiln
#

no CP. all Arduino.

#

so using the Arduino library

#

just a sanity check

pastel panther
#

oh, you're saying the arduino library works but the CP one doesn't

tidal kiln
#

forCP i'm testing with a Feather M4 Express and CP 3.0.2

pastel panther
#

Ok, I'll use my metro m4. I have to arrange dinner and do some dishes but I'll take a look when I'm done

tidal kiln
#

sure. np. and no worries. whenever's fine.

pastel panther
#

I have other stuff I want to get to so I want to put this one to bed

#

stares at brand new 'scope sitting on bench

tidal kiln
#

@pastel panther this seems to work. see if you can verify.

    @property
    def temperature(self):
        """The temperature of the sensor and return its value in degrees celsius. (read-only)"""
        self._perform_one_shot_measurement()

        # read three bytes starting at the MSB of the
        raw_read = self._read_u24(_MAX31856_LTCBH_REG)

        # why not just do this first?
        raw_read >>= 5

        # ok, now we're dealing with a 19 bit signed integer
        raw_read = raw_read - 0x080000 if raw_read & 0x040000 else raw_read

        # convert to temperature
        # see Table 3 in datasheet
        return raw_read * 0.0078125
#

i think the issue is due to the difference in the variables between C and python

manic glacierBOT
pastel panther
#

@tidal kiln seems like it works! Can you explain how you figured it out?

tough flax
#

So @tidal kiln (and everyone). Good news on the pressure sensor. Itโ€™s just the right range of sensitivity and I think we can read it plenty fast.

#

On the other hand Iโ€™m finding we probably need more math on the sip/puff detection

#

Something like, if the derivative shifts negative while below a threshold, count that as a sip and vice versus

#

Versa

#

Because we are not returning to idle/neutral between consecutive sips

#

(Or consecutive puffs)

pastel panther
#

right

tough flax
#

And I think we need some basic smoothing on the derivative

#

But I think the hardware will work great!

pastel panther
#

hmm. I wonder if you almost want a threshold on the derivative

tough flax
#

Bye inserting a 3/32 hose inside a 1/4โ€ hose makes a great tight fit

pastel panther
#

maybe not.. just thinking out loud here

tough flax
#

So when the derivative shifts from up to down it can mean two things

#

Another sip or a release of a puff

#

So thereโ€™s a threshold above which you assume itโ€™s a release of a puff

#

And below which itโ€™s a sip

pastel panther
#

I was just thinking that the difference would be that a sip would have a steeper slope than the release of a puff

tough flax
#

Perhaps but thatโ€™s going to be very user dependent.

pastel panther
#

right.. I think your idea is probably more universal

tough flax
#

Basically this means that if you switch from puff to sip (space balls?) it wonโ€™t register it until you cross that threshold

#

Iโ€™m thinking this is a problem thatโ€™s been solve on other variable inputs. @meager fog? @tulip sleet ? Anything to point us at?

pastel panther
#

Yea, I have no doubt this is a "solved" problem in other domains

tough flax
#

Anyway itโ€™s late but I bought Iโ€™d post an update. The itsy m4 rocks for this

sudden coral
#

Hey folks, any idea why bossac (either from the AUR on Arch Linux or the included tools/bossac_linux) turns off the bootloader light on my Feather M4 Express, hangs for a very long time, then returns SAM-BA operation failed? (I realize it's late even by west coast standards so I totally get if this question sits here until tomorrow)

#

I was able to flash an M0 Express no problem the other day

#

Command line I'm using is mostly ripped straight out of the docs online, sudo bossac -e -w -v -R --offset=0x4000 build-feather_m4_express/firmware.bin

#

or does this board HAVE to flash with the U2F flash drive thingy

pastel panther
#

has it been loaded (by jlink or similar) with the uf2 bootloader?

#

rather does it still go into bootloader when you double tap the reset?

sudden coral
#

it goes into bootloader when I double tap reset it appears: dmesg shows an sdf drive was added. There's also /dev/ttyACM0 still as expected, so I'd think bossa would work

#

for consistency with how I flash other boards in this project (I target several) I'd love to use bossa but if U2F is the most stable way to flash this thing, sure, why not

pastel panther
#

do you have a url for where you found that bossa command?

sudden coral
pastel panther
#

hmm I was thinking the offset might be off but it looks correct (and it would probably be borked if it were wrong)

#

are you not getting the normal M4BOOT or whatever when you put it in bootloader mode?

sudden coral
#

M4BOOT being... what? a disk device?

pastel panther
#

yea

sudden coral
#

the UF2 abilities seem to be intact, I do get a disk drive when I throw this in bootloader mode. I was just trying to avoid using it if I could due to the complexity of flashing the project I have at hand (which so far targets Micropython on a PyBoard which flashes over... either DFU or pyocd, don't recall, NRF52840 which flashes over pyocd, and now this board... which would be the odd one out)

#

it's... looking like fixing my flash scripts to support UF2 may be my safer bet though

pastel panther
#

I see

#

can you still load arduino builds? If so that would at least let you know that bossac is still working

sudden coral
#

haven't tried anything arduino on this board so far. I could give it a whirl.

pastel panther
#

to be honest I haven't used bossac for circuitpython stuff in a looooong time so I'm a bit rusty. I might have an old alias lying around however..

#

as far as I can tell the bossac command looks good

#

my old alias was basically the same except it left off the offset because was using it with different chips

sudden coral
#

hmmm

#

this same command without the offset thing works fine to flash my m0 express, which just adds to the confusion

pastel panther
#

I think without the offset it's going to overwrite the bootloader but it should work? I think?

sudden coral
#

I think I'd really rather not have to crack out my JLINK (or rather, learn how to use it to begin with) to recover bootloader if I screw this up ๐Ÿ˜‚

#

I'll just add UF2 support to my application if it comes to that.

pastel panther
#

the jlink is your friend

#

seriously I use mine all the time, it's nothing to be scared of

#

and of course they're irreplaceable for debugging

sudden coral
#

I'm not gonna lie - I write python for a living, but microcontrollers are something I've only recently gotten into (of course I jumped WAY off the deep end of doing advanced stuff with them right off the bat, go figure). I realize I'll have to learn how to use the thing, but midnight-thirty on a Friday is likely not my best time to do so lol

pastel panther
#

hah

sudden coral
#

For now, the entire idea of the JLINK is a black box of magic

pastel panther
#

we're not so different; I'm a ruby guy by day, trying to re-learn some of the stuff I learned in school a loooooong time ago

#

i did python for my day job in a previous life but most of that I've forgotten too

sudden coral
#

welp, uf2 flash worked perfectly, got my custom build of circuitpython on the device that way

#

soooooo I'll go with the thing that works I guess?

pastel panther
#

the one upside to bossac is you don't have to touch the hardware

#

but yea, I'd say go with what works until you can get bossac to work. When the geniuses wake up I'm sure they'll have something insightful to share

#

and 'grats on getting the custom build going. Is it your first time?

sudden coral
#

on this board, yeah, they just came in today. I've been flashing.... pretty crazy MPY/CPY builds for the past few weeks. Ported (it's hacky and partially unstable) CPY to the MakerDiary NRF52840 SDK, started a MicroPython port to STM32F3....

#

jumped way in the deep end for not being an embedded stuff guy

pastel panther
#

sounds like fun

sudden coral
#

all out of necessity for this particular project (which will end up in #show-and-tell and reddit eventually)

pastel panther
#

noice

sudden coral
#

the suuuuuper high level tl;dr (since I've discussed in this channel before, cat's already out of the bag) is a mechanical keyboard firmware

pastel panther
#

cool; I think scott has a CP powered keyboard, but I think it's wired

#

I've been meaning to get around to building a mechanical keyboard but it would be replacing my kinesis which seems like a hard act to follow

sudden coral
#

if you can adjust to layer switching instead of just having 25987543 keyswitches all present (the kinesis is a beast of a board IIRC), I can totally recommend the Keebio Iris or Levinson (both QMK boards, though I've got stuff in the works to convert them to this python firmware. more spoilers... oops). Solid, inexpensive, super flexible

#

The iris is a bit closer to what you'd be used to with the few thumb buttons. But anyway, this is now a bit o/t, my bad ๐Ÿ˜ƒ

pastel panther
#

The iris is pretty nice though one thing that the kinesis has that I haven't seen on many (if any) DIY keyboards is the tenting legs and palm rests

#

we're talking about CP powered keyboards at 1am-ish so I think it's all good ๐Ÿ˜›

sudden coral
#

a few ergodoxes have tenting legs and palm rests - I used to own an Ergodox EZ which came with both. I sold the board but kept the palm rests, lol

#

I am in fact using them right now with my Iris

sudden coral
#

new problem, perhaps for @tulip sleet when he's online next: I've identified the problem that I'm having on project import. The NRF52840 didn't show me the error message (and froze the board hard), but the M4 Express shows me an error message and recovers correctly. I'm hitting a max recursion depth error when importing the entrypoint of my project, YIKES! It seems sys.setrecursionlimit is not implemented in either MicroPython core or in CircuitPython for probably obvious reasons, so I'm genuinely unsure how to work around this short of writing some sort of AST parser on the host that scans all imports and crunches them down into a single Py file (if this idea sounds familiar it's loosely what Webpack does in JavaScript land)

#

however if I copy paste every single line of my entrypoint into REPL the project runs perfectly -I just can't do the shortcut from mything import main without crashing (which means I'm probably teetering within an import or two of the hard limit on CPY)

stuck elbow
#

have fewer levels of function calls

sudden coral
#

there's VERY few actual function calls of my own in this import/boot process

#

the recursion depth is presumably coming from __import__ under the hood

pastel panther
#

hey @stuck elbow , how do I load a bitmap onto my ili9341?

#

or rather I think I mean how do I do so without going through it bit by bit

stuck elbow
manic glacierBOT
sudden coral
#

pyboard limit is a whopping 63 though, allegedly, so this limitation seems goofy on atmel. I'll take a look in the morning to see what I can do to get out of this hole.

manic glacierBOT
#
manic glacierBOT
#

When I tried to enable the @micropython.arm_thumb decorator for the nrf port, the compilation failed with many pointer type errors, such as the one below:

In file included from ../../py/reader.h:29:0,
                 from ../../py/lexer.h:33,
                 from ../../py/emit.h:29,
                 from ../../py/emitinlinethumb.c:33:
../../py/obj.h:651:10: note: expected 'const compressed_string_t * {aka const struct <anonymous> *}' but argument is of type 'const char *'
 mp...
manic glacierBOT
tulip sleet
#

@sudden coral I canโ€™t stay online but you can increase the stack size. Thereโ€™s an open issue about stack size that will pony you to the #define to change.

manic glacierBOT
#

The micro:bits have a python module "radio", that implements the Nordic Gazell protocol.
This is different from the nRF24 protocol, but would maybe also a nice addition. The Gazell protocol is meant to be used in star topology, using one (always powered) hub, and up to eight (sometimes sleeping) nodes.
Ideal for building your own mice and keyboards.
I just don't know how difficult it would be to port that from Micro:Bit to circuitpython.

marble hornet
#

hey! may I ask if there is any news on asyncio?? I am writing button and touch for my gui. I am considering how to make the library easy to use by other people (touch screen and button passing to gui objects etc) is there any progress or suspected api for the module??

raven canopy
#

@marble hornet no news lately that i recall.

rustic nymph
#

Why is discord so against auto scroll ๐Ÿ˜ 

humble bronze
#

No idea what your talking about i can auto scroll without an issue

rustic nymph
#

Your channels stay scrolled to newest messages even when inactive?

humble bronze
#

Not when i

#

I'm inactive but usually yeah

rustic nymph
#

Oh jeez thought I was in general

raven canopy
#

hehe. i was about to request moving the convo. ๐Ÿ˜„

marble hornet
#

thanks @raven canopy

tidal kiln
#

@pastel panther it was some guessing on my part, so i may not be the best person to explain it. but has to do with 2s complement and subtleties of differences between implicit casting in C and whatever Python does.

for example, in the arduino library, there's an implicit cast from uint32_t to int32_t here:
https://github.com/adafruit/Adafruit_MAX31856/blob/master/Adafruit_MAX31856.cpp#L135
followed by an implicit cast from int32_t to float here:
https://github.com/adafruit/Adafruit_MAX31856/blob/master/Adafruit_MAX31856.cpp#L142
so there's some buried magic there that won't happen in python

also - the datasheet could be better, instead of describing the temperature format, it just says look at Table 3, so you have to infer it from there.

also also - you'll need to do a similar fix in your reference_temperature func. there may be a way to do this using struct.unpack, but my bit ninja skills are not that good

pastel panther
#

@tidal kiln ok, thanks. Based on your suggestion I figured that has something to do with it. Did you test it against any of the values in the table? I was just about to do that

#

@tidal kiln once you had a clue as to the potential cause how did you come up with the fix? Trial an error?

tidal kiln
#

good idea...easy enough...

>>> def foo(val):
...     val >>= 5
...     val = val - 0x080000 if val & 0x040000 else val
...     return val * 0.0078125
... 
>>> 

and....

>>> foo(0b111100000110000000000000)
-250.0
>>> foo(0b000001100100111100000000)
100.937
>>> 

looks ok

#

fix wasn't trial and error. decided to just ignore the arduino lib and do something different

marble hornet
#

i can't find the asyncio module in the micropython repo, is it even worth looking for to add into circuitpython?

tidal kiln
#

@pastel panther it comes down to dealing with the 19 bit signed int, this is stored in 3 8 byte registers, it's probably shifted up so that the sign bit ends up where it does, which would allow for dealing with it like in the arduino code

#

shifting is like multiplying by 2, so you could just work with the raw value and take that into account

#

by i just went ahead and shifted it back down

raw_read >>= 5
idle owl
#

@marble hornet We have a community member who started looking into it. It's definitely worth looking into, but there's apparently a lot to getting it ported. He's have a lot of life happen though so I'm pretty sure it stalled.

#

He was last working on paring it down to something that would actually fit because it's evidently massive.

idle owl
#

@raven canopy You around?

raven canopy
#

indeed, i am. ๐Ÿ‘‹

idle owl
#

Hi.

#

You've done Adabot stuff, you may be able to help me.

raven canopy
#

conjures up adabot sorcery knowledge

idle owl
#

So as it stands, Adabot only displays the first x-number of whatever's in parts of the output, so for parts of the output that have a lot of results, they're not all displayed (I can try to use more vague words here if needed ๐Ÿ™„ )

#

I assume this is a setting somewhere

#

I'm going to start keeping track of Everything Library โ„ข in a meta-issue on the CircuitPython repo, and I want it to have All the Things.

#

So like here ```CircuitPython drivers page missing driver - 14

Not listed on PyPi for CPython use - 18```

#

Nothing listed below it.

#

because it's over 5 or something, I don't remember the current limit.

raven canopy
#

ahh..ok, now i get what you're saying. i don't think it is a passable argument (list_threshold = 5) at the moment. let me take a gander real quick.

idle owl
#

I didn't expect it to be passable, I expected to have to edit a file somewhere.

#

But I guess if you can make it such, that would be amazing. I have no idea if that's even remotely reasonable or not. It hadn't ever occurred to me in the first place.

raven canopy
idle owl
#

Ok, good job me for remembering a thing!

#

I'm ok with editing that file and having the change locally. I should probably make the change on a branch so I don't get things all in a twist when I'm keeping it updated otherwise though.

raven canopy
#

it is doable to make it a passable argument. we could get all sorts of fancy: output to a file vs print, run a single test at a time, etc.
feels like he's walking himself into something, as he often does...

idle owl
#

I mean..... I wouldn't object. ๐Ÿ˜‰

raven canopy
#

๐Ÿ˜†

idle owl
#

๐Ÿ˜„

#

It would certainly make things easier on me than going in and changing it every time so I don't screw up the pull when I update.

raven canopy
#

want to discuss in the weeds on monday? Scott may have some input...

idle owl
#

Sure. I'm guessing his input is going to be do it up, but you're right that makes sense to discuss.

raven canopy
#

actually, is the meeting staying monday, or will it be tuesday? columbus day and all...

idle owl
#

Hmm, not sure. Will probably find out Sunday late when Scott gets back. Typically depends on whether it's a day off at his house too.

raven canopy
#

haha. fair point. i have off, so i could actually discuss realtime vs phone keyboard. ๐Ÿ™Œ

idle owl
#

Nice! Well, we'll see. Scott's out until Sunday so we'll know then.

manic glacierBOT
marble hornet
#

@idle owl could I ask this person's name?

#

and thank you

idle owl
#

Wolf ๐Ÿ˜ƒ

marble hornet
#

3777?

idle owl
#

I think we have an issue for it somewhere, but there's not a lot of information in it because I think most of the discussion was verbal

#

Yep that's him

#

I doubt you'll hear back from him here if you ping him though.

marble hornet
#

@idle owl thank you for the help !

idle owl
#

So yeah, nothing was ever pushed to GitHub it looks like.

#

I feel like if it's something you really want/need or want to work on, you should post to that issue and start looking into it. Unfortunately we can't really track community involvement as it's exactly that, community involvement.

marble hornet
#

๐Ÿ˜๐Ÿ‘Œ

idle owl
#

The last I knew of it, he was still working on understanding it well enough to start paring it down to a usable state with the limitations of CircuitPython. He showed me a number of functions he'd done and how they worked, but I don't know that it's anywhere public. Or maybe it is: https://github.com/wolf/exploring-asyncio

#

That may be what he was working on.

#

Sure looks like it. @marble hornet Start there ^^

#

But I still recommend posting to that issue if you're going to do anything with it as it's always better for us to have the most up to date awareness of things.

marble hornet
#

Thank you @idle owl I will be sure to put any questions or thoughts or ๐Ÿคž breakthroughs(not likely) in there

idle owl
#

Thanks!

manic glacierBOT
#

This is the place to stay up-to-date on the state of the CircuitPython libraries. We will be updating this issue each week with the most recent status from the wonderful Adabot!

If you'd like to contribute, CircuitPython libraries are a great place to start. Have an idea for a new driver? File an issue here on the CircuitPython repo! Interested in helping with current libraries? This issue is the place to start. We've included open issues...

idle owl
#

This song keeps repeating "The rebel, the rebel" and I keep hearing "The REPL, the REPL".

manic glacierBOT
tidal kiln
#

...and now i'm hearing the bikini kill song as REPL GIRL! REPL GIRL!

raven canopy
#

...makes me think of NIN The Wretched.

manic glacierBOT
raven canopy
idle owl
#

๐Ÿ˜†

raven canopy
#

although, not sure the URL query strings can be that long.

manic glacierBOT
idle owl
#

(โ•ฏยฐโ–กยฐ๏ผ‰โ•ฏ๏ธต โ”ปโ”โ”ป

raven canopy
#

uh oh. a heavy table has been tossed...

idle owl
#

can't figure out making this lib use time.monotonic. It's failing in every possible iteration I can think of and I'm pretty sure I'm going in circles.

tidal kiln
#

@idle owl async for the slide show?

idle owl
#

yah

tidal kiln
#

what's the idea for how the slide show will get driven?

idle owl
#

I don't understand the question

tidal kiln
#

yah. hard to phrase.

#

something has to "drive" the slide show

#

in the simple version, it's a while loop

#

which works, but the while loop blocks

#

so that'll have to go away

#

and something else will have to do the driving

idle owl
#

ohhh

#

I think.

tidal kiln
#

very roughly. you'd have to change from this:

ss.run()   # blocking call, returns when slide show is complete, if ever

to something like this:

while True:
    #
    # do some stuff, like read buttons with GPIO
    #
    ss.update() # blocking, but only does what's needed and returns
idle owl
#

I was more concerned with taking out the time.sleeps than the while loop, but yah.

tidal kiln
#

yep. time.sleep would go away also.

#

so there's more than one aspect to the change

idle owl
#

right

#

I'm seeing that now

#

bleh.

tidal kiln
#

time.sleep goes away, but you also probably will not have a while True in the class anymore either

idle owl
#

right right

tidal kiln
#

and in update would be something like:

now = time.monotonic()
if now - last_update > self.dwell:
    # update image
    last_update = now
else:
    # do nothing. just return.
idle owl
#

which means i've been banging my head against useless for the last however long... ๐Ÿ˜‘

#

I was trying to do that

tidal kiln
#

but....this is just one approach

idle owl
#

it was not being cooperative even though I used to have this down so easily

tidal kiln
#

which is why i was asking what the general idea was for how the slide show would get driven

idle owl
#

I don't think I know the answer.

#

mostly because I'm still not sure I understand the meat behind the question.

#

Or something.

tidal kiln
#

do you understand the approach above?

idle owl
#

yes. I think

tidal kiln
#

basically, the responsibility for driving the slide show is outsourced to the main program

idle owl
#

that's why I was leaning towards trying to get it all into generators is that's how I know how to do non-blocking sequence code.

#

ok

tidal kiln
#

it's up to someone to write a program properly to actually create a slide show

idle owl
#

but I don't know how to put generators into a lib, etc etc etc.

#

hmm

#

I guess that's really the only option.

tidal kiln
#

like, if you forget to call update, or the main program does something else that takes a long time before calling update, the slide show progress is affected

idle owl
#

if we want async.

#

hmm yeah

tidal kiln
#

this is pseudo-async, since we don't have threads

idle owl
#

right right. I mean conceptually asynchronous. except that's a lot to type.

tidal kiln
#

it's a lot like "blink without delay"

pastel panther
#

I kinda think of it like arduino where your code.py is responsible for calling loop()

#

(apologies if that's just confusing things further)

idle owl
#

ยฏ_(ใƒ„)_/ยฏ

tidal kiln
#

nope. that's saying the same thing.

idle owl
#

I don't know arduino, so it's not really confusing, it's not adding anything to what I understand

#

๐Ÿ˜ƒ

#

debating on whether I should wait to see what Limor or PT wants out of this in terms of it being asynchronous. Because this doesn't sound simple and if I head down the wrong rabbit hole that will be super frustrating. I can't wrap my brain around it apparently. Which in itself is super frustrating, really....

#

Actually it was mentioned. "we'll make it Awesome and Asynchronous after this works, so that it uses time.monotonic() and you just sorta poke it in your loop to 'check in' after dealing with GPIO"

#

Not sure that clarifies anything for me though.

tidal kiln
#

๐Ÿ˜ƒ yep

#

"poke"

pastel panther
#

You're not far off, just a few missing pieces I would guess

#

You'll get it

tidal kiln
#

that's saying the same thing i am, and notionally suggests the approach i showed

idle owl
#

ok

tidal kiln
#

"poke" = the call to update done from the main program

pastel panther
#

update will just be responsible for checking how long it's been since it's been called and then doing something if an appropriate amount of time has passed

idle owl
#

hmm.

tidal kiln
#
def update(self):
    now = time.monotonic()
    if now - last_update > self.dwell:
        # update image
        last_update = now
    else:
        # do nothing. just return.
idle owl
#

that deals with the image staying up, but I was trying to deal with the fade times

tidal kiln
#

replace #update image with whatever you want

#

the fade in/out does complicate it

idle owl
#

yah. so I was finding.

#

time.monotonic() was not wokring.

tidal kiln
#

easiest is to just make it part of the showing an image

idle owl
#

I have def _fade_in(self): separated out in a failed attempt to get it to work

#

oh

#

hmph.

raven canopy
#

keep track of a fade_status == [None][in][out] and glue it into update and show?

tidal kiln
#

i think you'll want fading in and fading out to be blocking

idle owl
#

oh.

tidal kiln
#

otherwise it might not be super smooth if it's driven from the main program

#

not ideal, but generally easier

#

but maybe it'd work..hmm..

#

so something like what @raven canopy is saying...

idle owl
#

I only partially understand that.

tidal kiln
#

another variable to keep track of current state "fading in", "showing image", "fading out"

#

and in update you have a conditional to check that

idle owl
#

I know how to use time.monotonic to make code non-blocking. However, I can't wrap my brain around how to do it right here. Because you have to have an initial time and a current time, compare them and blah... and I'm not seeing where to place those two instances to get the correct comparison because it's all spread around the library...

#

ok that makes a little more sense on that part

tidal kiln
#

and fading in/out would no longer be driven by a for loop

idle owl
#

Running this: ```python
import adafruit_slideshow

slideshow = adafruit_slideshow.SlideShow()

slideshow.order = slideshow.ALPHA
slideshow.dwell = 2
slideshow.loop = True

slideshow.slideshow()```

#

I know loop is default.

#

was trying to understand things anyway.

pastel panther
#

it looks good. Does it work?

idle owl
#

yah

pastel panther
#

In that case, commit it if you haven't done so yet

#

even if you don't push the commit

idle owl
#

I don't even have a repo for it.

#

or a local thing

#

been editing it all on the board ๐Ÿ˜„

#

terrible.

pastel panther
#

just git init in the directory and add the stuff and commit

tidal kiln
#
def update(self):
    now = time.monotonic()

    if current_state == self.FADE_IN:
        self.backlight.duty_cycle += DELTA_FADE 
        time.sleep(0.01)
        if self.backlight.duty_cycle == MAX_BRIGHTNESS:
            current_state = self.SHOW_IMAGE

    if current_state == self.SHOW_IMAGE:
        if now - time.monotonic() > self.dwell:
            current_state = self.FADE_OUT

    if current_state == self.FADE_OUT:
        self.backlight.duty_cycle -= DELTA_FADE 
        time.sleep(0.01)
        if self.backlight.duty_cycle == 0:
            current_state = self.NEXT_IMAGE

    if current_state == self.NEXT_IMAGE:
        #
        # load the next image
        # 
pastel panther
#

you can set up a remote later

idle owl
#

@tidal kiln huh. ok...

tidal kiln
#

very rough...still thinking about how the load next should work...and how you've stored the image file list....

idle owl
#

yah.... I'm not sure I have any idea.

tidal kiln
#

and ideally, the time.sleep(0.01) should go away

idle owl
#

do the same time.monotonic() magic on that too, I guess

tidal kiln
#

yah

#

but you can see how fade in/out smoothness is entirely up to calling program

idle owl
#

I think so

tidal kiln
#

imagine calling update once every 10 seconds

#

what fade in would look like

idle owl
#

I.. am not sure

tidal kiln
#

it'd be slooooowwwww

idle owl
#

ok

#

hmm

tidal kiln
#

it only bumps up duty_cycle when it gets called