#help-with-circuitpython
1150 messages · Page 2 of 2 (latest)
>>> def print_all_1(*args, extra):
... for arg in args:
... print(arg)
... print("extra", extra)
...
>>>
>>> print_all_1(2, 4, 6)
Traceback (most recent call last):
File "<python-input-7>", line 1, in <module>
print_all_1(2, 4, 6)
~~~~~~~~~~~^^^^^^^^^
TypeError: print_all_1() missing 1 required keyword-only argument: 'extra'
>>> print_all_1(2, 4, 6, extra=20)
2
4
6
extra 20
if *args is used then the second argument becomes key-word only
you can give a default value: extra=999, and then you don't have to supply the arg
Now it all makes sense. I appreciate the help. Thank you
Interesting appearance on the Adafruit front page...
Is that in reference to just setting up the board with CP? Or is Adafruit going to start promoting Firefox for all web based tools?
Perhaps because Firefox finally supports WebSerial? Seems also like a brand deal
Hi, I just started with circuitpython on a rp2040. To execute boot.py I need to restart the board, right? Atm I'm doing this by pushing the tiny little reset button. Is there something like machine.reset() or another way to reboot the board?
microcontroller.reset()
Is there a way to automatically import reset from microcontroller for repl cli?
you could create a r.py file that imports and calls it, and then do import r whenever you want to reset?
sound like an idea...
you can have a repl.py file that gets executed before the repl starts and imports stuff
(not in safe mode though)
Has anyone used the audiospeed module (https://docs.circuitpython.org/en/latest/shared-bindings/audiospeed/) I’m following the sample code using the latest version of CP on a pi pico and playing a wav works but the speed module doesn’t.
What errors do you get?
I haven't played with that module yet, but @solar orchid might be able to help
HI! If you're using the example code on that page verbatim you probably won't hear what you expect, since the code just exits (hi @pearl rapids!)
Here's an example I just tested on a Pico running 10.2.1 :
import time, board, audiobusio, audiocore
import audiomixer
import audiospeed
SAMPLE_RATE = 22050
CHANNEL_COUNT = 1
BUFFER_SIZE = 2048
i2s_bck_pin, i2s_lck_pin, i2s_dat_pin = board.GP20, board.GP21, board.GP22
audio = audiobusio.I2SOut(bit_clock=i2s_bck_pin, word_select=i2s_lck_pin, data=i2s_dat_pin)
mixer = audiomixer.Mixer(voice_count=1, sample_rate=SAMPLE_RATE, channel_count=CHANNEL_COUNT,
bits_per_sample=16, samples_signed=True, buffer_size=BUFFER_SIZE)
audio.play(mixer)
wav1 = audiocore.WaveFile("amen1_22k_s16.wav")
wav1adj = audiospeed.SpeedChanger(wav1, rate=0.5)
mixer.voice[0].play(wav1adj, loop=True)
while True:
print('hi', mixer.voice[0].playing, time.monotonic())
time.sleep(0.5)
And there does seem to be a bug in SpeedChanger if no mixer is used. Looks like in my refactor to pull it out of WaveFile and into it's own package, I messed up non-mixer playing. (filed issue https://github.com/adafruit/circuitpython/issues/11020)
Yeah I was thinking a brand deal as well since clicking on it takes you to a page on Firefox's site about using it with Adafruit. I wouldn't mind a bit of transparancy on Adafruit's part to explain this a little. Are they recommending Firefox now because it is actually better than other choices (more reliabile, more features, more something else)? Or are they simply in a marketing deal with Firefox?
I imagine it’s because Firefox is FOSS and independent. But a clear comparison table would be cool
What? You don't care about Mosiac? 😃
Mosaic was never my favorite, no. But Netscape had tabs before anyone else
I think InternetWorks was the first browser with tabs
Bought by aol
I only know this cos I was watching an LGR video yesterday hahaha
@solar orchid I just got back and saw your message. StreetChicken.wav played at half speed is a banger. Thanks!
I wish I had run across that sooner. I've been trying to do something like that for a long time and totally missed anything about repl.py. Thanks!
Oh hmm might be able to import the keyboard driver for the repl with that, could be handy
I don't know if anyone knows the internals of circup here but I have a couple of libraries I wrote and import in my code.py that in turn import a few Adafruit std libraries. When I either place my libraries in /lib or compile them to mpy and leave at top level circup can't find the dependencies to add the Adafruit libraries to lib/. If I leave them at the top level and uncompiled to mpy circup finds the dependencies and installs them. I'm pretty sure circup either can see into mpy files to find recursive Adafruit libraries to add or must have its own list somewhere of what depends on what.
when I have this kind of situation, I usually make an explicit "requirements.txt" file for my project that lists both external libraries that circup knows about and any local libraries. Then I do circup install -r requirements.txt to install both my libraries and their dependencies. Here's one example of what I'm talking about: https://github.com/todbot/pico_test_synth/tree/main/circuitpython
I am a little surprised that circup doesn't find the dependencies in a .py file in /lib, but it's been a long time since I had my hands in that code
by the way @solar orchid I keep delaying the patch you submitted to discotool because I wanted to take time to read through the code in detail, in part because I don't have access to a MacOS 26 compatible machine (or Windows 11 for that matter which is also broken it seems)
No problem! I think the main discotool user may be John Park! ahahaha. Seems like MacOS 26 changes has caused a variety of USB inspection issues: the Mac version of lsusb is broken and the old Mac "USB Prober" GUI app that I love has errors. So I've been working on a replacement called "USB Probester" that does both 😀
If discotool is broken then Adafruit_Board_Toolkit probably is too.
I don't know ? It's the code that gets the drives and pairs them with the serial ports by diving in the USB tree, but Adafruit_Board_Toolkit just does the serial ports with the pyserial inherited code, right ?
I mean it might still break, but not for the same reason
the port listing is done in an OS-specific way, with code I copied from you. I think I did the part of the windows code myself.
yeah it's the code we took from pyserial/list_ports (and submitted fixes to the pyserial repo years ago)
ah, I forgot that
but that's not related to the issue with 26 that was fixed here by todbot
Thanks, I'll look into setting up a requirements.txt file for my std installs. I was having to manually install my libraries anyway but was hoping to be lazy with following up with a circup install -a. In my first few tries to emulate your lib/synth_tools I get errors like: WARNING: lib/board_inventory is not a known CircuitPython library. so need to figure out how to add as bundle etc.
Is your library a single file board_inventory.py? If so, put that in your requirements.txt
I can't believe it was that easy. I guess I have to decide whether I'm using a mpy or py file rather than have it auto find whichever one is there. I was convinced that it was some enforced 'blessed by circup' trait. Thanks. I can use that!
I'm having trouble with some "object with buffer protocol required" errors. Is it true that bytes, bytearray, and array all support the buffer protocol in CircuitPython?
bytes are read-only. is it a buffer that is written.
The usual reason for that error is that None was accidentally passed
you could put a print statement in and see what the arg actually is
I'm trying to get a usb_hid led only usb descriptor right. I'm trying on rp2040. Does anybody know of some example code? Atm, I have a keyboard with no inputs, but only an output for two leds (msg waiting & ring)...
I think this page has examples of descriptor strings. https://docs.kernel.org/hid/hidintro.html#parsing-hid-report-descriptors
Thanks, I'll read through it. I guess best would be to find a led udb_hid device that is working with a linux host and copy that descriptor. That way it would be quite easy to work around any obscure stuff that might arise...
Also test with a descriptor decoder to make sure it’s formatted correctly, because circuitpython doesn’t validate this
Are you intending to follow an existing HID usage or your own? Here's an example with a two-report HID descriptor that sends & receives 64-byte reports: https://gist.github.com/todbot/6c39e9f2e9719643e5be8f1c82cf9f79
Need some help locating a very old resistive touch screen driver. I have a Adafruit TFT FeatherWing - 3.5" 480x320 Touchscreen for Feathers PID: 3651 which uses the discontinued STMPE811 I would like to use this display but now it looks like i am out of luck any ideas would be appreciated
Try the stmpe610 driver, some indication says it should work
Hi!
I cannot run CircuitPython on my ESP32-S3 board. This is ESP32-S3-Tiny by Waveshare, but instead of 512k/4M it has 8M/8M RAM/Flash.
- vanilla
adafruit-circuitpython-waveshare_esp32_s3_tiny-en_US-10.2.1.bingives a loop in bootloader:
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x403830b1
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce2820,len:0x1c4
load:0x403c8700,len:0xb24
load:0x403cb700,len:0x27b4
entry 0x403c886c
-
With rebuit tinyuf2, copying the UF2 image stucks with I/O errors in dmesg.
After reset there is the same loop with just more logs from tinyuf2. -
Much smaller (2.8M)
adafruit-circuitpython-waveshare_esp32_s3_tiny-en_US-9.1.4.uf2has the same issues -
Images for
unexpectedmaker_tinys3(quite generic board with same S3-N8R8 chip) don't work either -
I've built my own
build-waveshare_esp32_s3_tiny_n8r8/firmware.uf2which behaves the same -
MicroPython
ESP32_GENERIC_S3-20260406-v1.28.0.uf2works just fine -- copied fast, then boots in next second -
Tried writing the app directly:
esptool write-flash -z 0x10000 build-waveshare_esp32_s3_tiny_n8r8/circuitpython-firmware.bin-- all the same
Could anyone suggest steps to diagnose or fix this?
This seems like it might be like https://github.com/adafruit/circuitpython/issues/11009. There are some suggestions of images to try there. I'd be interested if any of those work for you. Feel free to follow up there if they do. Otherwise open a new issue. Thanks.
Thanks! Symptoms are identical indeed. Will try few things from there
So a question, on my picocalc nothing appears on screen if I dont tell it to, however if my program crashes i get the output on the screen, is this because I setup the screen in my program and circuitpython keeps that even if the program crashes?
the image for ESP32-S3-DevKitC-1-N8R8 booted well.
I compared board definitions and this is what I needed to make it work:
-CIRCUITPY_ESP_PSRAM_MODE = qio
+CIRCUITPY_ESP_PSRAM_MODE = opi
I don't see a schematic for the Tiny-N8-R8. It would be good to confirm that it is using octal SPI for the PSRAM
PSRAM is inside the chip. No visual difference from 512k ones
oh, I tried to look PSRAM stuff in datasheet. Turns out S3, S3-WR0OM, S3-PIC0 are different chip families.
N8R8 may refer both to WR0OM and PIC0 (may be more, but I stopped here). I have PIC0 apparently.
Fortunately, in all three R2 is always Quad SPI, and R8/R16 are always Octal SPI
Sound like there needs to be a new board def for this new version of the board.
yep. I'll make a PR when I'm sure it works as expected
but all this stuff looks like a matrix to me:
- we have variety of boards with specific wiring
- we have variety of chips with same footprint, but not very compatible firmware-wise
I'm new here, so I will not insist on rewriting build scripts and web pages
nice, 7 boards have the same error (actually, I copy-pasted qio from one of them)
$ git grep -l 'IDF_TARGET = esp32s3' | xargs grep -l 'CIRCUITPY_ESP_PSRAM_SIZE = [^2]' | xargs grep 'PSRAM_MODE = qio'
boards/circuitart_zero_s3/mpconfigboard.mk:CIRCUITPY_ESP_PSRAM_MODE = qio
boards/m5stack_cores3/mpconfigboard.mk:CIRCUITPY_ESP_PSRAM_MODE = qio
boards/m5stack_cores3_se/mpconfigboard.mk:CIRCUITPY_ESP_PSRAM_MODE = qio
boards/unexpectedmaker_feathers3/mpconfigboard.mk:CIRCUITPY_ESP_PSRAM_MODE = qio
boards/unexpectedmaker_nanos3/mpconfigboard.mk:CIRCUITPY_ESP_PSRAM_MODE = qio
boards/unexpectedmaker_pros3/mpconfigboard.mk:CIRCUITPY_ESP_PSRAM_MODE = qio
boards/unexpectedmaker_tinys3/mpconfigboard.mk:CIRCUITPY_ESP_PSRAM_MODE = qio
replied in issue
Any explanation on this?
Yes, if you just set up the display but don't display anything, your screen will be blank. As soon as your program quits, you'll see the REPL on the display as CircuitPython doesn't release the display unless you explicitly call displayio.release_displays()
Right right, is there a specifically approved method for initialising the display and then specifically showing REPL or console?
display.root_group = displayio.CIRCUITPYTHON_TERMINAL will put the serial console on the display.
you're welcome.
oh that's new to me, neat! thanks
No end of new things one learns in this channel! I'm already using this new trick on a Featherwing.
On further testing and looking at the library sources I think this happens automagically when I import the library adafruit_hx8357 based on BusDisplay. That is the import of the library sets the display.root_group to displayio.CIRCUITPYTHON_TERMINAL.
I can see that resetting display.root_group back to the above might be useful when a program exited that was using the display so it could show REPL output again.
I dropped the nicenano circuitpython into this controller and it drops out of bootloader mode. when I put it back into bootloader mode its still called NICENANO what could i try to get this thing back to square 1?
what is “this”?
Pro Micro nRF52840
I reflashed it with
adafruit-nrfutil --verbose dfu serial --package nice_nano_bootloader-0.6.0_s140_6.1.1.zip -p COM3 -b 115200 --singlebank --touch 1200
And got this 'success message'
But when I drop in the circuitpython uf2. it doesnt work. maybe the controller is borked.
Nvm...I just reflashed it again and this time it worked. 🤷♂️
I'm a little confused about differences in reading I2C data, depending whether an I2C Controller is reading, or an I2C Target is reading.
When an I2C Controller writes to an I2C Target, the I2C Target doesn't need to know how many bytes need to be read: https://docs.circuitpython.org/en/latest/shared-bindings/i2ctarget/index.html#i2ctarget.I2CTargetRequest.read & https://github.com/adafruit/circuitpython/issues/10423#issuecomment-2974082922. The I2C protocol takes care of signaling when the message is complete.
But when an I2CTarget writes to an I2C Controller, there doesn't seem to be an API mechanism other than reading until a buffer is filled, or until a specified slice of that buffer is filled: https://docs.circuitpython.org/en/latest/shared-bindings/busio/index.html#busio.I2C.readfrom_into. The result is that multiple messages can get concatenated into a single read, and message boundaries are lost. Shouldn't there be a mechanism for an I2C Controller to detect the end of the message and stop reading?
i’m pretty sure that the I2C controller decides how long a transmission is, no matter which direction it is. if the target is sending, it must stop after getting a NAK from the controller (to release the bus so the controller can send a STOP or repeated START signal)
Thanks, I'll read more on the specs. I have a different application, but it occurred to me that perhaps a sensor might send an (unknown length) sequence of values... but there's no way for a Controller to figure that out (currently?). I control both ends in my application, so I could add a layer of protocol to send the length first, but I was hoping to keep it simple.
i think you have to add something in your application protocol so the target can indicate how much data it wants to send. if the controller keeps reading, it’ll just get repeated 0xFF if the target decides to release the bus
Yes, in my case, the Target moves on to the next message, but the Controller keeps reading as if it's the same message. I'll add a data length and make it a two-part read.
I could also flip it so that there are multiple Controllers writing and one Target reading, but that seems like it's asking for trouble with collisions and throughput degradation and general robustness.
targets that implement a “register” model for their application protocol often implement an auto-increment procedure for extended reads
i’m unconvinced that most I2C firmware has well-tested multi-controller collision resolution
it’s probably best to treat an I2C transaction as having a fixed length determined in advance by the controller. some microcontrollers have I2C peripherals that can allow the controller to decide how many more bytes to read after already having read some data, but you shouldn’t depend on having that capability on all microcontrollers (and CircuitPython doesn’t seem to expose it)
I would not be surprised. Many masters don’t even support clock stretching.
I think a two-step read will do it... Controller reads a length, then fills a buffer/slice of that length with the next read. Then the message is done. This works with espressif Controller, and I will test with raspberrypi and samd. I have a CRC already. I2C Target only runs on samd and raspberrypi.
I've done simple multi-controller before in CircuitPython with two Controllers, and it worked fine, but I need way more than two and I'm skeptical.
Thanks, yes, I'm already using https://eleccelerator.com/usbdescreqparser/ and reading through https://eleccelerator.com/tutorial-about-usb-hid-report-descriptors/ to get better understanding...
Well, I'm at the beginning of learning and do not really know what is the best way to reach my goal: make a simple led show up in Linux under /sys/class/leds - like the leds on a keyboard, but just a led.
I thought I'd start looking at the descriptor used for a keyboard, then get rid of the keyboard part to just have the led part left over.
I do not need to do fancy stuff to the led, just switch it on and off.
My led for testing is the blue led on the rp2040 board. If I get a hold on how this all works, I'd love to make a rgb led work.
I've done some work with I2C and SPMI multi-controller setups and in both cases the bus arbitration adds an interesting challenge if the firmware doesn't support it
Having digital test muxes to see when the controller is having a line at high Z is a life saver. Unfortunately most consumer products don't have those features exposed :/
I realized that I do need multi-controller since my multis have to be espressif (I2C Target has to be either raspberrypi or samd). But in testing multi-controller more thoroughly with a raspberrypi I2C Target... two controllers works pretty well, but start increasing the number of controllers, the data sizes, or the frequency of messages and things go bad. And then recovery of multiple MCUs becomes an issue. So I've ruled out using I2C for my current project. Also ruled out SPI for now since SPI Target (available on M4 only) has a fatal issue. That leaves UART if I wan to keep costs low, but UART needs a multi-level hierarchy of forwarding due to limits in the number of UARTs per MCU.
What are you trying to do??
I'm trying to move a lot of data (frequent and large messages) from many espressif devices to a single other device, preferably espressif or raspberrypi, for further processing. The higher-cost solutions involve adding hardware like Ethernet or CAN (but CAN also breaks down with high bus utilization / multiple senders of frequent large messages).
SPI would typically be the simplest option. What is this about needing multiple UART masters? RS422 supports multi-drop
You could still use a CS pin like SPI does to select which device should be communicating
Hihi! I know this might not be the place to ask it but i'm pretty sure it is as its most likely a CiruitPhython thing. So i have a Matrix Portal M4 (Display is the 64x32 RGB LED Matrix - 2.5mm pitch) and i did all the setup, it has the files it should have and its connected to WIFI but I've hit a wall and i am unsure on what to do next, I've read the setup pages on the website but i am still unsure on what to do next, if someone could tell me or guide me in the right direction i would apricate it! again i apoligize if this is not the right place to ask this
Yes, SPI would be nice, but Target is only supported on M4 and has an open issue that is blocking its use in all but the simplest cases. UART is fine, but with limited UARTs per MCU, this yields a multi-level forwarding hierarchy. RS-422 is one driver, multiple receivers ...and is it supported in CircuitPython? RS-485 is supported and supports multiple drivers, I did look at that some time ago and dismissed it for reasons I don't remember, perhaps similar concerns about robustness under heavy utilization, or the caveat about best-case timing on the rs485_dir pin. I could test it out and see.
@near dagger Can you link to the tutorial you're using, and also describe more what is working so far, and what is not?
If you want to emulate the LEDs on a keyboard (which only have on/off state, no brightness), then you can use the built-in HID keyboard emulation that CircuitPython is already doing and just intercepting those HID reports. That would look something like this in your code.py:
import time
import usb_hid
import adafruit_hid
keyboard_hid = adafruit_hid.find_device(usb_hid.devices, usage_page=1, usage=6)
print("waiting for LED commands from computer")
while True:
out_report = keyboard_hid.get_last_received_report() # from computer
if out_report:
print(["%02x" % x for x in out_report])
time.sleep(0.5)
No need for a boot.py.
In Linux, you would trigger it with commands like this:
echo "1" | sudo tee -a /sys/class/leds/input41::scrolllock/brightness
echo "0" | sudo tee -a /sys/class/leds/input41::scrolllock/brightness
and "input41" will change depending on when and where you plug in your CircuitPython device.
this is what i used https://learn.adafruit.com/adafruit-matrixportal-m4/install-circuitpython
and it seems to be working? like its conected to wifi and everything and its all set up, i just dont know what to do next, like if theres more to set up
If it seems to be working, you could try one of the other Learn Guides written for MatrixPortal M4 https://learn.adafruit.com/search?q=matrixportal
Ok thanks!
It just didn’t seem to be displaying anything when I was running code in circuit python!
That’s what the issue was I’m pretty sure, sorry I completely forgot about that XD
yeah, I think that guide is just for set up, other guides have more interesting visual examples
Ok, thanks!
For UART with RS-485 https://docs.circuitpython.org/en/latest/shared-bindings/busio/index.html#busio.UART, what do I do with the rs485_dir output pins? I don't find any CircuitPython examples. Do I need external transceivers, termination resistors, bias resistors? This may get complicated pretty fast, and I wonder about robustness with many drivers. Almost $7 for a transceiver, I may be better off shelling out for Ethernet (or inexpensive ESP32SPI co-processors).
RS485 is UART with differential signals. You could do it without the transceivers if you can disable your outputs when not transmitting.
(Could make a switch with two mosfets if you’re really worried about cost)
The busio.UART module seems to support RS-485 to some degree, but it's not clear to me what it does and doesn't do, or even how to hook it up. It runs with one driver, but if I add a second, the second's writes are never read. But then I almost certainly am not handling the rs485_dir pins properly.
I'm more concerned about complexity (hardware, but also software and error recovery) than cost. If busio doesn't naturally handle multi-driver, then I'm more likely to add a network interface than to write complex low-level software specifically for RS-485. I don't even know if RS-485 will handle my overall project even if I do get the fundamentals working. This is really a networking application, I was just hoping to trim the per-MCU cost by using built-in comms.
Hey Ungor, It took some tweaking but I did manage to get that stmpe610.py driver working with the learn guide https://learn.adafruit.com/esp32-s3-ble-ios-media-controller with the older version of the 3.5" TFT Product ID: 3651 Thanks again for the help.
Nice!
Not sure why you need multiple drivers. Aren’t they all going on the same bus?
maybe I'm using the wrong terminology, I need multiple MCUs writing, and one MCU reading from all of them
Ok. Does it have to be simultaneous or can they take turns on the same bus?
they can take turns, but then there's complexity with how to coordinate that... think of multiple writers generating messages at random (but frequent) times. they could buffer multiple messages until it's their turn
Not random. It can be arbitrated by the master
well, the writers do randomly have messages to write... but they could be arranged into regular intervals
Each get their own timeslot?
there's some waste to time multiplexing though
Yes
I thought that was what you were suggesting
writer #2 may accumulate a lot more messages than writer #5, for example... then the time slot has to accommodate the busiest writer
think of the messages as random lengths of within a range of a say 100 to 1000 bytes, they may come in very fast, very slow, or something in between... some writers may routinely generate much more data than others
I could use a CS-type pin, but that would take up a lot of pins, similarly trying to multiplex... any kind of back-and-forth synchronization communication is prone to error and needed recovery (or data loss)... without a simple scheme, I'm probably better off using standard networking
Hard to design without solid requirements, but ok. How about chaining the CS signal so each device tells the next one when it’s complete?
maybe, unless a node goes down
You really want automatic arbitration? You could assert with a shared signal and do exponential + random backoff for conflict. Receive the sent data and make sure it matches what you intended in case two devices assert simultaneously. Send a CRC checksum at the end of the packet for integrity
But I’m not sure this extra complexity gets you extra performance
If you need more bandwidth, use a higher bitrate
Yes, I'll have a CRC (unless using TCP, then it's probably redundant). Multi-controller I2C with I2CTarget would have automatic (built-in) arbitration but it's too finicky for my heavy bus utilization. RS-485 (if I understand it correctly) with multiple transmitters would have automatic (built-in) arbitration, not sure if it could handle my number of transmitters, and message sizes and frequencies. I'm confident basic UART would work, though it makes for complex topology and message forwarding. I guess I'm trying to avoid inventing something new if there's something off-the-shelf with robustness built in. So I've been exploring SPI, I2C, and UART as possible alternatives to higher cost-per-node networking. But I do make a trade-off between the complexity of something more custom, vs the cost of something more standard.
Thanks for the suggestions and for listening as I sort through the issues.
I’d love to help more, but it’s really unclear what your requirements are. You’ve expressed concern over conflicts, but I’m not sure if the issue is throughput or latency
And then there’s the issue of robustness. What should happen in the event of a single-node failure?
How often do you expect this to occur?
If you can nail down some requirements, we can design a system to meet your needs
- What is the worst-case for packet size, frequency, and number of nodes?
- How important is it to receive these in a timely manner?
Hi! I'm working on a CP project where I need to time software processing in my pico2 from the moment the radio chip receives preamble to the moment a message was transmitted. The goal is to time the software processing time as accurately as possible.
I understand CP is designed to prioritise user friendliness over hardware access so hardware interrupts are hidden intentionally by design. My work is meant to be integrated to a larger CP project, which is why I can't just move to C or MP for direct access to interrupts ^^;
My question is:
- What would be the "circuitpythonic" way of doing this? If I use asyncio for software interrupt, for example, is it possible to characterize the few ns of software delay?
- If I want to read hardware interrupt anyway, how would I achieve this in CP? I know a bit of C so I don't mind having to frankenstein something together.
I also did some backreading in the server and found this thread #help-with-circuitpython message where @abstract wedge (sorry for the ping!) mentioned "C module in CP" as a workaround, which currently seems like the best solution to me. But I'd love to get some inputs from someone more experienced than I am ^^; ty in advance!!
the keypad module saves timestamps for the key events, maybe that would be enough for you? it's doing it by polling, though
the pulsein module saves precise timings of pin changes
it uses internal timers
I think polling might be a problem once integrated into the larger project, bc the processing load might vary drastically each poll :0 also, I read that keypad polls every millisecond, and my timing will have to be sub-ms accuracy^^;;; preferably with a couple of μs of error, though I'm unsure how achievable of a goal that is. I guess my work is to find out. ty for the fast response!
How about you time the pins with the PIO?
You’re not going to get 1us accuracy in Python. I think the best you could hope for is 100us
But you could get it with the PIO
If the radio tells you when you receive a preamble, that is
ty for responding! This was super helpful!
I looked into it bc I wasn't super familiar, but PIO is deterministic, right... So uncertainty would be the interaction between PIO and python? I was curious about how you'd estimated that number :o
I misunderstood, I thought you were trying to measure hardware timing. If you just want a software profiler you could use time.monotonic or maybe a debugger. Though the PIO might still give better resolution
Manually triggering the garbage collector might reduce your measurement jitter
ah, actually both are useful! the project is to measure range with lora, so the better i can capture the overall processing time, the better the ranging results would be 🙂↕️
Hmm. Maybe 100us was too pessimistic. Try it and see
Google claims the function overhead in Circuitpython is only a couple us
I followed all the tutorials and everything and I don’t know why but it still won’t display anything, am I missing something? Genuinely I’ve tried everything I can and I’ve asked different people and I’m so lost and confused at this point
have you verified the basic hardware setup is working? easiest way to do that is use the simpletest UF2 from here:
https://learn.adafruit.com/adafruit-matrixportal-m4/downloads
should see output like this when using the simpletest UF2:
https://cdn-shop.adafruit.com/970x728/5036-02.jpg
I haven’t and I’ll do that, thank you
Everything seemed to be set up and working as like the green light was flashing on the back and everything else seemed to be working as the guide said
that'll replace circuitpython, but is easy to go back once the test is done
just copy back the circuitpython firmware UF2
and remember that UF2's are copied to the BOOT folder (not CIRCUITPY)
Ok
Follow up question, is there a way to completely wipe the board and start from square one?
if the simpletest UF2 works, then we can take a look at why it's not working in circuitpython
it should just be a code issue if the simpletest UF2 works
I might not have stuff that I needed downloaded tbh, I have a feeling I missed something
download the UF2? or download firmware to the matrix portal?
I’ll have to double check
All I know is I got it connected to WiFi and that’s the furthest I got, nothing else was working
here's a direct link to the simpletest UF2:
https://cdn-learn.adafruit.com/assets/assets/000/123/404/original/matrixportal_m4_simpletest.UF2?1691705208
Danke! I will take a look when I get home, thanks again
I’m sorry for being slightly dumb with all of this, I’m like brand ish new to coding and stuff
no worries. asking here is perfect. it'll be best if you can ask again when you're with the hardware.
there'll be some stuff worth knowing that's just generic circuitpython stuff
and then stuff for getting the matrix to work
it can be a lot of new stuff to deal with initially
i think you mention having the PID 5036 panel?
https://www.adafruit.com/product/5036
you don't need anything else. just that and the matrxi portal.
I have the 64x32 RGB LED Matrix - 2.5mm pitch, idk if that’s the same
yes it is
Ohhhh, product ID, that’s what PID means
"hub 75" is an unfortunately overused term. it's often applied to any LED matrix panel thing and implies there's a standard. but there can be lots of variations in these panels. but if you got the LED matrix panel from adafruit, it should work.
yep, sry, PID = product ID
adafruit shop URLs are pretty simple - they include the product ID,
just wanted to verify what panel you have
software generally must be done correctly depending on the panel
that's why there's more than one simpletest UF2 for example
they are panel specific
Ohhh ok, that might be my issue
All good!