Search found 169 matches

by Christian Walther
Mon Aug 08, 2022 9:08 am
Forum: General Discussion and Questions
Topic: WebREPL and uasyncio
Replies: 9
Views: 10207

Re: WebREPL and uasyncio

There is an undocumented socket option that lets you register a callback that will then, if I understand correctly, be invoked “in between” regular Python execution whenever there is data/connections on the socket. Implementation, use.
by Christian Walther
Mon Aug 08, 2022 9:03 am
Forum: General Discussion and Questions
Topic: Problem with exec(open(filename).read())
Replies: 8
Views: 4162

Re: Problem with exec(open(filename).read())

Try using __import__() instead of exec() to run the other program. I don’t know if that uses less memory but it could be. You’ll have to remove it from sys.modules afterward so it can be run again. Example. Also, it’s hard to tell from afar, but I expect you should be able to deinitialize the displa...
by Christian Walther
Mon Aug 01, 2022 11:01 am
Forum: ESP32 boards
Topic: Detecting and counting pulses while in deep sleep
Replies: 4
Views: 3034

Re: Detecting and counting pulses while in deep sleep

Also, if you want to wake up the main CPU from the ULP, you will need to use a nightly build of MicroPython, as that ability was added after the current 1.19.1 release.
by Christian Walther
Fri Jul 29, 2022 5:20 pm
Forum: Other Boards
Topic: Load uP on STM Nucleo
Replies: 4
Views: 20501

Re: Load uP on STM Nucleo

I have very little experience with STM32 boards, but I seem to remember something to the effect of that the USB drive (and serial console) presented by MicroPython will be on a different USB port than the one presented by the ST-LINK. You may need to attach a USB connector to the respective pins of ...
by Christian Walther
Fri Jul 29, 2022 5:14 pm
Forum: General Discussion and Questions
Topic: ESP32 Port Tools
Replies: 2
Views: 1755

Re: ESP32 Port Tools

As far as I remember different versions are used for different boards and/or releases. You can check by installing the closest official (reasonably recent) firmware to what you would like to achieve and running

Code: Select all

import platform; platform.platform()
by Christian Walther
Thu Jul 14, 2022 7:11 am
Forum: General Discussion and Questions
Topic: Using a NodeMCU-mini with Thonny
Replies: 11
Views: 3874

Re: Using a NodeMCU-mini with Thonny

Have you tried different flash modes? Some boards and flash chips need a different setting than the default.
by Christian Walther
Sun Jul 03, 2022 7:46 pm
Forum: General Discussion and Questions
Topic: Call native functions from mpy C extension.
Replies: 2
Views: 1077

Re: Call native functions from mpy C extension.

Unless I missed any recent developments, the answer is no. This has been discussed and solutions prototyped over the years, I believe the latest part is in pull request #5711. Someone else might know more.
by Christian Walther
Sun Jun 26, 2022 8:41 am
Forum: ESP32 boards
Topic: Using UART0 on ESP32-S2
Replies: 2
Views: 1936

Re: Using UART0 on ESP32-S2

I don’t know any details, I don’t know if this is still relevant, and I also don’t know if it extends from the ESP32 to the ESP32-S2, but it may have something to do with the comment linked here (coming from this commit and removed in this commit ): Correction: I just learned that detaching the UART...
by Christian Walther
Sun Jun 26, 2022 8:19 am
Forum: General Discussion and Questions
Topic: bits to bytes
Replies: 58
Views: 21663

Re: bits to bytes

KJM wrote:
Sun Jun 26, 2022 1:27 am
Is there a way to force it show b'\x40\x80' in lieu of b' \x80' ?
No, but you can use

Code: Select all

>>> import binascii
>>> binascii.hexlify(b' \x80', ' ')
b'20 80'
by Christian Walther
Sat Jun 25, 2022 8:06 am
Forum: General Discussion and Questions
Topic: bits to bytes
Replies: 58
Views: 21663

Re: bits to bytes

What I would do is >>> struct.pack('<H', sum(b*(1<<(i^7)) for i, b in enumerate(bits))) b'\x10\x80' This is probably a bit more efficient as it involves no string manipulation. The i^7 is to get the first bit into the most-significant place as you did (big-endian), if you can choose the order then u...