#circuitpython-dev
1 messages · Page 329 of 1
haha, ok
also @slender iron I used the custom stubs function to get the gpio responsible for causing wake up from deep sleep and it works quite well.
thanks for the suggestion
nice!
@slender iron deep sleep api discussion if you are free ?
I have got some updates
I am considering creating a new module named alarm for getWakeAlarm() instead of implementing it in microcontroller.
microcontroller will only have a function to call for deep sleep which won't be visible from code.py as we only call deep sleep when we exit from code.py
draft PR coming soon 🙂
Thank you!!! This approach looks really good overall. I have a question about reload_on_success but it should be easy to sort out.
If this is used in an OTA case maybe we want something like "errors_ok=False" where a failure in the next code reverts what is run back to code.py. When on USB, I think an error would be ok.
Wild idea, what if you use the same approach to save the traceback string and provide it to the code.py? That way an OTA could capture the error.
I think it's ok to make it sticky. Save the next code state until it's set back to something else. When on USB, it's ok if it errors. However when trying to do an OTA we may want to go back to code.py or maybe a different default name.
What is this for? Please add a comment with the python stub. (Lines that start with //|)
I don't think so. It is set to 8 and we have: stack, heap, flash cache, terminal tilegrid, sharp display, rgb display at most.
SH1107 DisplayIO Support Update
I thought I would use this draft PR to keep posting progress on trying to get SH1107 supported under DisplayIO.
TL;DR:
I'm stuck because DisplayIO seems to expect the display controller to auto-increment past page (page mode writes) or column (vertical mode writes) boundaries. SH1107 requires you to set the page or column address at the end of each boundary or it will just wrap and start updating the same page or column of memory. I'm not sure this...
@slender iron @onyx hinge I posted my long sad SH1107 story to https://github.com/adafruit/circuitpython/pull/3450#issuecomment-697951372 Would really appreciate any ideas to move forward! Thanks -mark.
I think you can add a second quirk (or just call this the sh quirk and have it do two things.) The second thing you could do is change the subrectangle that is updated here: https://github.com/adafruit/circuitpython/blob/main/shared-module/displayio/Display.c#L277 Basically change each subrectangle to be the smallest area you can update.
I think you can add a second quirk (or just call this the sh quirk and have it do two things.) The second thing you could do is change the subrectangle that is updated here: https://github.com/adafruit/circuitpython/blob/main/shared-module/displayio/Display.c#L277 Basically change each subrectangle to be the smallest area you can update.
Thanks. I might try switching to 'vertical' mode as well, then the display will have a horizontal orientation naturally without the user having to set ...
Sorry, I understand this fixes the issue but I'd really like to understand the root cause.
The only way I imagine the reset failing is if the pulse is shorter than it should be. We should be able to verify that it is too short with a logic analyzer or oscilloscope. I'm worried the root cause is causing other issues.
When a pin is listed in board, it should print out with its first board name instead of microcontroller.pin.
With a pin definition like:
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO17) },
{ MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO17) },
}
Thi...
@tannewt Is it really just this simple?
diff --git a/shared-bindings/microcontroller/Pin.c b/shared-bindings/microcontroller/Pin.c
index 1294b78f0..409d998ee 100644
--- a/shared-bindings/microcontroller/Pin.c
+++ b/shared-bindings/microcontroller/Pin.c
@@ -71,7 +71,7 @@ STATIC void mcu_pin_print(const mp_print_t *print, mp_obj_t self_in, mp_print_ki
qstr name;
get_pin_name(self, &package, &module, &name);
- mp_printf(print, "%q.%q.%q", MP_QSTR_microcontroller...
on the page:
https://circuitpython.readthedocs.io/en/latest/shared-bindings/canio/index.html#canio.Message
this link:

points here, which doesn't exist:
https://github.com/adafruit/circuitpython/blob/main/shared-bindings/canio/index.rst
cool, I test it out this eve
that should fix the "run out after 21" bit
I still don't know why the esp32spi doesn't like the reuse
same-enough IDF I'd expect (though there's the Arduino abstractions), almost points to NINA, but I really don't know either
I think fixing this socket leak will at least succeed
oops, you get the idea
heh, I missed words too
Question - Is anyone having issues with today's 6.0.0-beta with saving a code.py file and having it update real-time on your device? What I am experiencing is when I made changes, for example change something simple like ->
cp.red_led = True
Changing it to False and clicking save is not updating live on the device. Has anyone else seen this or could someone else possibly build from source and see if you can reproduce?
what OS are you on?
Windows
the host OS sometimes waits to write to the flash
Yea I read that however time is passing and still not updating.
even if I go into the REPL and ->
import code
No effect
If I reboot the device the code changes take effect which is not expected behavior.
I am reproducing this on my MAC as well.
The Circuit Playground Bluefruit.
go ahead and file an issue. that way others can try and reproduce
6.0.0-beta.0-46-gdd86cb00a-dirty on 2020-09-23
Thanks
np
Issue: When I take a simple code block
`
from adafruit_circuitplayground import cp
while True:
cp.red_led = True
Then make a change such as the following
from adafruit_circuitplayground import cp
while True:
cp.red_led = False
`
Expected Behavior: The device will no longer illuminate the D13 LED
Actual Behavior: The device continues to illuminate the D13 LED
- Note: When I reboot the device any drive persistent saves will take effect however the expected b...
@slender iron I just did another pull and rebuilt. Strangely I am not seeing the issue.
interesting
Let me try to reproduce with my MAC brb.
kk
I did a new pull off master and I was unable to reproduce the issue. I confirmed successfully expected behavior mentioned above on both a Windows 10 and MAC env.
Closed...
YAY and stuff!
Previously, in a parallel dimension:

Parallel dimension @pastel panther well played!
should we close this since pr #3375 got merged?
Ok, I suspect this is how recv_into times out. Requests will fetch 32 byte chunks for parsing headers because it doesn't know the long they are. If recv_into waits for all 32 bytes which never come then the time out dictates how fast it happens.
Updated board files for FeatherS2 & FeatherS2 Prerelease
@slender iron lol I was getting errors before dinner, but I see you updated now 🙂
still getting every other socket: RuntimeError: Failed to send 3 bytes (sent 0)
yup, I didn't fix that 🙂
I think I'm going to pick up my split esp32spi code
it does fix the running out of sockets though 🙂
yup, that was my hope
wait, spoke too soon:```Fetching text...
22 RuntimeError: Failed to send 3 bytes (sent 0)
Fetching text...
23 Socket missing recv_into. Using more memory to be compatible
RuntimeError: Timed out waiting for SPI char
Fetching text...
24 RuntimeError: Expected 01 but got 00
maybe different issue
ya, that's a nina thing I think
had to reset... the esp32 got into an unhappy state
I reworked timeouts in my split branch that may help
should I wait if you're still tweaking?
I'm running again to see if it dies in the same place
I saw it after a while too
My though is that RTRs and normal messages are not functionally the same so using the same class for both is a bit awkward. If there were two types, then you'd have to know which type to pass into readinto to be filled by the next message of unknown type.
On the receiving end especially, you're going to want to know if it's an RTR message so at some point I would expect code like
while not timeout_expired():
message = <MessageGiver>.next_message
if message is None:
...
yeah, iteration #22 again
oops, sorry, cancel that, that's the expected even-iteration error
so it will run, presumably until it hits the (NINA) "RuntimeError: Timed out waiting for SPI char" error... will try to replicate
ya, I think the nina timeout is too low generally
I need to dust off my split branch and make it backwards compat
sequence this time:```Fetching text...
34 RuntimeError: Failed to send 3 bytes (sent 0)
Fetching text...
35 Socket missing recv_into. Using more memory to be compatible
RuntimeError: Unable to read HTTP response.
Fetching text...
36 RuntimeError: Expected 01 but got 00```but control-C, control-D got it back on track... I suspect if I catch the SPI error and esp.reset and retry it would
be fine... I'll play around some more
ya, I think so
the pyportal level is really aggressive in catching errors
frustrating for debugging but good for retrying
I pretty much operate at Requests level these days, do my own timeouts, retries, exception handling
thanks for the testing 🙂
np
sorry, I jumped the gun and thought pr addressed chunked, but you said if was for running out of sockets and that's looking good now
At default, need to pull up and down few pins for enabling the power to turn on for 40-pin header.
For ArduinoCore, this is done : https://github.com/Seeed-Studio/ArduinoCore-samd/blob/ef8f3edde07a701374b7c683510e33d42f6a9627/cores/arduino/wiring.c#L218
A question about Phillip Burgess's Moon Phase Clock, can the code be converted to work with the original PyPortal? If so can someone give me a lead on how to go about it.
I think you shouldn't be updating the unrelated submodules...
A question about Phillip Burgess's Moon Phase Clock, can the code be converted to work with the original PyPortal? If so can someone give me a lead on how to go about it.
@peak thicket Yeah, that could be great, actually a few of the Matrix Portal demo could work on PyPortal. For the Moon, I am afraid the BMP used will be low resolution and so not that nice. What I saw is 100 BMP files, but I don't know how they have been generated. Except for that the code get the time from internet, does some computation, and then ask an API with the real time (maybe UTC or something like that).
I posted this in the help-with channel, but digging into it a bit more, it might be more appropriate here:
uart = busio.UART(board.TX, board.RX, baudrate=9600)
msg = bytearray("hello world\n")
while True:
uart.write(msg)
time.sleep(.05)
data = uart.read(len(msg))
print(data)
data = ''
time.sleep(1)
When I run this code on a grand central m4 with nothing connected to it, my uart.read statements return "hello world\n"
If I run this on TX1/RX1 or TX2/RX2 this does not happen
is there some sort of unique shared buffer on the default uart that causes this?
I don't know why that would happen, absent a connection between the RX and TX pins that would "loop back" the signal from the transmit pin to the receive pin.
Yeah, nothing is physically connected to it. No matter what length message I send, I get equal bytes back in my rx buffer
@onyx hinge I've actually got a second grand central, but without headers. That board is acting properly. I've updated both boards to 5.3.1 and double checked the code to be identical. Any idea what could be going on there?
I double checked with a multimeter that there is no electrical connection
I'm starting to think it may be an electrical issue after all. Using jumper wires on my board without headers, if I hold the ends of the wires in separate hands I am able to replicate the behaviour I see on my board with headers
@prime cove What happens if you ground the relevant rx pin?
Grounding RX cleans it up
Sound like a quirk with the input left floating?
I think the headers might actually be adding enough capacitance to cause an issue. If i leave them floating on the headerless board I don't see the issue.
For comparison, this is what fingers can do on the TFT Gizmo and these aren't even floating inputs! https://www.youtube.com/watch?v=h5VPk8JsDXk
The CircuitPython code running on this Circuit Playground Bluefruit rotates through three non-moving sprites on the left side of the TFT Gizmo screen at 00:00 to 00:04.
If fingers are pressed firmly against the pad/screw heads of the Gizmo over SCL/SDA/RX/TX then this can c...
For sure! Fingers definitely cause problems, I just haven't run into headers having this sizeable of an impact before
Is there a way to disable the REPL in CP? In MP it is done by going into the ports folder of choice and editing main.c however the structure is different here and wanted to better understand how to do this if one was to ever create an app where we did not want REPL access.
How would I disable that? In addition what if I wanted to have serial coms is there another option?
there was an option for compilation for selecting which USB devices are to be active
CDC, MSC, MIDI, etc.
no idea for if you want serial but not REPL
I am looking for how CP implements main.c in a given port. In MP, main.c allows me to disable the REPL. There has to be something in CP that will allow this thus allowing a serial com however not having access to a REPL.
might be outside of use cases for CP
If CP was to be used on more sophisticated devices where security is an issue like a medical device, etc this feature must be available.
Obviously not now but I am just trying to think about ways we can push the CP into more advanced applications in addition to it being educational thats all.
MP is more suited in that area
If anyone can point me in the right direction to disable the REPL that would be great.
Yes MP is more suited I agree I am just looking at additional options for future needs that's all.
sure, you might have some luck searching the github issues
I think this might have come up before
I would like to see CP in a place where people will not be able to say, "Oh CP, it can't do that!" With unittesting and an ability to disable REPL it just opens potential doors for advanced makers.
sure, but the development focus is still gong to be the first 10 minutes of user experience
there is issue for disabling those USB devices at run time, by the way
with a boot.py
then it doesn't even require recompilation, and you can have something like "hold down this button at boot to have serial and usb disk"
A couple of forum posts recently have asked if HID or MSC could be disabled for security or device interference reasons. We need some kind of dynamic USB descriptors to do this. https://forums.adaf...
yes
Thanks @simple pulsar I am still looking for a way to disable the REPL rather than the USB altogether.
@slender iron I went way out on a limb and tried to kick off multiple requests and collect the responses later in a low-tech-async way, but got "Newer Response closed this one. Use Responses immediately." I assume that's expected.
@balmy stirrup You could add that as a comment to issue ticket. You want serial output (and input) but no REPL, then?
@simple pulsar what I am looking for is an easy way to:
1)disable REPL (like going into a given ports main.c in MP)
2)disable USB (for instances where you want both a REPL and USB no access)
How would one accomplish the two following tasks very specifically?
1)disable REPL (like going into a given ports main.c in MP)
2)disable USB (for instances where you want both a REPL and USB no access)
3)have full serial input and output available
The potential use case will NOT be default or standard it would be an option for advanced uses in the even CP were to be used in more advanced IoT devices where security is of primary concern. This can create significant potential for CP ho...
So for the record, @slender iron when we were talking about the "STM32G" this is what I thought you meant: https://www.st.com/en/microcontrollers-microprocessors/stm32g4-series.html
I think this is ST's replacement for the F1 line, basically?
I don't think they're too special right now because a lot of their chip lines aren't out yet, but I'll be interested in them once they get the CE lines (max RAM/Flash) released - they'll be the most powerful chip I know of for the QFN48 chip size.
It looks like https://github.com/adafruit/circuitpython/blob/main/main.c#L436 has a run_repl function that might be what I am looking for.
@simple pulsar @stuck elbow I think I found what I am looking for -> https://github.com/adafruit/circuitpython/blob/main/main.c#L508
@slender iron as for the GigaDevices, I guess they're actually a legitimate ARM licensee, which I'm not sure about for some of the sketchier clones. They claim to have done their entire own implementation, they just based it on the STM32 to make it "compatible". That said, I don't hear very good reviews for it - most people don't feel the chip's extensive errata and poor ADC performance make up for the small drops in pricing, when compared to the F103 or F401 which are often just as bottom barrel inexpensive
@onyx hinge I'm trying to translate to spanish "Already have all-matches listener". What would "all-matches" means in this context?
I'm trying to read the src, but the msg vs the conditions on the 'if's are not clear to me.
@slender iron :
1)You mentioned in git issue 1015 that CIRCUITPY can be edited to disable USB where specifically is that in main.c as there are many references as I would like to test disabling the USB drive however still having the ability of the internal .py modules to write to the disk (for example saving a setting throughout runtime)?
2)Where would one place a specific frozen module assuming there is no boot.py or USB to run if no REPL or USB or boot.py was present when flashing the drive? I am looking to where I can place a .py file which will be frozen and then ran on boot.
@balmy stirrup I have been wondering if over time there's room for the current maker\beginner CP and then through a series of CP add-ons (maybe a configurable build system) which enable\disable "advanced" features which might also be prohibitively complicated for makers\beginners another CP version to support "advanced" needs. Definitely NOT a fork though.
@idle wharf I agree that is exactly where I am going with this. It is not about changing the initial "experience" of CP. That has to be as basic and simple as possible to gain maximum new maker converts. I just want to understand how I may do some of these "advanced" techniques so that I create a detailed tutorial for anyone looking to use CP in a more advanced way.
I think that what is "advanced" would be an interesting list to put together.
@slender iron I went way out on a limb and tried to kick off multiple requests and collect the responses later in a low-tech-async way, but got "Newer Response closed this one. Use Responses immediately." I assume that's expected.
@crimson ferry Yup, because you may end up reusing the socket for the next request.
I don't think they're too special right now because a lot of their chip lines aren't out yet, but I'll be interested in them once they get the CE lines (max RAM/Flash) released - they'll be the most powerful chip I know of for the QFN48 chip size.
@ionic elk The access line actually goes down to 32qfn which is on the trinket and gemma. STM32G491KC/E. 112K ram and 256 or 512k flash. marked as q1 2021
@onyx hinge I'm trying to translate to spanish "Already have all-matches listener". What would "all-matches" means in this context?
@silver tapir A match is a set of condition for what messages to listen to. anall-matcheslistener includes all messages off of the bus
@onyx hinge Thanks.
@slender iron :
1)You mentioned in git issue 1015 that CIRCUITPY can be edited to disable USB where specifically is that in main.c as there are many references as I would like to test disabling the USB drive however still having the ability of the internal .py modules to write to the disk (for example saving a setting throughout runtime)?
2)Where would one place a specific frozen module assuming there is no boot.py or USB to run if no REPL or USB or boot.py was present when flashing the drive? I am looking to where I can place a .py file which will be frozen and then ran on boot.
@balmy stirrup 1) You can disable MSC in the USB descriptor or set it read-only in boot.py. I'm not sure what portion of the issue you are referring to. 2) I don't know. We don't support that. A system without USB isn't CircuitPython to me.
and if you do want to use CircuitPython code in a secure environment, it is your responsibility to make sure it is secure. Other contributors and I do not.
@slender iron I understand it would be my responsibility I am just trying to understand the "how" I apologize if it somehow offended.
As long as you understand it's on you I'm fine with you exploring it.
I would not expect an open-source community to provide security I don't think anyone would. I am just trying to understand what is possible. Any code and it's application is the responsibility of the developer never the community.
As you've seen, CircuitPython unifies main.c outside of ports. It is the equivalent of MicroPython's port/*/main.c but applies to all ports.
Take a look in supervisor for the serial APIs. It should be possible to disable USB and interface with a UART there.
Please continue to ask about this on Discord or a separate issue. This issue isn't a great place because it's specifically about changing the USB descriptor, not disabling it.
👍 I want to be explicit with that because I think some folks think that it's secure by disabling USB.
The intent of my question was not about getting an answer on how to secure a device. I understand your position. Disabling a USB does not at all secure a device I just wanted to understand better how it worked to help others if they wanted to build more advanced applications rather than hearing - "Oh that's something you should just do in C, C++ or MP". I respect your position and understand and will follow your advice in the issue comment.
MIDI SysEx messages are sent out the USB MIDI port are garbled.
Example:
import usb_midi
usb_out_port = usb_midi.ports[1]
sys_ex_test_msg = bytes([0xF0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xF0])
usb_out_port.write(sys_ex_test_msg)
The host system should receive an 11 byte MIDI SysEx message.... however it receives:
10:43:23.628 From CircuitPython usb_midi.ports[1] SysEx
F0 01 02 01 01 02 02 01 02 03 01 02 04 01 02 05 01 02 06 01 02 07 01 02 08 01 ...
Oops, forgot to add: This bug is observable in both release and latest versions of CP. From my test device boot_out.txt files:
- Adafruit CircuitPython 5.3.1 on 2020-07-13; Adafruit CircuitPlayground Express with samd21g18
- Adafruit CircuitPython 6.0.0-beta.0 on 2020-09-21; Adafruit CircuitPlayground Express with samd21g18
@onyx hinge - as per our prior discussion, I filed this issue so that CP is sure to pick up a newer tinyusb with this fix at some point.
@slender iron I am getting the following Build CI error with the deep sleep implementation.
@analog bridge when you have a name in single backticks like the alarm on discord, read the docs tries to link it to it's doc
if it isn't an object then you'll get the error
you can either correct it to match the name or wrap it in double backticks
@askpatrickw I don't think so because you need to account for printing objects that aren't in board as well.
That will also print board.pin.A0 I believe too.
@slender iron unable to find alarm in the code
I have deleted them all....... let me re-check
@slender iron do you want me to change canio.Message in response to @pastel panther 's comments? I don't see a way to make eveyone happy. Also worried that I'm attached to my design and not being objective.
still can't find alarm and I deleted all the //|
@slender iron OK thanks!
@slender iron can you have a look at the code when free
did you make a PR yet?
just make the draft even if the CI is broken
that way when I find it, I can comment on it 🙂
The board.c changes look ok. You'll want to rebase to remove all of the submodule changes. Ping me on WeChat if you need help with it.
Check git status before you commit to make sure you are only adding the changes you want. The modules will show as red and a git submodule update . will fix them up.
@siddacious has been kind enough to point out some other problems in the docs.
I'd like to consider a couple other changes while this still hasn't gone out as beta:
- I used send() and read(), but send() should pair with recv() and write() with read(). So one should be renamed
- Match(address=) should change to Match(id=), ditto the property
@jepler Yup, those seem like good changes. I would like recv to be receive though. Full words are easier to understand and we don't have an existing API we're trying to interoperate with (/me looks at socket).
@siddacious Are you proposing dropping readinto in favor of splitting Message into two types, Message and RemoteTransmissionRequest? I like that too. readinto isn't that helpful because you've already set filters so you only receive objects you are interested in.
Yup! Thanks @ricardoquesada
I'm not sure this is doable because we generate index.rst based on the .c files in shared-bindings.
@slender iron so canio.Message and canio.RemoteTransmissionRequest? and drop Listener.readinto altogether?
that's what I'm thinking
and then RemoteTransmissionRequest has size only and Message only has data

OK give me a bit of time to get this together @slender iron @pastel panther
@siddacious I don't have anything against readinto per se, I think it or something like it could allow for recycling message objects which might be useful. That said, I do like the idea of RemoteTransmisisonRequest.
If others agree that somehting like a "message pool" would be useful, it would be helpful to provide helpers because they're not trivial (I tried)
readinto can take two objects and return one of them 😜
Why are you including .py files in the board directory? If you are trying to ship with a demo that uses it, then the files should live on the FAT filesystem along with the example code.py.
Generally, frozen modules should only be used to save RAM on constrained devices like the SAMD21. The ESP32-S2 doesn't have that constraint and really shouldn't have frozen modules. Frozen code is hard to understand because it isn't on the drive. It's typically older code and it's impossible for the user...
This is very similar to how we do BLE advertisements and we do not have a readinto equivalent. Both of these APIs, BLE and CAN, can rely on upfront filtering to minimize memory churn.
The objects are typically small so they do not get harder to allocate as the heap fragments. (Reuse is way more important for large objects.)
If at some point we support CAN FD, the payload of a single message can be up to 64 bytes, rather than just 8.
@pastel panther @slender iron size= or length= for the constructor argument / property of RemoteTransmissionRequests?
@slender iron re the STM32G49, is that something you'd be interested in, then, once it's available?
chips that small would make for some interesting projects, that's a lot of flash/ram for such a tiny chip
circuitpython that fits in your ear canal
It seems as though the fix for nRF52840 Revision 1 Errata V1.4 - 3.8 in qspi_disable() is doing something to the SPI. If I comment out the two lines from that errata, SPI works correctly. Then running on battery I do not see QSPI in the peripheral list generated by the script above from @xiongyihui . However, I don't have a way of measuring any differences in the current draw from the battery with or without that code. I have not been able to find any reference saying what the line
`*(v...
@slender iron I fixed the Build CI error that I mentioned earlier 🙂
Getting a draft PR ready 
@ionic elk ya, I'm very interested in it
@onyx hinge I guess length to match len()? size is ok with me too
I don't mind if there is a link to actually edit the docs or not, I'd just don't like broken links.
Can you link to the processes and/or scripts that are responsible for generating the .rst files? I assume it's run by Actions?
Why are you including .py files in the board directory? If you are trying to ship with a demo that uses it, then the files should live on the FAT filesystem along with the example code.py.
Generally, frozen modules should only be used to save RAM on constrained devices like the SAMD21. The ESP32-S2 doesn't have that constraint and really shouldn't have frozen modules. Frozen code is hard to understand because it isn't on the drive. It's typically older code and it's impossible for th...
@pastel panther @slender iron https://gist.github.com/jepler/37722372347f6847278a67db3cc718c5 -- diff of docs https://gist.github.com/d8aedc6b12615970531f54a2f35b9b41 -- updated can_test.py
will PR, as well
just want to have a high probability that this is the last go-round of changing API for now 🙂
hmmm something about that doc is incomplete puzzled
or at least the diff is incomplete
Thanks to @siddacious for finding various problems and suggesting improvements to the API.
Net doc changes from this PR: https://gist.github.com/jepler/37722372347f6847278a67db3cc718c5
Revised loopback test program, passes on SAM E54: https://gist.github.com/d8aedc6b12615970531f54a2f35b9b41
High level summary:
- renamed Listener.read -> receive
- removed Listener.readinto (no zero-allocation CAN reading)
- added RemoteTransmissionRequest class (no voodoo switching between rtr ...
@tannewt Please let me know if you are ok with what I have now. I really want it in for beta 1 :)
Do updates to MicroPython get reviewed procedurally?
I ask because I reported a minor bug and they've fixed it, https://github.com/micropython/micropython/issues/6320, the creator closed the ticket today.
@simple pulsar if there's a change you think needs to be made in circuitpython, your best bet is to PR it against Circuitpython.
If the noreturn stuff doesn't work, I'll pull it out. However, it DOES become relevant when I start work on the stm32 CAN implementation, it got here by slight accident.
@jepler are silent and loopback not mutually exclusive on the SAM-E? Each of those tries to set the mode of the MCP2515 so I'm currently raising an AttributeError if both are set
All 4 combinations of silent= and loopback= work on SAM E5x and (as far as I can tell so far) on the STM32. If some combinations are NOT supported, the constructor should throw.

I agree, the datasheet says your device only supports 3 out of 4 of the modes.
Just saw this, I'll take a look!
This PR implements deep sleep support on CircuitPython!
Port(s) supported: (as of this PR)
- esp32s2
To-do:
- [ ] Get wakeup reason to work
- [ ] Implement custom wake stub
- [ ] Implement method to enter deep sleep when
code.pyfinishes
@slender iron idk pythonic-ness, but new network stack... thinking of operationally like the move from RGB_Display --> displayio, would they go in parallel so stuff doesn't break and people have time to migrate code while still updating bundles
@crimson ferry ya, agreed. I'm just worried I've broken the existing code with the requests switch
btw, there is a current issue in the github actions platform in case anyone sees anything weird in checks running right now.
'message': 'Github Actions Unavailable. We are working to restore all services as quickly as possible. Please check back soon.'
I guess I don't know what makes sense here; From a user perspective I think setting a mode that has the behavior you want is more important than what bits get set. I don't know if the MCP is the outlier here or the SAM; do other MCUs support all 4 options of the "transmit y/n" and loopback y/n" matrix?
If at some point we support CAN FD, the payload of a single message can be up to 64 bytes, rather than just 8.
We can always add readinto if we really need it. I suspect this approach will still be OK because 64 bytes is still only 4 blocks (16b each) of memory.
Looks good to me; the empty for loops are confusing but I don't think they're hurting anything
Does this and the others do something?
Ok, I played around with this on my Kaluga
diff --git a/shared-bindings/microcontroller/Pin.c b/shared-bindings/microcontroller/Pin.c
index 1294b78f0..5fc402316 100644
--- a/shared-bindings/microcontroller/Pin.c
+++ b/shared-bindings/microcontroller/Pin.c
@@ -71,7 +71,7 @@ STATIC void mcu_pin_print(const mp_print_t *print, mp_obj_t self_in, mp_print_ki
qstr name;
get_pin_name(self, &package, &module, &name);
- mp_printf(print, "%q.%q.%q", MP_QSTR_microcontrol...
You can all prolly see my last comment, but I wanted to ask as well. What's a good test case for a non-board pin where Print(module.pin_name) should be something other than board.pin_name.
@idle wharf probably easiest to just remove a pin from pins.c temporarily
Since e.g., NVIC_SystemReset never returns, this creates an unreachable 2 byte opcode that jumps to itself. However, this allows the compiler to conclude that reset() never returns, as promised. A more correct change would be to actually let gcc understand that NVIC_SystemReset does not return, but I don't know how to do that.
@grim dagger awesome! @meager fog is going to be so excited!
The problem I’m having now is the label text wraps at the halfway point!!!
Top string is supposed to be 0 thru F
And when it wraps it takes some of the 2 nd half of the bitmap with it!
But the circuitpython output text works fine
is it display_text.label?
@lone axle Yes
do shorter strings work fine? like 0-6 only or something?
There is a macro NORETURN which expands to __atribute__((noreturn)), which is described on this page:
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noreturn-function-attribute
@lone axle Yes... in the scaled font at the bottom SH*T works great! 🙂
Can I see your code that makes and shows the labels? gist/link or here if it's short. I don't know much about that feather wing but I am pretty familiar with the label module maybe I can help try t figure out what could be going on.
I also see a problem where it isn't releasing the display (re-load errors out no display) and D9 is busy sometimes.
Yes, I should have used the macro instead of the attribute here where I added it: https://github.com/adafruit/circuitpython/blob/dfdfbc4e01dc99c1fa90a9efe5675c02672b3cc5/ports/atmel-samd/reset.h#L39
gcc is complaning because of the NEW noreturn attribute; when it looks at the function definition it thinks it detects the function DOES return, because NVIC_SystemReset is not noreturn.
Draw some label text
text1 = "0123456789ABCDEF"
text_area = label.Label(terminalio.FONT, text=text1, color=0xFFFFFF, x=8, y=8)
splash.append(text_area)
#text2 = "DisplayIO on:"#text_area2 = label.Label(terminalio.FONT, #text=text2, color=0xFFFFFF, x=24, y=16)
#splash.append(text_area2)
text3 = "SH*T"
text_area3 = label.Label(terminalio.FONT, text=text3, scale=2, color=0xFFFFFF, x=4, y=44)
splash.append(text_area3)
Nothing jumps out as immediately strange to me with that. That is very odd behavior though I've never seen it jump back ontop of itself like that
I am curious how many characters it can handle before it wraps weirdly like that. And whether inserting newlines works correctly or not. But to be honest I'm not sure if either would get us closer to solved.
I can say there is no intentional wrapping built into the label at all so typically if you have a string that is to long the user code must put some newlines or using scrolling or some other strategy to show it.
The special thing about text is it is using pretty smallish-subrectangles. I didn't see any special clipping logic that might affect that though. I deliberately made various sized bitmap squares on the 2nd half of the screen to see if there was some issue with boundaries but they work fine.
It might be worth trying the bitmap label to see if it is any different you can easily swap by changing your import to from adafruit_display_text import bitmap_label as label
it uses one larger bitmap to store all of the glyphs instead of many tilegrids
O.k. will try that now.
We'll want to figure out what is going on with the regular label either way though that is definitely weird!
I should probably clean up the code and commit it to update my Draft PR
I feel like it's close now...
Commented out IO0
diff --git a/ports/esp32s2/boards/espressif_kaluga_1/pins.c b/ports/esp32s2/boards/espressif_kaluga_1/pins.c
index c1657d6c0..bd095d287 100644
--- a/ports/esp32s2/boards/espressif_kaluga_1/pins.c
+++ b/ports/esp32s2/boards/espressif_kaluga_1/pins.c
@@ -1,7 +1,7 @@
#include "shared-bindings/board/__init__.h"
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) },
+ // { MP_ROM_QSTR(MP_...
That helped! Thanks @slender iron Gotta go find takeout I'll pr later tonight.
Interesting. The differences between them could be a hint about why the other is not working. I'm not I know enough about some of the internals to know where that hint leads though.
For some reason the many tilegrids approach is getting thrown off somehow by some of them getting moved to the wrong spot it seems.
the way it copies the background with it extra weird too.
what kind of feather is running that?
I'll go clean up my code to make it presentable 😉 I probably over-simplified something. That is the 128x64 OLED FeatherWIng. It uses a different control chip than before.
because NVIC_SystemReset is not noreturn.
That is the kind of thing to fix in the asf4 repo, I'd say.
I have done a clean up and committed changes "Mostly-working-version with comments".
I have also updated the driver and the example code: https://github.com/mdroberts1243/mdroberts1243_CircuitPython_DisplayIO_SH1107 (don't know how to contribute that!)
Currently everything looks like it is working except label text (bitmap_label will work fine). An easy way to see the problem with text is to run the example code and then enter the REPL. You will see that the terminalio<?> output work...
REPL on SH1107 FeatherWing. Note the input characters wrap: I entered "print(1)" but when you hit return you see the console output render across the whole width of the screen. A similar problem exists with label text too.
Not 100% certain whether the underlying issue is in displayio or RGBmatrix. Regardless: sometimes after changing elements of a displayed group, nothing happens on the display, or only some of the changes take effect. Is there a way to force a full repaint for good measure?
This is sometimes seen on the Moon clock. It might stick on the splash screen (though I’ve confirmed it’s doing Moon math and updating elements in the active displayed group), or might only redraw a subset of elements on...
You'll need to add the prerelease board name to the github workflow to get the CI to pass: https://github.com/adafruit/circuitpython/pull/3463/checks?check_run_id=1162679057 and adjust the line endings for these two files: https://github.com/adafruit/circuitpython/pull/3463/checks?check_run_id=1162679034 (Exactly one line at the end.)
Because I think it's confusing for folks having just on the FS when they might not understand why it's there, when on "constrained devices" they don't ...
I tested this with a Clue as well. On 5.3.1 the error reproduced immediately, on 6.0.0-beta.0 it ran without error for 10 minutes. It looks like there were significant changes in how time.monotonic_ns is calculated on the nrf52840 port between the two versions.
what kind of feather is running that?
@lone axle Sorry I didn’t scan your question very well. I’m using the STM32F405 Feather.
REPL on SH1107 FeatherWing. Note the input characters wrap: I entered "print(1)" but when you hit return you see the console output render across the whole width of the screen. A similar problem exists with label text too.
@slender iron It occurred to me that each character in a label, and probably in input text, is rendered separately. In this mode of the controller I set a page 0-15 as I move horizontally across the screen. Perhaps there’s a circumstance where I mask only the lower three bits of the page to set it, dropping the upper bit and causing the wrap? Doesn’t explain why I saw some of the bitmap copied over though. In other operations the page will auto increment letting you paint the whole line.
O.k. I think I have a working quirk and driver and example code for the SH1107 128x64 Featherwing! Issue was where I masked the x address to form the set page command. Now I can get to sleep!
I fixed the masking error I had in setting the page on the controller and now all the basic operations work. You can use it with the REPL even.
How do I contribute the driver and example code linked above? Not sure how to create a "Pull Request" for something new.
Let me know if you need anything else.
-mark.
I played around with this a bit and came up with a conditional statement that outputs what I think is correct, but I'm not sure if there is some legacy behavior or other requirement about always having "pin" in there, I could add that back in for when the package is not present.
diff --git a/ports/esp32s2/boards/espressif_kaluga_1/pins.c b/ports/esp32s2/boards/espressif_kaluga_1/pins.c
index c1657d6c0..bd095d287 100644
--- a/ports/esp32s2/boards/espressif_kaluga_1/pins.c
+++...
I have a question is there something like upip from micropython for circuitpython? This would be handy for the esp32-s2 boards
@wooden lichen you can simply copy the lib of choice to the usb drive of the board in CircuitPython which makes it very handy.
@wooden lichen https://circuitpython.org/libraries To install, download the appropriate bundle for your version of CircuitPython. Unzip the file, open the resulting folder and find the lib folder. Open the lib folder and find the library files you need to load. Create a lib folder on your CIRCUITPY drive. Copy the individual library files you need to the lib folder on your CIRCUITPY drive.
Based on @tannewt’s first comments on #3454, let’s collect some more detailed requirements.
My work so far has concentrated on the game console use case, which I envision as follows (@deshipu or @robertgallup, correct me if you have any additions):
Thanks for the comments! Together with the implementation experience, they enable me to identify more higher-level requirements and I decided to go back to #1084 to discuss that, or should we continue everything here?
Wild idea, what if you use the same approach to save the traceback string and provide it to the code.py? That way an OTA could capture the error.
Sounds good, but maybe that would best be tackled in a separate PR? I’m not sure offhand how easy that is to obtain – is it s...
My plan was to add documentation later when we have a consensus on how things should work and it’s less of a moving target. Does what I wrote at the bottom of https://github.com/adafruit/circuitpython/issues/1084#issuecomment-698851943 explain it sufficiently for now? Otherwise I’ll add the documentation now.
I see 12 in https://github.com/adafruit/circuitpython/blob/dd86cb00adb2ecb1e0cdf256d9a4e0f96a0c6de1/supervisor/shared/memory.c#L34 But yeah, then that should be even more sufficient.
Sticky until set doesn’t work well for the “game console” use case where games shouldn’t need to set it to get back to the menu. See https://github.com/adafruit/circuitpython/issues/1084#issuecomment-698851943.
@balmy stirrup Thanks! I knew that already but I really liked the upip method!
It is not as important with circuitpython since it is much easier to transfer libraries
@wooden lichen check out Circup if you haven't seen it: https://github.com/adafruit/circup
it's not the exact same, but if you are familiar with pip or npm it will be somewhat similar to you.
Very cool @lone axle I did not know that was there. Thanks!
@idle wharf yesterday we spoke briefly about some steps for an advanced use case for CP. I put together a little tutorial if you are interested to experiment with @ https://github.com/mytechnotalent/CircuitPython_Frozen_Boot_No_REPL
I want to explicitly clarify that this is just some information for those who ever want to try to do some advanced projects with locking down some features. This is NOT the norm of CP as CP is designed to be beginner friendly and open-source however I wanted to create something for anyone who had a desire to experiment with advanced features this is not an attempt to try to change the direction of CP in any way at all.
For what it's worth, I've done a fair bit of displayio using various 5.x versions on CLUE and TFT Gizmo and haven't seen bugs like this. The one thing I have seen is surprising visual (and audio) effects of handling the pads which can happen with the TFT Gizmo depending on how you hold it: Circuit Playground Bluefruit with TFT Gizmo vs fingers - curious video artefacts - this doesn't sound anything like what's being described in issue ticket, t...
@balmy stirrup this is great info. Thanks for creating this document and sharing it. While it's not the primary purpose of CircuitPython it can still can be very helpful. My company occasionally will get tasked with setting up some hardware doo-dad that interacts with some of the software we wrote. We use CircuitPython because it lowered the barrier to entry for hardware to a point where we could actually make neat things that do what we need. We don't use it for anything particularly sensitive but we did look in to a sort of locking process to limit them as much as we could after their deployed. Looks like your process is more complete than ours was definitely bookmarking this for next time.
You may already be aware of this but there's a way of dumping the screen to a file described in [https://learn.adafruit.com/saving-bitmap-screenshots-in-circuitpython](Adafruit Learn: Saving CircuitPython Bitmaps and Screenshots) using the adafruit_bitmapsaver library. That might be useful for debugging to gather a bit more information on where the problem is likely to lie.
@lone axle thank you so very kindly for that! I really appreciate that and was very afraid some would misunderstand my intention. I LOVE the CP community as you all are so inclusive, non-judgmental, so friendly to help and you generally feel like a family. The CP community is so inviting to new makers and this little option that I put forth is only to help those who wanted to pursue something like you are referring to foamyguy. Thank you again!
@balmy stirrup This is really interesting, thanks for sharing. While this definitely isn't the norm, it may be useful for people creating test jigs
or commercial products where they don't want to give the user access to modifiable firmware for whatever reason
@prime flower thank you! That was the idea when coming up with it as I did a similar tutorial for MicroPython. I just wanted to have an option for people to build upon, an entry point so to say if they had such a need.
Great requirements spec! A couple of things caught my attention.
-
What's the use case for the requirement to reboot into game.py on a USB file write (in the case A table, above) ? (I'm not sure this is necessary/desirable for my use case -- but, possibly because I'm overlooking something.)
-
Exception handling. For my case, if "game.py" is running and I want to stop it and return to the main menu, I would expect to use CTRL+C, CTRL+D. From my read, it sounds like you're proposing thi...
What's the use case for the requirement to reboot into game.py on a USB file write (in the case A table, above)? (I'm not sure this is necessary/desirable for my use case -- but, possibly because I'm overlooking something.)
If you are working on your game, and modifying the file, you want to see your changes taking effect immediately without having to select it from the menu each time.
For my case, if "game.py" is running and I want to stop it and return to the main menu, I would expect to use CTRL+C, CTRL+D. From my read, it sounds like you're proposing this could return to either game.py or the main menu? I think my use case would require returning to the main menu.
Good point, I’ve changed that.
If you are working on your game, and modifying the file, you want to see your changes taking effect immediately without having to select it from the menu each time.
OK. I see. To me, this seems like a special case that might lead to unintended consequences/confusion in other applications and might be better handled by a developer disabling or bypassing the menu during development (e.g. renaming "game.py" to "code.py"). But, that's from my particular perspective.
Can you think of a concrete example of a situation where it would be unintended or confusing?
I don’t have a strong opinion either way, I guess I tend toward @deshipu’s view because I’m working on his devices, and also @tannewt has said above
My guess is that we want the currently running file reloaded
Can you think of a concrete example of a situation where it would be unintended or confusing?
I might be misconstruing this, but let's say that I'm working on a suite of programs. I might be making a change to a file other than the one that's currently running. In this case, I'd rather re-run from the top. Or, I might be adding a new game and want to see if the menu picks it up properly. Again, I'd want to rerun the menu. Trying to infer developer intent from a USB write can be difficult...
I have (or will have, in stm32 canbus) a function where it should be impossible to reach the end, so I put in a safe-mode reset at the bottom:
int find_unused_slot(void) {
// precondition: you already verified that a slot was available
assert(available_slot());
for (int i=0; i<NUM_SLOTS; i++) {
if (slot_free(i)) {
return i;
}
}
safe_mode_reset(MICROPY_FATAL_ERROR);
}
However, the compiler still gave a diagnostic, because saf...
@lone axle I also didnt know that!
Thanks, that helped me understand why you see it as an “exception” or “special case”. I was operating under the assumption that “the general rule that currently controls autorun” was equivalent to “always rerun the file that’s currently running”, because there was only one file that that could be, so it wouldn’t be an exception. But now I see that that’s not true: If you only have main.py and main.py is running and then you save a new code.py that didn’t previously exist, it will run code.py....
You also would get surprising behavior when you update a file that is imported in your game.py but not run directly.
@balmy stirrup thanks for posting that and I want to 2nd @lone axle as well. This looks very interesting as a tool for specific needs.
I have never heard of circup either. Lol.
The way I see it, the easiest to understand and explain behavior (apart from the current "always run main.py or code.py") would be:
- if a program finished running, or there was an error (including
KeyboardInterrupt), go back to the default behavior of running themain.pyorcode.py, and, depending on the options, show REPL, exception message with a pause, or reset immediately. - if there was a filesystem change, reload the currently running program.
Looks good to me; the empty for loops are confusing but I don't think they're hurting anything
I revised this push to get rid of the NORETURN stuff, now in #3469
@slender iron & community- thank you, thank you, thank you for creating YouTube Deep Dive timeline notes! This group is a sterling exemplar of a positive online community! 👍
STM and SAM both support all 4 modes. Feel free to throw an exception in your constructor if a non-supported mode is requested. Constructors will necessarily differ a little bit in their semantics as different HW has different capabilities.
Beginner question re debugging native USB on the saola-wrover- where to start? I'm not getting any hint of connection on Mac or Windows with CP. I've added a micro break out (5V->5V, GND->GND, D+ -> pin19, D- -> pin20, ID -> floating. All connections are at the end with the tact switches.) I may have broken some config- I got the breakout attached days after practicing compiling/downloading only via the built-in USB serial connection. I had downloaded U2F bootloader to the board and did have to do a full flash erase to be able to re-program it with CP. I've built the latest source code with both the latest IDF toolchain and the one embedded in the CP repo. USB breakout is connected by ~5cm of soldered on ribbon cable. I've checked for continuity and shorts. It does provide power... just no hint of CDC or mass storage. The RGB led does what I expect if CP is running, and I can get into safe mode by tapping the flash button at the right moment (LED stays yellow.) The IDF log on the builtin USB serial reports that CP is the app to be run. This is happening on two boards so far. I'm hoping I've missed a step? Is there an initial "image" that needs to be downloaded (like the optional SPIFFs for Arduino ESP8266?)
esp32s2 has distinct register bits so it looks like all 4 modes would be supported, but at another level the API only supports 3 of the 4 combinations.
uint32_t lom: 1; /* MOD.1 Listen Only Mode */
uint32_t stm: 1; /* MOD.2 Self Test Mode */
but
static inline void twai_ll_set_mode(twai_dev_t *hw, twai_mode_t mode)
{
if (mode == TWAI_MODE_NORMAL) { //Normal Operating mode
hw->mode_reg.lom ...
Greater that 100khz is technically out of the original spec.
Background here: https://github.com/adafruit/Adafruit_CircuitPython_CLUE/issues/36
@solar whale Doh! You're right. @slender iron the info on https://circuitpython.org/board/espressif_saola_1_wrover is backwards. The esp32s2/readme is correct. It's funny- there were three of us working on this last night, we had both this & the espressif schematic open and none of us caught this. Love an easy fix though!
Ah -- I see - taht should be fixed in the write-up The micro USB connector on the Saola is wired through a CP210x USB to serial converter chip for debugging and programming. The native USB is not available on a USB connector - instead you’ll want to pick up a Micro B USB connector breakout, Type C USB connector breakout or USB data cable and hand-wire D19/D20 to D+ and D- pads. @slender iron who can fix that?
@solar whale anyone. The source is here: https://github.com/adafruit/circuitpython-org/edit/master/_board/espressif_saola_1_wrover.md
doing it now
thanks! wroom and kaluga may have the same error
@solar whale - you beat me to it - thanks!
ok -- I'll check and update
Images automagically compressed by Calibre's image-actions ✨
Compression reduced images by <strong>44.1%</strong>, saving <strong>703.12 KB</strong>.
| Filename | Before | After | Improvement | Visual comparison |
|---|---|---|---|---|
| <code>assets/images/boards/large/bless_dev_board_multi_sensor.jpg</code> | 54.10 KB | 50.78 KB | -6.1% | [View diff](/adafruit/circui... |
@DavePutz Thank you for finding that! That's enough rood cause for me.
Kaluga is correct -- WROOM does not have as much detail -- so it's not "wrong"
kk
@slender iron @onyx hinge quick interesting note that I realized today - one advantage of the F103s is that they have CAN at smaller package sizes than a F4. No F4 access chip has CAN, which means no QFN48 CAN chips. However, a QFN48 or QFN32 F103 will still have it
Looks good to me! Thank you!
Looks like iMX RT and ESP32-S2 builds are broken.
@slender iron are the "image updates" something that should have happened? I did not do those? https://github.com/adafruit/circuitpython-org/pull/543
@solar whale I don't know why that triggered but I'm ok merging it
ok -- will do.
Please just split Message and RTR fully. It's easier understand a consistent structure.
Thanks! I like the address -> id switch but would like to see Message/RTR object split done completely. Otherwise, it's irregular to everything else in shared-bindings.
Please put this in a separate file. It'll be hard to find otherwise.
No need to have these functions here because they are in shared-bindings/canio/Listener.h.
@slender iron probably a real dumb question here, but I can't seem to get Circuitpython builds to find "driver/adc.h"? Looking at Busio/I2C, it's literally the exact same thing, #include "driver/i2c.h", but for my file I get No such file or directory. Is there something I need to change in the makefile?
ya, likely the include path list
I mean, how would it be different for two files that are both in the driver directory?
you are assuming there is only one driver directory
No, nevermind you're right components/driver/include/driver/i2c.h vs components/driver/esp32s2/include/driver/adc.h"
👍
also, what the heck with these file paths espressif
sure, just spam random combinations of driver, soc, include, src, and esp32, and hide all your files in different parts of it
I have a large-ish program (RPN calculator with decimal arithmetic) that runs on this hardware combination. After reloading it an indeterminate number of times, I get an inexplicable traceback like
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Traceback (most recent call last):
File "code.py", line 4, in
File "__init__.py", line 5433, in
RuntimeError: Corrupt raw code
or I'll get a full hang after trying to enter sa...
@slender iron now I'm getting error: "CONFIG_IDF_TARGET_ESP32" is not defined, evaluates to 0, even with all the header files of I2C
I fixed the idf to avoid the warnings for what we use
file by file?
@slender iron -isystem.
The header files declaring interfaces to the operating system and runtime libraries often cannot be written in strictly conforming C. Therefore, GCC gives code found in system headers special treatment. All warnings, other than those generated by ‘#warning’ (see Diagnostics), are suppressed while GCC is processing a system header. Macros defined in a system header are immune to a few warnings wherever they are expanded. This immunity is granted on an ad-hoc basis, when we find that a warning generates lots of false positives because of code in macros defined in system headers.
Header files found in directories added to the search path with the -isystem and -idirafter command-line options are treated as system headers for the purposes of diagnostics.
@ionic elk try ☝️
we should switch to it so we don't need to have a fork of the idf
that's a CFLAG?
I didn't read back but .. to silence warnings from headers we don't maintain, change -I path to -isystem path
doesn't do anything as a cflag
let me look back and see if I have anything else to add, I don't have the context yet
and no instances of -I path
So to clarify, you edited within the IDF to remove warnings within the I2C drivers?
@slender iron
so for instance git ref 760a171903e0f is where I changed nrf/Makefile to use -isystem for several directories inside nrfx/
what is -isystem though? Is it a CFLAG?
It is a flag received by the C compiler
Makefile:INC += -Iesp-idf/components/esp32s2/include
these 'uns
can you provide a link for your git ref
or a means of accessing it?
Sorry if that's a dumb question, i've just never accessed a git ref directly on github like that before
apparently I can't search it
@ionic elk I did change the idf but I don't want to keep doing that
instead replace -I with -isystem when you add a path to the include search
so say you have this line in components/soc/include/hal/gpio_types.h: :#ifdef CONFIG_IDF_TARGET_ESP32
and you have Makefile:INC += -Iesp-idf/components/soc/include and you #include "hal/gpio_types.h" which happens to resolve to components/soc/include/hal/gpio_types.h. This file will have normal processing of warnings. If you change -I to -isystem (add a space, too) then it will get processed as a "system header", according to what I pasted from the docs above
oh sure for a diff on my host system
I got hung up trying to figure out how to view it on github
oh github is awful for certain tasks
any include paths for the idf
tannewt is suggesting that, as we don't want to resolve compiler warnings in the idf headers, we make those paths all -isystem.
because we don't want to change those files
we DO want to resolve compiler warnings in our own headers
Oh, making every path Isystem
making every esp-idf path -isystem
Lowercase i
-isystem esp-idf/gnawing-my-own-leg-off-brb
I fixed the masking error I had in setting the page on the controller and now all the basic operations work. You can use it with the REPL even.
How do I contribute the driver and example code linked above? Not sure how to create a "Pull Request" for something new.
Let me know if you need anything else.
-mark.
For the driver we can either fork your copy into the adafruit org or you can transfer it. We'll maintain it since we sell a product with the display. Would you ...
well, it moved it along I guess, now the error is :
GEN build-espressif_saola_1_wrover/genhdr/qstrdefs.preprocessed.h
GEN build-espressif_saola_1_wrover/genhdr/qstrdefs.enum.h
ERROR: Empty preprocessor output - check for errors above
Also, congrats! You found all of the boards with displays initialized in board_init. You'll need to add extra , false to all of those calls to make the compiler happy.
https://gist.github.com/jepler/d0b9e83898e8f5947298c3781a86f4a8 is what I did locally relative to 6.0.0-beta.0-46-gdd86cb00a and it still built (for espressif_saola_1_wroom). However, I don't have whatever local changes made you start looking into this.
afk, possibly for the weekend.
I think it's fine to rely on your testing. pixels_in_byte_share_row should be what you want.
Really nice work @mdroberts1243, thank you! Just a couple suggestions to make the code clearer. You will also need to fix up the display construct calls for boards with built in displays. Thanks!
I think it may be clearer to add an if before this one where SH1107_addressing is true. This condition then goes back to normal as an else if on the quirk. Then, set both subrectangles, like you do above, and rows_per_buffer to 1 so you don't need to set remaining_rows to 1 each loop below. This approach also matches the if body here which sets both of those variables. I think the logic in the loop will just work as it originally was then. The only thing you'll need to add there i...
I think we should close this in favor of #3400
Can you link to the processes and/or scripts that are responsible for generating the .rst files? I assume it's run by Actions?
https://github.com/adafruit/circuitpython/blob/main/.github/workflows/build.yml#L70-L77
make stubs strips the //| lines out of the .c files in shared-bindings to create .pyi files. sphinx-build then uses the autoapi plugin to convert .pyi to .rst which is then rendered to the docs.
@DavePutz Totally, the sleep work I did switched our internal timekeeping to the real time clock on all ports.
@kevinjwalters I'm closing this because it is fixed for 6.x.
Not 100% certain whether the underlying issue is in displayio or RGBmatrix. Regardless: sometimes after changing elements of a displayed group, nothing happens on the display, or only some of the changes take effect. Is there a way to force a full repaint for good measure?
You can force a full repaint by switching the top level group to a different group and back. However, I don't think we should do that. Instead, we should figure out what the bug is.
How are you changing the elements...
I fixed the masking error I had in setting the page on the controller and now all the basic operations work. You can use it with the REPL even.
How do I contribute the driver and example code linked above? Not sure how to create a "Pull Request" for something new.
Let me know if you need anything else.
-mark.For the driver we can either fork your copy into the adafruit org or you can transfer it. We'll maintain it since we sell a product with the display. Would you ...
* with an exception: wait in the “Press any key to enter the REPL. Use CTRL-D to reload.” state so that the user can see the traceback.
I'm not sure you actually want to ever enter this state because in the game console case you may not be connected to a host computer. I suppose you could reset the device to get out of it though. An alternative would be to have another .py or main.py to handle exceptions, kind of like a 404 page. That way it can be branded and also read inputs li...
Sounds good, but maybe that would best be tackled in a separate PR? I’m not sure offhand how easy that is to obtain – is it still stored anywhere after
pyexec_file()returns, would it need to be recorded off the serial output, …?
Yup, agreed a separate PR is best. I don't know how to get it either.
That won't work out, because the type of message must be determined by the hardware.
Let's be explicit.
extern void common_hal_mcu_deep_sleep(void);
Why are you changing this? I don't think you should because some tools like the pyboard loader look for this string.
Let's not expose this. Instead we should sleep after the python code exits. (Controlled in main.c)
{ MP_ROM_QSTR(MP_QSTR_get_wake_alarm), MP_ROM_PTR(&alarm_get_wake_alarm_obj) },
This force push
- squashes and rebases the previous commits
- fixes the inconsistency in next-code-state preservation between a reload during execution and a reload during the wait state
- adds lots of options (keyword arguments) for prototype testing that can be removed again when considered useless.
By the way, are the artifacts from the automated build available anywhere? The logs say Artifact xxx has been successfully uploaded! but don’t say where. That would make it easier for pe...
This also introduces OPT vs DEBUG esp-idf settings.
Also, congrats! You found all of the boards with displays initialized in board_init. You'll need to add extra
, falseto all of those calls to make the compiler happy.
O.k. That was a bit tedious!
Also, there is an issue in build-arm (electronut_labs_blip) where it complains about too few arguments on the set region to update... I suppose they've made their own copy of that for some reason? I probably need to change that too...
O.k. I might leave the comment in place though. It seems the byte boundary is taken care of by the pixels_in_byte_share_row setting elsewhere, but the fact that this section claims to align on byte boundaries bothers me, because I'm skipping it!
I'm not sure you actually want to ever enter this state because in the game console case you may not be connected to a host computer.
But then, if you don’t happen to be connected to a host computer, you can’t see the traceback (on the display of the device) and don’t know what the bug in your game was. (The game console use case I have in mind is more aimed at (beginner) game developers than game players. They may be “playing”, not “developing” the game at this moment, but still be inte...
Changed Matricies to Matrices.
There is a new refresh option to refresh automatically of any dirty rectangles https://github.com/adafruit/circuitpython/pull/3366
But if you need a hard refresh of everything on the screen then @tannewt suggestion of display.show(None) and then back to your Group, will work too.
I've coded this change but will take some time to test a bit!
Not sure what you mean by "The only thing you'll need to add there is passing the quirk status into setting the region." The quirk is already passed into setting the region.
@slender iron what would it mean for qcfgs and qstrs to be empty? I tried running make translate, but that hasn't helped
did you clean and rebuild?
yes
Alright I've tried a bunch of stuff and I gotta say I'm totally stumped here.
Is there a way I can turn it off? or something?
no, QSTRs are all of the string inlining
Another option would be for the menu program to check for exception and display it (or otherwise handle) in a user-friendly manner. This way we can use the console's button to scroll and dismiss the message, for example.
found it, was a -isystem on a non-idf line that did it
Let me amplify on a hastily written answer.
When calling read() or next(), the software has to commit to taking the next messge that has arrived on this FIFO, regardless of whether it is a RTR or not. This is true of all 3 HW implementations I've looked at (SAM E, STM, and ESP32S2).
Having the common_hal routine read into a single structure which can accommodate either type of message is the simplest way I see to do it. Adding a "peek" routine, a union type, or other complicat...
I have made all the requested changes and updates. But a few boards are still failing the checks but due to messages related to the number of arguments passed to displayio_display_core_set_region_to_update. The errors seem to be the same. Boards include: electronut_labs_blip, pewpew_m4, pybadge, pybadge_airlift, pygamer, pygamer_advance, pyportal, pyportal_titano, ugame10. Many of these didn't show this problem until after the original common_hal function changes were made.
@tannewt I ne...
I left it there just for testing purpose, will remove it once entering sleep on code.py exit is implemented.
@slender iron I would like to have a discussion about deep sleep api implementation, ping me when you are free. 🙂
@analog bridge I’m off for the weekend. Will ping you if I have time but may not until Monday
np..... 🙂
Switched the board images out for the production boards
Is it possible to record audio using the mic on the Neotrellis M4 board? I was able to test the audio level, but couldn't find anything regarding recording or playing back a mic input
With the current implementation it is not clear when the soft reboot happened as it doesn't get printed out in a newline.
Following code can work without breaking compatibility:
serial_write("\n\n");
serial_write_compressed(translate("soft reboot\n"));
I can just remove it though, if you say so.
Right, I also came to that conclusion when I was mulling it over under the shower. That actually seems the more elegant solution to me. The ability to retrieve the last exception is required either way.
So until someone convinces me otherwise, I think there is no need to have different next file names for different outcomes. The capabilities of the current prototype plus retrieving the last exception are sufficient.
So all we need is an option that says what happens when the program finishes — either show the exception and drop to REPL (the default), or get back to the main program, possibly with a stored exception, and let that program decide what to do next.
A practical question:
Lets say pins gpio34-37 are used for bitbanging and SPI
and I need glitchless transition between those two modes.
What's the recommended solution, cCan I avoid
gpio_pin.deinit()
del gpio_pin
while not hwspi.try_lock():
and use something like switch_to_output(), switch_to_input()?
@quiet orchid do you mean the microphone in line that is in the headphone jack? To the best of my knowledge there isn't a microphone directly on the NeoTrellis
Translated into prototype-speak, that option would be a combined reload_on_error = reload_on_success with a default of False, while the rest would be fixed at sticky_on_reload=True, sticky_on_error=False, sticky_on_success=False, if I understand you correctly. Works for me.
However, for now, until we have established that the “retrieve last exception” feature is feasible and can land at the same time (which I intend to try, but no promise), I would prefer to keep `reload_on_error...
@lone axle yes, I guess I should have specified that. When having a mic plugged in to the headphone jack, is it possible to record audio using that
I think it could be done using this perhaps: https://circuitpython.readthedocs.io/en/latest/shared-bindings/audiobusio/#audiobusio.PDMIn. But I am not certain of how it's done
https://learn.adafruit.com/make-it-sense/circuitpython-3 this page shows a microphone example I think it should be somewhat similar to that one but perhaps with different pins.
Maybe this is for @tulip sleet : I have just upgraded my PyPortal to 6.0.0b0. So I figured I should upgrade AirLift to NiNa 1.6.1 (is there any better?) and then I should try https://github.com/adafruit/Adafruit_CircuitPython_AirLift but I believe that "_bleio" should be added to the build of PyPortal. So simple_test.py failed. It is already in "Adafruit Metro M4 Airlift Lite" but I think it should be in every PyPortal and PyBadge Airlift ... and possibly other board that could use the AirLift Feather Wing.
@lone axle that looks pretty close to what I wanted to do. At the moment I was looking into using the pyaudio module but was having trouble adding that to the board (how would I do that?). Thanks for the link
@quiet orchid PyAudio is a CPython ("Normal" Python) module. It cannot be used on CircuitPython devices. The libraries that work on CircuitPython devices are made especially for them typically.
On Raspberry Pi and other SBC devices you can sort of mix "normal" python with CircuitPython by using the Blinka compatibility layer.
but not on Microcontroller devices like the Neo Trellis M4
Darn so that was an hour wasted. Is there a list of modules that are circuitpython specific on the circuitpython website?
If I'm reading this correctly, I think for my case, all of the sticky_on_... flags would be False which looks like the default? So, in my main menu, to jump to a menu choice, I would use:
supervisor.set_next_code_file(filename='example.py')
supervisor.reload()
Is that correct?
And, if I press the reset button or disconnect/reconnect the device, everything returns to default, running code.py or main.py?
@quiet orchid they aren't exactly listed on the page but all of the ones supported by Adafruit are available on circuitpython.org in downloadable bundles here: https://circuitpython.org/libraries
There are some others that are created and maintained by members of the community listed in the Community Bundle repo: https://github.com/adafruit/CircuitPython_Community_Bundle.
All of the libraries in either of those bundles should definitely work on CircuitPython microcontrollers I believe.
Thanks for helping. I will look over these
If you’re okay with staying in the “Code done running. Waiting for reload. / Press any key to enter the REPL. Use CTRL-D to reload.” wait state after example.py has finished, that is correct, except that the filename argument is positional-only (that is not deliberate, but I didn’t see any way of making it positional-or-keyword).
What I do is
supervisor.set_next_code_file(selected + '.py', reload_on_success=True, sticky_on_reload=True)
supervisor.reload()
The `reload...
I went ahead and wrote what I think you want. It adds about 300 lines of largely duplicate code, because
- now common hal's implementation listener's receive needs two copies of the code, to read the HW registers into two different structures
- and an additional common hal send remote transmission request API is now needed, which duplicates copying the new rtr structure into the hw registers
This also amounts to about 300 extra bytes of firmware, but for me it is the duplicated code t...
The comment "+ ent->txb1.bit.MM = 0; // "remote_transmission_request marker"" is just wrong btw
@tulip sleet Would it be possible / make sense to list NINA >= v1.7.0 as a Dependency on the Airlift library page? cc: @thorny jay
Untested! I don't have my QT Py or flash chip yet! (and I didn't get the flash before it went out of stock)
This adds a variant of the QT Py modeled after the Trinket M0 Haxpress, which will require the GD25Q16C external SPI flash chip for its CIRCUITPY filesystem. Among other things, it is able to fit support for long ints. There's about 5kB flash left in the de_DE build.
@crimson ferry @thorny jay 1.7.0 doesn’t work properly with HCI BLE. We are working on another build. If it worked for you that would be very surprising to me
tested on a QT, enumerates with a disk drive
tested on a QT, enumerates with a disk drive
With/without keyword are both fine with me. Does CircuitPython have a convention?
It definitely sounds like 'sticky' options are useful in your application. It may be when I get a better feeling for them in practice I'll find their utility, but for now I'm happy with the default. :-)
Working with the STM32F405 Feather. Currently trying latest CP 6.0 Alpha. Using the AS7341 Colour Sensor and the provided simpletest example. After a while I see an I/O error:
F1 - 415nm/Violet [ 1129] *
F2 - 445nm//Indigo [ 2306] **
F3 - 480nm//Blue [ 3045] ***
F4 - 515nm//Cyan [ 4840] ****
F5 - 555nm/Green [ 7406] *******
F6 - 590nm/Yellow [10540] **********
F7 - 630nm/Orange [14415] **************
F8 - 680nm/Red [ 3623] ***
F1 - 415nm/Violet [ 1129] *
F2 - 445nm//Indigo [ 2306] **
F3 - 480nm//Blue [ 3045] ***
F4 - 515nm//Cyan [ 4839] ****
Traceback (most recent call last):
File "main.py", line 23, in <module>
File "adafruit_as7341.py", line 311, in channel_555nm
File "adafruit_as7341.py", line 382, in _configure_f5_f8
File "adafruit_register/i2c_bit.py", line 70, in set
File "adafruit_register/i2c_bit.py", line 65, in set
File "adafruit_bus_device/i2c_device.py", line 143, in write_then_readinto
OSError: [Errno 5] Input/output error
Is this a known error? I have even worse results if I'm heavily loading the I2C with the SH1107 OLED FeatherWIng.
Hi all. Was the module adafruit_pybadger.PyBadger depreciated since the release of the PyGamer? Besides this guide missing about half a dozen required libraries, the code also tries to import that module which does not exist in a 5.x library bundle downloaded today. https://learn.adafruit.com/pygamer-thermal-camera-amg8833/
@grim dagger make sure you have the newest version of the bus_device library. I think that might have been a known issue that got resolved.
@pulsar bobcat I do not think that the pybadger library is deprecated. It should still be included in the bundle. I just downloaded a fresh copy of the bundle right now and mine does contain the pybadger library:
I think I figured it out. I have a capitalization problem. the author of the code used PyBadger for the module name when it is pybadger in the library
There are other issues that I'm finding going line by line. I may submit a PR to update it if I get it working. Thanks for looking 🙂
Ah, I see now. Yep I think the import needs to be lowercase like from adafruit_pybadger import pybadger
@grim dagger make sure you have the newest version of the bus_device library. I think that might have been a known issue that got resolved.
@lone axle Seem to have the same issue using the latest adafruit_bus_device/i2c_device.py source from github. I might try and figure out how to drill down on this a bit since I have similar problem with my SH1107 driver too.
@crimson ferry @thorny jay 1.7.0 doesn’t work properly with HCI BLE. We are working on another build. If it worked for you that would be very surprising to me
@tulip sleet I did not go for 1.7.0 (or one found in a ticket), but the released 1.6.1. Also I was stop when _bleio was missing from PyPortal.
What I wonder is what hardware will get _bleio build into their image? Anything with build-in AirLift should get it. Maybe PyGamer too as you can plug a AirLift FeatherWing behind. Then anything with Feather form factor might also use the FeatherWing.
@lone axle After fixing the pybadger typo in code.py I'm getting this error:
File "code.py", line 19, in <module>
TypeError: 'PyGamer' object is not callable```
If I add
```from adafruit_pybadger import PyGamer```
then I see this error:
```Traceback (most recent call last):
File "code.py", line 14, in <module>
File "adafruit_pybadger/pygamer.py", line 138, in <module>
File "adafruit_pybadger/pygamer.py", line 68, in __init__
File "adafruit_pybadger/pybadger_base.py", line 147, in __init__
ValueError: SPEAKER_ENABLE in use```
I am at a loss. This guide is not that old, but it already has broken library imports.
@pulsar bobcat There is pretty active development in both the libraries and the core system, 9 months is longer than it seems like it might be. I am sorry you are running into these issues though. I don't have the thermal camera but I have a pygamer I can try to get the code into a state where it won't crash from that library
I just found something in the forums about this. between january and march the library was changed and it broke the guide
I think it doesn't need to use a constructor any more. It gets initialized on import now I believe.
Since the code also calls the constructor it tries to do some things twice and the pins are already in use.
so this isn't needed? panel = pybadger(pixels_brightness=0.1) # Set NeoPixel brightness
I think that is the case. But I'm not certain, and I don't know if there are other issues beyond that or not.
Grabbing my PyGamer to give it a try on my end.
👍 thank you. I looked in the learning system for an some other guide for an example CircuitPython initialization for the PyGamer, but there aren't all that many guides for it
@pulsar bobcat give this one a try when you can: https://gist.github.com/FoamyGuy/7a211743941188432b16f8a81b9ea2dd.
for me it is past the pybadger library issues and now failing because it doesn't find the thermal cam (expected in my case)
Had to remove the constructor (the line you posted above) and also tweak the import to rename it to panel so the rest of the code will work:
from adafruit_pybadger import pybadger as panel
@lone axle that did the trick! Thank you so much
Nice, you are welcome. I will submit feedback with the updated code so we can hopefully get that guide updated
Hi- I'm trying to get uf2 working on a saola-1-wroom. I suspect I've missed a step (pre-erasing or loading the flash?) it's stuck at a red neopixel; uf2 log messages are:
I (324) spi_flash: dtctd chip: gnric
I (328) spi_flash: flash io: dio
I (332) cpu_start: Starting schdulr on PRO CPU.
I (337) uf2: Hllo
I (337) uf2: _part_ota0->typ = 0
I (337) uf2: _part_ota0->subtyp = 0x10
I (347) uf2: _part_ota0->addrss = 0x10000
I (347) uf2: _part_ota0->siz = 0x160000
I (347) uf2: _part_ota0->ncryptd = 0
I (357) uf2: flash->chip_id = 0x204016
I (357) uf2: flash->siz = 0x400000
I (367) uf2: block_ras = 0x10000`
Looking at flash_hal.c I suspect I don't have the expected partition table on the flash.
The readme has a section about partitions, but I'm not seeing instructions for how to write out the partition table- what have I missed? 😉
Another weird thing- why is every 'e' being stripped by ESP_LOGI()?
added a log message after TUSB task is created (line 81 in main.c) - it displays, but not sure if TUSB task starts. Also never get the purple LED...
Recent ESP32-S2 release can mount SD card,
after setting pinout and SPI, this works
storage.mount(vfs, "/sd")
os.listdir("/sd") lists files stored on the SD card.
['KERNEL.SYS', 'COMMAND.COM', 'INVADERS.COM', etc..
Now I want to copy a file from PC to the mounted SD card
but linux PC usb-storage interface doesn't "see" mounted
"/sd" directory
cp README.md /media/guest/CIRCUITPY/sd/
cp: cannot create regular file '/media/guest/CIRCUITPY/sd/': Not a directory
A small status update:
- I decided to build the quirk for the GrandCentral M4 Express board I bought.
- The SH1107 quirk built and ran fine with my driver
- I wasn't able to recreate the lockup/freeze that I saw on the STM32F405 Feather, even after hammering the I2C bus with continuous updates (moving "SH1107" around the screen with random increments)
- In separate testing I found I would see OS ErrNo 5 (I/O Error) on the STM32F405 when running the simpletest for the AS7341 as well.
So...
@acoustic forum Yes, it should work on anything you can connect an AirLift to and that has the firmware space. In practice, this would not include SAMD21 or non-Express boards. And of course we would omit on nRF. RIght now it is only on the Metro M4 AirLift due to use still trying to get a good firmware build (that was the test board). We will add it it to lots more boards later.
The performance of CircuitPython on a Teensy 4.0 is very disappointing.
I have an application where the Teensy 4.0 running CircuitPython should be ideal.
After reading some comments (issue #3062) about how slow the Teensy 4.0 is updating a SPI driven display, I used a Teensy 4.0 in a Teensy-to-Feather Adaptor to compare performance of the M4E and Teensy 4.0.
Both T4.0 and M4E are running CircuitPython 5.3.1 andbootloader 3.10.0.
I reproduced the complaint about the T4.0 taking abo...
Closed my previous one and opened a new PR for only files i changed.
At default, need to pull up and down few pins for enabling the power to turn on for 40-pin header.
For ArduinoCore, this is done : https://github.com/Seeed-Studio/ArduinoCore-samd/blob/ef8f3edde07a701374b7c683510e33d42f6a9627/cores/arduino/wiring.c#L218
@phrogger the comment has been edited to remove words like "disappointing" - as it isnt constructive or helpful
I can confirm this problem is with the STM32F405 Feather and 6.0 alpha (latest). I can reproduce the problem quite easily with the AS7341 sensor and its simpletest. Reduce the sleep time to have the problem manifest quicker. It is even easier to reproduce the problem using the SH1107 quirk and the SH1107 128x64 OLED FeatherWing. When using the OLED I just move a lable around on the screen pseudo randomly to quicken the
I've seen I/O errors on write and write_then_readinto.
I have not...
@phrogger Very interesting findings! The port is still in an early stage and development focus of the core team has currently shifted in favour of the ESP32-S2. I would also be interested in further work on this port and you seem to know a fair bit about the i.MX RT. I think everyone would welcome more helping hands on the port if you would like to help out! I wanted to dive deeper into it but got distracted by other things unfortunately and not knowing all that much about this MCU to begin w...
I’m hopping I posted this in the correct place.
Hi, has anyone used the ‘SparkFun Pulse Oximeter and Heart Rate board’ (see details below) and is there a CircuitPython library that would work with it? I know SparkFun has an Arduino Library for it but I really want to use CircuitPython and the Feather nRF52840 Sense.
Thanks in advance.
SparkFun Pulse Oximeter and Heart Rate Sensor - MAX30101 & MAX32664 (Qwiic)
Id# SEN-15219
Link: https://www.sparkfun.com/products/
15219?_ga=2.83573398.1233392454.1601214429-1269510697.1563593287
The SparkFun Pulse Oximeter and Heart Rate Monitor is an I²C based biometric sensor. Utilizing two chips from Maxim Integrated, the SparkFun Pulse Oximeter and Heart Rate Monitor has both the MAX30101 biometric sensor and MAX32664 biometric hub.
@dense pike #help-with-circuitpython is a slightly better channel for "how do I" type questions. I looked in our CircuitPython bundle but I don't see max30101 or max32664 listed.
those chips do connect via standard I2C and the datasheets are available, so if you want to learn about writing register-level code in CircuitPython this is something you could consider taking on
@tulip sleet I don't know who else to ask, but would a Rust part in CPy be merged? I want to write a matrix module for example and I was thinking to write it in Rust. Write just the bindings that I need and combine the rust build system with the existing one
the idea is that the only additional build dependency to be rustup, nothing else
@slate scroll I don’t know that anyone has tried that yet. We have not even tried to integrate C++ code. Have you seen ulab, a numpy-like module that is included in most larger builds?
As far as I can see, it's in C and a tiny bit C++.
Oh you meant for the matrix. I meant a keyboard matrix, not an algebric matrix
would you (adafruit) be willing to go veeeery slowly towards rust? if you can't answer, who can I ask?
I don’t know anything about the C abi vs the Rust abi. Also, whether there’s a rust runtime library that would be brought in
it's very close to C from what I know and is compatible (I wrote a hello world in Rust that called the Arduino Framework)
We are very unlikely to try to move CircuitPython towards being written in Rust, given that we’re still merging Micropython occasionally
meh, it's a shame...
There was a user on discord that was doing everything in Rust on samd21 or 51, but it was not mixed with CircuitPython. It was part of some embedded rust build system
yea, there is the rust-embedded HAL, but that's not what I'm suggesting. I just want to call the existing C functions of CircuitPython from Rust, (almost) no external library dependencies and call Rust code from CircuitPython
I may do it just for a blog post anyway, I'll keep in mind that it probably won't merge
thank you! 🙂
@PTS93 I am currently doing a C-Language project on iMX RT1052 bare metal, no RTOS, and still learning how to manage the beast. At least in my case, the entire compiled program and data will fit in the tightly coupled RAM without paging, so I expect to get the full performance of the processor.
Paging can slow things down, and the speed of the memory/bus where the code is resident can change the overall performance.
There is also an option called XIP (execute in place) where instead ...
anyone know how to connect vscode to the serial port/console/repl? so that I can visualize prints like mu using https://marketplace.visualstudio.com/items?itemName=hediet.debug-visualizer
If you got to f.e. https://circuitpython.readthedocs.io/en/latest/CONTRIBUTING.html
Clicking on any link that is supposed to go to a markdown file in the github repo yields a 404 because it removes the file extension.
F.e. instead of linking to https://github.com/adafruit/circuitpython/blob/main/CODE_OF_CONDUCT.md (notice the .md)
it links to https://github.com/adafruit/circuitpython/blob/main/CODE_OF_CONDUCT
The markdown file this page is based on is correct though, it includes...
Yea afaik there were some plans for CPY's architecture on how to deal with the segregation of memory. @tannewt or @arturo182 might have more to say about this.
If you want to evaluate further it is probably also a good idea to work with version 6 beta of CPY or a nightly release, it wont very change much for the i.MX RT but it is closer to the main development branch.
Compiling CPY is very straight forward and not hard at all to get started on. For the i.MX RT port the NXP SDK is pulled...
Trying to run adafruit_io_weather.py example app on original PyPortal. Runs to getting weather record from IO, but draws 404 error line 497 in adafruit_io.py. I think the location_id passed from line 64 of adafruit_io_weather.py is wrong. Comment says to obtain code from io.adafruit.com/services/waether. There it says the locationValue is a string (lattitude,longitude) but the library is looking for location_id as an int. So where do I get the int location_id?? (yes, I have the Adafruit IO Plus subscription.) Thanks!
@lethal maple I don't know much about adafruit io but we do have a dedicated help channel for it: #help-with-wippersnapper-and-adafruitio
also if you found a problem with our guide code please use the link to report a problem that is on the website; if you found a bug in the library or documentation, you can file it on github. Thanks!
@onyx hinge Thanks, will repost there.
Great, thank you!
anyone know how to connect vscode to the serial port/console/repl? so that I can visualize prints like mu using https://marketplace.visualstudio.com/items?itemName=hediet.debug-visualizer
@teal bear I am very intrigued by this. I’ve been wondering if/how you could do this with VSCode. Let us know what you learn.
I guess that's not for VS Code though, just Visual Studio. I don't use either one. Sorry for the noise.
Is there a current CP build for the QT PY?
I'm not finding one on circuitpython website
I see it on the S3.. now to load it on the QT PY
@narrow dirge E. thanks will repost to help-CPy
Can someone tell me whether there is any difference in how the HID lib works between most CircuitPython boards and the Trinket M0 and related boards like the PyRuler? The examples in the lib bundle and on the Adafruit Learning system do not work on the Trinket M0. The examples and Learning System guide import usb_hid and initialize the keyboard with kbd=Keyboard(usb_hid.devices) which generates an error on a Trinket M0. The Pyruler sample code calls Keyboard with no argument which works on a Trinket M0.
I'm using CircuitPython 5.3
@teal bear I am very intrigued by this. I’ve been wondering if/how you could do this with VSCode. Let us know what you learn.
@idle wharf I think this is a dead end. looks like the vis thing is for in memory data structures, not std out spew
Boooo ! That stinks.
I wonder if the folks over on the Msft Python discord would have ideas
Its not the most active place though
They also need to fix VSCode crashing when the USB drive goes away (on MAC anyway)
I wouldn't be surprised if there is another plugin. someone else pointed me at this a few days ago, I have only put enough effort into getting this far
I’ll do some hunting tonight.
would you (adafruit) be willing to go veeeery slowly towards rust? if you can't answer, who can I ask?
@slate scroll I'm interested in this. I think the module level is totally ok to do this at.
With/without keyword are both fine with me. Does CircuitPython have a convention?
keywords are generally preferred. When you have multiple positional arguments of the same type I like to make them required.
T4.0 SPI single byte transfer events are spaced 7200 ns (7.2 us) apart
This looks like a red flag to me. The SAMD51 is fast with SPI because it uses DMA. If the iMX isn't using DMA then this could be the culprit.
My intent was to setup the iMX so that the core CircuitPython VM code live in ITCM, the stack in DTCM and the caches were left for parts of CircuitPython used off and on. There is definitely tuning to do.
As, I wrote that, I realized displayio buffers live on the stack whi...
Please resolve the conflict. Looks good otherwise.
We don't support the SD card over USB. The USB Mass Storage protocol works on the blocks below the filesystem. So, we'd need to expose the SD card as a second drive (logical unit in USB parlance). It would have the same read/write constraints as the internal flash.
@slender iron
I’ll start writing a PoC this week
I don't understand how to apply your recommendation in
my code. So protocol must first start in bitbanging mode
and then switch to SPI. If I try to init SPI then, it will be
rejected reporting some error like "pin already in use".
My solution to avoid this error was to deinit the pin and delete it.
It is very slow then, I suppose I needs a lot to allocates objects and memory.
OK, let SD-over-USB be a feature request,
it's ok for me to appear as another drive.
Intuitively, I have expected this to "just work".
Now I need to first upload file from USB to internal flash,
write my own copy.py application, upload it too, then
enter python prompt and finally copy this file from flash to SD.
On 9/28/20, Scott Shawcroft notifications@github.com wrote:
We don't support the SD card over USB. The USB Mass Storage protocol works
on the blocks below the filesystem. So...
@slender iron btw I did a failed attempt to auto generate Rust bindings for the Arduino framework (C++ totally freaks bindgen out): https://github.com/dzervas/platformio-arduino-rust
I blinked a LED though 😊
@tannewt I fixed the last lines on the 2 .mk files, but I have no idea how to do...
You'll need to add the prerelease board name to the github workflow to get the CI to pass: https://github.com/adafruit/circuitpython/pull/3463/checks?check_run_id=1162679057
I've never used (or even looked at) git workflows before, sorry. Git noob here!
Everything you say makes sense, but since every thing measured on the iMX RT is slower than the M4E, there is still some fundamental memory management thing to "tune". I am still learning the vocabulary that NXP uses to talk about their memories and management, much less understanding how to do it, yet.
@soft dove the change to require an argument to Keyboard was made quite a while ago, well before 5.3.x. Make sure your libraries are up to date, and confirm the CPy version. Post the exact error you are seeing if you still have a problem.
@slender iron Could you give me pointers to specs for that debug edge connector and the matching physical connector? I think I have another application for some really cheap system like that
In case you haven't seen it yet, this is a nice app note by NXP specifically focusing on their "FlexRAM" architecture and its limitations: https://www.nxp.com/doc/AN12077
@slender iron is the way to add new components to the ESP32 the ESP_IDF_COMPONENTS_LINK variable in the makefile? There's a note that says order matters for it, and I assume there was something in the IDF you based it off, but I can't seem to find an example makefile that includes the esp_adc_cal component I need.
Is ESP_IDF_COMPONENTS_LINK an original creation? it doesn't show up on google at all, so there doesn't seem to be any way to determine what the "right" order is
Hi Everyone. I'm trying to add a new driver busIO for one CPy platform on a forked version of the repository. Development of this new driver requires constant recompilation and transfer of uf2 to device. I'm getting fatigued by the amount of time this cycle takes (in excess of a minute and a half) and I'm wondering if there are some features I could disable to reduce this time. Is there some guide I've missed or advice anyone can impart? I'm on MacOS if that helps.
@timid wind If your board as a SWD connector, I recommend getting and learning how to use the j-link. you can load a new firmware over j-link, and in my experience it has faster cycle times than using uf2. For some ports, the build time itself can be decreased by disabling lto, which requires editing a Makefile and removing "-flto" in a few places (this applies to samd and nrf but I think not to others). that's about it for my immediate suggestions.
@soft dove answering late, but I think the difference is that old versions of circuitpython didn't require (or accept) usb.hid_devices in the constructor to Keyboard() but it's required now; this was changed so that BLE HID devices could work too.
@ionic elk best guess, while ESP_IDF_COMPONENTS_LINK may be based off of some example somewhere, it's something created/used by us. It just gets expanded to list the libraries in order, with paths added: Makefile:ESP_IDF_COMPONENTS_EXPANDED = $(foreach component, $(ESP_IDF_COMPONENTS_LINK), $(BUILD)/esp-idf/esp-idf/$(component)/lib$(component).a)
Using the linker's special --start-group and --end-group flags might work instead and not require a special order to be given
right. But unfortunately, it's apparently not compiling the component I need, so I must be missing a setting even earlier
build-espressif_saola_1_wrover/esp-idf/esp-idf/esp_adc_cal/libesp_adc_cal.a: No such file or directory
The idea is, with static linking, if you link liba and libb, the order matters. If liba uses symbols from libb, liba needs to be earlier.
--start-group / --end-group lets the linker consider the things between those things multiple times, until no more symbols are resolved
What's frustrating is that espressif does not have makefiles of the typical variety, and esp_adc_cal is not mentioned in any build files of the idf, and it's not documented in their online docs, so I guess I'm on my own figuring out how to actually make it compile?
was there another part to your error message?
# ToDo: re-enable adc-cal for other target
if(NOT ${target} STREQUAL "esp32")
return()
endif()
idf_component_register(SRCS "esp_adc_cal.c"
INCLUDE_DIRS "include"
REQUIRES driver)
``` I notice this in components/esp_adc_cal/CMakeLists.txt of esp-idf -- that __MAY__ mean that it is disabled for esp32s2
@onyx hinge thanks for the tip on -flto! Much quicker. I have tried to program my board (adafruit clue, nrf52840) using SWD but it doesn't seem to flash the VM portion. I assumed it was write protected (which is probably why you are recommending J-link? 🙂 )
Yeah that can't be it, this is a valid esp32-s2 example https://github.com/espressif/esp-idf/blob/8bc19ba893e5544d571a753d82b44a84799b94b1/examples/peripherals/adc/main/adc1_example_main.c
@ionic elk can you build the example or are you just assuming that if the example is there it builds?
... yes I guess I am assuming they aren't shipping broken examples 🤦♂️
@timid wind I would expect any swd adapter (like, say, one working with openocd) to work the same for uploading firmware. I just happen to do it with jlink
@onyx hinge Ok, I'll give it another go then 🙂 are there any existing APIs for logging to memory? I see mention of "ramlog", is that the best interface to use?
I dunno about that
@onyx hinge thanks for pointing that out though, I hadn't considered that as a possibility.
//Convert adc_reading to voltage in mV
uint32_t voltage = esp_adc_cal_raw_to_voltage(adc_reading, adc_chars);
printf("Raw: %d\tVoltage: %dmV\n", adc_reading, voltage);
#elif CONFIG_IDF_TARGET_ESP32S2
printf("ADC%d CH%d Raw: %d\t\n", unit, channel, adc_reading);
#endif
``` in that example, it looks like the esp32s2 build would skip performing the calibrated conversion and just show the raw value
Are we somehow looking at a different example? I literally don't see that preprocessor code in the file I'm looking at
Or is my esp-idf mismatched from the online version?
yep that's it. Our idf is out of date as of july 9th
okay ... ?
ok, yup, https://github.com/espressif/esp-idf/issues/5455 has been resolved since the point where we forked it
Ver: Master branch https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/api-reference/peripherals/adc.html above docs mention ADC Calibration feature in esp_adc_cal/include/esp_adc_cal.h, ...
@slender iron what's the process for updating the IDF? You mentioned you had edited some files? As Jeff has helped me discover above, they only recently added support for the ADC calibration components, which I'd like to include in our ADC implementation as they compensate for non-linear parts of the ADC readings. ESP32-S2 ADC readings are reportedly not very accurate without it.
Mechanically, you have to git merge the branch we're using and esp-idf's master branch, which has conflicts at the moment. Then PR it to the place we get our module from (https://github.com/tannewt/esp-idf.git) and once that PR is merged, PR the update of the submodule in circuitpython.
that'll have a second level of work because one of the conflicts is in lwip, which is also forked into tannewt
a fun way to blow a day, or more if this is out of your git comfort zone
make translate script doesn't include ports/esp32s2 directory. Is this intentional ?
@onyx hinge currently working on applying a fix for translating strings referenced form header files, will update the translate script along with it.
excellent, thank you!
hmmmm, it's definitely a lot of work, but I'd also really like to have this ADC calibration step. ADC readings without it can be off by hundreds of mV.
so report other testers, anyway
agh I need to stop getting mad about bugs before double checking my release version. Discovering your righteous indignation was actually foolish assumption is the worst feeling.
Together we found the right info, my default of looking with git grep in the files I have, instead of on github using the web ui, let us get enough conflicting data to figure out the actual problem
Yes my foolishness was luckily contained, with your gracious help! Still embarrassing though 😆
@onyx hinge do you know if it’s still possible to request a VID/PID in this manor for my samd21 board I’m developing?
We built a board roughly based on the trinket m0 with IR receive/transmit capabilities. It's a shitty addon for conference badges. Hardware and software are all opensource: https://github.c...
^ @slender iron ?
I was potentially going to use the PID codes open source path, but I want to make sure I evaluate all my options. I need to get a VID/PID this week so I can get the binaries for the board for CP
Seems fine, the double-grep issue is minor so please merge if you don't care to do anything about it right now.
On Linux, you can use grep's -f FILENAME more than once. If this works across platforms, is the stripped1 file necessary?
For doing the DAP process too
There is also AN12437, "i.MX RT Series Performance Optimization", which assumes that you have already read AN12077.
@slender iron Could you give me pointers to specs for that debug edge connector and the matching physical connector? I think I have another application for some really cheap system like that
@tulip sleet debug-edge.io
?serverinfo
Is ESP_IDF_COMPONENTS_LINK an original creation? it doesn't show up on google at all, so there doesn't seem to be any way to determine what the "right" order is
@ionic elk Order doesn't matter any more. That comment is old
Yes my foolishness was luckily contained, with your gracious help! Still embarrassing though 😆
@ionic elk I’m facepalming myself - I’ve been using a different idf version and didn’t realize there were changes in the version with CP. If you hadn’t bought this up I’d still be stuck with no ideas how to progress (trying to get uf2 working- my board is crashing in tinyusb). Now I have an idea of where the user error is 🙂
@slender iron what's the process for updating the IDF? You mentioned you had edited some files? As Jeff has helped me discover above, they only recently added support for the ADC calibration components, which I'd like to include in our ADC implementation as they compensate for non-linear parts of the ADC readings. ESP32-S2 ADC readings are reportedly not very accurate without it.
@ionic elk All my updates are for the include stuff. So if you can switch back to mainline IDF with -isystem that would be best
Oh, that might be a nice update - that'd just be updating the submodule, then?
@onyx hinge do you know if it’s still possible to request a VID/PID in this manor for my samd21 board I’m developing?
https://github.com/adafruit/circuitpython/issues/2322
@ornate breach I'd prefer folks use pid.codes going forwards
We built a board roughly based on the trinket m0 with IR receive/transmit capabilities. It's a shitty addon for conference badges. Hardware and software are all opensource: https://github.c...
@ionic elk yup
(I didn't know about -isystem when I started it)
Ok, I'll do that. Should I open a new PR for it, or fold it into my ADC PR?
Ok I might do a new PR just to keep them distinct then
kk
@slender iron thanks
Is there a special flashing process for loading a new hex file via GDB with the Adafruit Clue?
(gdb) load build-clue_nrf52840_express/firmware.hex
`/Users/XX/ports/nrf/build-clue_nrf52840_express/firmware.elf' has changed; re-reading symbols.
Loading section .sec1, size 0xf8 lma 0x26000
Loading section .sec2, size 0x9000 lma 0x27000
Loading section .sec3, size 0x10000 lma 0x30000
Loading section .sec4, size 0x10000 lma 0x40000
Loading section .sec5, size 0x10000 lma 0x50000
Loading section .sec6, size 0x10000 lma 0x60000
Loading section .sec7, size 0x10000 lma 0x70000
Loading section .sec8, size 0x10000 lma 0x80000
Loading section .sec9, size 0xd67c lma 0x90000
Start address 0x27000, load size 485236
Transfer rate: 151 KB/sec, 978 bytes/write.
The command seems to execute successfully (as above), but the microcontroller is not executing the newly loaded code...
I verified this by setting a while(1) in the constructor of some code I am adding. The newly loaded file has this loop removed, yet the MCU is still sitting in that same constructor (though now one line further on in the program as the while(1) has been removed from the symbol file).
@timid wind use the elf file
Gdb firmware.elf
Though.. I'm not sure why loading the hex wouldn't work, it's just not what I do
And I don't specify any argument to "load"
Ok, thanks for the help @onyx hinge
<@&356864093652516868> It's about 1 hour and 15 minutes until our weekly meeting. If you plan to speak during the Hug Reports or Status Updates, please add your name the notes document in each section. Adding your notes ahead of time is also super helpful! If you have notes but can't (or just prefer not) to go on mic, note that you're "text only". If you can't add yourself to the document for any reason, please let me know and I'll add you. If you're not in the document, we will assume that you are "lurking" (just listening in) and skip over you during the Round Robin sections. Thanks!
Here's the link to the notes doc: https://docs.google.com/document/d/11JULkBnDzsJVIfGiiqWPszEd7mb001P7qg-8LyucmcE/edit
If you're not yet a circuitpythonista but want to speak during the meeting, just let me know and I'll add you. I'll be taking notes today and Scott will be running the meeting. See you soon!
@timid wind I checked my gdb configuration, and I use an alias that does: mon reset / load / mon reset. A typical "load" looks like ```Loading section .isr_vector, size 0xf8 lma 0x26000
Loading section .text, size 0x787d0 lma 0x27000
Loading section .data, size 0x53c lma 0x9f7d0
Start address 0x27000, load size 495108
Transfer rate: 53722 KB/sec, 15003 bytes/write.
@slender iron deep sleep api discussion before/after/in CPY meet ?
@analog bridge we can do it in the weeds at the end of the meeting
I have a meeting before the public one
Other changes include:
- unhiding TG-Watch-02A since there was enough information available online that it looks good.
- I kept BD Micro M0 (which is not on their website anymore) since it's still a separate supported board in CircuitPython
The BDmicro Vina M0 was renamed the Vina SAMD21: https://github.com/adafruit/circuitpython/pull/3432
@idle owl it's QTPY_BOOT as the filesystem/volume name btw
@onyx hinge Thanks!
We're finishing up our internal meeting, thanks for your patience!
@slender iron I wonder if the terminal should have a non-scrolling ("roll") mode where it just starts painting at the top when it reaches the bottom. It would eliminate scrolling but you have to become familiar with it
Happily lurking today -- updated the notes doc to reflect as such 
🐱🤮
lurking (until in the weeds)
we had the same issue a few minutes ago...
I just joined.....cat whatsitnow? I'm glad I joined late 🙂
hello!
lurking
See #546 for more details. It was renamed to BDMicro Vina-D21 which is now a separate board on here.
@grim dagger are you planning to speak in the meeting today?
@onyx hinge Just lurking to see what this meeting is like
Lurking not present.
Send news items to Anne on Twitter @anne_engineer or post a pull request https://github.com/adafruit/circuitpython-weekly-newsletter
Lurking.
oof. best wishes @tulip sleet and speedy recovery.
Hope you feel great soon @tulip sleet !
David G said he was lurking and/or not present
Get well soon @tulip sleet
I don't hear him.
Indeed, welcome back Kattni 🙂
Thanks!
@onyx hinge Thanks, I am OK, only a bit busy.
One of my non-adafruit-associated friends excitedly shared TG's watch progress with me, it was cool to see that come back around. small world.
will try.
Streaming (and taking snapshot) of the VGA output of my Colour #Maximite 2 from a Raspberry Pi.
This is thank to #pikvm or more specificaly to the ustreamer component: https://t.co/DOEiq2hw4s
I might add keyboard input, but I can already SSH on my PI and use the serial consol...
You could use kmk instead, it's made of circuitpython 😉 @lone axle
@lone axle I just joined so I didn't hear well, but I have experience with QMK
there are also some "simple" keyboards for circuitpython, if you feel kmk is heavyweight
@stuck elbow foamyguy was mentioning it
That is definitely my ultimate intention (KMK). This one is running on Pro Micro's though so needs to be Arduino style, it's a Dactyl that my wife is building.
keyboards are great projects (for some kinds of people anyway)
@lone axle I'm happy to help
@ionic elk 👍
I used QMK in the 5plit clone I made
@stuck elbow Thank you! I will get what I have so far put into something coherent and then ping you once I've got my specific questions nailed down
"git submodule sync" will be a step you'll have to remember
seems like running the idf's "install" script is pretty quick the second time, it avoids redownloading
Take printout of the CAN dump to your local garage -- I'm sure they'll understand it.
@onyx hinge did I mention my findings about STM32 CAN to you last week?
Sorry late lurking.
@ionic elk I don't recall, feel free to repeat it
lurking too
I found that the F103 has CAN at way lower flash and package sizes than the F4s
So once that port is in, it might be a good target for the API
oh yeah I did see that go by! We're starting with the STM32F405 since it's in a shipping Adafruit product but adding others would be great too.
no access-tier F4 board (F401, F411, most of the common cheap ones) supports CAN, but the F103s do
So if people want to make a 32QFN board with CAN, or an STM32 SoC that's under $2, they have to use an F103
does it have enough ram & flash for ciruitpython?
🏔️
🐐
Yeah higher level F103s do - that's what Dahanzimin and Mark Ollson are interested in. Normally, F103s get beaten on most other metrics by the Access level F4 series. But apparently CAN is an exception, where no Access F4s have it
@ionic elk ow
In low, medium-, high- and XL-density devices the USB and CAN share a dedicated 512-
byte SRAM memory for data transmission and reception, and so they cannot be used
concurrently (the shared SRAM is accessed through CAN and USB exclusively). The USB
and CAN can be used in the same application but not at the same time.
that's about page 654 in RM0008 Rev 20
I could still see us supporting it but we'd need some kind of mediator system. Might not be worth it. I wonder if the STM32G series will have that problem
I have another obligation and will be leaving before In The Weeds today. Nice to hear from everyone!
@analog bridge did you want to talk about deep sleep?
class Foo:
_SOME_VAR = const(23)
def __init__(self):
print(_SOME_VAR)
Adafruit CircuitPython 5.3.1 on 2020-07-13; Adafruit ItsyBitsy M0 Express with samd21g18
>>> import foo
>>> f = foo.Foo()
23
>>>
@onyx hinge 👋
class Foo:
_SOME_VAR = const(23)
def __init__(self):
print(Foo._SOME_VAR)
Adafruit CircuitPython 5.3.1 on 2020-07-13; Adafruit ItsyBitsy M0 Express with samd21g18
>>> import foo
>>> f = foo.Foo()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "foo.py", line 6, in __init__
AttributeError: type object 'Foo' has no attribute '_SOME_VAR'
>>>
@ionic elk will be having a discussion probably after the meet
class Foo:
_SOME_VAR = 23
def __init__(self):
print(Foo._SOME_VAR)
Adafruit CircuitPython 5.3.1 on 2020-07-13; Adafruit ItsyBitsy M0 Express with samd21g18
>>> import foo
>>> f = foo.Foo()
23
>>>
I'm not sure if CircuitPython makes use of the decorator @staticmethod, but a possible solution.
Of course that doesn't address variables.
const only works on globals anyways
python preprocessor
The idea is that you want to substitute the constant value directly in your code. If you write some Python code that uses a (global) variable, then looking up that global variable is relatively expensive (in time). If it's a constant value then you could just write that constant value in the code directly (eg i2c.send(0x42, 0x54)), but that would make it difficult to read (don't want magic numbers!).
Micro Python recognises the "x = const(123)" pattern in your script and during the compile stage will replace "x" in your code with "123", in that module/file. This makes it a lot faster when running.
The reason it also uses RAM is because it still puts "x" in memory as a global variable, in case someone external to the module also wants to use this constant; eg mpr121.DEBOUNCE will still work.
The recommended use for const is: use it when you have a global variable which is a constant integer that is set once and never changed.```
It is also about speed.
Oof, had I known that, I would have used it in the RA8875 library which would be helpful, but I guess it doesn't matter if it's going away.
Whats going away?
The use of const() in libraries.
@teal bear potentially the use of const() in library code. It's being discussed in the meeting going on in the voice chat.
Looooong term going away. Like years in the future.
got it. was thinking I wouldn't be able to use const in my code. was very confused.
@teal bear Totally unrelated.
actually const does two things, it does the search-and-replace mentioned above, which gives a speedup, and if the variable starts with _, it doesn't store the name
What about in supervisor/share/usb/usb.c there might be something there your looking for. That is where you work with usb_msc_mount(); and usb_msc_umount();, etc.
⚒️
Add some information about caveats when using MicroPython's const(). There are ways to use it that will work with MP/CP but not with main Python. Can't be used for class level things, etc.
Way later hug report: Thanks @slender iron for running the meeting today 😄
Thanks
Thanks 🙂
thanks!
Welcome @analog bridge!
@ionic elk for esp32-s2 ADC, are there any new APIs exposed, or do we assume for example, fixed bit width and attenuation, and calibration uses the efuse values when present?
Here in PA, the humidity is off the charts -- it's 70, but feels like 90.
No, not right now. @slender iron is that something we'd ever consider adding?
we assume bit width of 13 and attenuation of 11DB
that said, I don't think there's much point to adding variability for most use cases, 11DB is the only setting that covers the entire 0-3.3V range (others only go up to lower voltage values) and I'm not sure that the bit width can even be changed on ADC2
@ionic elk not to the global API. if folks want implementation specific classes they could be added on a per-port basis
@slender iron where will we be running further conversations discord or github ?
for the usb connection we can chat on discord. otherwise the github is good for discussion
@slender iron is it PR 3454 you wanted me to look at?https://github.com/adafruit/circuitpython/pull/3454
@solar whale yes and there is a corresponding issue
I know you don't like using code.py so I'm wondering if it could be helpful for you
Thanks -- will look at it.. I have not been following the discussion closely.
👍
@slender iron custom wake stub is also concerning me........
I don't think it's critical for this first PR
getting the type of wake is enough to start with
ok....cool 🙂
hmmm. ok. so it's the additional optimization of the leading _ that's preventing using the class prefix, since the name isn't stored. without it:
class Foo:
SOME_VAR = const(23)
def __init__(self):
print(Foo.SOME_VAR)
Adafruit CircuitPython 5.3.1 on 2020-07-13; Adafruit ItsyBitsy M0 Express with samd21g18
>>> import foo
>>> f = foo.Foo()
23
>>>
👍
so in that ^^ example, what was gained by use of const()?
¯_(ツ)_/¯
@stuck elbow thanks for pointing out the _ behavior with const(). do you know what the benefit of use of const() without leading underscore is? for example above
if used in a class, like above, is anything gained?
where #help-with-mu ? (only 1/2 kidding)
no, const does absolutely nothing when it's not on a module level
@onyx hinge including ports/esp32s2 in make translate also includes bunch of esp-idf strings
what is the best way to deal with it? I was thinking -prune
Question: if I want to contribute my volume based LED animation and a timed sequence animation code to the animation library, is the basic process just get it into git, put in a PR and go from there? Not sure if there is any vetting process if it is needed/wanted, etc. thanks
@blissful pollen yup! I think a PR to the library is the place to start
@blissful pollen The PR is essentially the vetting process. We can decide on how to move forward within the PR.
Thanks @slender iron @idle owl, so I put together the PR with the code and then you can decide where to go. Still a newbie with git but I think I can handle that. Thanks
@blissful pollen Always happy to answer questions. Don't hesitate to ask. Also there's a guide 🙂
I saw the guide, next step to review it again!
@analog bridge I agree -prune will probably work. one thing, cross reference with what is supported in the find on macos, which is probably not equivalent to linux in all cases.
you could also be more specific with the input list of paths so instead of giving find the argument ports/esp32s2 and working on everything below, you could list ports/esp32s2/*.[ch] ports/esp32s2/common-hal and so on
@onyx hinge Are the masks for the SAM-E can filter per-filter? As in the mask given to a Match only applies to the given filter?
I am not sure whether we intentionally find translate() strings from other submodules, so maybe you want to use a form of git ls-files (consider files known to git, and not including submodules) instead of find .. oh wait, we do, within ulab
@pastel panther if I understand your question, yes. One filter could be "just address 0x408", another could be "if the low 0xff bits match 0xaa", etc.
in my mind (even though I keep saying both things) they are matches, not filters, since they specify what to include
right, I agree with that term
I'll have to check the DS but I think the MCP's masks are global, applying to all filters/matches
When mask is specified, the check is packet.id & match.mask == match.id & match.match I think
(sometimes the hardware supports that the bits can also include the "is-rtr" and "is-extended" bits but that is not exposed to CP)
yaa
Some info regarding power consumption with and without this PR. Data was gathered using an Adafruit INA260 power sensor running the peripherals script from @xiongyihui
6.0.0-alpha-3 (SPI not working)
1.026 mA 1.275 mW
6.0.0-alpha3 with nrf errata disabled (SPI working)
2.174 mA 6.619 mW
6.0.0-alpha-3 with this PR (SPI working)
1.075 mA 1.333 mW
so yeah it looks like for rxb0 you can accept either 2 specific addresses, or 2 masked matches but only if their masks are equal
and for rxb1 it would be 4, but all their masks have to match or they have to all be specific addresses
which is "fine", in that the docs say (or are intended to say), if the HW can't do it, an exception will be thrown
right
not even the "simple" filter examples in my loopback test program look like they'd fit in this implementation though. bummer.
ya
may I just add that I am amused by the register named BUKT
@onyx hinge thanks for the suggestions.... can you link an example for git ls-files implementation
lol, I thought the same
@analog bridge I may be on the wrong track with git ls-files, but here's an example: $ git ls-files "ports/atmel-samd/**/*.c" | wc 247 247 11778 $ find ports/atmel-samd/ -name "*.c" -print | wc 563 563 28750 so find finds 563 files including in the submodules like ports/atmel-samd/peripherals.h and generated source files like ports/atmel-samd/build-snekboard/autogen_display_resources.c, while git ls-files doesn't.
If I'm reading/understanding correctly, the MCP can support:
RXB0:
1x Filter+Mask or
2x Filter w/o mask
RXB1:
1x Filter+Mask or
6x Filter w/o mask
which I think is rephrasing what you said
(or several filters sharing a mask)
@pastel panther coudn't it support [Match(id=37, mask=0xff), Match(id=54, mask=0xff)] ?
ok yeah
ya
or [Match(id=37), Match(id=54)]
for a single non-extended address the mask is 0x7ff or something? 11-bit addresses?
we don't get strings from other ports submodule.......
possibly another problem with how I drafted the docs, it says a zero mask gives you a single address
@analog bridge we get strings from at least extmod/ulab which is a submodule, so its individual files would not be shown by git ls-files.
If you specify an extended id for a filter, it will apply to 11-bit addresses as well and will use the "extra" to match against the first two data bytes, because reasons
yeah it looks like MCP2515 can't match an extended address only, or a standard address only?
they suggest it helps with some HLAs that use the first two data bytes as identifiers, presumably while sticking with a 11-bit id
@onyx hinge will take a look into it.... 🙂
@onyx hinge I'm going to add some more tests to verify the behavior
@pastel panther sure, please do. did you figure out a good way to have an "apply this test only to this HW" in the tests?
That was hastily thrown together/chopped up to make pylint happy
I may try to spike on using the CP unit test lib that ... personiforget wrote
oh hey, can we change Listener(match=XX) to Listener(matches=XX)?
I try to noun my args and I read match as a verb
sure, but if match is a noun, passing it several seems strange
I'm mildly embarrassed that I care about such pedantry
//| """Construct a Match with the given properties.
//|
//| If mask is not None, then the filter is for any id which matches all
//| the nonzero bits in mask. Otherwise, it matches exactly the given id.
``` I want to change the Match doc to say this and fix the implementation to , er, _match_
this I think would make a mask of 0 match everything(?)
yes, I believe so. And 0xFF would be an exact match
which I assume would be the default if no mask is provided
which is what the docs say 😅
(or will)
hehe
int id_bits = args[ARG_extended].u_bool ? 0x1fffffff : 0x7ff;
I think those are the full bits of an extended or standard address, 0xff is fewer than all of them
I don't think that's important to your point, just being pedantic
we should start a club, but I'm sure we'd never agree if it should be a club, organization, or fraternity
😉
what is id_bits used for? is it masking something?
@slender iron when I build my uf2 for my board, where does that get stored?
I see it, thank you
@solar whale I disconnected you from the CP audio chat.
the sight of your first firmware.uf2 is a glorious thing
indeed 🙂
firmware.elf is my favorite
@umbral dagger fyi we gc.collect after every import automatincally now. re: https://forums.adafruit.com/viewtopic.php?f=60&t=169920#p830932
Also, I'm realizing that some pin selections are not that great so revisions are in place, but that's why we prototype 🙂
@pastel panther any other changes to ask for while I'm touching that PR yet again? You have until I'm done with my pre-push testing, which does involve hooking up that SAM E board again so you've got a bit of time
There is a logic error in the supervisor memory allocation functions that causes the supervisor heap to get into an inconsistent state, eventually resulting in crashes, when allocations are freed in a different order from the reverse of how they were allocated (leaving holes). Apparently nobody has been doing that so far, but now my recent experiments on #1084 at one point did.
free_memory() relies on having allocations in order, but allocate_memory() does not guarantee that: It reuses...
Here is a better link: https://github.com/adafruit/circuitpython/pull/3463/checks?check_run_id=1175885989#step:22:7
You need to add the new board name here: https://github.com/adafruit/circuitpython/blob/main/.github/workflows/build.yml#L423
@onyx hinge lemee see 👀
@idle owl thank you! forgot.
@solar whale No worries!
Thanks @DavePutz. The root cause search ended in an errata so this is the best fix. More info on the issue: https://github.com/adafruit/circuitpython/issues/3367#issuecomment-698546003
@slender iron I'm sorry, but I've run out of time and won't be able to do any testing of PR 3454 until I get back this weekend. I read over the discussion and don't have any concerns but there are a lot of options/kwargs to understand and it'll take more time than I can give it today.
@solar whale k, no problem. lots of kwargs is my worry too and I need to wrap my brain around it too
This is good sleuthing work!
I think there's little reason to support a zero-byte supervisor allocation, and every reason to avoid having to give the supervisor heap a non-zero initialization.
Will this change allow a supervisor block that is deallocated from the middle to be allocated again, if the new allocation fits? This would be very beneficial for the framebuffer displays, RGBMatrix and SharpMemoryDisplay.
FYI, I'll make changes to the Python side of this in the next few days.
@onyx hinge want to push the changes you made to the CAN impl? you replied but didn't push from what I can see
@slender iron yup, getting close, siddacious and I were discussing some other stuff
what API discussion were you alluding to earlier?
here in this channel, renaming a parameter and changing how a defaulted parameter behaves
OK, so if you're prepared for a grumpy commit message, here's the change to fully split the Message and RemoteTransmissionRequest Python types at the C level as well: https://github.com/jepler/circuitpython/commit/8c527d0d5a3a76795f1f7480ac550fb8cc3d4f52
In my opinion it is mere code duplication and does not improve things
I did just eat lunch 🙂
so, I think you can share the code but it'd be better to do it like display_core
merely splitting the bindings of the new Python type out to its own file is .. not bad, by comparison at any rate https://github.com/jepler/circuitpython/commit/14d14de683c28dcc112f9883693bb4796534a48a
where you have the Message.c and RemoteTransmissionRequest.c files everywhere but then call out to a shared impl in shared-modules
Is that what the 14d14d commit does?
@jepler , are you able to attach the program you are running so I can test?
@onyx hinge re: the above docs+implementation update for Match will that be the whole docstring for Match? You're proposing to remove the " If extended is true then only extended addresses are matched, otherwise only standard addresses are matched."?
If so I don't disagree, just clarifying
@pastel panther no I just trimmed for the sake of brevity
ah
This is good sleuthing work!
It taught me how to use a Raspberry Pi with OpenOCD as an SWD debugger, which I’m sure is going to come in handy again! :)
I think there's little reason to support a zero-byte supervisor allocation, and every reason to avoid having to give the supervisor heap a non-zero initialization.
OK, will force-push the other solution. Should I try to adjust rgbmatrix_rgbmatrix_make_new() to that situation? I didn’t actually test it (so my analysis may be wron...
welp, ugly duckling that it is the MCP won't work that way by default, I don't think
@onyx hinge yes mostly. I think you also want receive to return mp_obj_t and have send take a mp_obj_t
@slender iron OK I thought I already changed receive to return mp_obj_t, maybe I didn't. I can change send to take an mp_obj_t as well.
you did, it's just not in the PR commit you linked me to