Skip to content

ports/esp32/modmachine: Callbacks for system events. #7562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

eydam-prototyping
Copy link
Contributor

Capability to register Callbacks on wifi/eth/ip-events.

Signed-off-by: Tobias Eydam eydam-prototyping@outlook.com

With this PR you can register callbacks on wifi/eth/ip-events:

>>> import network
>>> import esp32
>>>
>>> w = network.WLAN()
>>> esp32.register_event_handler(handler=lambda x: print("WIFI_EVENT: {}".format(x)), event_base=esp32.EVENT_BASE_WIFI)
>>> esp32.register_event_handler(handler=lambda x: print("IP_EVENT:   {}".format(x)), event_base=esp32.EVENT_BASE_IP)
>>> w.active(True)
True
WIFI_EVENT: 2
# WIFI_EVENT_STA_START
>>>
>>> w.scan()
...
WIFI_EVENT: 1
# WIFI_EVENT_SCAN_DONE
>>>
>>> w.connect("ssid", "pass")
WIFI_EVENT: 4
# WIFI_EVENT_STA_CONNECTED
IP_EVENT:   0
# IP_EVENT_STA_GOT_IP
>>>
>>> w.disconnect()
WIFI_EVENT: 5
# WIFI_EVENT_STA_DISCONNECTED

With this you could set status LEDs, for example, which is great for debugging.
Currently supported event_bases are EVENT_BASE_WIFI, EVENT_BASE_IP, EVENT_BASE_ETH and EVENT_BASE_ANY.

You have to create the WLAN-Object first and then assign the callbacks, because the wifi event loop is re-initialized on w.active(True).

Capability to register Callbacks on wifi/eth/ip-events.

Signed-off-by: Tobias Eydam <eydam-prototyping@outlook.com>
Capability to register Callbacks on wifi/eth/ip-events.

Signed-off-by: Tobias Eydam <eydam-prototyping@outlook.com>
Capability to register Callbacks on wifi/eth/ip-events.

Signed-off-by: Tobias Eydam <eydam-prototyping@outlook.com>
tannewt added a commit to tannewt/circuitpython that referenced this pull request Apr 19, 2023
PicoDVI in CP support 640x480 and 800x480 on Feather DVI, Pico and
Pico W. 1 and 2 bit grayscale are full resolution. 8 and 16 bit
color are half resolution.

Memory layout is modified to give the top most 4k of ram to the
second core. Its MPU is used to prevent flash access after startup.

The port saved word is moved to a watchdog scratch register so that
it doesn't get overwritten by other things in RAM.

Right align status bar and scroll area. This normally gives a few
pixels of padding on the left hand side and improves the odds it is
readable in a case. Fixes micropython#7562

Fixes c stack checking. The length was correct but the top was being
set to the current stack pointer instead of the correct top.
Fixes micropython#7643

This makes Bitmap subscr raise IndexError instead of ValueError
when the index arguments are wrong.
tannewt added a commit to tannewt/circuitpython that referenced this pull request Apr 19, 2023
PicoDVI in CP support 640x480 and 800x480 on Feather DVI, Pico and
Pico W. 1 and 2 bit grayscale are full resolution. 8 and 16 bit
color are half resolution.

Memory layout is modified to give the top most 4k of ram to the
second core. Its MPU is used to prevent flash access after startup.

The port saved word is moved to a watchdog scratch register so that
it doesn't get overwritten by other things in RAM.

Right align status bar and scroll area. This normally gives a few
pixels of padding on the left hand side and improves the odds it is
readable in a case. Fixes micropython#7562

Fixes c stack checking. The length was correct but the top was being
set to the current stack pointer instead of the correct top.
Fixes micropython#7643

This makes Bitmap subscr raise IndexError instead of ValueError
when the index arguments are wrong.
@projectgus
Copy link
Contributor

This is an automated heads-up that we've just merged a Pull Request
that removes the STATIC macro from MicroPython's C API.

See #13763

A search suggests this PR might apply the STATIC macro to some C code. If it
does, then next time you rebase the PR (or merge from master) then you should
please replace all the STATIC keywords with static.

Although this is an automated message, feel free to @-reply to me directly if
you have any questions about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants