#circuitpython-dev

1 messages · Page 363 of 1

manic glacierBOT
#

I forgot to reply back with a few notes after playing around yesterday.

  • I was trying to play audio while also running some NeoPixel animations. When both were playing the audio distortion would randomly come in and out. Disabling or pausing the NeoPixel animations while audio is playing seems to have completely cleared up the audio distortion except for the initial audio file (next bullet). I don't know if this is a CPU/memory thing or if I just can't do audio and animations at the same ...
manic glacierBOT
orchid basinBOT
orchid basinBOT
onyx hinge
#

OK I do NOT understand why we got that ^^^ immediately after I incorporated Dan's change to use 2.3.1. It seems like 2.3.0 was maybe written in two separate places?

#
Gemfile.lock:    kramdown (2.3.0)
Gemfile.lock:      kramdown (~> 2.0)

three .. three times

#

Gemfile.lock: kramdown (>= 1.17, < 3) four times

manic glacierBOT
#

Firmware

This occurred on
Adafruit CircuitPython 6.1.0 on 2021-01-21; Adafruit Matrix Portal M4 with samd51j19

Code/REPL

Here is a sample program that demonstrates the problem and my boot.py

code.py

import supervisor
import time

run_reason = supervisor.runtime.run_reason 
time.sleep(1)
print("run reason == {}".format(run_reason))
print("Exit via supervisor.reload()")
supervisor.reload()

boot.py

import supervisor
import storage

...
onyx hinge
#

ooooooh,

<!-- Optionally, add any other information like hardware connection, scope output etc.
If you have already done some debugging, mention it here. -->

Removing this line resolves the issue.
it's our own issue template that keeps adding this to issues people file

manic glacierBOT
manic glacierBOT
ionic elk
#

@tulip sleet you still awake? Quick question about power - Jun2Sak actually triggers a full chip reset when common_hal_alarm_pretending_deep_sleep evaluates that the chip woke from fake deep sleep (otherwise going to REPL). Thinking about it, do we want to make that standard? It guarantees that the chip wakes in the same way as a true deep sleep. The only trick is remembering what woke the chip up, which is easy on STM32 with the backup registers but I dunno about other ports.

tulip sleet
#

a full chip reset would force usb to re-enumerate, and would break a serial connection. Maye that is the problem I am seeing with his current PR ?

ionic elk
#

Oh

#

yah maybe!

tulip sleet
#

like if you pressed the reset button

#

we don't want that to happen, we want you to stay connected so you can ctrl-c, see what it prints, etc

tulip sleet
#

I think I just had a lightbulb moment about what I saw with the latest version of the PR. thanks for asking !

ionic elk
#

I noticed it when asking about the decision to put return false after common_hal_alarm_pretending_deep_sleep returns in main, which had me thinking "wait this can't be right"

tulip sleet
#

maybe jun2sak is on windows and using something like Tera Term, which reconnects automatically

ionic elk
#

I see your point about the reconnect

tulip sleet
#

or at least easily

ionic elk
#

yeah that seems totally plausible for why you're seeing different stuff

tulip sleet
#

i will put a comment in the PR tomw, or you can

ionic elk
#

I defer to your understanding of the deep sleep USB philosophy, if you can spare the cycles to look over that section again

#

I thought something was up with it, but I just figured we needed to nail down whether all ports should go one way or the other

tulip sleet
#

i did not mean to ask them to do a full reset

#

i think there may have been a misunderstanding

ionic elk
#

I will make a quick note as a part of my comment about the return false but I think you might want to follow up with your own input

tulip sleet
#

i will, thanks. good night!

ionic elk
#

yah sorry for late ping

tulip sleet
#

not an interruption, np

manic glacierBOT
#

I see that the reset_cpu() in alarm_pretending_deep_sleep actually hard reboots the CPU when waking, circumventing the alarm detection process entirely. Unfortunately, this may actually be what is causing @dhalbert's problems with USB, because it will force re-enumeration. Since the idea of fake sleeping is to avoid any serial disconnection, we may need a different strategy here. @dhalbert will have more details.

idle wharf
#

@mental nexus (listening to the weekly) a good place to stick links to all the things is Awesome CircuitPython. You mentioned a FAQ for example and I didn't find it there ... That's a resources I need to learn to use more more myself.
https://circuitpython.org/awesome

manic glacierBOT
#

I see your point, but:

  • that would make looping (or even passing the same AudioSample to play() repeatedly) impossible;
  • the protocol for audiosample_reset_buffer_fun has no way to report failure if the AudioSample is not rewindable;
  • if the queued MIDI stream depletes during playback, the playback will stop, instead of waiting for new input. For real-time input, when the MIDI events arrive at the same speed that they're played, this would happen after every event!

Perhaps a ...

mental nexus
# idle wharf <@!366059101203202052> (listening to the weekly) a good place to stick links to ...

Thanks for the suggestion. I agreed to create a starting list of memory-management ideas on github and then all can add their own tidbits and discussions. Main goal is to have a place to bridge the gap between the basics and deep dive. Once it gets created, Awesome CircuitPython is a good place to link it to.

Here is the rough cut first notes from the meeting.

Tips:

  • Do a gc.collect() prior to large allocations
  • There was the "use bytearray" advice.
  • And use binary font (unsure).
  • Reduce color depth.
  • Avoid recursivity? To avoid “pystack exhausted”
  • Use generator rather than build big list.
manic glacierBOT
#

Could we just have a Palette object available as .palette instead? That would allow for transparency and such.

In fact, maybe we should switch to returning the pixel index here so that it's truly a value. Then TileGrid could map that to a color with its pixel_shader (like odb.palette).

To be perfectly honest I couldn’t decipher the syntax to make something act as a .palette getter and setter property versus just a plain function. Can you point to a good example? This may be...

manic glacierBOT
onyx hinge
#

... what if you could circup install-example....!

manic glacierBOT
raven canopy
idle wharf
#

The question would then become where are they copied to and which one, since several are board\network variant specific

onyx hinge
#

good question, I haven't thought it through

ionic elk
#

hey @slender iron, sorry for the dumb question, but what is the actual specific point in main.c where Circuitpython is actually running the user code? Is it after mp_init in start_mp?

slender iron
#

looks

ionic elk
#

I'm trying to understand out where the alarms are reset in relation to the user code and regular VM resets

slender iron
#

so just after start_mp

ionic elk
#

Ok, so all of start_mp runs, and then hits maybe_run_list. Thanks!

slender iron
#

yup yup

#

start_mp does all of the things to get the vm state ready

ionic elk
#

Could I put a comment in there to that effect?

slender iron
#

totally

ionic elk
#

Cool. That whole system has been a bit of a mystery to me, I probably should have asked sooner.

lone sandalBOT
slender iron
#

np 🙂

#

it's good to wait to learn something until you need to know

#

otherwise you'd spend all of your time learning

manic glacierBOT
#

Current build 3/29/2021 new firmware build after disabling modules

BOARD=adafruit_feather_rp2040
ERROR:
kevin@Aorus:~/circuitpython/ports/raspberrypi$ make BOARD=adafruit_feather_rp2040 Use make V=1, make V=2 or set BUILD_VERBOSE similarly in your environment to increase build verbosity. make: *** No rule to make target 'common-hal/sdioio/SDCard.c', needed by 'build-adafruit_feather_rp2040/genhdr/qstr.split'. Stop. kevin@Aorus:~/circuitpython/ports/raspberrypi$

Module settings i...

#

To be perfectly honest I couldn’t decipher the syntax to make something act as a .palette getter and setter property versus just a plain function. Can you point to a good example? This may be moot if we redefine this to be a palette object.

Sure! The key thing is that there is an intermediate "property" object that stores pointers to the getter and setter functions. See: https://github.com/adafruit/circuitpython/blob/main/shared-bindings/digitalio/DigitalInOut.c#L224 (This is how prope...

#

Build 3/29/2021
Trying to make a 'lite' system but the build system is ignoring the module setting for FRAMEBUFFERIO and with V=2 it appears to be building modules that are disabled.

ERROR:
`kevin@Aorus:~/circuitpython/ports/raspberrypi$ make BOARD=adafruit_feather_rp2040
Use make V=1, make V=2 or set BUILD_VERBOSE similarly in your environment to increase build verbosity.
make: *** No rule to make target 'common-hal/sdioio/SDCard.c', needed by 'build-adafruit_feather_rp2040/genhdr/qst...

idle owl
#

@onyx hinge Do the iMX chips have a temp sensor built in?

#

Is there a temp sensor built into every chip we have a board for at the moment?

onyx hinge
#

@idle owl let me find out!

idle owl
onyx hinge
#
>>> import microcontroller
>>> microcontroller.cpu.temperature
67.0
>>> microcontroller.cpu.voltage
>>> 
``` so temperature is implemented and returns a number (67 seems high!), voltage returns None
idle owl
#

Fair enough

slender iron
#

maybe temp is in farenheit when it should be celcius

idle owl
#

Google is not giving me a clear answer on whether there are microcontrollers without temp sensors.

onyx hinge
#
    return temp;
``` seems simple enough
idle owl
#

Yeah that does seem more like Fahrenheit.

slender iron
#

I'm sure there are but most of the ones we use have it

onyx hinge
#

* return current temperature with degrees Celsius. docs say it's in C. Maybe it runs warm in that CPU.

idle owl
#

Trying to write up the template for CPU temp and trying to figure out how to word it. Is why I'm asking.

idle owl
#

Especially with what you've been testing I suppose.

onyx hinge
#

I don't see that there's a CPU voltage monitor

idle owl
#

I didn't know there was one to begin with.

#

In other boards, I mean.

idle owl
onyx hinge
#

I should go touch the CPU package and see if it's hot

idle owl
#

Knowing a board can return that high means I need to word this page differently. We're usually saying "oh it sucks for precise temp, but for ambient, it's good enough!" Which is apparently a lie for that board.

jaunty juniper
#

I got a QTPY to 55°C by running a full brightness rainbow neopixel strip (testing using the stemma qt connector for signal and power)

#

not that I recommend doing that

onyx hinge
#

this CPU doesn't seem like it can be 67°C inside, the package is warm to the touch but just barely, so it doesn't seem likely to be over 40C. But at the same time, it's warm enough that it's not going to be a good way to estimate the ambient temperature.

#

I'm not making it "do" much, it's just sitting at the REPL

#

it does return different numbers, but clustered around 67/68

idle owl
#

Hmm.

onyx hinge
#

the code's not doing anything obviously wrong

#

but it doesn't seem like it can reach 62°C after being off for >5 minutes then on <20 seconds

idle owl
#

Hmm no.

onyx hinge
#

pointing a hot air gun at it makes the temperature go up, and taking it away makes it go back down again. Putting a fingertip on it makes it go DOWN from 68 to 65

#

so maybe it is real? If it's not over body temperature then touching it should make it go up

idle owl
#

Mine always goes down when I touch it. Cold hands.

#

Right.

onyx hinge
#

breathing onto it also lowers it a bit I think

#

hard to say

#

spraying isopropyl alcohol on it got it down to 61

#

and blowing on that got it down to 59

idle owl
#

Too bad the datasheet isn't amazing and lists some operating temperature or some such. 🙄

#

(I realise that's too much to ask of a datasheet.)

onyx hinge
#

so in summary, I dunno. It sure senses change in temperature but verifying the base temperature seems hard

#

it supposedly is factory calibrated!

#

the calibration is being used

idle owl
#

Fair enough

onyx hinge
#

I haven't tried printing the calibration values, but I don't know what they should be either

idle owl
#

Right.

#

So... values.... but what to compare to.

onyx hinge
idle owl
#

Well. Good to know now I guess.

onyx hinge
#

OK very interesting, I un-plugged the shield that was on this thing and the temperature went right down to 33 which is very plausible

idle owl
#

Huh.

#

What was the shield?

#

What was I even trying to say here? "This works on the Adafruit CircuitPython boards it's built into the microcontroller used for these boards." Missing some punctuation and words there apparently.

onyx hinge
#

it's a GPS shield (non-adafruit)

idle owl
#

Hmm. Wonder if it does stuff automatically then.

onyx hinge
#

In googling about this I ran across a page that suggested it could happen if you had an I/O pin shorted, so the first though I thought of was removing the shield

idle owl
#

That makes some sense

onyx hinge
#

yeah

#

so now I need to figure out whether there's something wrong with the shield. the GPS works (sends messages over UART)..

idle owl
#

But could have something else going on.

onyx hinge
#

right

ionic elk
#

@tulip sleet if I am understanding the alarm system correctly, when you use light sleep and access alarm.wake_alarm, it is actually a different alarm than the one that is returned by the sleep function itself. The alarm returned by sleep is the true alarm, while the global alarm is a copy just like deep sleep. Is this intentional?

tulip sleet
#

That would be true for deep sleep, because the original alarm object is gone. But for light sleep, I thought it was just assigned to alarm.wake_alarm

#

two ways to get the alarm, via return or via alarm.wake_alarm

ionic elk
#

No. alarm.wake_alarm is not capable of accessing the "true" alarm from deep sleep since it does not have access to the internal alarm array

ionic elk
#

this is true for both light and deep sleep

tulip sleet
#

i think it should not be true for light sleep; the alarm object is available and should be used for both. Where is the copy done?

ionic elk
#

the return version has the alarm array to work with, so it can search it and return the actual alarm instance that was passed in. But common_hal_alarm_get_wake_alarm always works with null parameters for the array, meaning the global instance of the alarm will always be a constructed one, not the true alarm

tulip sleet
#

no reason to make a copy for light sleep

#

isn't there a common_hal_set_wake_alarm()? There used to be; I used it to set the module dictionary entry

ionic elk
#

I think in the light sleep case we want to replace alarm.wake_alarm with the actual, true wake alarm, not make both alarms default to the constructed copy. So I think the best case is to store a "most recent wakeup alarm" as a static object within the alarm module, and overwrite alarm.wake_alarm with it, if it is available (not NULL)

tulip sleet
#

it's alarm_save_wake_alarm() in shared-bindings/alarm/__init__.c.

ionic elk
#

@tulip sleet yes, but all it calls is _get_wake_alarm(0, NULL);, which translates to "make me a new alarm copy"

tulip sleet
#

ok, that changed from when i wrote the code, I think

#

originally I had the wake-up code call alarm_save_wake_alarm() directly

onyx hinge
#

there doesn't seem to be a schematic available, but it kinda looks like this shield is designed only for 5V microcontrollers and has pull-ups to 5V. Yeah that's not good

ionic elk
#

I'd still like to revisit the names of these functions, having the request for a fake alarm to be made being signaled by null parameters still feels very obscure to me and I'd rather it just be a new set of functions that specify what they're doing more clearly.

tulip sleet
#

that is a good idea

ionic elk
#

Anyway, for now I will have it override with the static object, and I'll revisit later to see if I can simplify the program flow a bit somehow.

idle owl
#

@tulip sleet We haven't gone and turned off the CircuitPython code error LED blink codes anywhere, have we?

tulip sleet
#

we are thinking about not doing it over and over, but no, that was going to be in 7.0.0. Is there a board that's not working?

idle owl
#

No, I'm creating the "Status LED: NeoPixel" template, and stated that the LED does bootloader status, and CircuitPython error codes. Wanted to make sure I wasn't making things up.

tulip sleet
#

it will still be true, but we want to reduce the frequency so as not to run down batteries, etc.

idle owl
#

@tulip sleet Could you review this? I'm leery of making multiple PRs to Learn at the same time because of merge conflicts and I would like to work on some more template code. It's a basic touch/blink example with the touch pin being a variable and instructions to change it. It's mean to be copied and pasted without the docstring into a template code embed and have that variable changed. I am basically the only one who will be using it anyway, but I tried to make it so others could as well. https://github.com/adafruit/Adafruit_Learning_System_Guides/pull/1499

tulip sleet
idle owl
#

Oh, right. Bleh. No, we want it to be more "readable" so we include a "this could be more 'Pythonic' but it's not because readability" in the template

idle owl
tulip sleet
#

I actually think it would be good to mention the "more Pythonic" version at some point; people will catch on.

idle owl
#

But I honestly forgot that touch returns true/false.

#

Yeah I agree, really. The paragraph reads: Note that the code is a little less "Pythonic" than it could be. It could also be written as led.value = touch.value. That way is more difficult to understand if you're new to programming, so the example is a bit longer than it needed to be to make it easier to read.

tulip sleet
#

similar is a blinky that does led.value = not led.value and needs only one sleep instead of two

idle owl
#

Yes.

tulip sleet
#

ok, so I understand, and it looks fine otherwise. Not sure about "little red LED" as opposed to just "red LED" (how little is little). Maybe it's a "wee red LED" 🙂

#

but that's fine too, if it's in the spirit of the context

idle owl
#

Oh man, I like "wee" much better.

#

I refer to it as "little" because it's "littler" than the NeoPixel/DotStar

#

Since they can be red as well.

#

If you make them.

tulip sleet
#

it seems like an affectionate term here, as opposed to "small", then, which is your point

idle owl
#

True

tulip sleet
#

i'll approve it either way

idle owl
#

Cheers

slender iron
manic glacierBOT
#

I just got a general protection fault (Kubuntu 20.04). 6.2.0-beta.4 version of circuit python, I had unmounted the CIRCUITPYTHON device, and then powered off the PICO. Until now turning off auto mount and unmounting the device has saved me from getting these. This appears to be in the ACM/CDC driver though which I have never seen happen before. Although I got this luckily linux didn;t totally crash and I was able to reboot gracefully.

[684258.426420] general protection fault: 0000 [#1...
manic glacierBOT
#

I think there are multiple ways Linux can be upset with connect or diconnect. The original way I was seeing was that an abrupt disconnect and reformat of the CIRCUITPY filesystem confused Linux. That appeared to be on reconnect. However, we have also seen these disconnect bugs. If you are willing to submit this to Ubuntu with kdump info and maybe write to linux-usb, that would be great. I have found one disconnected reference in recent linux-usb emails that sounds similar, but I haven't fou...

manic glacierBOT
#

Hello,

With Raspberry Pi Pico: installed firmware using UF2 is Adafruit CircuitPython 6.2.0-beta.4 on 2021-03-18; Raspberry Pi Pico with rp2040.

In Thonny, when trying to create a ULAB array that is 1024 length, I receive "RuntimeError: pystack exhausted".

import ulab test_array=ulab.array=([])

I did not want to include the large array here, but its 1024 length of float64...basically a hanning window array.
I also tried just values 1-1024 int and it gave the same error.

I ...

manic glacierBOT
hollow gazelle
#

What's the general guidance or standard work for asserts() in circuit python.
Are they turned off in releases?
Are they expected to catch run time execution errors ( e.g. bad data ), or just the impossible / can't happen errors
https://en.wikipedia.org/wiki/Assertion_(software_development) suggests that in contrast with error handling, "Using assertions as a general-purpose error handling mechanism is unwise: assertions do not allow for recovery from errors; an assertion failure will normally halt the program's execution abruptly; and assertions are often disabled in production code. Assertions also do not display a user-friendly error message."

In computer programming, specifically when using the imperative programming paradigm, an assertion is a predicate (a Boolean-valued function over the state space, usually expressed as a logical proposition using the variables of a program) connected to a point in the program, that always should evaluate to true at that point in code execution. A...

loud berry
#

hello everyone,

i want to start an project with an micro-Controller...

ich need:

  • network.lan (looks like is disabled by default in Micropython)

further i need:

  • JSON
  • send via MQTT
  • HTTPS-Server

can anyone tell me if these elements are available in CircuitPython?
-> is there a support, if it doesn't work?

best regards

stuck elbow
#

@loud berry I suppose a raspberry pi would be best for this.

#

then you can use regular python

loud berry
#

i need a PoE-Supply, i want to use an ESP32

stuck elbow
#

well, esp32 is not supported by circuitpython

loud berry
#

it's a pitty... anyway, thanks!

fossil gorge
#

Out of curiosity, is there a manual process which needs to be performed when a new board is added for it to be available on circuitpython.org ? I received my Neo Trinkey yesterday (WHEE!) but didn't see an image there. Nor did I see one today. However, checking the latest CP build actions output, there is a package there.

onyx hinge
#

@hollow gazelle I think most builds are done with -DNDEBUG, which turns the assert() macro into a do-nothing operation.

#

For conditions that could arise by executing Python code, the core C code should throw a Python exception or return an error value (which would be turned into a Python exception at a higher level), whichever one makes sense.

manic glacierBOT
#

We had the "Remote Wakeup" bit turned on in the USB configuration descriptor we send to the host. This is problematic for two reasons:

  1. We don't handle remote wakeup; we should be calling tud_remote_wakeup() at appropriate times.
  2. Some chips don't fully support USB suspend/resume, notably RP2040 and STM. TinyUSB has workarounds for some but not all of these. See https://github.com/hathach/tinyusb/pull/700 for some discussion. It is on TinyUSB's agenda to work on this further.

Some ...

#

Can you verify that you've correctly shown the source code you are executing? The code you showed gives a different error, because you cannot assign to 'ulab.array':

>>> import ulab
>>> test_array=ulab.array=([])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object cannot assign attribute 'array'

To create an array filled with 1024 zeros of a given type, you should instead write

>>> test_array = ulab.zeros(1024, dtyp...
tulip sleet
#

we agree, they are not too useful, since often the effect is just that the board stops working

onyx hinge
#

I think this came up because I added one, and it was .. not correct.

tulip sleet
#

i saw that after I read my mail 🙂

manic glacierBOT
crimson ferry
#

Browsing the most recent pystack issue, #4516, I wonder if there should be a function to set pystack limit just like stack limit, and for any stack limit set function to return its actual set value, since "If its too large, the default will be used."

manic glacierBOT
#

This allows more options to be overridden to 0 in an mpconfigboard.mk.

Improved:

  • FRAMEBUFFERIO, FULL_BUILD, BITOPS, PWMIO, RGBMATRIX, OTARYIO, PULSEIO, WATCHDOG

Still problematic (pull requests welcome):

  • RP2PIO & NEOPIXEL_WRITE, possibly only if a status neopixel is defined
  • BITBANGIO, possibly only if BUSIO is enabled
  • RTC

Incidentally, with RP2PIO & NEOPIXEL_WRITE, BITBANGIO, and RTC re-enabled I get

323956 bytes used, 720524 bytes free in flash firmware space o...
crimson ferry
manic glacierBOT
#

supervisor has a function to "Set the size of the stack for the next vm run."
https://circuitpython.readthedocs.io/en/latest/shared-bindings/supervisor/index.html#supervisor.set_next_stack_limit

But "If its too large, the default will be used." The function has no return value. Returning the actual value set would be useful. to know whether the request was successful, or for programmatically obtaining the default limit.

manic glacierBOT
lone sandalBOT
manic glacierBOT
lone sandalBOT
manic glacierBOT
idle owl
#

@tulip sleet Do we have any boards that don't have at least one pin that you can read the analog value of using analogio and printing pin.value?

#

That you can think of anyway.

idle owl
hollow gazelle
# onyx hinge For conditions that could arise by executing Python code, the core C code should...

Thanks @onyx hinge - I did NOT dig into the code further, perhaps these asserts are designed to catch the configuration errors in the CP build that could be detected (only?) at runtime. I would agree that this is a reasonable middle ground for assert that matches the "don't use asserts to catch Python errors", right?
Oh, the issue that triggered my question does look like python code triggered it. '''uart = busio.UART(None, board.TX, baudrate=9600)'''

idle owl
#

@tulip sleet I guess it doesn't matter. Nevermind my question.

#

The template wouldn't go into a guide that the board didn't support it, so it's fine.

#

I'm trying to figure out wording for explaining analog pins etc.

onyx hinge
#

@hollow gazelle yes, I think the correctly-written assert would have been triggered by the code in that issue, however at the same time as I added the (slightly wrong) assert i also corrected the logic to ensure that a Python error was previously generated. So if I'm right about what I implemented, just calling busio.UART with wrong args cannot cause the assertion error.

manic glacierBOT
idle owl
#

Ok for the CircuitPython-compatible microcontroller boards, are all GPIO pins digital or analog or both? Or are there GPIO pins that don't have one of those functionalities?

manic glacierBOT
idle owl
#

Adafruit's boards.

#

Specifically.

tulip sleet
#

It is not a safe assumption to make

idle owl
#

Hmm.

#

But are all GPIO pins either analog, digital or both?

#

Is that what makes them GPIO

tulip sleet
#

GPIO would mean they can be DigitalInOut

idle owl
#

Ohhh ok.

#

Bad wording then on my part.

tulip sleet
#

But on ESP32-S2, for instance, some "GPIO" pins have restrictions. I think one is input or output only, for instance. It's a sloppy term.

idle owl
#

Ok. I'll avoid GPIO here then for sure.

tulip sleet
#

yeah, that's a good idea, it really doesn't mean a lot

idle owl
#

Is this safe? Your microcontroller board has both digital and analog signal capabilities. Some pins are analog, some are digital, and some are capable of both. Check the Pinouts page in this guide for details about your board.

#

It then goes on to explain what analog signals are, but I'm trying to get an intro in there.

tulip sleet
#

that sounds good

idle owl
#

Ok thank you

manic glacierBOT
#

@jepler my apologies.

Yes when creating an empty array it gives that error. I updated my post to show some sample values I am loading into the array. I basically created a numpy hanning window of 1024 values on my personal machine, then copied it over to Thonny connecting to RP2040; I am trying to perform FFT using ULAB (can't quite figure out if there is a way to get frequencies yet but the transforms work).

Any direct array creation that is about 200 plus records gives me the pystac...

crimson ferry
#

@idle owl There's also the nuance of "analog" PWM out vs. DAC true analog out ...the latter often limited to one or two pins

idle owl
#

@crimson ferry Right. That will be explained in two other sections. PWM and Analog Out.

#

I'm sure I'll be back with more questions when I get there.

alpine nimbus
#

I had a strange problem with circuit python last night. I wonder if its worth reporting even though I have no idea how to reproduce it. For each print statement I deleted (or commented out) a character would be removed from the name of a function call and it complained that there was no function by the truncated name. Deleting enough code eventually swallowed up the entire function call and it died for some other reason. Adding the code back allowed my code to run normally again. Power cycling the board fixed everything. Maybe the parser got clobbered by a buffer overrun?

tulip sleet
#

@alpine nimbus it could have been some odd corruption of the filesystem. I would recommend doing a storage.erase_filesystem() after you've saved your work. What editor are you using?

alpine nimbus
#

mu

tulip sleet
#

I have no explanation then 🙂

alpine nimbus
#

hmm, the file itself didn't seem to be wrong, just the parser's interpretation of it

tulip sleet
#

Mu's idea of what was in the file vs what was actually on CIRCUITPY may not have matched

#

The OS does caching, etc.

alpine nimbus
#

the problem persisted even after restarting mu

tulip sleet
#

writes are done to a USB devices as blocks of bytes, not as "files"

alpine nimbus
#

and i didn't lose anything after restarting the board

#

although maybe i had undeleted everythign at the time I rebooted. i forget

tulip sleet
#

when you restarted the board, the OS would have re-read the metadata of the CIRCUITPY filesystem. Yes, it could be an internal issue, but the one-off errors don't sound like something going on in parsing

alpine nimbus
#

also, I wasn't editing the function call. it kept getting shorter and shorter after I deleted lines in other parts of the file

tulip sleet
#

if the function name straddled a block boundary, for instance, then rewriting only one block but not the other would shorten the name (assuming you made single character changes, like adding # to comment out, etc.)

alpine nimbus
#

commenting out a line had the same effect as deleting the line

tulip sleet
#

the file would have gotten completely re-read on each save, it's not incremental, and the internal heap is also cleared and restarted on each save (auto-reload restarts the Python VM). So this is why I think it's more likely to be a filesystem issue. ... It could also have been some odd problem with Mu's editor widget. When you restarted the board, some things got reset.

alpine nimbus
#

OK, thanks. I'll erase then.

#

oh, here's a clue. I just noticed a file named CALIBR~1.PY, which looks like a DOS file name. I'm on a mac. That's a file I deleted a while ago

tulip sleet
#

it does sound like there's a least some mild corruption.

#

if the board was ever reset or unplugged before the OS wrote something back, that will make corruption. Sometimes it's not obvious right away

idle owl
#

@onyx hinge I used your fancy git ls-files command to figure out which Adafruit CircuitPython compatible boards do not have board.A1.

onyx hinge
#

ooh I am glad you were able to adapt the example

idle owl
#

Took a few tries, but I think I got a valid result in the end.

#
ports/atmel-samd/boards/pirkey_m0
ports/atmel-samd/boards/rotary_trinkey_m0```
#

Which makes sense. I checked a couple others I was unsure about and they have A1.

manic glacierBOT
idle owl
onyx hinge
#

A friend randomly suggests "I wish Adafruit guides would list the libraries you need in alphabetical order like they show up in the file explorer"

tidal kiln
#

^^ and separate folders from files

idle owl
#

I do it in in order usually, I thought...

#

Since I'm usually reading it from the lib folder.

tidal kiln
#

i'll admit i'm not that organized, or at least not consistent 😦

#

a screen cap of the lib folder is my fall back 🙂

onyx hinge
#

this particular friend is good with the commandline so I suggested circup to him

idle owl
#

Fair enough.

onyx hinge
#

and maybe we'll have this web-based bundle builder, that would be very neat

onyx hinge
#

friend likes circup 🙂

idle owl
#

Good to hear.

manic glacierBOT
onyx hinge
#

thanks @tulip sleet -- I had meant to file a similar PR but must have forgotten

manic glacierBOT
tulip sleet
#

I am trying to do all the odds and ends for rc.0

idle owl
#

You folks are plowing through it too!

manic glacierBOT
#

When creating a literal sequence, the amount of pystack used is proportional to the size of the sequence.

>>> eval(str(list(range(367))))
[0, 1, ¸, 365, 366]
>>> eval(str(list(range(368))))
RuntimeError: pystack exhausted

To allow a list of 1024 numbers to appear in a literal list or tuple value, even if there are no other function calls, imports, etc., involved, it appears that pystack would need to be enlarged by about 2700 bytes (to somewhat over 4200 bytes total) ...

idle owl
idle owl
#

Ok so CircuitPython. And analog values. 16 bit values, right?

tulip sleet
idle owl
#

Ok

#

This page is turning out to be way longer than the original.

#

Explained ADC, explained analog signals, explained potentiometers.... now explaining the 16-bit values....

tulip sleet
#

e.g., the actual resolution might be 12 bits (0-4095) so we multiply by 16 (or shift left 4 bits),

idle owl
#

Maybe too much? I don't know. Limor asked for me to explain what a NeoPixel is on the NeoPixel page, so I feel like we're trying to be more explainey with these new pages.

#

But I kind of think it's not too much. We have glossed over this concept in pretty much every guide that does anything with it. I found one that has a SUPER detailed explanation. Everything else is mostly gloss or doesn't mention any of it. We need something in the middle. Not a deep dive, but not hand-waving either.

tough flax
#

Hi folks. Thank you all for thinking of me and checking in

idle owl
#

@tough flax Hey! Glad to see you!

tidal kiln
#

hey @tough flax !! yah, excellent to hear from you!

idle owl
#

Whew. I think this page is looking good.

#

Significantly longer than its predecessor, but has some simple explanations of things that we haven't really covered in a simple manner.

#

Hmm. I have two different values for the max 16 bit analog value: 65535 and 65536. One is 2^16 -1, the other is 2^16. Which one is correct? I understand that rarely do you reach that max value anyway, but what is the proper theoretical max? @tulip sleet

valid bison
#

hi there. is there a benefit of using a mpy file instead of a .py file? I only found information about creating them

idle owl
#

@valid bison Hello! .mpy files are smaller, and have less memory impact. So if you're using a board with less memory, such as a SAMD21, or a SAMD21 non-Express, you'll definitely want to use .mpy files. Or, if on larger boards, you run into a memory allocation failure, you can switch to .mpy files.

valid bison
#

ah thx. Does it make a difference in execution speed?

idle owl
#

Not that I'm aware of.

thorny jay
#

It should make a difference for execution speed. The parsing and translation to VM code is already done. But this need confirmation.

#

Now, it might only accelerate loading time, not execution time... so if you use that imported code many time, you will only notice at loading time.

thorny jay
idle owl
#

Oh because it starts at 0.

#

Right.

thorny jay
#

It does not seems hard to reach the maximum 3v3 will give you the max if 3v3 is the reference value... but I don't play much with analog. My worry is when you are above as many documentation warn you about not going above it.

#

And then ESP32-S2 that cannot measure up to the max and start degrade it's measurement.

#

There might be a nice writing by Stargirl about analog reading and how it is done on SAM microprocessor. She did a few very good blogpost, so it must be where I read about that.

idle owl
#

I think I explained things pretty well, albeit basically.

#

Though there's always room for improvement.

manic glacierBOT
#

It appears that MacOS changed something that caused HID to stop working. This was already true with iOS: the presence of the gamepad HID device causes other HID devices to not work for iOS.

I will test this myself with a custom build. You can turn off the gamepad HID device if you want to try a custom build: https://learn.adafruit.com/building-circuitpython/customizing-usb-devices#customizing-usb-hid-devices-3084080-4

thorny jay
#

Where is it? Is it recent? I might have read it from you!

idle owl
# thorny jay Where is it? Is it recent? I might have read it from you!

There's a new back-end feature in the Adafruit Learn system where you can create a template page, and the main content of it is immutable, but there are sections where you can add things like wiring diagrams for a specific board. The plan is to basically redo the CircuitPython Essentials guide in templates, so instead of a general set of pages, each one is tailored for each board. So every Adafruit CircuitPython-compatible board will have its own set of specific pages that show things.

#

This is one of those templates. So it's not published yet because I think my plan is to make all the templates and then add them a a group to the guides.

#

Also I finished it half an hour ago 🙂

thorny jay
idle owl
#

Not in exactly that way, but I noted that it's normal to not reach the maximum.

#

What you said is correct, but I think that goes one step deeper than I want to go with this page.

thorny jay
#

And not all board have the same "resolution". 🙂

idle owl
#

Also true.

manic glacierBOT
manic glacierBOT
tulip sleet
#

@slender iron #4522 looks good to me, and I tested a simple central role to check the discovery fix. I would feel fine adding this before rc.0; you too?

slender iron
#

ya, fine with me

#

I found some packet buffer bugs too...

tulip sleet
#

that is completely not surprising

slender iron
#

😄

manic glacierBOT
manic glacierBOT
#
[adafruit/circuitpython] New tag created: 6\.2\.0\-rc\.0
#
[adafruit/circuitpython] New branch created: 6\.2\.x
orchid basinBOT
orchid basinBOT
orchid basinBOT
manic glacierBOT
manic glacierBOT
manic glacierBOT
manic glacierBOT
analog bridge
#

@tulip sleet were you able reproduce the i2c-wifi issue with IDF?

manic glacierBOT
manic glacierBOT
#

I encountered a question with a situation like that in #help-with-circuitpython, and assuming that the cause was that the literal array was created on the stack before being put in a variable on the heap, I suggested cutting it into parts of 300 items length (approx).

long_list = [0, 1, 2 ... 1000]
# pystack exhausted
long_list = [0, ... 300,] + [301, ... 600] + [601, ... 900] + [901, ... 1000]
# works
manic glacierBOT
#
[adafruit/circuitpython] New branch created: re\-arrange\-ci\-task
analog bridge
# manic glacier

oh shoot... I accidentally created a new branch on core... was editing a file using web-editor and thought It was on my fork. 🤦

#

it can be deleted once #4528 is merged

manic glacierBOT
onyx hinge
#
    /* Set deadtime count, we set this to about 650ns */
    uint16_t deadTimeVal = ((uint64_t)PWM_SRC_CLK_FREQ * 650) / 1000000000;

Don't we usually configure the PWM peripheral so that it can give 100% duty cycle? "Dead time" is useful in motor control scenarios but not necessarily for the things our users use PWM for..

tulip sleet
#

When I was debugging the original problem, I was not seeing a crash, but instead that things became unresponsive. And when I looked at the running tasks in the fixed vs unfixed case, they looked superficially the same:

gdb) i thread
  Id   Target Id         Frame
* 1    Thread 1073346568 (Name: main, State: Running @CPU0) 0x401752bd in tu_fifo_count (f=0x60023)
    at ../../lib/tinyusb/src/common/tusb_fifo.c:300
  2    Thread 1073610488 (Name: IDLE0) 0x40176c12 in esp_pm_impl_waiti ()
    at ../../esp-idf/components/esp32s2/pm_esp32s2.c:479
  3    Thread 1073613136 (Name: Tmr Svc) 0x4003419c in prvProcessTimerOrBlockTask (xNextExpireTime=<optimized out>,
    xListWasEmpty=<optimized out>) at ../../esp-idf/components/soc/src/esp32s2/include/hal/cpu_ll.h:33
  4    Thread 1073573936 (Name: usbd) 0x40034b45 in xQueueGenericReceive (xQueue=0x3ffd0be8 <_usbd_qdef+8>,
    pvBuffer=0x3ffd7a10 <usb_device_stack+2184>, xTicksToWait=<optimized out>, xJustPeeking=0)
    at ../../esp-idf/components/soc/src/esp32s2/include/hal/cpu_ll.h:33
  5    Thread 1073345452 (Name: esp_timer) 0x40034b45 in xQueueGenericReceive (xQueue=0x3ff9e350, pvBuffer=0x0,
    xTicksToWait=<optimized out>, xJustPeeking=0)
    at ../../esp-idf/components/soc/src/esp32s2/include/hal/cpu_ll.h:33
  6    Thread 1073730444 (Name: tiT) 0x40034b45 in xQueueGenericReceive (xQueue=0x3fffc4b0, pvBuffer=0x3fffd330,
    xTicksToWait=<optimized out>, xJustPeeking=0)
    at ../../esp-idf/components/soc/src/esp32s2/include/hal/cpu_ll.h:33
  7    Thread 1073737860 (Name: wifi) 0x40034b45 in xQueueGenericReceive (xQueue=0x3fffe994, pvBuffer=0x3ffe1850,
    xTicksToWait=<optimized out>, xJustPeeking=0)
    at ../../esp-idf/components/soc/src/esp32s2/include/hal/cpu_ll.h:33
  8    Thread 1073734504 (Name: sys_evt) 0x40034b45 in xQueueGenericReceive (xQueue=0x3fffd4e8, pvBuffer=0x0,
    xTicksToWait=<optimized out>, xJustPeeking=0)
    at ../../esp-idf/components/soc/src/esp32s2/include/hal/cpu_ll.h:33
#

Unfortunately when trying to track things down, I found that I ended up inside the closed-source esp-idf wifi stack

analog bridge
tulip sleet
#

I was preparing to do that, but figured I immediately be asked for a test program.

#

We have heard about wifi/i2c issues with ESPHome / Home Assistant as well, but I haven't looked into that in any detail.

#

do you want to post the issue, or would you rather that I did?

analog bridge
#

you can go ahead as you have already done more research on this 🙂

tulip sleet
#

I think we were trying to figure out where to patch the Home Assistant

#

or even if it was possible

#

I have much less experience writing ESP-IDF C code, though; would you be willing to work on the test example a bit?

analog bridge
#

ok... is it i2cwifi.c?

tulip sleet
#

yes, i copied the structure of that example from the esp-idf examples. have you written standalone esp-idf programs?

#

(it took a while just to get it to compile 🙂 )

analog bridge
tulip sleet
#

ok, so, if you feel like playing with it, great; I think I will only be able to show that the debug UART output differs

#

but that may be sufficient for a bug report

manic glacierBOT
#
[adafruit/circuitpython] New tag created: 7\.0\.0\-alpha\.0
stuck elbow
#

\o/

tulip sleet
#

it's just a tag for now, so the prompts reflect moving on from 6; we won't create any alpha releases until 6.2.0 is out the door, because circuitpython.org only can handle one stable and one unstable release at a time

stuck elbow
#

oh

tulip sleet
#

otherwise the PR builds will still say "6.2.0-rc.0" or whatever

#

in their prompts

onyx hinge
#

@tulip sleet does it mean I can prepare a PR to upgrade ulab to their main branch in our main branch though?

tulip sleet
#

yessir, i was going to say it's clear for that and any other incompat changes

#

looking forward to that PR

onyx hinge
#

you don't have to "sir" me 🙂

tulip sleet
#

any further 6.2 work will be in the newly created 6.2.x branch

onyx hinge
#

that thing you just said will be good to remember

#

important to remember

tulip sleet
#

a little mild jokey; I was up til 1am fighting with circuitpython-org

#

I found this interesting thing this morning: https://github.com/nektos/act

#

would be a way to test changes to actions .yml files; that was what caught me last night

manic glacierBOT
#

@anecdata Hey, sorry for the late response, you were right about the command, I didn't copy and paste it properly in this issue.
It should have been like this: python esptool.py -c esp32s2 --port COMx --after=no_reset write_flash 0x0 <firmware.bin>
However I think this isn't the issue here.

I've been able to get the ESP32S2 to work over the last couple of weeks by plugging it into another USB2.0 Hub that worked with it this time, and I also noticed that can also work on some USB 3.0 po...

cobalt grail
#

@slender iron Does it refer to a "nordic soft" "device" or a "nordic" "soft device"? Why the word "soft"? Seems I am missing something?

tulip sleet
#

"SoftDevice"

onyx hinge
cobalt grail
#

Hm. Sounds like we are leaking implementation details to the end user?

tulip sleet
#

we use the softdevice for BLE and other things. you don't have to - there are other libraries that do the same thing (e.g. zephyr has its own BLE stack)

#

I think this leak is ok - it's informative, if confusing, and then someone will ask, and we can help

cobalt grail
#

What I mean is that we can't reuse that error message for other MCU's.

#

But thanks for the clarification! 🙂

tulip sleet
#

i guess it could be "third-party firmware out of memory", but that's pretty vague

#

or maybe it's second-party 🙂

#

in this case

cobalt grail
#

Well, I would argue the "nordic soft device" is vague enough so I actually had to ask. 😆

jaunty juniper
#

BLE firmware out of memory ?

tulip sleet
#

that could be ok, but it's actually more than the BLE firmware, because the SoftDevice manages some other things

#

a good suggestion is welcome! I think the point is to point the finger at non-circuitpython code but still make it identifiable if reported to us

onyx hinge
#

yessss! I have a PWM

manic glacierBOT
#

After this change, the following program works for me on the MIMXRT1010-EVK:

import pwmio
import board

p = pwmio.PWMOut(board.D13, frequency=1_000_000, variable_frequency=True)
p.duty_cycle = 32868

while True:
    pass

Querying and varying the duty_cycle and frequency work as well.

The lowest frequency obtainable is about 2kHz; there is an additional divider which would allow lower PWM frequencies (I think 1kHz is important for servos?)

In the commit message...

analog bridge
#

@tulip sleet i2cwifi.c does not result in a hang for me.

tulip sleet
#

right, it doesn't hang. the issue in CircuitPython is not a simple hang either; it might be too many itnerrupts, etc.

#

the CPy problem disconnects USB, but the threads that are running appear to be ok

#

all I have is that the debug trace is different with and without my change. I did remove all the stuff in the interrupt handler, and want to try put it back, a bit at a time

analog bridge
#

okay so this is not an idf issue after all...

tulip sleet
#

!

analog bridge
#

thanks for looking into this @tulip sleet
I think we will have to stick with a patched idf even for V4.3...

tulip sleet
#

wait, but you said it's not an IDF issue??

analog bridge
#

ya... from what I understand this is a corner case which isn't properly handled in idf

tulip sleet
#

i am not sure about a corner case; what we see is that if you delete an I2C driver instance, it somehow affects the functioning of I2C, if started after the deletion. The destruction of the semaphore somehow affects the wifi. But I tried a non-static semaphore, and I also did some test where I made sure that the I2C driver storage block was not being reused (I did not free()) the block, and it still had the problem. So it seems more like a semaphore/event queue problem. I cannot get inside the wifi stack to see what's actually happening :/

analog bridge
#

it would be great if we can get someone from espressif involved in this because of the closed source wifi stack... that's why the pitch for an esp-idf issue

tulip sleet
#

right, exactly, but I don't yet have a good test case for them. I don't think they want to try to debug CircuitPython. We talked about this internally and I may just go ahead and post the issue and say that a test program is under development, but do they have any idea. I did ping igrr on this earlier but did not hear from him

analog bridge
#

I don't think there's any harm in posting an issue at this stage...

tulip sleet
#

i will go ahead and do that -- I am less busy with 6.2.0 stuff now and can take the time; thanks for your thoughts on this

analog bridge
#

thanks for your efforts 🙂

#

I am doing some CI stuff now and wondering why every board build is done separately...? Is their any issue with building the boards in the same environment?

still zephyr
tulip sleet
cobalt grail
manic glacierBOT
#

@tannewt Is "needs the ability to specify an array of 1024 float values inline, in a module directly imported from code.py or the repl" a concrete enough story, and one we want to support? If so, it points to increasing the pystack to somewhere around 4200 bytes. If not, hopefully a different technique like one of the ones I suggest above will work for our original reporter.

I'm totally open to increasing the pystack size. We just need to remember that it's a tradeoff with heap size.

...

#

Thank you all for the support. I think the suggestions are great and even just importing from a file is sufficient for me. Now, I cannot speak for the average user and if there is enough use case to create large arrays of static values, then it may be worth it without compromising a lot of performance.

Thanks again for looking into this, I leave the rest to you great developers!

manic glacierBOT
#

I apologise, that comment was a leftover from the issue template that I missed and left there by accident.

We took that out of the issue template; it was confusing, in this case both to you and me.

I just re-tested on High Sierra 10.13.6 and Big Sur 11.2.2. In neither case did the mouse work in the stock build, but if I set CIRCUITPY_USB_HID_GAMEPAD = 0 in mpconfigboard.mk for the board I was using, the mouse does work. If you would like help with the custom build, feel free t...

#

Setup

  • Firmware: CircuitPython 6.2.0 beta 3 (en_US)
  • Board: Raspberry Pi Pico
  • Host: Apple MacOS Big Sur 11.2.2 on MacBook Pro 2014

Reproduce

  1. Load this code as code.py
import time
import board
from digitalio import DigitalInOut, Pull
import usb_hid
from adafruit_hid.mouse import Mouse

button = DigitalInOut(board.GP16)
button.pull = Pull.DOWN
mouse = Mouse(usb_hid.devices)

while True:
    time.sleep(0.1)
    if button.value:
        print('CLICK!')
  ...
ionic elk
#

@tulip sleet hey dan sorry to bother you again, but would you have a minute to spare today? I'm in some debugging trouble and could use a second opinion

manic glacierBOT
manic glacierBOT
manic glacierBOT
onyx hinge
#

working on updating ulab but not sure how to resolve this ... checking consistency... /home/jepler/src/circuitpython/shared-bindings/ulab/numpy/approx/index.rst: WARNING: document isn't included in any toctree (and other ulab submodules)

tulip sleet
#

is approx mentioned in api.rst??

#

i'm guessing about the cause

onyx hinge
#

hm there ends up being no numpy/index.rst file.

tulip sleet
#

i would build the tip of main now and see the old ulab struct to compare; you're probably doing that already

#

@ionic elk btw, now that I've branched 6.2.x, your reworking of the internal API naming, etc., is free to proceed

onyx hinge
#

there's an extra level, ulab/numpy/approx vs ulab/numpy .. that's part of it

tulip sleet
#

there is max toc nesting of 3, I think, would that make any diff?

ionic elk
#

@tulip sleet ok, should we merge my PR for it?

tulip sleet
#

it just means the nrf PR has to be revised, etc.

#

to match what you do

ionic elk
#

right, I could put in some time to do that

#

push to their PR with the changes, if it's open to contributions

tulip sleet
#

we still need to remove the hard reset in that pr too

ionic elk
#

by the way, re: Jlink disconnecting due to the optimization settings, this is the error I'm getting ERROR: Cannot read register 0 (R0) while CPU is running

tulip sleet
#

does the stlink work with gdb, maybe better?

#

I thought the j-link was quite good, though

ionic elk
#

I just don't understand why optimization settings would full on disconnect my debugger. That seems so bizzare.

#

none of these problems happen with a normal build, only debug ones

#

I'd like to just ignore it and solve bugs manually with the regular builds, but I'm worried that whatever it is could be mysteriously screwing up my program in any number of ways

tulip sleet
#

i looked at the Makefile; I see nothing fishy in there

#

update the J-Link sw if you have not done so in a while

#

they update like once a week

ionic elk
#

Gotta look up how to do that again

onyx hinge
ionic elk
#

must have notes on it somewhere

tulip sleet
#

is this on Linux or Mac or WIndows?

#

@onyx hinge that seems very odd, but sphinx is far from my favorite tool

ionic elk
#

bleh, no dice.

manic glacierBOT
#

This includes ulab with https://github.com/v923z/micropython-ulab/pull/359 added. We can anticipate that a future ulab release will be made before CP7.0 goes out stable :)

Testing performed: On the unix port, ran ulab.numpy.linspace(0, 10) and the result looked plausible.

The upgraded version of ulab is nearly fully incompatible with 6.x, but is much more compatible with a subset of numpy & scipy. We believe this provides a better path for users of standard Python systems too.

ionic elk
#

It doesn't fail when I'm stepping through it either

#

only when I continue with no breakpoints

tidal kiln
#

how does CP do the I2C pull up check?

stuck elbow
#

I think it pulls the pin down and reads it

#

internal pulls are much weaker (higher resistance) than the i2c pull-ups are supposed to be

tidal kiln
#

so internal pulls are required?

tulip sleet
#

no

#

it pulls the pin down, waits 10us, lets go, waits 3us, and sees if it's high

#

the 3us is the longest to wait for satisfactory 400kHz operation

#
    // We must pull up within 3us to achieve 400khz.
    common_hal_mcu_delay_us(3);
tidal kiln
#

how is the pull down done?

stuck elbow
#

so pulldowns

tidal kiln
#

so it does rely on internal pull downs?

tulip sleet
#

just to test

tidal kiln
#

yep. just asking about the test.

tulip sleet
#

yeah, the pull-ups are not enabled during normal operation

stuck elbow
#

if it instead switched to output and switched the pin low, and the pin was connected to vcc, you would get a short

tidal kiln
#

yep. thanks. code listing helps...pretty simple test.

ionic elk
#

@tulip sleet hmmm I think I figured out why it's tossing the JLink - for some reason, the optimized debug code isn't connecting to USB, so it enters actual deep sleep

#

unoptimized I should say. I wonder if it's too slow?

slender iron
#

@tulip sleet want me to PR the packet buffer fixes to 6.2.x?

tulip sleet
#

does it fix some common problems that people are encountering?

#

i would try to get it in right away, maybe do an rc.1 tonight

slender iron
#

I don't know how common it is

#

they are small changes like the last pr

manic glacierBOT
tulip sleet
#

go ahead and PR to main; I can take a look. I am a little inclined to just wait if there are no known roadblocks

slender iron
#

kk, will switch it

#

not urgent

tulip sleet
#

i am just thinking of doing 6.2.0 final on Monday or Tuesday; does that seem too soon to you

slender iron
#

nope, I know the spresense folks want it

#

and that will enable us to do 7.0.0 alphas

tulip sleet
#

yes, both are good reasons, and we can do 6.2.x's with these small changes if we want

slender iron
#

yup yup

tulip sleet
#

there are plenty of worse problems still present 🙂

slender iron
#

I'm not a huge fan of dual commits

#

one for main and one for 6.2.x

tulip sleet
#

i am willing to cherry pick; I would only do it if we felt there was a strong blocker in 6.2.0 final. Getting 7.0.0's going is good because people will be testing other things too; we can always say: it's fixed in unstable, please try

slender iron
#

yup yup

tulip sleet
#

kind of a saleae / kicad attitude

slender iron
#

and we don't need to wait months for 7.0 stable either

tulip sleet
#

yeah, i think it would be when i.mx was settling down; the BLE workflow would be nice, but it can be minimal in the first versions

slender iron
#

I think that's the last fix for the BLE entry change

#

ya, we'll see how far I get

#

we can always do 8.0

#

🙂

tulip sleet
#

if chrome can do 89, we can do 8

slender iron
#

yup yup

#

we have plenty of numbers

#

I think I saw them here so it may have been answered on discord already

manic glacierBOT
fossil gorge
#

Hey there fine folks! I'm looking at the list of issues, to see where I might be able to help, and I saw the SD card library (https://github.com/adafruit/Adafruit_CircuitPython_SD/) has a few issues I'd like to take a shot at, particularly #8. I assume the same library should work with any device with native SD or a breakout, correct?

tulip sleet
#

there are now native implementations sdioio and sdcardio, which are missing only on the smallest boards

#

This library is called back from native code, and there are inherent problems with that.

#

so this lib is less important than in the past

fossil gorge
#

I see. So would it be fair to say that this library is destined for the "archive" list soone than later?

#

Gotcha

#

Makes sense

tulip sleet
#

as long as there are boards that can't fit the other impls, it has a place, but if someone wanted to do SD card operations with any seriousness, we would recommend an M4 or other board with more flash

#

sorry if it's a letdown; @onyx hinge you may have something more on point to sya

onyx hinge
#

I'd say that's about right, we can't just remove it because there are some limited scenarios where it's the only option

fossil gorge
still zephyr
#

@fossil gorge

#

🙂

fossil gorge
#

Will keep looking, and iterate through some infrastructure issues as I look

still zephyr
#

I would love your help with something

fossil gorge
#

Oooh, sorry.l.. I'm all booked up! 😛

still zephyr
#

😦

fossil gorge
#

Nah, I'd be happy to help

#

April Fools. Ha ha (not)

#

What's up?

still zephyr
#

ok it regarding the Community bundle

#

wait I am looking for the issue

fossil gorge
#

ok

still zephyr
#

I am guessing that this is made json/github but I do not know how to start or where 🙂

fossil gorge
#

Ok. I was looking at that one earlier actually, and was going to look into it. I guess it just got bumped up the list! 🙂

#

...right under "supper", which apparently needs my attention!

still zephyr
#

oh really? that would be awesome

fossil gorge
#

Really! 🙂

still zephyr
#

Thank you 🙂

fossil gorge
#

You're welcome!

#

Gonna deal with feeding family, and then will come back and look into it

#

I'll probably reach out if I have questions or want to run some ideas by you

still zephyr
#

Thanks no rush, if you teach me I can do it (y)

fossil gorge
#

Ok, that can work too

still zephyr
#

Good 🙂

fossil gorge
#

Learn and teach together!

still zephyr
#

yes lets do that

manic glacierBOT
manic glacierBOT
ionic elk
#

@tulip sleet I'm thinking that some of my debugging troubles are because the STM32 RTC does not reset when the MCU does (due to Jlink or otherwise). Thus, when it crashes and de-enumerates USB, it will not re-enumerate until the power is cycled (because the tick count is already way higher than the USB delay). I can reset it in the HardFault handler, but what is the Circuitpython standard for timekeeping - should I make it so the tick count is reset every time Circuitpython is reset/woken from deep sleep, so the state is the same as after a power cycle?

#

Alternatively I could make the USB delay relative to when it begins looping, rather than an absolute based on the global tick

tulip sleet
#

Scott talked about making time.monotonic() start from zero on a reload/reset. The STM32 RTC is much fancier than many of the others. There is tick counting and there is time keeping. The ticks could start from zero but the RTC does not need to be reset. You just need to keep an offset, which is something we talked about.

#

what does the ESP32 usb delay do? Does it also delay only the first time?

ionic elk
#

I haven't really checked in detail. I only know about this STM32 issue because the RTC specifically doesn't reset with everything else, it keeps going, which has caused me all kinds of headaches

#

but I imagine is useful in general

#

I don't know how standard that is, I'd have to read about the ESP32-S2 one to see if it's the same

fossil gorge
#

@still zephyr - I had a bit of a look at what the CP bundle is doing to build up that page. Looks like there are a few systems coordinating to build it, but no JSON or other such input.

tulip sleet
#

btw is the reset line from your j-link hooked up to the boardd?

ionic elk
#

It's true though, I could store an offset in my RTC module

#

yes

tulip sleet
#

maybe the esp32 behavior is alos not good, I don't know. But I think the hard crash would cause it to start over

ionic elk
#

Just in this case, it wasn't helping with the USB not enumerating, because it basically stays timed out forever after the board is powered on

tulip sleet
#

the RTC in the nrf52 gets reset all teh time

#

it is just a tick counter

#

i would not necessarily expect USB to recover after a hard fault anyway, but I guess it would be nice

ionic elk
#

I will try putting in a tick offset and see how that goes. If it doesn't work, I may revert to just resetting the RTC every time we start up and revisit this issue later

#

I'd like USB to recover after I hard fault and re-flash the board!

#

it won't even do that

fossil gorge
#

Somewhat. Still need to dig into the part that does the work, but it appears to mostly be a script that loops over the driver and library directories to get the necessary data, and then generate the page

still zephyr
#

I see, mm interesting

#

Thank you Hugo

fossil gorge
#

It looks like there might be a portion, like adding the generated page to the repo, that's handled by Adabot. But that is about it

still zephyr
#

yeah I was looking at Adabot yesterday, but I could not figure out anything

fossil gorge
fossil gorge
still zephyr
#

Just in case one day you have this error in the CI: Inline strong start-string without end-string.

#

Only the CI will catch it, if you build you documents locally using sphinx-build -E -W -b html . _build/html the error will not be there.
The CI will report a line, but the line is wrong. Not luck looking for that in google.

#

**Title*

#

should be like this

#

**Title**

fossil gorge
jaunty juniper
#

oh you're looking for where it's called from

still zephyr
#

@jaunty juniper but how to build the *.md file?

#

oh I see

#

We just need to give it the current bundle_path

manic glacierBOT
still zephyr
#

So why included in the search list to not included after

jaunty juniper
#

seems to be only for that file I guess

still zephyr
#

you are right

#

How we say to adabot to build the list for the other libraries?

jaunty juniper
#

that's where I would look for a change, the hard part being testing it

#

I guess printing update_info and exiting at line 380 would do it

#

the line updates.append(("https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md" has to be changed with the bundle repo name in it I'd say, and the test at 60 removed and then what happens

#

lines 97-99 should be guarded by the removed test, or parametrized somehow

still zephyr
#

is there any way to test this, I mean like try it?

#

with clone of the community bundle locally?

jaunty juniper
#

like bundle_path[-1].replace("_"," ").title() to generate the name on line 97/99

#

yes, I would try running python3 circuitpython_bundle.py

still zephyr
#

🙂

#

good

#

Thank you @jaunty juniper

jaunty juniper
#

you would clone the bundle repos and also update submodules

#

that's how you pull all the libraries in

still zephyr
#

ok Ill do that

jaunty juniper
#

ah actually adabot-cron calls it with python -m adabot.circuitpython_bundle (in a venv) so I would do that (with python3)

still zephyr
#

Thanks

fossil gorge
#

@jaunty juniper is a lot more helpful than I've been!

fossil gorge
#

You're welcome. I tried, and hopefully was marginally helpful

still zephyr
#

Of course, you still could help 🙂

#

I am not so sure, when you hear it from neradoc it seems so easy, but I am not so sure myself

fossil gorge
#

Everything always seems so easy when someone who knows what they're doing explains it. Then the "here, you try" moment appears and it's like everything I saw or heard fell out of my head onto the ground!

jaunty juniper
#

I've fought with the bundles in the past when I looked at circuitpython-build-tools 😉

idle wharf
#

@still zephyr thank you for looking into the Community Bundle issue ❣️

lone sandalBOT
astral tinsel
#

I forked circuitpython to my github, cloned that to my local ubuntu, built my rp2040 board but the update.sh (git pull && git submodule sync && git submodule update --init) script I'd run every day didn't seem to do anything. I discovered remote, added that then fetched/merged, I show I have 6.2.0-rc.0 but how to I use 6.2.0-rc.0 to build a board?

jaunty juniper
#

is make BOARD=somethingsomething failing ?

astral tinsel
#

No, I was removing modules and broke the build tools, they say it is fixed with 6.2.0-rc.0

jaunty juniper
#

have you run pip install -r requirements-dev.txt ?
I believe there's some new things in it (the file itself was recently added)

astral tinsel
#

just ran it, everything is already satisfied

#

How do I just git requirements-dev.txt

jaunty juniper
#

I'm sorry, I don't know what you mean, I'm also not super knowledgeable on the build process, you might have to wait for somebody else to be there

astral tinsel
#

git restore requirements-dev.txt grabed the April 1 version, mine was 3/27

#

no difference, everything was already there

#

ll

manic glacierBOT
valid bison
still zephyr
manic glacierBOT
manic glacierBOT
#

This includes ulab with v923z/micropython-ulab#359 added. We can anticipate that a future ulab release will be made before CP7.0 goes out stable :)

Version 3.0 should not change how ulab behaves, it should only add a new module: https://github.com/v923z/micropython-ulab/pull/327
However, I thought that circuitpython would stay with the legacy branch for the 6.x series. Has anything changed?

manic glacierBOT
jaunty juniper
#

accidentally validating the PR form because of weird shortcuts makes me want to cry >_>

tulip sleet
# cobalt grail Well, I would argue the "nordic soft device" is vague enough so I actually had t...

I've thought about a more appropriate term a bit more: how about "system firmware"? If you want to PR a change to CircuitPtyon for generic mentions of "Soft Device" and "SoftDevice" converted to "system firmware" or some similar phrasing, that would be great. I agree "Soft Device" should not have a space, as well.
(I found the Nordic choice of "SoftDevice" to be confusing as well when I first saw it, and the acronym "SD" overlaps with SD cards.)

#

@timber mango thank you for the issue cleanup!

manic glacierBOT
#

Here's an idea about using Python exceptions to allow something like a button push or other external interrupt to interrupt normal program flow, without having to provide general interrupt handlers or having to poll.

For example, suppose you want a button push to interrupt a NeoPixel animation, and go on to the next animation. Instead of checking for the button push at various strategic places, we could just ask that a transition DigitalInOut cause an exception to be raised. The outer lo...

manic glacierBOT
#

Here are some initial thoughts.

  • It risks running afoul of places where people wrote 'except Exception as e:', unless this new kind of exception is outside of the Exception class hierarchy (like KeyboardInterrupt is).
  • More generally, there is a lot of code which assumes that exceptions can only happen at known moments, except for program-terminating exceptions like KeyboardInterrupt generally is. We could fix the code once we know about it, of course.
  • Would the 1ms tick need to b...
#

Basic PWM has been enabled, but there are still limitations. Here are the ones I know of:

  • [ ] never-reset PWMs (like for backlight)
  • [ ] correct checking for PWM sharing
  • [ ] support for "X-channel" PWM, if possible (no code in SDK for it) - this affects only pin A4 (and ESP_READY) on the metro m7 1011
#
  • It risks running afoul of places where people wrote 'except Exception as e:', unless this new kind of exception is outside of the Exception class hierarchy (like KeyboardInterrupt is).

I think except Exception as e: is kind of poor practice, and presumably someone using TransitionException would know that would happen.

  • More generally, there is a lot of code which assumes that exceptions can only happen at known moments, except for program-terminating exceptions like Keyboar...
slender iron
#

@astral tinsel what error are you getting when trying to compile circuitpython?

manic glacierBOT
#

Safer if one time:

while True:
    # Triggers once only. Re-enabled each time around the loop.
    button.raise_exception_on_transition(digitalio.Transition.DOWN)
    try:
        while True:
            # Animation can be interrupted at any time,
            # not just when it finishes.
            run_animation_once(animation_number)
    except digitalio.TransitionException
        animation_number = (animation_number + 1) % NUM_ANIMATIONS
slender iron
#

it's very weird

#

I could ask them to try resoldering the usb

tulip sleet
#

@slender iron @tidal kiln the bit being changed is 0bnnn0nnn in the two examples they gave

#

so I'd suspect a stuck bit somewhere in the hw; worth replacing, seems to me

#

not USB connector

tidal kiln
#

yah, that soldering looks fine imo

#

and connection issue would be more random

#

@slender iron just replace it. actually RMAing would be up to limor. i can respond if you want.

slender iron
#

@tidal kiln please respond. I'm not sure of the language

#

thanks!

tidal kiln
#

np

manic glacierBOT
#

+1 for this. Why not point the existing alarm api to raise an exception. We already use interrupt in fake deep sleep.

import alarm
import board

pin_alarm = alarm.pin.PinAlarm(board.IO0, edge=True)

while True:
    # Triggers once only. Re-enabled each time around the loop.
    alarm.raise_exception_on_alarms(pin_alarm)
    try:
        while True:
            # loop
    except alarm.PinAlarmException
        # handle interrupt

manic glacierBOT
slender iron
#

calling usb background from an interrupt

cobalt grail
#

Wohooo. Just got CircuitPython compiling on my Mac. Thanks for good documentation!

#

Anyways, I need some help. I have forked the repo, cloned it to my local machine, added adafruit/circuitpython as upstream and ran the command git fetch upstream. Seems not to be enough to see all the latest code?

still zephyr
#

?

cobalt grail
cobalt grail
#

Thanks @analog bridge that did it.

#

So. How do I get my clone fork on Github updated now that my local repo is up to date?

#
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   extmod/ulab (new commits)
    modified:   lib/mp3 (new commits)
    modified:   lib/protomatter (new commits)
    modified:   lib/tinyusb (new commits)
    modified:   ports/esp32s2/esp-idf (new commits)
    modified:   ports/raspberrypi/sdk (new commits)```
manic glacierBOT
#

However, I thought that circuitpython would stay with the legacy branch for the 6.x series. Has anything changed?

This has not changed. The main branch for circuitpython is now the start of 7.0.0. 6.2.0-rc.0 was released this week, and we created a new 6.2.x branch for it. We hope 6.2.0 final is imminent.

@dhalbert Thanks for the clarification! By the way, if you think that https://github.com/v923z/micropython-ulab/pull/327 has any relevance for circuitpython, you coul...

analog bridge
thorny jay
#

Is there an easy way to know what linguistic version of the firmware is running? The idea would be to have a multi-lingual program that will display by default message in the language of the firmware (assuming it is what the user expect/want).

analog bridge
#

a submodule update will resolve the unstaged submodule changes, then you can do a git push

manic glacierBOT
tulip sleet
thorny jay
#

Not really looking for a "standard" way. an CP way would be good enough. Maybe a string to be translated would contain the language name... and getting that one will be the answer.

tulip sleet
#

we could add supervisor.language or something like that. I'm not sure where else it would live right now

#

there is no circuitpython module; maybe there should be, but it's another thing to take up valuable space in the smallest builds

manic glacierBOT
cobalt grail
#

Tada! My first pull request!

thorny jay
#

Something broke my code and I noticed while upgrading to rc0:

#

TypeError: object with buffer protocol required

#

I remember someone wanted to simplify the reading of usb report.

#

I was doing this to get NUM/CAPS/SCROL LOCK:

#

leds[0].value = (report & 0x01) == 0x01 # NUM LOCK
leds[1].value = (report & 0x02) == 0x02 # CAPS LOCK
leds[2].value = (report & 0x04) == 0x04 # SCROLL LOCK

gloomy shuttle
still zephyr
#

@cobalt grail Not in Weblate?

cobalt grail
#

I changed the english error message in the .c files, need to wait for a merge before I can do the actual translation. 🙂

#

So, not in weblate.

still zephyr
#

Yes I changed the message this morning in weblate following dan<s recommendation, but Thank you, now I need to go back an re-translate 😆

cobalt grail
#

Yeah, I thought it would be kinda strange if only non english speakers would get proper error messages. Besides, @slender iron always nags about pull requests when I nag about his error messages.

manic glacierBOT
#

Adding bool to constructor to reverse direction would probably solve this. It looks like this would about 10 lines of code. Bool change operation from += to -=. Logic is incremental encoder so reversing the pins will just change the direction.

https://github.com/adafruit/circuitpython/blob/51c09e877d72d07d06276a8f9d40342833412a72/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c#L161

Probably should add bool to structure here.
https://github.com/adafruit/circuitpython/blob/51...

still zephyr
#

@jaunty juniper 👀

thorny jay
manic glacierBOT
#

I looked at this more, and did some instrumentation of the current code and your PR #3967. I instrumented the interrupt handler and noticed it is losing interrupts sometimes (though that may be due to my print statement). A couple of observations on the base algorithm:

  • If interrupts are missed, then there will be missed counts, because the count-to-4 logic won't count to 4 by the next detent, and will get out of sync.
  • If we can determine the quiescent state (at a detent, usually 11), ...
tulip sleet
thorny jay
#

I think it was None. I am afraid I scratched my original code to fix it. Looking for the gist where I would have published that.

tulip sleet
#

so maybe that is what is returned if a report has never been received

#

i'd have to check that

#

yes:

//|     last_received_report: bytes
//|     """The HID OUT report as a `bytes`. (read-only). `None` if nothing received."""
#

so it has been this way before, maybe it just never happened to be tested in a case where no report was yet received

manic glacierBOT
cobalt grail
#

Do I need to do anything else besides push the make translate change?

tulip sleet
#

that should be it. There is a new way to check for these and other issues in advance:

pip3 install pre-commit
cd <your-repo>
pre-commit install
cobalt grail
#

Nice. Will try that.

tulip sleet
#

pre-commit will run a bunch of checks before it actually does a commit, so various things can get caught in advance of pushing. I think it may do a translation check, but I can't remember if we got that to work or not

#

you only need to run pre-commit install once on the repo. You can also run the checks by hand before even trying a commit by doing pre-commit run --all or something like that

cobalt grail
#
Fix End of Files.........................................................Passed
Trim Trailing Whitespace.................................................Passed
Translations.............................................................Passed
Formatting...............................................................Failed
#

It fails on Formatting - FileNotFoundError: [Errno 2] No such file or directory: 'uncrustify'

manic glacierBOT
tulip sleet
#

i know how to install it for linux

cobalt grail
#

Yep, brew managed to install it. No it says FileNotFoundError: [Errno 2] No such file or directory: 'black'

tulip sleet
#

hmm, pre-commit should try to install it, I thought

cobalt grail
#

Might be a Mac thing?

tulip sleet
#

you can do this
$ cd circuitpython
$ pip3 install -r requirements-dev.txt

#

I may just be mistaken. I do these installations once and then forget because they work happily ever after

cobalt grail
#

To late, alreayd running brew install black

tulip sleet
#

use the pip3 version, not brew

cobalt grail
#

Ah.

tulip sleet
#

they may not be the same, and we use the pip3 version in general

#

e.g. pre-commit on GitHub will use it

cobalt grail
#

Oh, that was a long list of requirements.... 🙂

#

Nope.

  File "/Users/jonny/Developer/circuitpython/tools/codeformat.py", line 186, in <module>
    main()
  File "/Users/jonny/Developer/circuitpython/tools/codeformat.py", line 182, in main
    batch(command, lang_files(PY_EXTS))
  File "/Users/jonny/Developer/circuitpython/tools/codeformat.py", line 164, in batch
    subprocess.call(cmd + file_args)
  File "/usr/local/Cellar/python@3.9/3.9.2_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 349, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/local/Cellar/python@3.9/3.9.2_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/Cellar/python@3.9/3.9.2_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1823, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'black'
#

And

#
Requirement already satisfied: black in /usr/local/lib/python3.9/site-packages (20.8b1)```
#

I don't get it.

tulip sleet
#

which black

#

echo $PATH

cobalt grail
#

black not found

tulip sleet
#

did you ctrl-c the brew install black? It may have left it in a partially installed state

#

try brew remove black

#

or uninstall i forget which

#

pylint would also have been installed, I think; can you run pylint?

cobalt grail
#

Which pylint says not found.

tulip sleet
#

no, it's not installed, sorry

cobalt grail
#

🙂

tulip sleet
#

which mypy

cobalt grail
#

/usr/local/bin/mypy

#

Looks like black isn't linked?

tulip sleet
#

well, try the brew uninstall of black and then pip3 install it

#

yes, maybe the linking stage got interrupted

cobalt grail
#

Yeah, that did it!

#
Check Yaml...............................................................Passed
Fix End of Files.........................................................Passed
Trim Trailing Whitespace.................................................Passed
Translations.............................................................Passed
Formatting...............................................................Passed```
#

Tada! 🥳

#

Thanks for the help!

tulip sleet
#

yw!

#

i updated the guide to include uncrustify. The pip3 install -r requirements-dev.txt was already on the "Build CircuitPython" page, because it requires cloning the repo first

manic glacierBOT
#

I do not know if this is helpful or not. I made this translation by reading ARM instruction set documentation: (Note I have not tested this. It may have errors.)

const uint32_t upper = (1 << (bits - 1));
const uint32_t lower = 0 - upper;

int32_t lo, hi;

// asm volatile ("smulwb %0, %1, %2" : "=r" (lo) : "r" (mul), "r" (val));
int64_t tmp = mul * (val & 0xFFFF);
lo = tmp >> 16;

// asm volatile ("smulwt %0, %1, %2" : "=r" (hi) : "r" (mul), "r" (val));
int64_t tmp = mul *...
manic glacierBOT
manic glacierBOT
#

I hadn't realised there was so much code shared here. What's the explanation for the difference between nrf and raspberrypi implementations for level changes while the voice is playing?

There were problems with the non-ASM math which is why "level" didn't work. Sorry I was not super familiar with audiomixer to start and missed testing the level parameter. The latest build should have it working.

#

Maybe. I fixed the errors so it now works and seems acceptably fast on the RP2040. I think with a bit of work the above ASM may be able to be used without the float being used, but in that case you may need an int64 which I'm not sure limits us on some boards or not? I did upload the fixed code so it can at least work, not sure if its worth continuing on the potential speed improvement or PRing this now?

manic glacierBOT
manic glacierBOT
#

I do not know if this is helpful or not. I made this translation by reading ARM instruction set documentation: (Note I have not tested this. It may have errors.)

Cool thanks. I did look at it and I think with looking at it, it may work. The question I'm thinking about is if this way of doing it is meaningfully faster then the other way.

I just went through the git log and found this:
https://github.com/adafruit/circuitpython/blob/362c1664ae5979f288e8cb12d528f8cd44100410/shared-...

analog bridge
#

can we create an exception in CPY where some data is passed through the exception... something like following

try:
    # underlying c code triggers exception
except FooException as e:
    print e.foo
slender iron
#

ya, python supports that. it should be possible

manic glacierBOT
#

Also note that slower clock does not always mean less power because it takes code longer to execute. My understanding for low power is that you want to process quickly so that you can get to sleep faster.

I agree this should be enabled at some point though for overclocking when power doesn't matter. We could make it settable from boot.py only.

Clock generally predicts higher power consumption. It is complicated. It depend on a number of things. For some parts this can be true. You...

manic glacierBOT
#

I do not know if this is helpful or not. I made this translation by reading ARM instruction set documentation: (Note I have not tested this. It may have errors.)

Cool thanks. I did look at it and I think with looking at it, it may work. The question I'm thinking about is if this way of doing it is meaningfully faster then the other way.

Stupid idea, but I will say it anyhow. That logic may force the compiler to optimize in M4 and run basically the same instructions on M0/M0+. Pe...

serene briar
#

I was looking though the release notes of the 6.2 betas and I found as of beta 4 USB cdc is disabled by default. What is the reason for this?

jaunty juniper
#

two reasons:
1 - the ports where not always in the expected order (REPL first) on windows, so Mu would not see the REPL for example
2 - workarounds using the cdc channel names would not work with the current version of pyserial

#

it will come back in 7.* when we have the feature to enable/disable USB endpoints in boot.py

serene briar
#

Thanks, I need it for a project so I will compile it from source. Will the order be correct on Linux?

jaunty juniper
#

I think it should be when ordered by path, but also the REPL name is "Circuitpython CDC ..." and the other is "Circuitpython CDC2 ..."

from serial.tools.list_ports import comports
for port in comports():
  print(port.device, port.interface)
/dev/ttyACM1 CircuitPython CDC2 control
/dev/ttyACM0 CircuitPython CDC control
/dev/ttyAMA0 None
#

ACM0 is the repl here

serene briar
#

Thanks, makes much more sense now

jaunty juniper
#

the issue with pyserial is that on windows port.interface is empty and on mac it's the same value for each port. If you need that on those platforms, Dan wrote a library with fixed versions of comports() because the pyserial repo seems to be inactive and our PRs are left unmerged so far.
https://github.com/adafruit/Adafruit_Board_Toolkit

manic glacierBOT
#

I did some more work on this and came up with the following api:

import alarm
import board

touch_alarm = alarm.touch.TouchAlarm(board.IO6)
alarm.raise_exception_on_alarms(touch_alarm)

try:        
    while True:
        pass
        # loop
except alarm.AlarmException as exc:
    if exc.args[0] == touch_alarm:
        # handle interrupt
        print(exc.args[0].pin)

This is similar to the existing alarm api and also reduces the exception to only one (i....

serene briar
lone sandalBOT
manic glacierBOT
#

I am trying to make a custom build but I keep getting errors. I followed all setup instructions from the documentation and I tested it on macOS Big Sur and Ubuntu 20.04.

On Ubuntu I get the following error:
`ubuntu@circuitpython:~/circuitpython/ports/raspberrypi$ make BOARD=raspberry_pi_pico
Use make V=1, make V=2 or set BUILD_VERBOSE similarly in your environment to increase build verbosity.
QSTR updated
Traceback (most recent call last):
File "gen_stage2.py", line 82, in <module>
...

manic glacierBOT
thorny jay
#

@gilded cradle Hi, I have some doubt about display (minipitft 240x240) on CP (with physical wiring to Pi) on a mcu and display on a Raspberry Pi Zero. I have the feeling that there are difference in API.

#

#it is in:
import adafruit_rgb_display.st7789 as st7789
#...
display = st7789.ST7789(

I had to replace:

colstart=0,

rowstart=80,

with this:

x_offset=0,
y_offset=80,
#

Now that the code is working on the Raspberry Pi Zero, I will see if the same code works on the Raspberry Pi Pico (with pin adaptation).

#

Now I am a bit confuse on why use adafruit_st7789 or adafruit_rgb_display when you want to drive a st7789. What is the "right" thing to do? Is one the old way and the other the new way?

manic glacierBOT
#

What you need is a clocking manager for each port. Under the covers each module that needs a clock will register a callback to that specific clock. When you change the frequency it will compute the correct settings. Manager will then call each handler notifying it of the new clock value.

Handlers will throw exception if failure occurs for "critical" clocks. Others can fail silently as they are best effort. USB for example is critical clock, while SPI is not. This is a poor example, because...

#

@microDev1 Thanks for doing a proof of concept so fast! I am interested in having these even in small builds, so we have to think about how to make alarm pervasive and still fit. It may not be possible. Perhaps we would leave the sleep functionality out, but I think we may still have to remove something else from small builds to make it fit.

manic glacierBOT
crimson ferry
#

@thorny jay I use adafruit_st7789 for displayio on MCU (it's just the init), and adafruit_rgb_display.st7789 on Pi with Blinka (and PIL)

thorny jay
#

Hum...

#

So if I want to run the same code on both a Pi Zero and a Pi Pico... what would you use (for the LCD)?

#

More or less the same code. 🙂

#

And I am currently trying to find the most simple way to know where the code is running.

#

something in os. or board. or sys.

crimson ferry
#

Does displayio work on Pi? I think I tried that and couldn't get it going, so reverted to PIL.

thorny jay
#

I can import it...

manic glacierBOT
#

What is more, I would suggest updating the MacOS Setup guide to replace the brew install gcc-arm-embedded with the manual installation (similar to the Linux setup). That is because the gcc-arm-none-eabi-10-2020-q4-major-mac.tar.bz2 package is not signed and the MacOS prevents executing the compiler binary with the "Unidentified Developer" error. The gcc-arm-none-eabi-10-2020-q4-major-mac.pkg package is "Signed and notarized" and it works fine.

Thanks for noting this! This is a movi...

crimson ferry
#

sys.implementation.name will tell you what kind of Python you're running

#

cpython on Pi; circuitpython on MCU

#

other ways to differentiate: sys.platform, os.uname()

manic glacierBOT
manic glacierBOT
#

Following the guide at https://learn.adafruit.com/how-to-add-a-new-board-to-circuitpython/ :

  • copied boards/simmel, which is another nRF52833-based board;
  • updated mpconfigboard.mk with
USB_VID = 0x0d28
USB_PID = 0x0204
USB_PRODUCT = "micro:bit"
USB_MANUFACTURER = "BBC"
  • updated mpconfigboard.h with
#define MICROPY_HW_BOARD_NAME       "micro:bit"

#define DEFAULT_I2C_BUS_SCL         (&pin_P0_26)
#define DEFAULT_I2C_BUS_SDA         (&pin_P1_00)

#define D...
manic glacierBOT
manic glacierBOT
#

The nRF chip on the micro:bits is not connected directly to the USB pins; it goes through the interface unit microcontroller, as you may know . So I'm not surprised you are not seeing the REPL. All the current CircuitPython code assumes that the REPL is over USB. We never supported the micro:bit V1 with CircuitPython. There is a specialized port of MicroPython that did a lot of squeezing to get it to fit in the small RAM and flash space.

Currently, we would not support the micro:bit V2 bec...

onyx hinge
#

I have been playing with the enhancements to ulab and bitmap with the clue fft example https://learn.adafruit.com/ulab-crunch-numbers-fast-with-circuitpython/fft-example-waterfall-spectrum-analyzer

Per row, here are some timings. Reading the audio samples takes about 16ms, and doing the fft calculations another 7ms, both approximate. Using assignment via bitmap memoryview is fastest, taking about .5ms per row. Using arrayblit is next, taking about 1.2ms/row. Using the looped pixel assignment is slowest, taking about 12ms/row. Going from 12ms to .5ms is good, for the part we optimized; but even before starting it was the smaller part of the whole process, so overall it goes from about 36ms to about 24ms, only 33% faster.

If we could sample in the background, then either arrayblit or memoryview are fast enough that we could continuously display the fft of our audio signal which is really awesome! audio improvements like that are something we'd love to see. (assuming sampling itself doesn't take away any CPU time, the fft+bitmap update code only needs about 8ms out of every 16ms, or 50% of the CPU)

Eventually, when CP7 is closer and these things are nailed down, we'll have to update the ulab guide.

manic glacierBOT
#

The nRF chip on the micro:bits is not connected directly to the USB pins; it goes through the interface unit microcontroller, as you may know . So I'm not surprised you are not seeing the REPL. All the current CircuitPython code assumes that the REPL is over USB.

Yes, but the interface controller is supposed to expose the specific pair of nRF pins (P0.06 and P1.08) as a USB serial interface -- that's my understanding from their schematic page. Mass storage experience aside, why does the...

manic glacierBOT
#

why does the non-direct USB connection stop the REPL from working?

The CircuitPython REPL code is sends and receives characters over USB serial port using TinyUSB, not via the UART port you mentioned (P0.06 and P1.08). There is some latent support for this in the nrf port, but we haven't tried it out in a while and it may have gone stale. Try setting CIRCUITPY_REPL_UART = 1 in mpconfigboard.mk, which primarily controls code in ports/nrf/supervisor/serial.c.

manic glacierBOT
#

I understand in theory how to load the code. I understand in theory what you can do with that second core that may be of interest. In theory I understand the appeal of Python here and how it could be terrible yet passable.

What I do not understand is how you plan to implement it and provide something like real time. I am also curious to know if you know where that issue could exist.

The RP2040 provides the raw materials to achieve it. They are cost optimized and will not play nice with ...

manic glacierBOT
manic glacierBOT
#

It is required to call .dirty() with appropriate arguments after modifications through the buffer protocol, or the display might not be updated correctly.

I've played with this a bit locally with #4547 with an adapted FFT waterfall and it is the fastest method I found to update bitmap content. However, both this and arrayblit were about 10x faster than repeated assignment to b...

#

There's no code per se, because it locks up during disk activity and/or soft reload. I assume that the code from the guide will set up the conditions for eventual failure:

displayio.release_displays()
matrix = rgbmatrix.RGBMatrix(
    width=64, bit_depth=4,
    rgb_pins=[board.D6, board.D5, board.D9, board.D11, board.D10, board.D12],
    addr_pins=[board.D25, board.D24, board.A3, board.A2],
    clock_pin=board.D13, latch_pin=board.D0, output_enable_pin=board.D1)
display = f...