#circuitpython-dev

1 messages ยท Page 278 of 1

manic glacierBOT
onyx hinge
teal bear
#

"not too much" I like it

manic glacierBOT
manic glacierBOT
lone sandalBOT
river quest
tough flax
#

Hi Folks - Any update on the Bonding issues with BLE HID? I have projects that are kind of stuck and we're about to go with an Bluefruit Friend + an M4 board. I'd much rather spend the same money on NRF52840 Feathers & be done with it.

meager fog
#

@tough flax no updates yet, and folks are out for the holidays

tough flax
#

Ok... my day job is dead over the holidays so I have some time starting Thursday...

#

I could probably do this in Arduino & at least not change the hardware

#

I know @tulip sleet was very close

#

Thanks for the update though... missed you in NYC last week

onyx hinge
#

hmmm looks like I've softbricked an nrf52840. code.py crashes it so fast and hard that I can't get to repl or remove code.py via CIRCUITPYTHON. I know what to do, and also that I need to debug it now ๐Ÿ˜›

#
import busio
import digitalio
import time

b = busio.SPI(board.SCK, MOSI=board.MOSI)
stb = digitalio.DigitalInOut(board.D5)

stb.switch_to_output(True)
d = bytearray(4)
d[0] = d[1] = d[2] = d[3] = 0xff
print ("trylock")
b.try_lock()
print ("write")
b.write(d)
print ("strobe")
stb.value = False
stb.value = True

print ("done")
while True:
    time.sleep(1)
``` looks like this is approximately what I last wrote to code.py, earlier I had seen it was dying after the s.write call.  Wonder why.
#
nrfx_spim_xfer (p_instance=0x200044a0 <spim_peripherals>, p_xfer_desc=0x2003fd28, flags=0)
    at nrfx/drivers/src/nrfx_spim.c:581
581            while (!nrf_spim_event_check(p_spim, NRF_SPIM_EVENT_END)){}
(gdb) where
#0  nrfx_spim_xfer (p_instance=0x200044a0 <spim_peripherals>, p_xfer_desc=0x2003fd28, flags=0)
    at nrfx/drivers/src/nrfx_spim.c:581
#1  0x00055d6e in common_hal_busio_spi_write (self=self@entry=0x20008680, data=0x200086d0 "\377\377\377\377", 
    len=<optimized out>) at common-hal/busio/SPI.c:249
onyx hinge
#

it's mesmerizing, and there are a bunch of numbers you can try changing and see what they do ๐Ÿ™‚

#

(never did make any headway on my spi crash ๐Ÿ˜ฆ )

manic glacierBOT
#

I ran the following code:

import board
import busio
import digitalio
import time

b = busio.SPI(board.SCK, MOSI=board.MOSI)
stb = digitalio.DigitalInOut(board.D5)

stb.switch_to_output(True)
d = bytearray(4)
d[0] = d[1] = d[2] = d[3] = 0xff
b.try_lock()
b.write(d)

and it hangs during write. The last few frames of the traceback are:

Program received signal SIGTRAP, Trace/breakpoint trap.
nrfx_spim_xfer (p_instance=0x200044a0 , p_xfer_desc=0x2003fd28, flags=0)
...
onyx hinge
#

hm that read a little snippy. wording hastily revised ๐Ÿ™‚

#

'night and merry xmas. ho ho ho.

manic glacierBOT
tawdry gust
#

So it turns out if you try to instantiate a UART on a 4mb ESP32 micropython build it just gives a guru meditation error.

#

And crashes and reboots

manic glacierBOT
manic glacierBOT
tulip sleet
#

@tough flax I am writing code, but it's not done. Bonding is my first priority right now

tough flax
#

Happy Hanukkah @merry turretb. Let me know (after tonight) if I can help test.

tulip sleet
#

@tough flax HID should work with just pairing. You just have to pair each time (and maybe forget the device in between0; the only thing bonding is adding is not having to re-pair.

manic glacierBOT
#

fix race condition with setup packet + scsi status response
adafruit/Adafruit_TinyUSB_Arduino#37

Also use the new dcd_edpt0_status_complete() to prepare for next setup packet, and SET_ADDRESS request
https://github.com/hathach/tinyusb/blob/master/src/portable/microchip/samd51/dcd_samd51.c#L151

composed of
https://github.com/hathach/tinyusb/pull/243
https://github.com/hathach/tinyusb/pull/244
https://github.com/hathach/tinyusb/pull/245

manic glacierBOT
#

I tried this directly from https://github.com/hathach/circuitpython/tree/samd-improve-usb. On a cold restart (plugging in USB cable), there are severe delays. CIRCUITPY mounts, but it takes a very long time (see the 11 second gaps):

Dec 25 13:09:22 salmonx kernel: [517406.491287] usb 3-1: new full-speed USB device number 56 using xhci_hcd
Dec 25 13:09:22 salmonx kernel: [517406.654664] usb 3-1: New USB device found, idVendor=239a, idProduct=8026
Dec 25 13:09:22 salmonx kernel: [5174...
manic glacierBOT
manic glacierBOT
#
[adafruit/circuitpython] New branch created: badge\-develop
#

Building the ports/atmel-samd/pybadge_airlift firmware (as of the morning of 12/25/2019) and then loading it onto a PyBadge (I don't see a hardware rev designation) causes the board to stop working. By that, I mean CIRCUITPY doesn't reappear as a mass storage device the display doesn't initialize (it stays dark with no backlight). The bootloader, however, works, so I can load the ports/atmel-samd/pybadge firmware (built at the same time) to restore functionality.

Let me know if you need an...

manic glacierBOT
lone axle
#

Is there already effort underway to bring the Bluefruit Playground app to Android?

manic glacierBOT
lone sandalBOT
slender iron
#

@lone axle not that I know of

obsidian compass
#

Hi, Is there a sample code where multiple rotary encoders have been interfaced to a board running CP?

#

Need it for a project

manic glacierBOT
manic glacierBOT
lone axle
#

@slender iron Santa brought me a Circuit Playground Bluefruit, and I've got a knack for making things with Android. I think I'm going to have a go at starting a version of Bluefruit Playground for Android.

manic glacierBOT
#

The issue is caused by race issues when receiving SETUP packet, that cause the setup sometime get lost. The issue exists, but got worse with latest changes (that make timing is just right for the issue).

@tannewt @dhalbert I recently made several improvements for samd51 then mostly copy over to samd21. I am tired of copying, so I take this chance to unify them into single dcd_samd.c file as well. SAMD51 split the interrupt source into multiple IRQ, there is a bit of overhead when putti...

slender iron
#

@lone axle that would be amazing! Let me know if you have any questions about the BLE service API

old smelt
stuck elbow
#

that's a big chip

stuck elbow
#

anybody remembers how to access arbitrary memory locations in CP?

solar whale
#

@stuck elbow is is builtins.memoryview?

solar whale
stuck elbow
#

no, memoryview is a way to slice and dice bytearrays

#

ctypes is for calling C functions on Unix

solar whale
#

oh well -- sorry -- not much help.

stuck elbow
#

yeah, I seem to remember talking with tannewt about making a library that gives you access to the bootloader config, and I think he said you could do that in pure python

#

but I may be remembering wrong

stuck elbow
#

so PewPew M4 works with MakeCode Arcade

#

only had the time to test it now

timber mango
#

Is uctypes.bytearray_at(addr, size) in CP? That would work. Edit: oh sorry, already mentioned.

stuck elbow
#

it's only in the Unix port

#

not on the microcontrollers

#

thanks for looking, I guess I was wrong

twilit geyser
#

Can I do something like pms_uart = busio.UART(board.D13, board.D12, baudrate=9600, timeout=10)? Software UART's fine, if I don't have to write one

#

I know Arduino has SERCOMs

ruby atlas
#

Hrm, I seem to have caused a feather nrf to not boot circuitpython. the bootloader gladly starts up, but when booting 5.0.0b2 (or my own branch build) it flashes the nepixel red once then clears it. Not sure how to check what it's doing from jlink/gdb too see what's going wrong.

stuck elbow
#

@twilit geyser sure, it should work, as long as you pick pins that support uart

#

@ruby atlas there was a learn guide on debugging

ruby atlas
#

@stuck elbow i'll guess i'll start by double checking if i even hit the circuitpython code by stepping every instruction.

stuck elbow
#

you can display the call stack to see where you are

ruby atlas
#
#0  0x00027000 in cpu_get_regs_and_sp ()```
stuck elbow
#

that doesn't look very promising

ruby atlas
#
^C
Program received signal SIGTRAP, Trace/breakpoint trap.
[Switching to Thread 57005]
0x000f9f9a in ?? ()
(gdb) bt
#0  0x000f9f9a in ?? ()
#1  <signal handler called>
#2  0x00000000 in ?? ()
#3  0x00000adc in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)```
#

ya

stuck elbow
#

memory corruption?

ruby atlas
#

or maybe flash corruption?

stuck elbow
#

I meant something is overwriting the stack

ruby atlas
#

oh, yeah, i agree.

#

or the stack isn't from circuitpython - "start" isn't stopping.

#
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Temporary breakpoint 1 at 0x438e0: file ../../main.c, line 406.
Starting program: /Users/rhooper/Devel/cp/circuitpython/ports/nrf/build-feather_nrf52840_express/firmware.elf```
#

time to re-build, re-flash, and re-try.

stuck elbow
#

good luck

twilit geyser
#

@ruby atlas How do I create one?

#

I did it in Arduino on the same board same pins

onyx hinge
#

@old smelt I'm excited about Evo M51, even though I don't have a use for it in mind...

old smelt
#

Thanks @onyx hinge! It's fun to see things start coming together.

ruby atlas
#

Hrm, had to (re-)flash the bootloader then flash 5.0.0 beta 2. (Now re-flashing my build)

manic glacierBOT
#

While the MAC is still changing every power cycle, calling ifconfig appears to correctly set the IP address now (v4.1.2):

# set up networking
spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)

eth = wiznet.WIZNET5K(spi, board.D10, board.D11)
eth.ifconfig(('10.2.1.220', '255.255.255.0', '10.2.1.1', '10.2.1.1'))

I didn't need to explicitly disable DHCP, and the correct IP shows up in eth.ifconfig() calls after a few seconds.

manic glacierBOT
lone axle
#

@slender iron in the Bluefruit Playground BLE services API do we need to do anything to "enable" the outputs? I think I've got the CPB connected to Android and I've found each of the services that it offers with the adaf... UUIDs. As a first test I'm attempting to read from the temperature service / characteristic (adaf0101-c332-42a8-93bd-25e905756cb8) but I am always getting back null data. Wondering if something else needs to be done before the first value can be read.

slender iron
#

@lone axle are you paired?

#

that might matter

lone axle
#

Hmm that could be my issue perhaps. I didn't do any sort of manual pairing process like I would for headphones or a speaker. But I am connected enough from the Android code to list out the services and characteristics. Maybe I need to be paired more explicitly to use them

slender iron
#

it doesn't look like it needs it

#

there is a measurement period characteristic that might need to be set

lone axle
#

I did try setting characteristic (adaf0001-c332-42a8-93bd-25e905756cb8) to 0 then wait 500ms and attempt temperature read, got null that way as well

slender iron
#

hrm, @gentle bronze would know

#

(he may be asleep though because it's getting late for him)

lone axle
#

ah, 0 is update when change, maybe I should try 1 or something more specific

#

thank you for that link, I found the iOS code but hadn't come across the CPB side yet.

gentle bronze
#

value in is period in ms, 0 is update on changes, -1 is disabled ๐Ÿ™‚

#

Measurement Period: 0001
{ int32: period }
Read + Write
period = 1 to 2^31-1: Milliseconds between measurements
period = -1: Stop measuring
period = 0: Update the measurement whenever it changes, as often as possible

slender iron
#

@gentle bronze what is the default value?

gentle bronze
#

for temp it is 1000 (ms)

lone axle
#

I tried setting to 0 and 1, in both cases I get success result from android setValue() function call, and afterward I can successfully read the int that I wrote from the 0001 period characteristic. But still getting null when I attempt to read value from 0101 temperature characteristic 500ms later.

gentle bronze
#

it is the arduino implementation default, not the specs default though

#

did you enable the cccd of the 0101 characteristic

lone axle
#

Hmm, to be honest, I'm not sure what that means so I'm guessing not

#

I am a bit new to BLE, reading into CCCD a bit now. Tis probably part of my problem. Thank you

gentle bronze
#

write value 0x0001 to cccd to enable the notification on a char, CPB will start a timer for sampling temp

prime flower
#

@solar whale Did you ever figure out the "behind the scenes" issue with the ESP-IDF's NTP call?

slender iron
#

@gentle bronze shouldn't a read work even if notifications aren't active?

lone axle
#

I did find a descriptor on the 0101 temperature characteristic it's uuid is "00002902-0000-1000-8000-00805f9b34fb" which I think is the one for cccd. Tried writing the Android API constant BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE as well as a byte array constant like: {0x0001, 0x0000}. Both indicate success true on the gatt.writeDescriptor() function call but still always getting null when I attempt to read the temperature characteristic.

idle owl
#

<@&356864093652516868> Today is the last day to add your hug reports and status updates to the Notes Only Edition of the CircuitPython Weekly! Please try to have your notes in by 4pm Eastern. If you need more time, let me know directly and I'll do what I can to work around it. The next time we'll be meeting in Discord is 6 January 2019 at 11amPT/2pmET. Hope you're all having a wonderful holiday! https://docs.google.com/document/d/1qcUDQqpMWpGJG-k72A39dbQ3a86JXMlnighWci6pS20/edit

slender iron
#

@lone axle that sounds like the right approach

#

does android have an api for setting the cccd itself? nrf does

lone axle
#

I didn't find anything mentioning cccd in the API, I was able to find it with this getDescriptors() function on the BluetoothGattCharacteristic instance for the 0101 characteristic.

slender iron
#

ya, descriptor is the right thing

#

can you set its value?

lone axle
#

I wonder if I should be attempting to listen for the notifications instead of attempting to read it once more manually

#

That portion of the code looks like this atm:

                                Log.d(TAG, "descriptor: " + desc.getUuid());
                                desc.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
                                boolean descWriteResult = gatt.writeDescriptor(desc);
                                Log.d(TAG, "descriptor val : " + desc.getValue());
                                Log.d(TAG, "descriptor write result : " + descWriteResult);
#

Where desc is the BluetoothGattDescriptor instance with uuid 00002902-0000-1000-8000-00805f9b34fb and gatt is the BluetoothGatt object with the open connection

#

Hmm, earlier hathach mentioned the default period value for temperature characteristic is 1000. I attempted to read that value before writing as well and I am getting null value when I read that as well

#

maybe I have a larger issue that is causing all of the reads to fail. I will tinker with it some more. Thank you though I think you guys got me pointed in the right direction

lone axle
#

I managed to get -Infinity instead of null reading the temp so, getting closer I think.

ruby atlas
#

Hmm, is there a better spot to set a breakpoint than softdevice_assert_handler to catch why I'm ending up in the hardfault handler?

66      STATIC void softdevice_assert_handler(uint32_t id, uint32_t pc, uint32_t info) {
(gdb) bt
#0  softdevice_assert_handler (id=1, pc=87328, info=0) at common-hal/_bleio/Adapter.c:66
#1  0x00024a44 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)```
manic glacierBOT
#

Interesting. I'll xheck it out.

On Sat, 28 Dec 2019, at 03:13, Sean Sube wrote:

Revisited this over the break using v4.1.2, and with a few tweaks to my code (and a fixed IP address https://github.com/adafruit/circuitpython/issues/2274#issuecomment-569294120), things seem more stable with the Feather M4/Ethernet Wing setup:

[09:38:29] ssube@cerberus ~/code/ssube/prometheus-express (master@93aa0347) > time ./scripts/bench-curl.sh
...
Request: 9800 of 10000
Request: 9900 of 10000
Request...

drowsy geyser
#

I notice there's no documentation of the stm32f4 port on circuitpython.readthedocs.io. Is this by design, or is there something I can help configure?

lone axle
#

@slender iron @gentle bronze I've managed to get successfull reads

#

Thanks you both for the help. I'm able to subscribe to notifications on the buttons now and get good results back that represent the states. Didn't get the temperature working yet, but I think I should be able to figure out the rest of them.

lone axle
#

I got temperature working as well now. I was getting -Infinity due to differences in the float formats I think. Wrapping with a different byte order like this is allowing me to get usable values out of the temperature notification:
float tempVal = ByteBuffer.wrap(characteristic.getValue()).order(ByteOrder.LITTLE_ENDIAN).getFloat();

slender iron
#

@lone axle nice job!

#

@drowsy geyser we probably need to add something to the docs directory for it

manic glacierBOT
gentle bronze
#

@lone axle glad that you work it out. @slender iron yeah with cccd disabled, the active read will return the most recent sample

lone axle
#

I think there will be similar issues with writing to the services. I'm having a go at the tone service now, but probably will call it a night soon.

manic glacierBOT
#

SPI and I2C do it a different way, like this, in the constructor. They do disable in deinit(), and in the constructor, they try to do do an nrfx init(), and only if that fails do they do the uninit(). I can't remember exactly why, but this was a better choice. Is UARTE different for some reason? Maybe it should follow the pattern in SPI and I2C.

    nrfx_err_t err = nrfx_spim_init(&self->spim_peripheral->spim, &config, NULL, NULL);

    // A soft reset doesn't uninit the driver ...
lone axle
#

Hooray! The tone playing is working now.

drowsy geyser
#

@slender iron Ok. I haven't read the "how to generate the docs" docs yet, but I just wanted to offer.

manic glacierBOT
#

I have the Feather STM32F405 Express board. I built firmware for it on Christmas. I have an LPS3x bord connected via QT. If I just print data, everything is fine. If I try to push the data to AdafruitIO, though, I get an error "AttributeError: 'str' object has no attribute 'encode'. When I run
adafruit/Adafruit_CircuitPython_AdafruitIO/examples/mqtt/adafruit_io_simpletest.py it throws the same error and backtrace. Here's the backtrace, code to follow down below.

Press any key to ente...
manic glacierBOT
manic glacierBOT
manic glacierBOT
#

I was able to create a workaround by editing adafruit_minimqtt.py tp replace all the .encode calls to use bytes(string,"UTF-8") or equvalent fro the calls:
here are the diffs:

jerryneedell@Ubuntu-Macmini:~/projects/stm32f405/airlift$ diff adafruit_minimqtt.py ~/projects/adafruit_github/Adafruit_CircuitPython_MiniMQTT/
121c121
<         if self.password is not None and len(bytes(password,"utf-8")) > MQTT_TOPIC_LENGTH_LIMIT:
---
>         if self.password is not None and len(pa...
manic glacierBOT
#

false hope -- this workaround does not work for the originally posted issue
fails with ```Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 2.0.0-6036-g7387f6092 on 2019-12-28; Feather STM32F405 Express with STM32F405RG

import minimqtt_demo
Connected to Adafruit IO! Listening for DemoFeed changes...
Subscribed to jerryn/feeds/DemoFeed with QOS level 0
Publishing a new message every 10 seconds...
Publishing 38 to DemoFeed.
Traceback (most recent...

manic glacierBOT
lone axle
#

Got the light sensor, accelerometer, and neopixels working successfully this morning. I think I've got everything from the iOS app now. Time to build out a more generalized component to control everything and then build out the GUI.

Is there any video that goes more in depth on each module within the iOS Bluefruit App than this one: https://www.youtube.com/watch?v=pThUwgZF6p0 ? I will try to match the iOS interface as best as possible but I don't have a iDevice to play with the app so I'll have to work from a video for now.

Preview of "Bluefruit Playground" ... working on the best way to record the iPhone screen and the wireless Circuit Playground Bluefruit (Nordic nRF52840). Using Wirecast for now...

#bluetooth #iphone #ble

Visit the Adafruit shop online - http://www.adafruit.com

-----------...

โ–ถ Play video
slender iron
lone axle
#

Done.

onyx hinge
#

boy there's nothing like starting a "full" keyboard implementation to make you appreciate how much is baked into easyavr / qmk! a bit bogged down in just how to handle "layers" at the moment.

manic glacierBOT
#

@jerryneedell CIRCUITPY_FULL_BUILD is a setting directed at the features in py/circuitpy_mpconfig.mk, and was created for new boards such as the STM32 that do not include all features yet. It should probably get revisited to either update existing ports to use it (CXD does not, for instance) or remove it in favor of manually disabling everything that isn't used per port.

Could you try manually adding the MICROPY_CPYTHON_COMPAT setting to mpconfigport.mk, or moving it from full to minimal ...

manic glacierBOT
#

When attempting to run the sample circuitplayground_button_a.py code that came with the CircuitPython 5 bundle (adafruit-circuitpython-bundle-5.x-mpy-20191228). Code crashes at imports due to

no module named 'adafruit_lis3dh'

This is with adding the adafruit_circuitplayground to the lib folder on the CircuitPlayground Bluefruit.

From online searching it implies their is an error with the CircuitPython build or the Ada library. If you think this is user error please let m...

#

@hierophect I made this change

jerryneedell@Ubuntu-Macmini:~/circuitpython_jerryn/ports/stm32f4$ git diff
diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h
index 932d4f855..ff6b7f4ad 100644
--- a/py/circuitpy_mpconfig.h
+++ b/py/circuitpy_mpconfig.h
@@ -182,7 +182,7 @@ typedef long mp_off_t;
 
 // Remove some lesser-used functionality to make small builds fit.
 #define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (CIRCUITPY_FULL_BUILD)
-#define MICROPY_CPYTHON_COMPAT     ...
slender iron
#

@onyx hinge have you seen kmk? circuitpython keyboard software inspired by qmk

onyx hinge
#

@slender iron ooh I'll look

slender iron
manic glacierBOT
manic glacierBOT
ionic elk
#

@slender iron is there any way at the moment to edit the contents of a bitmap for displayIO directly?

slender iron
#

@ionic elk bitmaps support assignment of pixels via []

ionic elk
#

Sweet. So I can perform a transform pixel by pixel?

slender iron
ionic elk
#

can I turn an OnDiskBitmap into a regular bitmap?

slender iron
#

no, because we assume OnDiskBitmap files won't fit in memory

ionic elk
#

gotcha

manic glacierBOT
#

It seems very strange to choose the function monotonic_ns() when you cannot achieve nanosecond resolution. What is the point of using ns, rather than ms. monotonic_ns() gives the user the immediate impression that the function provides nanosecond resolution; what else could it mean? Why else does it exist?

A compounding issue is that the resolution restriction is not documented in the circuitpython docs, along with the unit that time.monotonic() yields.

ionic elk
#

@slender iron in that case, is it possible to make a regular bitmap out of an on disc bitmap? Since onDiskBitmap isn't subscriptable. nevermind found imageload

manic glacierBOT
#

Ah, thank you! I actually have never seen time.monotonic_ns() in Python3 before, so I assumed it was a CircuitPython specific function. I was just using it to benchmark a sampling rate, and realized the output was too chunky by about 3 orders of magnitude. Yes, I'll open an issue shortly about the documentation; as CircuitPython is geared more towards beginners, it seems important to equip them with details of function inputs and outputs.

#

In general, any module in CircuitPython whose name matches a CPython (regular Python) module has an API that is the same or a subset of the CPython API. This way people can write programs in CircuitPython and expect them to run on CPython if they use the standard CPython modules. This is unlike MicroPython, which feels free to alter the CPython API. In the past, MicroPython prefixed their modules with "u" (like ujson) to indicate they were not compatible with CPython, but they are moving aw...

manic glacierBOT
#

I've used MicroPython quite a bit, which is probably why I was confused. Very unfortunate that they are moving away from that; It makes sense that a domain specific language (or branch) would provide different functionality and toolsets than one for general computing, but this comes with the requirement that nomenclature indicates the difference between the parent language and the domain specific language. As I'm just starting to look into CircuitPython, I find it an interesting middle ground...

manic glacierBOT
#

It looks like lines 307 and 312 of py.mk use the alias PYTHON rather than PYTHON3 which is used later in the file (at 330 and 338). Evidently this breaks building mpy-cross if your system does not point python at the python3 . Changing the PYTHON references to PYTHON3 fixed it for me on a completely vanilla, brand-new WSL install of ubuntu 18.04

manic glacierBOT
lone sandalBOT
subtle sun
#

@tulip sleet I am updating my fork of circuitpython for a badge i am working on. I seem to have a problem with I2C. I get an exception with "SDA or SCL needs a pull up". When i looked through the changes since my last pull i saw that you made a change effecting I2C https://github.com/adafruit/circuitpython/commit/85a648224fea027eb3635b7a3746cd6c12d738a6 . I am trying to understand what has changed. If i understand correctly the code now checks for presence of external pull up resistors. Could you please explain to me why this is necessary? aren't the built in pull up resistors enough?

tulip sleet
#

@subtle sun busio.I2C does not use the internal pullups. It expects external pullups on the devices (e.g., on the breakout board). And there are not external pullups on the microcontroller board.

#

So the code checks that there is actually an I2C device connected, with proper pullups. This code is not new.

#

The internal pullups are quite weak (20kohms, if I remember right). The external pullups are typically 10k, and on a few devvices you need stronger pullups (typically 2.2k - 4.7k)

subtle sun
#

@tulip sleet I see that the code has existed on the samd port but this commit introduced it to the nrf port. It seems that the twim peripheral on the nrf which is used to implement busio.I2C does use the internal pullup. I see this issue when using I2C Addons (SAO) which don't always have pullups.

#

@tulip sleet if i understand correctly you are saying that not using an external pullup is bad practice. It may work but it is not guaranteed.

tulip sleet
#

you are right, using the TWIM driver does turn on the pullups, which are 13kohms. However, this is not true on other boards.
...
yes, that's what I'm saying. We've seen some devices for which 10k pullups are insufficient. Our practice of adding pullups to all our I2C breakouts is from long ago (possibly partly due to how Arduino did I2C).

#

in the case of #2253, there are two external pullups on the unpowered device. They are both connected to the +V for that device, but they are unpowered, so it's basically like a 20k resistor between SDA and SCL, and that causes the TWIM peripheral to hang.

subtle sun
#

Thanks for the explanation. I think i will build an adapter for last years badge with pullups and add pullups directly to the new badge. Hopefully that should solve this for me.

tulip sleet
#

does the SAO "standard" have no pullups for I2C devices on the SAO add-on?

subtle sun
#

To the best of my knowledge this is not required.

tulip sleet
#

The "S" in SAO does have relevance here, maybe ๐Ÿ™‚

stuck elbow
#

iirc almost no addon actually uses the i2c

#

they just use the power pins

#

but from the design perspective, the pullups should be on the addon

tulip sleet
#

when I first saw a board with SAO, and that it used an unkeyed 2x2 connector, I thought it was aptly named.

#

@stuck elbow thanks for your informed comment; I am pretty unfamiliar with them

subtle sun
#

@stuck elbow This is generally true. I am testing one that does and we are planning to make a bunch. @tulip sleet the new SAO use 2x3 and have a keyed version.

stuck elbow
#

I think the latest version of the connector, V.1.69Chtulhu, has a key

ionic elk
errant grail
#

I've found that external I2C pullups are essential for reliably extending the length of the interconnecting cable. The I2C bus is designed to be mostly a current-based interconnect (from the host's perspective) to help with noise immunity, I believe.

timber mango
lone axle
#

Still lots to do, but it's coming along nicely. Tone generator is the first working module with an interface.

manic glacierBOT
#

I have flashed this STM F405 feather numerous times.
here are my repeated steps:
install jumper wire between 3.3v and B0.
insert usb cable. yellow light flashes.
remove jumper wire.
program following STM32CubeProg steps and receive "File download complete alert"

what i get is the neopixel pulsing green, the yellow led still rapidly flashing, and no circuitpython drive coming up on my computer.

manic glacierBOT
#

With a file testme.py which consists of the single import statement:

import adafruit_circuitplayground.express

I get a maximum recursion depth error:

Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 5.0.0-beta.0 on 2019-11-19; Adafruit CircuitPlayground Express with samd21g18
>>> import testme
Traceback (most recent call last):
  File "", line 1, in 
  File "testme.py", line 1, in 
  File "adafruit_circuitplayground/express.py", line 699,...
arctic hamlet
#

Technical question: Is it possible to share the SPI bus between the (Q)SPI flash memory allocated as external memory and say an SD card connected to same SPI bus? Currently when trying I get a "pin in use" style error when trying to connect the SD card over the same SPI bus. And apologies if this is not the right place, I considered an issue on GitHub, but is this an issue? /Bjarke

drowsy geyser
#

I know tomorrow's meeting is text-only, and I seem to remember there will be the normal Show and Tell and AaE on Wednesday, but are there any special Adafruit events Tuesday or Wednesday that I missed? (I know Big Clive is doing a livestream, but that starts at 1300 Pacific...) You know what they say about New Year's - whatever you are doing will be plentiful for the rest of the year, so I figure hanging out with "electronics Internet friends" is a good thing to do.

solar whale
#

@arctic hamlet I'm not sure I understand what you are trying to do. Have you modified the core Circuitpython code to do this or are you trying to do it in in python code? Can you provide an example of what you have tried?

arctic hamlet
#

@solar whale We have created our own port, with a mpconfigboard.mk containing:
LD_FILE = boards/samd21x18-bootloader-external-flash.ld
USB_VID = 0x04D8
USB_PID = 0xED5E
USB_PRODUCT = "XinaBox CW03"
USB_MANUFACTURER = "XinaBox"

CHIP_VARIANT = SAMD21G18A
CHIP_FAMILY = samd21

SPI_FLASH_FILESYSTEM = 1
EXTERNAL_FLASH_DEVICE_COUNT = 1
EXTERNAL_FLASH_DEVICES = GD25Q32C

#

@solar whale, that flash runs on the same SPI pins as my SD card, so when I used the SD card, it says one of the SPI pins are in use.

#

@solar whale, obviously the CS is different between the flash and the SD card...

solar whale
#

@arctic hamlet ah -- ok -- then I will step back an let the core developers respond -- but it sounds like you are trying to create the allocate the SPI bus pins twice rather than share the SPI bus and just have distinct selects.

arctic hamlet
#

yes @solar whale, I think that is what I am doing, but since it happens two different places (one being when compiling the CircuitPython .uf2 (in C I assume) and one being inside the CircuitPython in ... Python), I don't know how to tell either in C or in Python to share/use shared pins.

solar whale
#

I can see how that would be an issue! I thought possibly you were adding the SDCard interface into the core C code.

arctic hamlet
#

No, I am adding them as Frozen libs:
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD

#

And that works fine if I don't use external flash, such as if I do:
LD_FILE = boards/samd21x18-bootloader.ld
USB_VID = 0x04D8
USB_PID = 0xED5E
USB_PRODUCT = "XinaBox CW03 SD"
USB_MANUFACTURER = "XinaBox"
CHIP_VARIANT = SAMD21G18A
CHIP_FAMILY = samd21
INTERNAL_FLASH_FILESYSTEM = 1

solar whale
#

OK -- so then do you configure the two SPI devices in your python code? Or is the External Flash done in the C code and you are trying to do the SD card in Python?

#

As I said, I should let one of the core developers try to help you.. I wish I could help more.

arctic hamlet
#

Thanks, @solar whale, so the SD card SPI device is configured in my python code, and the the external flash is done in the C code ... so the latter of your 2 questions. Thank you anyhow, I will await the core developers, when they got a minute. ๐Ÿ‘

onyx hinge
#

hi all! I'll continue to be "out" through thursday

#

bummed because winter static electricity seems to have taken out one of the touch pads on my pyruler ๐Ÿ˜ข sparky

solar whale
#

@onyx hinge I had a similar failure on a gemma_m0 -- I guess they "wear out"

onyx hinge
#

my user reported feeling a static shock when she touched the pad which then never worked again...

#

it always reads the same high value now

solar whale
#

IIRC on mine, the pin also was not useable as output any more

onyx hinge
#

I've always been SURPRISED not to kill a pin with static discharge yet, since getting back into electronics with circuitpython. Used to be a very common failure mode, it seems like.

#

I may experiment and see if I can cover the exposed pads with a clear lacquer, which should not affect cap touch but (my gut tells me anyway) should mitigate ESD

solar whale
#

May be a long day -- waiting for the snow to change to ice and take out the power lines.....

cursive condor
#

the snow is scheduled for noon here : warning for 25-35 cm (8-12") in 24h or so...

solar whale
#

I'm in NH -- started snow last night but may change to freezing rain -- Much worse in the western part of the state. We may be spared on the seacoast... up to .5inchs of ice expected in some areas -- poor trees....

#

only 5 inches of snow predicted -- no concern there!

#

@idle owl is there another "notes-only" meeting today -- or just resume normal meetings next Monday?

onyx hinge
#

@solar whale just next Monday

drowsy geyser
#

@solar whale Hanscom AFB is alreay operating on reduced staff. Mid-MA/Boston and North are supposed be bear the brunt of it. I hope you and yours are ok. When I lived in Delaware I was looking into one of those 10KW Koeler(?) LPG generators, because hurricanes. I didn't mind the storms, it was the days-long power outages.... I imagine you're in the same boat.

raven canopy
drowsy geyser
#

@solar whale Here in the Pugent Sound area they (1) don't like road salt because it gets into the water supplies, and salmon. (2) don't get enough snow to invest in road-clearing equipment. On those occasions when it does snow, given all the hills, it can be a dicey proposition. Last February we got 10 inches and the greater Seattle area basically shut down.

raven canopy
#

Hanscom was likely on skeleton already. Tis the season... ๐Ÿ˜

manic glacierBOT
solar whale
#

@drowsy geyser We are lucky in that we live on the same block as the schools so we tend to get power restored quickly! We have a wood stove for heat and our gas stove and water all work without power so it's really not too bad for us when it goes out. My daughter live in Seattle and we hear the tales of the impact of snow on the area. Having learned to drive here, she is amused by the panic that ensues when it snows ๐Ÿ˜‰

drowsy geyser
#

@solar whale Oh yeah. I grew up in Indiana (much snow/ice/cold) and then lived for a long time in Delaware, where we'd get Nor'Easters four or five times a year that down by the coast we'd get 35+ inches each time. I've driven to work in Jeep with snow sheeting back over the hood because it was deeper than the Jeep was tall. Then everyone here freaks at anything more than a heavy frost. It's fairly amusing.

manic glacierBOT
#

Adds the MICROPY_CPYTHON_COMPAT flag to the STM32 port, which does not currently use the FULL_BUILD setting. Resolves #2433.

I think this might be a good opportunity to discuss the build settings in py/circuitpy_mpconfig.mk, since they're getting a little bloated. Right now we have:

  • CIRCUITPY_FULL_BUILD (everything on the list)
  • CIRCUITPY_SMALL_BUILD (just turns off full build only items)
  • CIRCUITPY_DEFAULT_BUILD (everything not in full build
  • CIRCUITPY_MINIMAL_BUILD (turns ...
lone axle
manic glacierBOT
idle owl
#

<@&356864093652516868> Reminder, no meeting today! Next recorded meeting is 6 January 2020. Looking forward to seeing you all in the new year!

river quest
#

hi hi @lone axle that is neat! may i add it to the newsletter we do each week?

manic glacierBOT
lone axle
#

@river quest You can for sure. Thank you ๐Ÿ™‚

river quest
#

thanks!

manic glacierBOT
slender iron
#

@arctic hamlet I don't think we have a way to concurrently do QSPI and user SPI

#

you may be able to run the SPI flash over SPI with the board.SPI object that the user code can access too

#

@ionic elk wasn't having much success sharing SPI between flash and display on meowbit though so it might need more work

ionic elk
#

I haven't been able to test it much. I was planning on making an issue as soon as I wrap some other Meowbit issues. But it might just be Displayio that'd have that issue.

stuck elbow
#

I suppose dma makes this really tricky

manic glacierBOT
#

@ladyada

From the top of my head, these are the remaining tasks:

  • [ ] Free up time somehow!
  • [ ] Sort out making it so native method calls can call python subclass overrides (specifically so the native .fill() can call .show() on the python subclass). This is needed for auto_write to work properly with the native .fill(). We could skip native .fill() for now.
  • [ ] Finish writing pypixelbuf so that implementations without pixelbuf work
  • [ ] Test and merge the neopixel c...
ionic elk
#

I was successful in accessing the board.SPI part, but since it blew up USB right after I figured it was likely DisplayIO calls on reset conflicting with required MSC activity

manic glacierBOT
orchid basinBOT
manic glacierBOT
manic glacierBOT
orchid basinBOT
river quest
manic glacierBOT
lone axle
#

I've never done 3D rendering before but going to try to figure it out for the accelerometer next.

river quest
#

Preview of the latest "Python for microcontrollersโ€ newsletter! Last one for 2019! Featuring community projects, sneak peeks of hardware, and more! SIGN UP! โ€œPython for microcontrollersโ€ newsletter! https://www.adafruitdaily.com

https://youtu.be/iE5otclY4TQ

Preview of the latest "Python for microcontrollersโ€ newsletter! Last one for 2019! Featuring community projects, sneak peeks of hardware, and more! SIGN UP! โ€œPython for microcontrollersโ€ newsletter! https://www.adafruitdaily.com

#circuitpython #python #micropython

โ–ถ Play video
manic glacierBOT
#

I have been running into an issue where the hard-fault handler gets triggered on the Feather nRF52840. Unfortunately, the board starts flashing yellow and isn't visible on USB when this happens: neither as a serial port, nor as a drive. Pressing reset is required.

I tried disabling the bluetooth code.
I tried 5.0.0b2
I tried master
I tried new-pixelbuf-api without bluetooth code.
I tried not using pixelbuf at all (just neopixel).
I tired without USB connected.

The same code on...

manic glacierBOT
manic glacierBOT
#

Even on a fresh board, it faulted.

I did, it didn't trigger. Interrupting execution showed it in the NORDIC_SOFT_DEVICE_ASSERT safe mode. I set a breakpoint on softdevice_assert_handler. See below.

(gdb) break HardFault_Handler
Breakpoint 1 at 0x43b16: file supervisor/port.c, line 168.
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /Users/rhooper/Devel/circuitpython/ports/nrf/build-feather_nrf52840_ex...
manic glacierBOT
#

One reason this can happen is if the softdevice detects that it has missed a BLE timing window. This is often due to something else taking too long with interrupts off. I did search for this pc value, but no one has reported that.

It could be that neopixel_write is taking too long somehow. Could you try this specifying DotStars instead? You don't have to actually connect anything, just try the same code.

manic glacierBOT
manic glacierBOT
manic glacierBOT
lone axle
lone axle
#

The rotation pivot point was at the bottom of the board instead of the center I think, that is what was making it a bit wonky still.

inland tusk
#

Was there a circuitpython weekly meeting and when is the recording going up on youtube?

cunning crypt
#

@inland tusk Not yesterday nor last week.

#

The next recorded one is on Monday

inland tusk
#

okay thanks and HAPPY NEW YEAR to everyone

manic glacierBOT
cursive condor
#

@lone axle very nice ...

ruby atlas
#

touch pads control colour, buttons adjust brightness, switch turns off the LEDs.

umbral dagger
#

@ruby atlas Nice!

#

@ruby atlas But doesn't that glare on their iPad screens?

ruby atlas
#

Not much at the default brightness (0.04)

onyx hinge
#

Nice!

raven canopy
#

automate is a pretty good series.

lone sandalBOT
drowsy geyser
#

@raven canopy Ooooh, Python Discord? How does one get an invitation to that server?

raven canopy
drowsy geyser
#

Thanks, @raven canopy !

raven canopy
#

yw!

raven canopy
#

started my CircuitPython in 2020 entry. already feels like the longest first draft in history. ๐Ÿคฃ

manic glacierBOT
tulip sleet
#

@timber mango I edited the GitHub comment to add "So you can change these constants in your mpconfigboard.h"

stuck elbow
#

@tulip sleet thanks! I'm not yet entirely sure if I want nvm or not

#

it could be useful for savegames, but I would need some way of managing saves from multiple games then

tulip sleet
#

you could shrink the filesystem a bit and get back some native modules if you want them. nvm has to be at least one page long (8k) if it exists

pastel panther
stuck elbow
#

@tulip sleet yeah, it's a difficult decision, but I think it's mostly supposed to be for games, not for electronics, so it should be fine, I can still disable analogio if I need more space โ€” it saves a lot

manic glacierBOT
#

The exception was:
'OSError: [Errno 5] EIO\r\n'

I do not have line info but I believe it occurs during an I2C read when the device is not ready [ device.readinto() ]

Unfortunately the crash occurs irregularly and almost randomly. I have the code running on multiple "systems" and at best (from debug point of view), a crash occurs after several hours, and at worst never. This one happened overnight.

I have not tried updating as of yet.

Is there a way to force an automatic restart...

pastel panther
manic glacierBOT
#

You can call microcontroller.reset() to do the equivalent of pressing the reset button.

Do you need 100Hz update? what happens if you lengthen the sleep() in the main loop. I see that the datasheet says it can take 3 msecs or 8.4msecs to get a reading (at "4 MHz" -- I'm not sure what clock frequency it's talking about there, because the max I2C freq is 400 kHz).

Also there is a typo in your test program:

                    FaultCount = FalutCount + 1
manic glacierBOT
#

We are using 4.7K pullups.

The wires we ended up with are shorter - we are deploying the 40mm length.

Crashes are uncorrelated with pressure, or changes in pressure. Usually the crash happens when there is a constant (low) pressure. My overnight failure happened on the bench, with no pressure at all.

I appreciate the questions, and the help.

In my code I plan to replace the time.sleep() statement with the microcontroller.reset() in the exception handler. Is there an easy way fo...

#

To cause an exception, you just raise it: raise OSError, for instance.

The exact part number you gave, FX29J0-040B-0100-L, does not seem to be stocked anywhere. The "J" says I2C without sleep, and no one stocks J models. https://te.com does not list that as a regular item either, though the datasheet implies you could order it (which I guess you did). See below.

So this looks harder to reproduce on our bench. We could get the I2C controller and try that. But do you have a J-Link and...

#

I believe the sensor is new - which is why we ended up ordering the parts digikey had in stock at the time rather than the ones we originally wanted.. And that means we got the K version (with sleep) rather than the J version (which we wanted).

I don't have the setup you describe - so remote debugging is not in the cards at this point. Sorry, but thanks for the offer.

solar whale
#

@pastel panther @trim elm Thanks for the warm welcome to my "inbox" on this New Year!

trim elm
#

@solar whale lol

manic glacierBOT
#

This is the correct sensor. The "sleep" feature may indeed be the cause or part of the cause.
Unfortunately, the IDT controller referenced above is programmable only during manufacturing and not during operation - so sleep can not be disabled once a part is in your hands.

All of the sensors are mechanically identical
The load range is determined by a resistor so it should not affect communications
The cable length is short enough so that it should not be a factor
We are using the conn...

manic glacierBOT
manic glacierBOT
slender iron
#

<@&356864093652516868> here is the CircuitPython 2020 post! I'm excited to hear from you all! https://blog.adafruit.com/2020/01/01/what-do-you-want-from-circuitpython-in-2020-circuitpython2020-circuitpython/

Adafruit Industries - Makers, hackers, artists, designers and engineers!

As 2020 starts, letโ€™s take some time to set goals for CircuitPython in 2020. Just like 2019 (full summary here), weโ€™d like everyone in the CircuitPython community to contribute by posting theโ€ฆ

cunning crypt
#

@slender iron Perhaps the "A post on the CircuitPython forum" could be a link to said forum?

slender iron
#

@cunning crypt good idea. updated!

drowsy geyser
#

Oh, now this has completely de-railed what I was working on. Writing a blog post on my thoughts.

slender iron
#

Thanks @drowsy geyser !

drowsy geyser
#

No worries. I'll give it more thought and update the list as I go. ๐Ÿ™‚

onyx hinge
#

these are a lot more introspective than my first draft

raven canopy
#

hehe. most of mine at this point is "last year"... ๐Ÿ˜„

manic glacierBOT
onyx hinge
#

@raven canopy with my weekly reports, I find I seldom worked on what I said I would. How much less likely is it for a whole year?

raven canopy
#

lol. fair point. i've definitely had This Week: do x entries for multiple weeks.

#

@onyx hinge i do currently have an "overall goal" in my draft at this point, but i will be adding some SMART* goals. (* Specific, Measurable, Achievable, Realistic, Time-based)

obtuse pulsar
#

hoping for any help with a problem initializing I2C on an ItsyBitsy M4 Express to control an Adafruit DRV2605L haptic motor controller - using the example code, I receive an "ValueError: SCL in use" error.

#

Running 4.1.2 with associated drivers

onyx hinge
#

oops wrong link

obtuse pulsar
#

@onyx hinge I will try that

#

@onyx hinge That does not error and returns I2C addresses found: ['0x5a']

onyx hinge
#

Okay, that may mean it's something wrong with the other example. Can you send a link to that code?

#

I do have an itsy m4 if I can find it, but not the motor controller

obtuse pulsar
#
import busio
import adafruit_drv2605
i2c = busio.I2C(board.SCL, board.SDA)
drv = adafruit_drv2605.DRV2605(i2c)```
#

this code causes the error

onyx hinge
#

I see.

#

I tried that code but because I don't have the board, I get this: ```Traceback (most recent call last):
File "code.py", line 5, in <module>
File "adafruit_drv2605.py", line 101, in init
File "adafruit_bus_device/i2c_device.py", line 78, in init
File "adafruit_bus_device/i2c_device.py", line 76, in init
ValueError: No I2C device at address: 5a

#

line 5 is the one which says drv=.

#

Can you paste your whole error, from "Traceback" to the end? And for that first line in code.py, verify whether it's the drv= or i2c= line

obtuse pulsar
#
  File "code.py", line 4, in <module>
ValueError: SCL in use```
#

The line causing the error is the i2c= line

#

newbie question, how do you properly paste code in the chat window to format properly?

onyx hinge
#

Put three of the "backtick" character together: This character: ` at the start and the end

raven canopy
#

```
code
```

code
obtuse pulsar
#

thank you

onyx hinge
#

@obtuse pulsar what you are seeing is really strange. What happens if you move the "import adafruit_drv2605" line below the "i2c =" line? It seems like something unexpected is happening before "i2c =" and this may help figure out what it is.

obtuse pulsar
#
import busio
i2c = busio.I2C(board.SCL, board.SDA)
import adafruit_drv2605
drv = adafruit_drv2605.DRV2605(i2c)```
#

produces

  File "code.py", line 4, in <module>
  File "/lib/adafruit_drv2605.py", line 10, in <module>
ValueError: SCL in use```
onyx hinge
#

How did you put adafruit_drv2605 on your device? Can you erase adafruit_drv2605 from CIRCUITPY and copy it fresh from the bundle?

obtuse pulsar
#
import busio
import adafruit_drv2605
i2c = busio.I2C(board.SCL, board.SDA)
drv = adafruit_drv2605.DRV2605(i2c)```
produces
```Traceback (most recent call last):
  File "code.py", line 4, in <module>
ValueError: SCL in use```
onyx hinge
#

(is it possible that you accidentally put some of your code in adafruit_drv2605?)

obtuse pulsar
#

I will install a fresh library bundle

tulip sleet
onyx hinge
raven canopy
#

note: if using .mpy, none of the comments will be there. i'm suspecting that its line 101 in the raw file (it's the only one that makes sense.) ๐Ÿ˜„

tulip sleet
#

but I still think it preserves the line numbering ??

#

when reporting errors in the backtrace

onyx hinge
#

My error was with a .mpy file too, and it reported what I think is the true location in the .py file, line 101

raven canopy
#

hmm... TIL. nevermind me... ๐Ÿ˜„

obtuse pulsar
#

@tulip sleet I do not have a boot.py on the circuitpy flash

tulip sleet
#

@onyx hinge's point about the line numbering is well-taken. Either the file in lib/ has been changed by mistake or you have another adafruit_drv2605.py or .mpy in the top level directory (which gets searched before lib/)

obtuse pulsar
#

I may try to reflash and start fresh with the OS and LIB bundles to make sure

tulip sleet
#

you don't need to replace the whole bundle, just that .mpy file

raven canopy
#

i'm checking the file in today's bundle. @obtuse pulsar is that the version you are using?

obtuse pulsar
#

12/28

tulip sleet
#

make sure on Linux and Windows when copying to CIRCUITPY via Finder or Explrorer or command line that you eject the drive on windows or sync on Linux

obtuse pulsar
#

will do

tulip sleet
#

that ensures the file is completely copied

raven canopy
#

everything looks copasetic in the bundle (.py and .mpy).

#

๐Ÿฝ๏ธ _ โฐ _

onyx hinge
#

thanks for checking @raven canopy

lone axle
#

Is there any effective difference between setting neopixels to a dark color like (0,0,1) vs. setting them to a bright color like (0,0,255) but also setting the brightness setting down to something low like 0.01?

onyx hinge
#

@lone axle You can change the brightness dynamically

#

so for instance you could set brightness to 0.01, set all your pixels, and then ramp brightness from 0.01 to 1.0 in steps, without recalculating all your pixels

#

(of course, circuitpython is recalculating the pixels for you :))

lone axle
#

I see. Thank you

pastel panther
#

@idle owl, to update the bundle to reflect a lib being renamed, is it as simple as replacing the old with the new in the .gitmodules, docs and wherever else the old one is used?

obtuse pulsar
#

A refresh of the file system and libraries fixed the issue!@onyx hinge @raven canopy @tulip sleet

#

now onward with my haptic project! a haptic remote extension for visually impaired television "watchers"

onyx hinge
#

@obtuse pulsar I'm glad to hear it. Sorry you ran into trouble in the first place!

#

that sounds like an interesting project, I hope you'll let us know more as it progresses.

#

If you haven't met @tough flax it sounds like you should.

pastel panther
#

indeed!

obtuse pulsar
#

will do and thank you...great experience as a first timer with CircuitPython! I will reach out to @tough flax as I have a number of accessibility projects in mind

tulip sleet
#

@obtuse pulsar You may be interested in this: https://github.com/dhalbert/ShortcutBox, which is what got me working on CircuitPython. I built it for a filmmaker with cerebral palsy who wanted to use keyboard shortcuts in Adobe Premiere using foot-operated buttons.

onyx hinge
#

huh seems I toasted the neopixels on this pygamer. They were working, but now they don't light at all. including when I double-click into the bootloader.

#

on my other pygamer they light up when going to bootloader

#

I wonder what happened, I guess I was repeatedly picking up and putting down the board to press buttons, so it could be another static shock

#

๐Ÿ™Ž

#

oh well, time to call it a night!

tulip sleet
#

i think you need a wrist strap! humidity there must be low!

onyx hinge
#

it is and I guess I do

tulip sleet
#

would be interesting to Saleae it and see if you're getting signals to the first neopixel. you could skip over the first if it's the first that's fried.

lone axle
onyx hinge
#

@tulip sleet that occurred to me too

#

looks like the output of the mcu is damaged, no signal can be seen at the input of the first neopixel.

idle owl
#

@onyx hinge Seems unlikely to be static shock, these boards are pretty tolerant.

onyx hinge
#

not sure what else to blame. software shouldn't be able to do that either

idle owl
#

Well if you scoped it and it's not sending a signal, then no, that's pretty likely to be hardware.

#

But I've zapped a Feather so hard that it hurt, made my display flicker, ejected everything I had connected to my laptop and put the board into safe mode. Still worked.

onyx hinge
#

same here, but this week my luck changed

idle owl
#

Fair enough ๐Ÿ™‚

#

@onyx hinge Have a minute to review a super simple PR?

onyx hinge
#

@idle owl happy to, link?

idle owl
#

Pro tip: Your board will not mount CIRCUITPY or *BOOT if you have it plugged into a wall charger and not your computer. ๐Ÿคฆ

onyx hinge
#

I ran into two charge-only cables recently. curse them.

idle owl
#

@onyx hinge Thank you!

#

And yes, they are awful.

onyx hinge
#

you're welcome

manic glacierBOT
ionic elk
#

Ok, I'm properly back today for the rest of January! I've done my best to keep up/catch up on any STM32F4 bugs/happenings but if anyone sees something I don't appear to have responded to, please let me know so I can get on it! @pastel panther just made a note of that I2C displayio thing on the corresponding issue, I'll take a look ASAP

pastel panther
#

@ionic elk welcome back!

onyx hinge
onyx hinge
#

OK, that does it for today's random acts of github.

main meteor
#

I did too. Was having errors flashing old Arduino boards with an FTDI Friend. The problems turned out to be 2 bad Arduinos, 1 bad FTDI Friend, 1 bad FTDI cable, and 2 charge-only USB cables (one mini, one micro). That was a long difficult slog.

#

Note to future self: when you can't connect or even find a port, check the USB listing for your serial chip: if it ain't there, you've got a bad chip and/or a bad cable/port, don't bother looking downstream until it at least enumerates as a USB peripheral.

slender iron
#

@onyx hinge pulseio should work in the background. how slow are the pulses though? it caps out at 16bit microseconds

slender iron
#

@drowsy geyser re your post: feature requests should be done as github issues

#

for the live stream what would you like to see? the in the weeds section tends to be the place we take questions now

ionic elk
#

could someone do a sanity check for me? I need to figure out the difference between these two blocks of code:

    self->chan_handle.OCNPolarity = 0;
    self->chan_handle.OCIdleState = 0;
    self->chan_handle.OCNIdleState = 0;
    self->chan_handle.OCMode = TIM_OCMODE_PWM1;
    self->chan_handle.Pulse = 7000;
    self->chan_handle.OCPolarity = TIM_OCPOLARITY_HIGH;
    self->chan_handle.OCFastMode = TIM_OCFAST_DISABLE;
    if (HAL_TIM_PWM_ConfigChannel(&self->handle, &(self->chan_handle), self->channel) != HAL_OK) 
    {
        mp_raise_ValueError(translate("Could not initialize channel"));
    }

    TIM_OC_InitTypeDef sConfigOC = {0};
    sConfigOC.OCNPolarity = 0;
    sConfigOC.OCIdleState = 0;
    sConfigOC.OCNIdleState = 0;
    sConfigOC.OCMode = TIM_OCMODE_PWM1;
    sConfigOC.Pulse = 7000;
    sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
    sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
    if (HAL_TIM_PWM_ConfigChannel(&self->handle, &sConfigOC, self->channel) != HAL_OK)
    {
        mp_raise_ValueError(translate("Could not initialize channel"));
    }
#

On the STM32F401, only the second, with a locally declared config structure, will allow PWM to start. The first version works on every other STM32 we support.

slender iron
#

are there fields that the first will leave uninitialized?

ionic elk
#

nope, every single field in the struct is initialized in both versions

#

I also tried a memset(&(self->chan_handle), 0, sizeof(TIM_OC_InitTypeDef)); in the first, didn't seem to do anything

slender iron
#

hrm, what is the error code you get back when it fails?

ionic elk
#

No errors. the PWM just either works or it doesn't. Internal values are all as expected.

slender iron
#

did you check the errata for the chip?

ionic elk
#

This works, which is wack:

    self->chan_handle.OCNPolarity = 0;
    self->chan_handle.OCIdleState = 0;
    self->chan_handle.OCNIdleState = 0;
    self->chan_handle.OCMode = TIM_OCMODE_PWM1;
    self->chan_handle.Pulse = 7000;
    self->chan_handle.OCPolarity = TIM_OCPOLARITY_HIGH;
    self->chan_handle.OCFastMode = TIM_OCFAST_DISABLE;
    TIM_OC_InitTypeDef sConfigOC = self->chan_handle;
    if (HAL_TIM_PWM_ConfigChannel(&self->handle, &sConfigOC, self->channel) != HAL_OK) 
    {
        mp_raise_ValueError(translate("Could not initialize channel"));
    }
slender iron
#

hrm, that is doing a copy

ionic elk
#

right. So the values of the chan_handle are fine... but passing it in is screwing up somehow

slender iron
#

is the address of the one in self aligned?

#

what does the hal impl do with it?

ionic elk
#

haven't dealt with data alignment in this context, what are you suggesting?

manic glacierBOT
slender iron
#

@ionic elk print out the address of the two and see if they are aligned

#

I don't think that is it

#

I'd suggest using gdb to look at all of the registers of the timer after you call set

ionic elk
#

I'll give that a shot. I still don't totally get what could be going on with the alignment.

#

is that something I should keep researching here or are you confident that's not it

slender iron
#

it doesn't seem like an issue

#

I'd skip to the register stuff

ionic elk
#

good link

slender iron
#

very helpful

prime flower
#

@slender iron thanks for the "in 2020" post notification, I've been writing my thoughts throughout the last month in prep for a post ๐Ÿ˜„

ivory yew
slender iron
#

๐ŸŽ‰

ionic elk
#

@slender iron just for the record addresses are 0x20007004 (&(self->chan_handle), bad) and 0x20017c58 (sConfigOC), good.

slender iron
#

hrm, so those are both word aligned

#

and probably the same section of ram

raven canopy
#

is now super intrigued on @ivory yew's library package management thoughts. ๐Ÿ˜„

manic glacierBOT
onyx hinge
#

@slender iron interesting, I overlooked that it works that way. For wwvb you need to distinguish .2, .5, and .8 second pulses

slender iron
#

can you do that by just sampling the pin?

manic glacierBOT
ionic elk
#

@slender iron I have determined that the problem is not specific to the F401, but actually to the DEBUG=1 flag of the makefile: IE, whether the cflags -ggdb, -fno-inline, and -fno-ipa-sra are enabled. When they are, the issue does not occur.

slender iron
#

hrm weird

#

so it fails on optimized builds?

ionic elk
#

I had turned DEBUG off to compile at a smaller size to try and fit it into the remaining space allocated by the Meowbit custom bootloader

#

basically yeah. Fails only when I can't look at it lol

slender iron
#

fuuuuun ๐Ÿ™‚

ionic elk
#

and it's at that exact spot: where &(self->chan_handle) is passed in

slender iron
#

you can try with each of those flags off separately

ionic elk
#

When I looked at it with GDB, everything was the same ofc

#

I'll research the flags a bit. But at this point it's worth asking whether I should switch to something else, since I've at least diagnosed the problem and it's quarantined with DEBUG.

slender iron
#

all of our release builds are optimized though

ionic elk
#

Oof gotcha. I'll dig deeper then

#

Probably good to get a nice hard answer here since I'm not sure if other STM32 hal components might be affected. I haven't tested super extensively with DEBUG off - it's enabled in all current builds.

slender iron
#

we should definitely getting it going with opt

#

you can still read the peripheral registers so it'd be worth getting that workflow going

#

asm("bkpt") can break you where you want to too

ionic elk
#

that'll work without ggdb?

#

assuming that's the problem, which it might not be

slender iron
#

ya, I believe so

ionic elk
#

ok, new learnings. i'm on it

slender iron
#

๐Ÿ‘ keep me posted on how it goes

ionic elk
#

what's the biggest benefit to optimized build? Speed or size?

#

Just noting that we can't increase internal filesystem size due to caching

slender iron
#

size and speed due to the inlining

drowsy geyser
#

@slender iron I updated the post with your answers, but the one thing I wanted to clarify is the office hours idea. Here's what I replied: I was actually thinking more along the lines of a university professor or teaching assistant office hours, where any of the students can show up for detailed help or questions. "In the weeds" feels more like the Q&A at the end of Ask and Engineer. Also, since I didn't realize that was open to anyone, for non-CircuitPython-implementation questions, I'm pretty sure other community people won't know that. Discord is great, and people seem to ask in either #help-with-circuitpython or #circuitpython-dev, but I feel like people refrain from long threads in-channel. Office Hours would be a place to interact and teach in a more face-to-face way, if that makes any sense.

manic glacierBOT
onyx hinge
#

-ggdb should be the least capable of introducing behavioral differences, nothing of 'debugging info' makes it to a .bin / .uf2 file

slender iron
#

@drowsy geyser for private discussions I'm going to start a calend.ly for scheduling mentorship time

#

for technical support/help I'd rather do it publicly

#

have you watched any of my streams I did

drowsy geyser
#

Totally understand. Thanks. Uh, no, didn't know you did those streams!

onyx hinge
#

@slender iron background sampling means never having to worry how long foreground stuff takes. The AVR 8-bit MCU ones I've tinkered with just used a 100ms sampling interrupt but you may be right that I am just not framing the problem in the right way to fit with CP.

slender iron
#

@drowsy geyser need a link to the recordings? I'd be happy to do more like them.

drowsy geyser
#

@slender iron Please! I'll binge them this afternoon. ๐Ÿ˜‰

onyx hinge
#

it would be nice to accurately know the time of the transition because one of them (would have to look up which) is synchronized to the start of the second

slender iron
#

@onyx hinge to use PulseIn we could just switch to a 32-bit time value

onyx hinge
#

Or add a prescaler?

slender iron
#

it doesn't use sampling though, it uses extint

#

ya, that would work too

onyx hinge
#

honestly though if CP already could do one of the things I imagined, that's a good outcome too and I'm still happy it was something I posted about ๐Ÿ™‚ ๐Ÿ™‚

#

what the ---- ! my pygamer LEDs are working again, and I didn't change anything

slender iron
#

Live stream of @tannewt debugging memory issues in CircuitPython.

Visit the Adafruit shop online - http://www.adafruit.com


LIVE CHAT IS HERE! http://adafru.it/discord

Adafruit on Instagram: https://www.instagram.com/adafruit

Subsc...

โ–ถ Play video

Go behind the scenes and see how CircuitPython is released as @tannewt releases 4.0.0 Beta 4. Afterwards, have some Friday fun hacking on a GameBoy with CircuitPython.

Originally streamed on https://www.twitch.tv/tannewt/

Visit the Adafruit shop online - http://www.adafruit...

โ–ถ Play video

Scott (@tannewt) did a livestream on how-to review CircuitPython code on his Twitch channel: twitch.tv/tannewt

Scott's sponsored by Adafruit to work full-time on CircuitPython.

Visit the Adafruit shop online - http://www.adafruit.com

---------------------------------------...

โ–ถ Play video
#

@onyx hinge ๐Ÿ™‚ it's interesting to know what things people don't know about

drowsy geyser
#

Thanks, @slender iron !

raven canopy
#

its been so long since i opened the sheet. but wouldn't 32-bit time value consume two TCs? and aren't they specific groups, that might be complicated on a pin-mapped basis? loads the sheet, after asking the question.

manic glacierBOT
#

Do we have a new issue for using the CCRAM? We could definitely use it and free up the normal ram for the circuitpython heap.

I want to start adding more information about memory locations to CircuitPython. The iMX RT line runs code off of flash so we'll want to start designating some code to sit in RAM. We may also be able to speed up execution by moving the stack and other common state to core coupled memory. (mp_state struct is one candidate.)

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

As 2020 starts, letโ€™s take some time to set goals for CircuitPython in 2020. Just like 2019 (full summary here), weโ€™d like everyone in the CircuitPython community to contribute by posting theโ€ฆ

manic glacierBOT
ionic elk
#

what is fno-ipa-sra? Google shows nothing

#

@slender iron

slender iron
#

dan added it, some sort of optimization

#

`-fipa-sra

Perform interprocedural scalar replacement of aggregates, removal of unused parameters and replacement of parameters passed by reference by parameters passed by value.

Enabled at levels -O2, -O3 and -Os.`
manic glacierBOT
onyx hinge
#

@ionic elk Suppose you have a structure: struct pt { int x, y; }; as a local inside a function. If the complier turns it into two variables pt__x and pt__y, it might have new opportunities for optimization. For instance, if it then notices that pt__y was never ever assigned, or an assigned value never used, it can omit it. Like all optimizations, it's not intended to make a visible difference for "conforming code" but of course sometimes we all write code which ends up being interpreted differently than we expected the compiler to do..

#

anyway, that is my lay understanding of what "scalar replacement of aggregates" is ..

ionic elk
#

HMMMMM

#

BIG HMM

#

so, say, in a struct, where you've got a bunch of variables that are getting assigned to registers, it could decide that some of them don't matter, for some reason? Potentially?

manic glacierBOT
ionic elk
#

also I guess dan created no-ira-spa? my mistake was searching for the whole thing as opposed to just the ira-spa part

onyx hinge
#

-fFOO usually enables an optimization, and -fno-FOO turns it off again.

ionic elk
#

so it's an implicit thing

manic glacierBOT
pastel panther
#

@idle owl @ruby atlas I'm about to add a review to the Adafruit_CircuitPython_PyPixelBuf PR, please wait to merge

stuck elbow
slender iron
#

thanks @stuck elbow

manic glacierBOT
ionic elk
#

@slender iron is it OK if I wait on mine until Monday? I've got a Circuitpython buddy here in A2 who uses it full time and we were going to co-op on a post

drowsy geyser
#

@stuck elbow and @slender iron I strongly second a community keyboard design!!!! I've wanted one ever since the Hackster site published an article about it. I would be very much willing to help with requirements and programming (not good enough at PCB design yet.) Definitely would want per-key LED lighting with Cherry MX or Brown switches. BLE. USB interface for wired connections. LiPo battery. OLED status display, etc, etc.

ionic elk
#

But I could push him if earlier is better

stuck elbow
#

@drowsy geyser there is KMK

drowsy geyser
#

Err? Not familiar with it. Off to Google.

slender iron
#

@ionic elk no rush at all. We want to wrap up by the 13th

stuck elbow
#

they have their own discord server

onyx hinge
#

@drowsy geyser I am excited about keyboards too.

slender iron
#

@drowsy geyser @obra from keyboard.io and I were discussing a CP dev keyboard

onyx hinge
#

second hand-wire keyboard in progress, I think I'll be able to slot in the itsy nrf when it shows up on my doorstep ๐Ÿ™‚ ๐Ÿ™‚

#

personally I want some kind of screen and an FN+??? key to switch to the Python REPL on the built in screen and FN+??? to paste the last printed result in as though I typed it. that would be amazing.

#

so! many! things! to be excited about

drowsy geyser
#

That looks interesting, but it's a bit to Kerbal for me. I'd like all the components surface mounted, program directly in CircuitPython, not by adding on boards.

tall vigil
#

Hi folks

onyx hinge
#

I can totally see that POV too. A product couldn't be hand-wired IMO. For me, it's the right choice, due to PCB fabrication costs vs my time being "free"

stuck elbow
#

I'm not sure you can inject characters into the REPL at the moment

tall vigil
#

Coming in completely blind, so possibly totally wrong on context, but I've been loving JLCPCB's low-cost SMT service.

#

They've made me some fairly decent keyboard PCBs with surface mounted components quite cheaply and quickly in the past few months.

onyx hinge
#

@stuck elbow not yet, micropython has some provision for it (webrepl) but it's not in CP at the moment

tall vigil
#

You'd have to hand-solder connectors

stuck elbow
#

@onyx hinge I'm sure @indigo wedge will be working on it for his keyboard wing

onyx hinge
#

It's a bit more complicated for CP, because in micro they can set it up in boot.py and it doesn't have any trouble persisting into REPL or main.py ...

stuck elbow
#

@tall vigil I think I ordered the pcb for my Flouder keyboard from them too, was something like $12

onyx hinge
#

maybe interact.py can be ported from python to circuitpython

stuck elbow
#

@onyx hinge I wouldn't be above having a separate chip for the keyboard handling, talking serial

#

even a stupid atmega would do, or attiny with a shift register

tall vigil
#

Some of our boards, we push the key scanning and last-mile LED driving off to an ATTiny88 so that the user's code doesn't mess with our keyscanning and led driving timing loops

#

Then we talk to that over i2c.

stuck elbow
#

right, here serial would be probably more intuitive

tall vigil
#

For a hobbyist board, I might not bother. But for a product, it's super-useful.

slender iron
#

hi @tall vigil ! thanks for jumping in.

#

I'm very excited for BLE HID support

tall vigil
#

I really need to deal with BLE HID. What's been scaring me off is having to deal with shipping lipo batteries

ionic elk
#

@slender iron I figured out the thing by the way. It was a dereferenced pointer from a totally different part of the code that was being cleverly disguised by the optimizer as a struct issue due to memory organization.

#

I'll get a PR in tomorrow

tall vigil
#

(This is an extreme example of what "full stack" now means in my world ๐Ÿ˜‰

ionic elk
#

@tall vigil Can you package it so the user puts in their own batteries? Because that's way easier

slender iron
#

nice job @ionic elk

#

@tall vigil rechargeable double As aren't good enough?

tall vigil
#

Quite possibly. But it's -not- the common practice in the industry

#

And really, we've got plentry of product backlog ๐Ÿ˜‰

ionic elk
#

Well the industry standard practice is to have a billion dollars

manic glacierBOT
ionic elk
#

so I try not to take too many tips from them ๐Ÿ˜‰

tall vigil
#

It's more about customer perception than anything else

slender iron
#

๐Ÿ‘

tall vigil
#

Though there was a very cheap bluetooth keyboard on kickstarter recently that did...very well.

ionic elk
#

Did they deliver?

tall vigil
#

It's the third product by a funded company

#

They had a unique solution here. They did not make a big deal about it, but the way they want you to use it is to plug in a USB power brick.

#

(We did a kickstarter for our first product. It took us 3 years to deliver. I... have a lot of empathy)

ionic elk
#

I mean most of the time I find Kickstarter projects are a) doomed b) a tiny pretend shell company funded by a chinese OEM to field test a prototype or c) the rare well managed startup that really ought to be on crowdsupply instead

tall vigil
#

I love the folks at crowdsupply. The target demographic is very different than kickstarter.

ionic elk
#

yeah they're fun. But category b) was really my point - they make projects that are actually extremely expensive seem dangerously accessible. They aren't things you want to emulate

tall vigil
#

Interestingly, I'm seeing more and more tiny chinese companies try kickstarter, which is super fascinating.

ionic elk
#

in my experience they are rarely actually tiny

tall vigil
#

I've talked to a bunch of them behind the scenes.

#

I spend a bunch of time in SZ. I've visited some of 'em in person.

#

Really, there are all kinds of things going on

ionic elk
#

Well, I'm just speaking to my personal experience running a KS. YMMV

tall vigil
#

Yup!

#

It's all good

slender iron
tall vigil
#

@slender iron is there other keyboard-related stuff I can be helpful about?

slender iron
#

I don't think so, it's been pretty stable. The last challenging thing was getting BLE HID working with iOS but its been sorted out

tall vigil
#

I absolutely need to play with this ๐Ÿ™‚

#

But I've gotta run for a bit

slender iron
#

๐Ÿ™‚

#

we're here all week

tough flax
#

Thanks @slender iron (and @tulip sleet) - I know you have all been working hard on it - just lots of things in our world that will be much easier w/o the Feather M0 BLE + Arduino code :-

#

๐Ÿ™‚

onyx hinge
#

@slender iron @raven canopy should volume control go in audiomixer if it's being added? Per channel float, default 1.0?

raven canopy
#

@onyx hinge audiomixer has level per voice/channel.

onyx hinge
#

Oh already? Yay!

raven canopy
#

yeah, that's what i was working on with finishing up DeanM's initial work. ๐Ÿ˜„

onyx hinge
#

The site is called read the docs but apparently I don't

raven canopy
#

lol. i'm guilty of it everyday...

tough flax
#

I am making great progress on the USBFilter project that lets me convert weird old USB protocols to standard ones (mainly USB). It "just works" and I'm thrilled with how easy it is to tweak the code in Python for our end-users.... However (there's always a However)....

I am running this on two Trinkets with the USB Host (Arduino) running on one and the other running CP talking over UART to it. And I keep running out of memory. I know I could use an M4 Itsy, but a) that's more cost and I want to make these very affordable and b) it's lots more pins for these kids to solder (more chances to screw up).

The biggest memory hog (I think) is the map that converts (x,y) coordinates to keystrokes. It's a 8x12 array of Keycode values. I switched it to be a tuple of tuples which got me to the point where I can have one grid in memory and it works. When I add a second (for the other side of the keyboard overlay), I get

MemoryError: memory allocation failed, allocating 1265 bytes

Can anyone think of a more efficient way to allocate these? Or perhaps a way to reload the whole program when the overlay changes? I REALLY don't want to redo this in Arduino (I know I can)... I like the kids being able to tweak this for their target users, and CP really works for that.

Thoughts?

#

I probably should have made an issue ๐Ÿ™‚

scarlet maple
tough flax
#

I'm getting no joy on these in CP 5.x... were they removed?

idle owl
#

They were not removed...

#

What do you mean "no joy", @tough flax?

tough flax
#

I can't call, import, or reference them from CP at the REPL

idle owl
#

Oh, the shared bindings. I thought you meant CP overall, apologies. I think they're no longer u.

tough flax
#

I tried with no u...

idle owl
#

Fair enough. I'm not sure then.

tough flax
#

Thanks for the tip though

#

@scarlet maple have you used these on a Trinket?

scarlet maple
#

Nope. Just did some searching. Have no Trinkets, just a Portal and a Gemma.

idle owl
#

Wait...

#

They might not be implemented for Trinket because of the size.

#

Dan or Scott would know for sure.

tough flax
#

I'm all for removing things for more space on the M0s... but it does make them less useful as a suggestion ';-)

scarlet maple
#

Wouldn't think 96 (then 192) copies of an element would be that large, but depends on what they're made of. Is this tuple of tuples containing bytes, int32, etc.?

manic glacierBOT
tough flax
#

It's containing constants from Keycode in the Adafruit_hid library. They are integers.

#
qwerty = ((Keycode.ESCAPE,Keycode.TAB,Keycode.GRAVE_ACCENT,Keycode.KEYPAD_NUMLOCK,Keycode.KEYPAD_NUMLOCK,Keycode.INSERT,Keycode.HOME,Keycode.END,Keycode.END,Keycode.PAGE_UP,Keycode.PAGE_DOWN,Keycode.DELETE),
      (Keycode.F1,Keycode.F2,Keycode.F3,Keycode.F4,Keycode.F5,Keycode.F6,Keycode.F7,Keycode.F8,Keycode.F9,Keycode.F10,Keycode.F11,Keycode.F12),
      (Keycode.ONE,Keycode.TWO,Keycode.THREE,Keycode.FOUR,Keycode.FIVE,Keycode.SIX,Keycode.SEVEN,Keycode.EIGHT,Keycode.NINE,Keycode.ZERO,Keycode.MINUS,Keycode.EQUALS),
      (Keycode.Q,Keycode.W,Keycode.E,Keycode.R,Keycode.T,Keycode.Y,Keycode.U,Keycode.I,Keycode.O,Keycode.P,Keycode.BACKSPACE,Keycode.BACKSPACE),
      (Keycode.A,Keycode.S,Keycode.D,Keycode.F,Keycode.G,Keycode.H,Keycode.J,Keycode.K,Keycode.L,MOUSE_NW,MOUSE_N,MOUSE_NE),
      (Keycode.Z,Keycode.X,Keycode.C,Keycode.V,Keycode.B,Keycode.N,Keycode.M,Keycode.SEMICOLON,Keycode.QUOTE,MOUSE_W,MOUSE_CLICK,MOUSE_E),
      (Keycode.CAPS_LOCK,Keycode.LEFT_SHIFT,Keycode.LEFT_SHIFT,Keycode.SPACEBAR,Keycode.SPACEBAR,Keycode.SPACEBAR,Keycode.COMMA,Keycode.PERIOD,Keycode.FORWARD_SLASH,MOUSE_SW,MOUSE_S,MOUSE_SE),
      (Keycode.LEFT_CONTROL,Keycode.LEFT_ALT,Keycode.WINDOWS,Keycode.LEFT_ARROW,Keycode.RIGHT_ARROW,Keycode.UP_ARROW,Keycode.DOWN_ARROW,Keycode.ENTER,Keycode.ENTER,MOUSE_DBL_CLICK,MOUSE_RIGHT_CLICK,MOUSE_DRAG))
scarlet maple
#

Is each int 32 bits, then?

tough flax
#
#pylint: disable-msg=invalid-name
    A = 0x04
    """``a`` and ``A``"""
    B = 0x05
    """``b`` and ``B``"""
    C = 0x06
scarlet maple
#

So 1 byte each. If that list/tuple/etc. were implemented as a linked list of some kind, then maybe that's 9 bytes per element (8 bits for the keycode, 32 bits for the forward and backward neighbor)? 864 bytes for each list/tuple, and the M0 has 32 KB RAM.

tough flax
#

I don't think it's one byte each. I think by default Python stores everything as a larger number than that. So, probably 32 bits... maybe more. Maybe some arbitrary precision number with way more than 4 bytes. Then overhead for the tuple. I can't think of why they'd store an unmutable tuple as a linked list (you can't modify it).

The reason I asked this was to see if there was a more efficient way of doing these maps (I knew they weren't efficient... I just don't know how to do better in Python).

scarlet maple
#

True. So might just be basically an array, but if the keycodes are stored as a 32-bit or greater, we're still in the roughly 1 KB range for each array.

tough flax
#

yes

scarlet maple
onyx hinge
#

If you have all "small" integers then a bytearray or array.array can store them in less memory

tough flax
#

So, it seems the code to assign each value to an element of an array takes more memory than the declared nested tuples (does that sentence make sense?) So I need some approach that can be declared without adding all of the assignment code. Perhaps struct.pack() into a bytearray?

onyx hinge
#

there's also the space used by the python code, it seems to me.

#

i.e., the space to actually store the processed form of "C = 0x6"

scarlet maple
#

bytes might be even more compact than bytearray.

tough flax
#

Right, originally I had a two dimensional list that I declare each element

qwerty[0][0] = Keycode.ESC
qwerty[0][1] = Keycode.F1

Etc...

That didn't even let me have one set of values. The nested tuples got me running (yay) but I can't change the overlays because I can't declare a second grid.

#

I am going to try using struct.pack() and see where that goes

#

BTW, does anyone know if Keycodes can be > 1byte?

onyx hinge
#

no, USB keycodes fit within 1 byte

tough flax
#

Ok, thanks

#

Nope! Even doing this I can't fit two grids in memory:

qwerty = (struct.pack('BBBBBBBBBBBB',Keycode.ESCAPE,Keycode.TAB,Keycode.GRAVE_ACCENT,Keycode.KEYPAD_NUMLOCK,Keycode.KEYPAD_NUMLOCK,Keycode.INSERT,Keycode.HOME,Keycode.END,Keycode.END,Keycode.PAGE_UP,Keycode.PAGE_DOWN,Keycode.DELETE),
            struct.pack('BBBBBBBBBBBB',Keycode.F1,Keycode.F2,Keycode.F3,Keycode.F4,Keycode.F5,Keycode.F6,Keycode.F7,Keycode.F8,Keycode.F9,Keycode.F10,Keycode.F11,Keycode.F12),
            struct.pack('BBBBBBBBBBBB',Keycode.ONE,Keycode.TWO,Keycode.THREE,Keycode.FOUR,Keycode.FIVE,Keycode.SIX,Keycode.SEVEN,Keycode.EIGHT,Keycode.NINE,Keycode.ZERO,Keycode.MINUS,Keycode.EQUALS),
            struct.pack('BBBBBBBBBBBB',Keycode.Q,Keycode.W,Keycode.E,Keycode.R,Keycode.T,Keycode.Y,Keycode.U,Keycode.I,Keycode.O,Keycode.P,Keycode.BACKSPACE,Keycode.BACKSPACE),
            struct.pack('BBBBBBBBBBBB',Keycode.A,Keycode.S,Keycode.D,Keycode.F,Keycode.G,Keycode.H,Keycode.J,Keycode.K,Keycode.L,0,0,0),
            struct.pack('BBBBBBBBBBBB',Keycode.Z,Keycode.X,Keycode.C,Keycode.V,Keycode.B,Keycode.N,Keycode.M,Keycode.SEMICOLON,Keycode.QUOTE,0,0,0),
            struct.pack('BBBBBBBBBBBB',Keycode.CAPS_LOCK,Keycode.LEFT_SHIFT,Keycode.LEFT_SHIFT,Keycode.SPACEBAR,Keycode.SPACEBAR,Keycode.SPACEBAR,Keycode.COMMA,Keycode.PERIOD,Keycode.FORWARD_SLASH,0,0,0),
            struct.pack('BBBBBBBBBBBB',Keycode.LEFT_CONTROL,Keycode.LEFT_ALT,Keycode.WINDOWS,Keycode.LEFT_ARROW,Keycode.RIGHT_ARROW,Keycode.UP_ARROW,Keycode.DOWN_ARROW,Keycode.ENTER,Keycode.ENTER,0,0,0))
#

I think the code to make those calls is actually bigger than the declared tuples.

tulip sleet
#

@tough flax You could store a precompiled version of the table in a file and just read the bytes in the file

tough flax
#

Which brings me back to my original thought. Can I modify code.py to import a different file & restart the interpreter somehow? I know this would add writes to the Flash, but they don't change overlays too often

tulip sleet
#

the table can be an array.array so it's packed as densely as possibl.e It could be bytes or halfwords.

tough flax
#

Precompiled as in MPY?

#

Or C?

tulip sleet
#

no, I mean just raw bytes. You build that table offline

#

into a file

tough flax
#

In what language, Dan?

#

Python or C? I am good with Python, but C would be hard for folks to change

tulip sleet
#

could be python, running on a larger computer

#

you could import the existing HID keycode file so people can use the same names

#

since all it does is define a bunch of integers

tough flax
#

I do import the HID keycode file, but the order of the grid is how I look things up.

#

I think what you're saying is to make the two arrays (probably nested tuples) and then run mpy-cross on them

tulip sleet
#

I mean in the generating script that runs on the larger computer, you would import the keycode file

tough flax
#

The might make it small enough to import?

tulip sleet
#

not nested tuples, because that will contain pointers. It would be most compact to store a one-dimensional bytes and index into it "manually", with

tough flax
#

I'm good with one dimension

tulip sleet
#

i*<row_length> + j

#

because the rows are all the same length, is that right?

tough flax
#

In this case, yes

#

So, I write a separate program (in Python) that just reads the two grids and writes them out as bytes in the right order to two files

#

overlay1.dat and overlay2.dat.

tulip sleet
#

right

tough flax
#

Then I read that in from my code.py?

#

And it becomes what, an object of type bytes?

#

a bytearray?

#

Can you index into those in Python?

tulip sleet
#

right, you would allocate a bytestring that is the right length (you could find out the length of the .dat file and allocate it once).

#

a bytearray would be beter, right

unreal vault
#

Anyone have a link to what the CircuitPython Runtime Staus LED flashes mean on a Feather M0 Express?

tulip sleet
#

sure, we do that in the audio code

#

for instance

unreal vault
#

Thank you @tulip sleet !

tulip sleet
#

@unreal vault you'd be happier connecting via serial and seeing the printout though ๐Ÿ™‚

tough flax
#

I know this is just the jaded old C programmer in me, but doesn't this seem nuts, @tulip sleet that you can't declare 100 bytes in code and have it take up roughly 100 bytes in memory?

tulip sleet
#

the problem is the size of the initialization code, because it has to run at runtime. You could also do something like
a = bytes('\x03\x04\x55...') which would mostly be parsed at compile time

#

in a true compiled language, all the names would get resolved at compile time, but not in this interpreted language

tough flax
#

What will mpy-cross do for me? Nothing?

tulip sleet
#

it saves having to compile the .py at run-time when you do an import, but it is not going to do the initialization at compiile time, except for building literal strings, etc.

unreal vault
#

@tulip sleet thats the thing, nothing showing on serial when running example code. Just flashing. If I try simple example code at REPL it works. Working with sample code provided for CharlieWing

tulip sleet
#

do you have Serial open in Mu? Try typing ctrl-c to interrupt the running program, then at the >>> prompt type ctrl-D

tough flax
#

Mwuuuhahaaaa - mpy-cross on the file got me two ๐Ÿ™‚

tulip sleet
#

right, it will save some memory, maybe that is all you need !

#

if you get a failure on the import it's becuase the on-board compiler ran out of memory

tough flax
#

Nope! I can actually do 3!

tulip sleet
#

it concatenates all the invidual bytes at compile time to make one string. But it is not going to do the lookups Keycode.WHATEVER at compiled time

#

(it would be nice, but that's not the language semantics)

tough flax
#

AH! But I could copy that to a file, manipulate it into the right order (using your awesome comments) and then mpy-cross them

#

Probably get all 7 of the standard overlays in!

tulip sleet
#

I didn't realize that example was relevant :), I just gave it as an example of a compile time bytes . Great!

tough flax
#

So, for today (which is what matters today), I have my two standard overlays fitting using just mpy-cross

#

That means Intellikeys users who have the QWERTY and Web Access overlays can flip them over and have both work.

#

Over time, I can go through the yukky process of mapping all of the standard overlays into your bytes structure and them mpy-cross'ing them into a "overlays.mpy" file

#

This works

#

I mean, it sucks, and I wish I had M4s... but this works

#

Turns out I can get 6 copies of that array in by mpy-cross'ing the file!

#

That's plenty!

manic glacierBOT
craggy galleon
#

Is there any CircuitPython Learn Guides for adding new sensors to the CircuitPython eco-system?

E.g. SDS011 Pollution Sensor does not have any CircuitPython support atm but I am working on building a driver but have no guide or standards to stick to.

I've sort of just been making it up as I go - but then realising that it is hard to stick to any existing standards when using this method.

I'm happy to help write up a guide if that is what is needed. I have a pretty strong idea after playing around with all the low-level drivers for other existing sensors for the past year.

#

All I can say now is that the best method for adding support for a new sensor is to take a relatively new CPY driver repository and copy the core components then follow along adjusting as needed.

It just gets a bit tricky at times. If there was a guide it would be straight forward and all new device drivers would come out the same.

solar whale
craggy galleon
#

@solar whale this is what I was looking for ๐Ÿ˜„

But I think it needs to go a bit further into how to structure the driver as well - like if you are using an I2C or SPI device. They are all very specifically set out in the other drivers.

solar whale
#

I hope it helps -- and typically, I think people just use an existing driver as a starting point especially for the I2C/SPI implementation.

craggy galleon
#

Any ideas on how to fix the "toJson is undefined" for cookiecutter?

#

I've tried both Python2 and Python3 just to see if that makes any difference.

solar whale
#

I wonder if the guide needs to be updated since the switch to github actions from travis.... hopefully someone involved in that will be online later.

craggy galleon
#

I'll wait patiently ๐Ÿ˜‰ . I tried a few different versions of python just in case that was the issue. No luck.

timber mango
#

Hi experts, just a quick, probably unnecessarily broad question, but:
I want to program my CPX from a linux laptop. Is this hard to set up?

solar whale
#

Not at all. The CPX will mount as CIRCUITPY. Just copy files to it.

#

You can install mu on Linux as well

timber mango
#

I meant finding Mu for linux.

#

Ah.

solar whale
#

pip3 install mu-editor

#

See The section python instructions

#

Note that your user has to be a member of the dialout group

timber mango
#

Haha, I don't even know what that means :D
Guess I have some reading up to do.

solar whale
#

Ask if you need help

#

What version of Linux are you using n your laptop?

onyx hinge
#

morning all

#

switching to a non-Python implementation of SD card I/O might work, because it would likey be written so that background tasks can't occur while a foreground SD card read is ongoing.

#

Providing a "critical section" (e.g., as a decorator) that could block background task processing while it existed is another option, but it would be easy to misuse, again resulting in apparent lockups of the device

#

right now I have careful coding in JEplayer so that background I/O (mp3 playing, OnDIskBitmap reading) can never overlap with foreground SD I/O, but that feels easy to break

tulip sleet
#

@onyx hinge i have to go out in a minute, but my basic thoughts are: SD access needs to be serialized. A simple lock for SD actiivity in pariticular might work, or a work queue might be better. At one time we thought about redoing the SD card library in C, because it was so buggy, but it's now in better shape, and it's not clear how it would fit in the M0 ports.

onyx hinge
#

OK, "serialized" seems a lot like my "critical section decorator" idea, so maybe we're on the same wavelength. ttyl. I'll potentially bring this as an In The Weeds item Monday

#

if disk_read/disk_write blocked background tasks when calling into Python it might suffice, and not put any burden on Python code authors or provide a dangerous "block background tasks" decorator

onyx hinge
#

hm running into safe mode resets with audiomixer, but I don't have my segger at the coffee shops. changing gears from trying to add volume to JEplayer via audiomixer to .. not sure what

timber mango
#

@solar whale Thanks, I'm working on setting the laptop up now, just installed new harddisk, next up: Finding power supply and a big enough USB pen to install the linux system.
Do you have any suggestions? It's jungle for me, the only reason I want to go with linux is that I don't need to worry about purchasing and installing windows on this ancient X200.

onyx hinge
timber mango
#

Thank you, @onyx hinge, I'll give them a go. I remember having used Ubuntu long ago, so I'll start with that. Cheers.

manic glacierBOT
#

I saw a __disable_irq() during neopixel_write. Here's the traceback.

#0  common_hal_neopixel_write (digitalinout=digitalinout@entry=0x20008790, pixels=0x20009eb0 "\023", numBytes=960)
    at common-hal/neopixel_write/__init__.c:229
#1  0x0005e79c in neopixel_write_neopixel_write_ (digitalinout_obj=0x20008790, buf=<optimized out>)
    at ../../shared-bindings/neopixel_write/__init__.c:74
#2  0x000364c6 in fun_builtin_2_call (self_in=0x82e84 <neopixel_write_neopixel_write_obj>, n...
#

@tannewt I haven't gotten to making a new issue yet as I wasn't sure exactly what I would be making it for. Check out my posts earlier in the thread for some more CCRAM info - it's restricted enough that right now I can't think of a much better use for it than what Micropython uses it for, which is simply a large buffer for internal filesystem tasks (which is something I do want to implement this month). I'll link the appnote I attached earlier again:
https://www.st.com/content/ccc/resource/...

onyx hinge
#
Adafruit Industries - Makers, hackers, artists, designers and engineers!

Introduction Hi!ย  Iโ€™m Jeff Epler, AKA @jepler.ย  Python has long had a special place in my heart, because it is the computer language that makes me feel like I can accomplish anything I dream up. Whโ€ฆ

old smelt
#

Hi All - I have a vague recollection of seeing usage guidelines for the CircuitPython/Blinka logos before. Do they exist? Can someone point me in the right direction?

tulip sleet
#

@timber mango @onyx hinge I use Ubuntu (long term support 18.04.x, 20.04 arriving in April), but use it with the cinnamon desktop, which I find more compact than the Unity interface. After I install Ubuntu, I do apt install cinnamon-desktop-environment

wind trellis
#

@timber mango If you're looking for recommendations, I've been enjoying Debian 10 with the Mate desktop lately, from the same family as Ubuntu and Linux Mint which I've also used. (They're both Debian derivatives actually.) It seems solid and non-quirky, and also most similar to Raspian if that matters. For installation, the smallest USB stick you can buy should be enough. 4GB would work but I haven't seen those for sale for a while.

river quest
#

hi hi @old smelt

#

feel free to email me as well if needed, pt@adafruit.com with any questions on usage, etc.

old smelt
#

Thanks Phil!

raven canopy
#

@onyx hinge if I'm understanding that comment correctly, and remembering how FrequencyIn ended up; that's essentially what happens. It sets up a reference timer as a counter, attaches pin interrupts to the reference to capture triggers, and tracks any overflows. The only issue to deal with when freewheeling the ISRs is smashing the other interrupts; mainy USB.

idle owl
#

Working on updating a guide. There is a microphone on both the Circuit Playground Express and Bluefruit, however, the special sound features of the Circuit Playground Library are not supported on Express due to memory limitations. In the guide page, if you were going through it, would you want to know why it doesn't work on the Express? Or would you rather there simply be a warning saying it doesn't work on the Express, and not have an explanation and only discuss Bluefruit in the page content?

manic glacierBOT
#

Based on that traceback, the nRF neopixel_write implementation is falling back to a busy-waiting NeoPixel write implementation:, which will mess up the BLE timing. That will happen if it can't get a PWM peripheral. So find_free_pwm() is returning NULL for some reason. Maybe the PWM peripheral is not reset properly and appears to still be in use even after it's freed after the neopixel write.

I think the correct thing to do instead is if we can't get a PWM peripheral, then check to se...

slender iron
#

@onyx hinge I think you could start work on removing systick if you have cycles

#

that is preventing us from starting to sleep

manic glacierBOT
slender iron
#

@tulip sleet you around? want to sync on ble in 5?

tulip sleet
#

yes, you mean video?

slender iron
#

yup

tulip sleet
#

sure, started a call

solar whale
#

@timber mango You'l find most of the guides assume you are using Ubuntu so it's a good choice. I've had no problems with it.

lusty crane
#

im getting a "NotImplementedError: Board not supported GENERIC_LINUX_PC" error with the examples/veml7700_simpletest.py

solar whale
#

@lusty crane -- is this with an MCP2221 on a linux system?

lusty crane
#

no, it's a I2C-Tiny-USB on linux

timber mango
#

@solar whale sounds pretty perfect to me ๐Ÿ™‚

#

Thanks all others for your input too.

solar whale
#

@lusty crane OK -- I know nothing about that ... sorry -- the only way I know to use the CP libraries on linux is with an FT232H or MCP2221 but I ran into that same error with the MCP2221

#

@tulip sleet Do you have any idea what is shipped on an ItsyBitsy nrf52840 -- can't make much sense of it

#

/dev/ttyACM0 is streaming BLE data , but no CIRCUITPY and nothin shows up on my iPhone to connect to.

#

I put CP on it ian it seems happy, just curious what it was running

idle owl
#

@solar whale Arduino example.

solar whale
#

@idle owl thanks -- pretty blinking lights

solar whale
#

@idle owl @raven canopy did you see the questions from @craggy galleon at about 0604 EST above -- about using cookiecutter to set up a library -- are there some new steps not in the guide for using it now that travis is not used?

raven canopy
#

@solar whale I did. I'll take a peek a little later if noone jumps on it.

half sedge
raven canopy
#

@craggy galleon @solar whale i peeked real quick. cookiecutter uses Jinja2 as its templating parser, which uses {{ }} as an expression delimiter. this is causing the issue with the Actions workflows, which also have ${{ }} as an expression delimiter. there's one way around it that i know of right now. i'll do deeper dive on it and come up with something though.

slender iron
#

@half sedge here is perfect

#

we can move to email as needed

half sedge
#

Thanks @slender iron : (1) I am looking for a list of date related to the history of Circuit Python (and Micro Python) and I believe that Mister Ladyada has been collecting those. Could I have access to that? Is it published somewhere?

#

Like date of release (that I can find in the release page), some key dates, ...

#

That would be put in the slide deck, not that I hope to have much time to talk about this in the presentation.

lusty crane
#

it doesn't have the GENERIC_LINUX_PC

half sedge
#

That also would be to put in the slide deck, and some will be used in the presentation. The idea is to bootstrap user into Adafrult words, or better understand documentation.

lusty crane
#

could i modify the blinka to include the PC?

half sedge
#

(3) I am looking for news and ETA about the LED baseball hat support. I have ordered one, that should arrive on time for my presentation and could use as a wow demo of BLE communication from CircuitPython and a device. I have no clue who was working on this.

#

(4) I was wondering if I could get Circuit Python giveway to distribute at Fosdem to the participant of the IoT track. Something like "stickers" with Blinka on it.

slender iron
#
  1. I believe the person released a library for it. nothing is needed in the core
half sedge
#

adafruit/OTD ? I was talking about key date in Circuit Python history. ๐Ÿ™‚

slender iron
#

I would hope that would have circuitpython dates

#

release dates are easy to pull from github

#

and most other stuff ends up on the blog

half sedge
#

Ok, I'll dig the date I believe are important. I started a cross reference of CP release and relate that to new hardware. Like 4.0 => displayio => PyPortal

solar whale
#

@raven canopy Thanks for digging into it

lone sandalBOT
onyx hinge
#

@slender iron I may start SysTick work when I need small breaks from JEplayer but really getting heads down on it will come later on.

half sedge
#

@slender iron I sended the email.

manic glacierBOT
#

We sure can't guarantee that the I/O operation will take any bounded length of time, so I agree there's a chance of missing some ticks. But isn't that already the case, when the display background text needs to read from SD?

The main difference I can think of is, the total quantity of I/O in one background task is probably bounded, but a user could probably read larger amounts of data (say, 32kB if they work at it?) in the foreground, and that blocks background by much longer than reading...

onyx hinge
#

how long does it take to read 32kB from SD?

#

about 0.7s, ouch

#

reading 1 block takes 7ms already ๐Ÿ˜ฆ

manic glacierBOT
slender iron
#

@onyx hinge can you see the baudrate?

onyx hinge
#

I am not aware of setting a baudrate so it's at a default value

slender iron
#

hrm, I wonder. you could use a logic analyzer to see why it takes so long

onyx hinge
#

so you're surprised at 7ms / 512 bytes? I mean, I am a bit too

#

is the SPI bus the same one that's on regular I/O pins, making it easily scopable?

#

just CS i guess would be private

slender iron
#

it's been a while since I've done it

#

it may not be broken out, next time you do an order you should pick up a breakout for sd

#

problem is that long wires can cause a lower speed

onyx hinge
#

I guess I can trust my working source code though ``` spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
cs = digitalio.DigitalInOut(board.SD_CS)

onyx hinge
#

oh silly me

slender iron
#

looks like it is broken out on the featherwing

onyx hinge
#

baudrate=1320000 (default)

slender iron
#

that is a weird number

onyx hinge
#

so I'm getting roughly half that as an effective speed (512Byte/7ms ~= 585000bit/s)

manic glacierBOT
onyx hinge
#

oh even the sd-cs is broken out, that's convenient

onyx hinge
#

f.seek(0); f.read(512). it takes some time to get going and then it does a big block

slender iron
#

right, the big block could probably be faster but not the polling

onyx hinge
#

during the tail it is 1.32MHz as expected

onyx hinge
manic glacierBOT
#

I was playing around in CircuitPython to work out the possible and best ways to detect if os.urandom is present. It turns out it's always present so I then started looking at the exceptions that it throws on platforms with no hardware, e.g. SAMD21 (M0) like the CPX. I noticed during that experimentation that even on a CPB where there is hardware support this fails for values above 64. Either that's a bug or it's a confusing use of the NotImplementedError exception?

Adafruit Circui...
slender iron
#

interesting

#

I wonder if you could detect sequential reads and make them faster

onyx hinge
#

that sort of happens at the fatfs layer

#

it looks if >512 (>1023?) bytes are being written AND they are sequential in block address, and issues a read for them all.

onyx hinge
#

but maybe the python layer could track this across multiple requests too, and get some savings from sequentiality

manic glacierBOT
onyx hinge
#

64MHz doesn't work (errors). 32MHz doesn't work (doesn't error, but gets wrong data). Maybe the 13.2MHz was an empirical maximum.

#

os.listdir("/sd")
['000.BLP']

#

should have been 000.bmp

slender iron
#

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

stuck elbow
#

close enough!

slender iron
#

that number probably came from testing

onyx hinge
#

16MHz happens to work on this one card

#

but clearly not a lot of headroom in SPI baudrate

#

what does any of this mean for #2446, if the concern is the amount of time foreground I/O can block a background task?

#

this is NOT blocking JEplayer, fwiw, it is a tangent because I coded around it..

manic glacierBOT
#

There should be plenty of data that we use in RAM that is only accessed by the CPU. The stack is almost that but we may need to move some DMA memory.

Buffering the internal flash filesystem isn't something I'd do in that space because DMA could be used to flush the cache out of RAM. With external flash it will be used for that.

Please open a placeholder issue and we can discuss related work there. Thanks!

#

We sure can't guarantee that the I/O operation will take any bounded length of time, so I agree there's a chance of missing some ticks. But isn't that already the case, when the display background text needs to read from SD?

Yes, but that is interruptible, I think, so that USB background tasks are not blocked during that time. Display refresh prevents itself from being called recursively. Blocking all background tasks is problematic. Blocking background tasks that do SD operations is w...

gilded cradle
#

@drowsy geyser I got your friend request, but I needed to turn off PMs because I was starting to get too many. Did you have a question?

manic glacierBOT
#

You don't need to allocate everything out of that block, you just need to allocate the things that are hard to reallocate.

I'm wary of this change because it breaks the mental model of one MP3File per file. It'd be more of a MP3Decoder at that point. That may be ok but I feel like there may be a way to make the allocations more reliable instead.

drowsy geyser
#

@gilded cradle I was just going to say I haven't forgotten the CPB+Gizmo issue. Try/Except can work around the problem, but I want to find out what's causing it, and why it happens for me but not you. I'm still working on it. ๐Ÿ™‚

#

And totally understand the "too many PMs" problem.

gilded cradle
#

Sounds good. Just update the issue whenever you get a chance.

manic glacierBOT
drowsy geyser
#

Will do!

manic glacierBOT
ruby atlas
#

Ooh, I can run master now!

slender iron
#

๐ŸŽ‰

stuck elbow
#

got oshhw certification for pewpew m4! apparently it's the sixth device in ch

slender iron
#

nice job @ruby atlas

drowsy geyser
#

Holy smokes. I just did a git pull and the number of diffs is huge....

tulip sleet
#

@slender iron when you need non-py-object heap storage, you always use gc_alloc(), is that right? and do you ever bother to gc_free()?

slender iron
#

I think m_malloc is a slightly higher level macro

#

I'm not sure I free but I definitely make sure the collect process will find the pointer

tulip sleet
#

right, I have to make the beginning of my linked list a root pointer

#

i think I am going to be adding a bleio background task to do the deferred internal flash writes

slender iron
#

kk

tulip sleet
#

@slender iron ok sorry, a little more thinking on this. I was going to alloc in a BLE event handler, but if that triggers a gc, i wonder if we'll be in trouble. we have other cases where we add to a list or something in a BLE event handler (like during BLE discovery), and I was always worried about those. You probably encountered those in your refactoring. So I'm wondering if I should worry or not.